Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:29

0001 
0002 #pragma once
0003 
0004 #include <optix.h>
0005 
0006 
0007 #include <stdexcept>
0008 #include <sstream>
0009 
0010 
0011 //------------------------------------------------------------------------------
0012 //
0013 // OptiX error-checking
0014 //
0015 //------------------------------------------------------------------------------
0016 
0017 #define OPTIX_CHECK( call )                                                    \
0018     do                                                                         \
0019     {                                                                          \
0020         OptixResult res = call;                                                \
0021         if( res != OPTIX_SUCCESS )                                             \
0022         {                                                                      \
0023             std::stringstream ss;                                              \
0024             ss << "Optix call '" << #call << "' failed: " __FILE__ ":"         \
0025                << __LINE__ << ")\n";                                           \
0026             throw OPTIX_Exception( res, ss.str().c_str() );                   \
0027         }                                                                      \
0028     } while( 0 )
0029 
0030 
0031 #define OPTIX_CHECK_LOG( call )                                                \
0032     do                                                                         \
0033     {                                                                          \
0034         OptixResult res = call;                                                \
0035         if( res != OPTIX_SUCCESS )                                             \
0036         {                                                                      \
0037             std::stringstream ss;                                              \
0038             ss << "Optix call '" << #call << "' failed: " __FILE__ ":"         \
0039                << __LINE__ << ")\nLog:\n" << log                               \
0040                << ( sizeof_log > sizeof( log ) ? "<TRUNCATED>" : "" )          \
0041                << "\n";                                                        \
0042             throw OPTIX_Exception( res, ss.str().c_str() );                   \
0043         }                                                                      \
0044     } while( 0 )
0045 
0046 
0047 
0048 
0049 class OPTIX_Exception : public std::runtime_error
0050 {
0051  public:
0052      OPTIX_Exception( OptixResult res, const char* msg )
0053          : std::runtime_error( createMessage( res, msg ).c_str() )
0054      { }
0055 
0056  private:
0057      std::string createMessage( OptixResult res, const char* msg )
0058      {
0059          std::ostringstream out;
0060          out << optixGetErrorName( res ) << ": " << msg;
0061          return out.str();
0062      }
0063 };
0064 
0065 
0066