|
|
|||
File indexing completed on 2026-04-09 07:48:58
0001 #pragma once 0002 0003 /** 0004 InstanceId.h 0005 =============== 0006 0007 SEE CSGOptiX/InstanceId.h : 24-bit limit in early OptiX7 versions 0008 makes make bit packing inside the InstanceId not very useful 0009 0010 TODO: confirm and remove 0011 0012 0013 :: 0014 0015 epsilon:opticks blyth$ opticks-f InstanceId.h 0016 ./CSGOptiX/SBT.cc: unsigned instance_id = optixGetInstanceId() ; // see IAS_Builder::Build and InstanceId.h 0017 ./CSGOptiX/InstanceId.h: unsigned instance_id = optixGetInstanceId() ; // see IAS_Builder::Build and InstanceId.h 0018 ./CSGOptiX/CSGOptiX7.cu: unsigned instance_id = optixGetInstanceId() ; // user supplied instanceId, see IAS_Builder::Build and InstanceId.h 0019 ./CSGOptiX/IAS_Builder.cc://#include "InstanceId.h" 0020 ./u4/U4Step.h: 409 unsigned instance_id = optixGetInstanceId() ; // user supplied instanceId, see IAS_Builder::Build and InstanceId.h 0021 epsilon:opticks blyth$ 0022 epsilon:opticks blyth$ 0023 0024 0025 0026 Beware the OptiX limits:: 0027 0028 limitMaxInstanceId : 16777215 ffffff 6*4 = 24 bits 0029 0030 In [32]: 0x3fff 14bits 0031 Out[32]: 16383 0032 0033 In [19]: "%x" % ( 0x7fff | 0xffc000 ) 0034 Out[19]: 'ffffff' 0035 0036 In [21]: 0x3ff 0037 Out[21]: 1023 0038 0039 In [22]: "%x" % (0x3ff << 10) 0040 Out[22]: 'ffc00' 0041 0042 1 1 0043 3 11 0044 7 111 0045 f 1111 0046 0047 **/ 0048 0049 struct InstanceId 0050 { 0051 enum { ins_bits = 14, gas_bits = 10 } ; 0052 0053 static constexpr unsigned ins_mask = ( 1 << ins_bits ) - 1 ; 0054 static constexpr unsigned gas_mask = ( 1 << gas_bits ) - 1 ; 0055 0056 static unsigned Encode(unsigned ins_idx, unsigned gas_idx ); 0057 static void Decode(unsigned& ins_idx, unsigned& gas_idx, const unsigned identity ); 0058 }; 0059 0060 inline unsigned InstanceId::Encode(unsigned ins_idx, unsigned gas_idx ) 0061 { 0062 assert( ins_idx < ins_mask ); 0063 assert( gas_idx < gas_mask ); 0064 unsigned identity = (( 1 + ins_idx ) << gas_bits ) | (( 1 + gas_idx ) << 0 ) ; 0065 return identity ; 0066 } 0067 0068 inline void InstanceId::Decode(unsigned& ins_idx, unsigned& gas_idx, const unsigned identity ) 0069 { 0070 ins_idx = (( (ins_mask << gas_bits ) & identity ) >> gas_bits ) - 1u ; 0071 gas_idx = (( gas_mask & identity ) >> 0 ) - 1u ; 0072 } 0073 0074 0075
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|