Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #include "Properties.h"
0002 #include "Ctx.h"
0003 #include <optix.h>
0004 #include <optix_stubs.h>
0005 #include "OPTIX_CHECK.h"
0006 #include <iostream>
0007 #include <sstream>
0008 #include <iomanip>
0009 #include <bitset>
0010 #include <cassert>
0011 
0012 Properties::Properties()
0013 {
0014     OPTIX_CHECK( optixDeviceContextGetProperty(Ctx::context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_TRACE_DEPTH                   , &limitMaxTraceDepth                 , sizeof(unsigned int)) );
0015     OPTIX_CHECK( optixDeviceContextGetProperty(Ctx::context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_TRAVERSABLE_GRAPH_DEPTH       , &limitMaxTraversableGraphDepth      , sizeof(unsigned int)) );
0016     OPTIX_CHECK( optixDeviceContextGetProperty(Ctx::context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_PRIMITIVES_PER_GAS            , &limitMaxPrimitivesPerGas           , sizeof(unsigned int)) );
0017     OPTIX_CHECK( optixDeviceContextGetProperty(Ctx::context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_INSTANCES_PER_IAS             , &limitMaxInstancesPerIas            , sizeof(unsigned int)) );
0018     OPTIX_CHECK( optixDeviceContextGetProperty(Ctx::context, OPTIX_DEVICE_PROPERTY_RTCORE_VERSION                          , &rtcoreVersion                      , sizeof(unsigned int)) );
0019     OPTIX_CHECK( optixDeviceContextGetProperty(Ctx::context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_INSTANCE_ID                   , &limitMaxInstanceId                 , sizeof(unsigned int)) );
0020     OPTIX_CHECK( optixDeviceContextGetProperty(Ctx::context, OPTIX_DEVICE_PROPERTY_LIMIT_NUM_BITS_INSTANCE_VISIBILITY_MASK , &limitNumBitsInstanceVisibilityMask , sizeof(unsigned int)) );
0021     OPTIX_CHECK( optixDeviceContextGetProperty(Ctx::context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_SBT_RECORDS_PER_GAS           , &limitMaxSbtRecordsPerGas           , sizeof(unsigned int)) );
0022     OPTIX_CHECK( optixDeviceContextGetProperty(Ctx::context, OPTIX_DEVICE_PROPERTY_LIMIT_MAX_SBT_OFFSET                    , &limitMaxSbtOffset                  , sizeof(unsigned int)) );
0023 }
0024 
0025 
0026 /**
0027 Properties::visibilityMask_FULL
0028 -------------------------------------
0029 
0030 ::
0031 
0032     +---------------------+--------+----------+
0033     | ( 0x1 << 8 ) - 1    |   255  |  0xff    |
0034     +---------------------+--------+----------+
0035 
0036 **/
0037 
0038 unsigned Properties::visibilityMask_FULL() const
0039 {
0040     return ( 0x1 << limitNumBitsInstanceVisibilityMask ) - 1 ;   
0041 }
0042 
0043 
0044 
0045 unsigned Properties::visibilityMask(unsigned idx) const
0046 {
0047     unsigned FULL = visibilityMask_FULL(); 
0048     assert( FULL == 0xffu );  
0049     unsigned BITS = std::bitset<32>(FULL).count(); 
0050     assert( BITS == 8 );  
0051     unsigned marker_bit = std::min( idx, BITS - 1 );  
0052     unsigned visibilityMask = 0x1 << marker_bit ;   
0053     assert( ( visibilityMask & 0xffffff00 ) == 0 ) ;   
0054     return visibilityMask ;
0055 }
0056 
0057 
0058 
0059 std::string Properties::desc() const 
0060 {
0061     std::stringstream ss ; 
0062     ss
0063         << "Properties::desc" << std::endl 
0064         << std::setw(40) << "limitMaxTraceDepth" 
0065         << " : "
0066         << std::setw(10) <<  limitMaxTraceDepth 
0067         << std::endl 
0068         << std::setw(40) << "limitMaxTraversableGraphDepth" 
0069         << " : "
0070         << std::setw(10) <<  limitMaxTraversableGraphDepth 
0071         << std::endl 
0072         << std::setw(40) << "limitMaxPrimitivesPerGas" 
0073         << " : "
0074         << std::setw(10) <<  std::dec << limitMaxPrimitivesPerGas 
0075         << std::setw(10) <<  std::hex << limitMaxPrimitivesPerGas 
0076         << std::endl 
0077         << std::setw(40) << "limitMaxInstancesPerIas" 
0078         << " : "
0079         << std::setw(10) <<  std::dec << limitMaxInstancesPerIas 
0080         << std::setw(10) <<  std::hex << limitMaxInstancesPerIas 
0081         << std::endl 
0082         << std::setw(40) << "rtcoreVersion" 
0083         << " : "
0084         << std::setw(10) <<  rtcoreVersion 
0085         << std::endl 
0086         << std::setw(40) << "limitMaxInstanceId" 
0087         << " : "
0088         << std::setw(10) <<  std::dec << limitMaxInstanceId   
0089         << std::setw(10) <<  std::hex << limitMaxInstanceId 
0090         << std::endl 
0091         << std::setw(40) << "limitNumBitsInstanceVisibilityMask" 
0092         << " : "
0093         << std::setw(10) <<  std::dec << limitNumBitsInstanceVisibilityMask 
0094         << std::endl 
0095         << std::setw(40) << "visibilityMask_FULL" 
0096         << " : "
0097         << std::setw(10) <<  std::hex << visibilityMask_FULL() << std::dec 
0098         << std::endl 
0099         << std::setw(40) << "limitMaxSbtRecordsPerGas" 
0100         << " : "
0101         << std::setw(10) <<  std::dec << limitMaxSbtRecordsPerGas 
0102         << std::setw(10) <<  std::hex << limitMaxSbtRecordsPerGas 
0103         << std::endl 
0104         << std::setw(40) << "limitMaxSbtOffset" 
0105         << " : "
0106         << std::setw(10) <<  std::dec << limitMaxSbtOffset 
0107         << std::setw(10) <<  std::hex << limitMaxSbtOffset 
0108         << std::dec
0109         << std::endl 
0110         ;  
0111 
0112     std::string str = ss.str(); 
0113     return str ; 
0114 }
0115 
0116 
0117 
0118