Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #pragma once
0002 /**
0003 SOPTIX_Properties.h : optixDeviceContextGetProperty results
0004 =============================================================
0005 **/
0006 #include <bitset>
0007 
0008 struct SOPTIX_Properties
0009 {
0010     unsigned rtcoreVersion ; 
0011     unsigned limitMaxTraceDepth ; 
0012     unsigned limitMaxTraversableGraphDepth ;
0013     unsigned limitMaxPrimitivesPerGas ;
0014     unsigned limitMaxInstancesPerIas ;
0015     unsigned limitMaxInstanceId ;
0016     unsigned limitNumBitsInstanceVisibilityMask ;
0017     unsigned limitMaxSbtRecordsPerGas ;
0018     unsigned limitMaxSbtOffset ;   
0019 
0020     unsigned visibilityMask_FULL() const ;     
0021     unsigned visibilityMask(unsigned idx) const ;
0022      
0023     SOPTIX_Properties(OptixDeviceContext context); 
0024     std::string desc() const ; 
0025 }; 
0026 
0027 
0028 
0029 /**
0030 SOPTIX_Properties::visibilityMask_FULL
0031 ----------------------------------------
0032 
0033 ::
0034 
0035     +---------------------+--------+----------+
0036     | ( 0x1 << 8 ) - 1    |   255  |  0xff    |
0037     +---------------------+--------+----------+
0038 
0039 **/
0040 
0041 inline unsigned SOPTIX_Properties::visibilityMask_FULL() const
0042 {
0043     return ( 0x1 << limitNumBitsInstanceVisibilityMask ) - 1 ;  
0044 }
0045 
0046 
0047 /**
0048 SOPTIX_Properties::visibilityMask
0049 ------------------------------------
0050 
0051     +----------+--------------------------------------+
0052     |  idx     |   visibilityMask(idx)                |
0053     +==========+======================================+
0054     |   0      |   0x1 << std::min(0, 7) = 0x1 << 0   | 
0055     |   1      |   0x1 << std::min(1, 7) = 0x1 << 1   | 
0056     |   2      |   0x1 << std::min(2, 7) = 0x1 << 2   | 
0057     |   3      |   0x1 << std::min(3, 7) = 0x1 << 3   | 
0058     |   4      |   0x1 << std::min(4, 7) = 0x1 << 4   | 
0059     |   5      |   0x1 << std::min(5, 7) = 0x1 << 5   | 
0060     |   6      |   0x1 << std::min(6, 7) = 0x1 << 6   | 
0061     +----------+--------------------------------------+
0062     |   7      |   0x1 << std::min(7, 7) = 0x1 << 7   | 
0063     |   8      |   0x1 << std::min(8, 7) = 0x1 << 7   | 
0064     |   9      |   0x1 << std::min(9, 7) = 0x1 << 7   | 
0065     |  10      |   0x1 << std::min(10,7) = 0x1 << 7   | 
0066     +----------+--------------------------------------+
0067 
0068 
0069 For idx of 7 or more visibilityMask does not change, reflecting
0070 the limited number of bits of the mask. 
0071 
0072 This means that visibility of geometry with the first seven idx 
0073 (0,1,2,3,4,5,6) can be individually controlled but all the rest 
0074 of the geometry with higher idx can only be controlled 
0075 all together. 
0076 
0077 For example with mmlabel.txt::
0078  
0079   +-----+----------------------------------------+
0080   | idx | mmlable                                |
0081   +=====+========================================+ 
0082   |  0  | 3218:sWorld                            |
0083   |  1  | 5:PMT_3inch_pmt_solid                  |
0084   |  2  | 9:NNVTMCPPMTsMask_virtual              |
0085   |  3  | 12:HamamatsuR12860sMask_virtual        |
0086   |  4  | 4:mask_PMT_20inch_vetosMask_virtual    |
0087   |  5  | 1:sStrutBallhead                       |
0088   |  6  | 1:uni1                                 |
0089   +-----+----------------------------------------+
0090   |  7  | 1:base_steel                           |
0091   |  8  | 1:uni_acrylic1                         |
0092   |  9  | 130:sPanel                             |
0093   +-----+----------------------------------------+
0094 
0095 ::
0096 
0097     VIZMASK=5 ~/o/sysrap/tests/ssst1.sh run   # just 1:sStrutBallhead 
0098     VIZMASK=6 ~/o/sysrap/tests/ssst1.sh run   # just 1:uni1
0099     VIZMASK=7 ~/o/sysrap/tests/ssst1.sh run   # just 1:base_steel
0100     VIZMASK=8 ~/o/sysrap/tests/ssst1.sh run   # just 1:uni_acrylic1 OpenGL, blank with OptiX
0101     VIZMASK=9 ~/o/sysrap/tests/ssst1.sh run   # just 130:sPanel OpenGL, blank with OptiX
0102 
0103 
0104 NB currently the OptiX render and the OpenGL render do not match for
0105 VIZMASK=7,8,9 because OptiX has the 8 bit limitation but OpenGL does not. 
0106 
0107 **/
0108 
0109 inline unsigned SOPTIX_Properties::visibilityMask(unsigned idx) const
0110 {
0111     unsigned FULL = visibilityMask_FULL(); 
0112     assert( FULL == 0xffu ); 
0113     unsigned BITS = std::bitset<32>(FULL).count(); 
0114     assert( BITS == 8 ); 
0115     unsigned marker_bit = std::min( idx, BITS - 1 );  
0116     unsigned visibilityMask = 0x1 << marker_bit ;  
0117     assert( ( visibilityMask & 0xffffff00 ) == 0 ) ;  
0118     return visibilityMask ;
0119 }
0120 
0121 
0122 
0123 
0124 inline SOPTIX_Properties::SOPTIX_Properties(OptixDeviceContext context)
0125 {
0126 
0127     OPTIX_CHECK( optixDeviceContextGetProperty(context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_TRACE_DEPTH                   , &limitMaxTraceDepth                 , sizeof(unsigned int)) );
0128     OPTIX_CHECK( optixDeviceContextGetProperty(context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_TRAVERSABLE_GRAPH_DEPTH       , &limitMaxTraversableGraphDepth      , sizeof(unsigned int)) );
0129     OPTIX_CHECK( optixDeviceContextGetProperty(context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_PRIMITIVES_PER_GAS            , &limitMaxPrimitivesPerGas           , sizeof(unsigned int)) );
0130     OPTIX_CHECK( optixDeviceContextGetProperty(context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_INSTANCES_PER_IAS             , &limitMaxInstancesPerIas            , sizeof(unsigned int)) );
0131     OPTIX_CHECK( optixDeviceContextGetProperty(context, OPTIX_DEVICE_PROPERTY_RTCORE_VERSION                          , &rtcoreVersion                      , sizeof(unsigned int)) );
0132     OPTIX_CHECK( optixDeviceContextGetProperty(context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_INSTANCE_ID                   , &limitMaxInstanceId                 , sizeof(unsigned int)) );
0133     OPTIX_CHECK( optixDeviceContextGetProperty(context, OPTIX_DEVICE_PROPERTY_LIMIT_NUM_BITS_INSTANCE_VISIBILITY_MASK , &limitNumBitsInstanceVisibilityMask , sizeof(unsigned int)) );
0134     OPTIX_CHECK( optixDeviceContextGetProperty(context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_SBT_RECORDS_PER_GAS           , &limitMaxSbtRecordsPerGas           , sizeof(unsigned int)) );
0135     OPTIX_CHECK( optixDeviceContextGetProperty(context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_SBT_OFFSET                    , &limitMaxSbtOffset                  , sizeof(unsigned int)) );
0136 }
0137 
0138 inline std::string SOPTIX_Properties::desc() const 
0139 {
0140     std::stringstream ss ; 
0141     ss
0142         << "SOPTIX_Properties::desc" << std::endl 
0143         << std::setw(40) << "limitMaxTraceDepth" 
0144         << " : "
0145         << std::setw(10) <<  limitMaxTraceDepth 
0146         << std::endl 
0147         << std::setw(40) << "limitMaxTraversableGraphDepth" 
0148         << " : "
0149         << std::setw(10) <<  limitMaxTraversableGraphDepth 
0150         << std::endl 
0151         << std::setw(40) << "limitMaxPrimitivesPerGas" 
0152         << " : "
0153         << std::setw(10) << limitMaxPrimitivesPerGas 
0154         << std::setw(10) <<  std::hex << limitMaxPrimitivesPerGas << std::dec
0155         << std::endl 
0156         << std::setw(40) << "limitMaxInstancesPerIas" 
0157         << " : "
0158         << std::setw(10) << limitMaxInstancesPerIas 
0159         << std::setw(10) <<  std::hex << limitMaxInstancesPerIas << std::dec 
0160         << std::endl 
0161         << std::setw(40) << "rtcoreVersion" 
0162         << " : "
0163         << std::setw(10) <<  rtcoreVersion 
0164         << std::endl 
0165         << std::setw(40) << "limitMaxInstanceId" 
0166         << " : "
0167         << std::setw(10) << limitMaxInstanceId   
0168         << std::setw(10) <<  std::hex << limitMaxInstanceId << std::dec
0169         << std::endl 
0170         << std::setw(40) << "limitNumBitsInstanceVisibilityMask" 
0171         << " : "
0172         << std::setw(10) << limitNumBitsInstanceVisibilityMask 
0173         << std::endl 
0174         << std::setw(40) << "visibilityMask_FULL()"
0175         << " : "
0176         << std::setw(10) << visibilityMask_FULL() 
0177         << std::setw(10) << std::hex << visibilityMask_FULL() << std::dec  
0178         << std::endl 
0179         << std::setw(40) << "limitMaxSbtRecordsPerGas" 
0180         << " : "
0181         << std::setw(10) << limitMaxSbtRecordsPerGas 
0182         << std::setw(10) <<  std::hex << limitMaxSbtRecordsPerGas << std::dec
0183         << std::endl 
0184         << std::setw(40) << "limitMaxSbtOffset" 
0185         << " : "
0186         << std::setw(10) <<  limitMaxSbtOffset 
0187         << std::setw(10) <<  std::hex << limitMaxSbtOffset << std::dec
0188         << std::endl 
0189         ;  
0190 
0191     std::string str = ss.str(); 
0192     return str ; 
0193 }
0194 
0195