Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #pragma once
0002 /**
0003 Pointer.h
0004 ============
0005 
0006 https://github.com/ingowald/optix7course/blob/master/example08_addingTextures/devicePrograms.cu
0007 
0008 See env-;optix7c-
0009 
0010 **/
0011 
0012 static __forceinline__ __device__ void* unpackPointer( uint32_t i0, uint32_t i1 )
0013 {
0014     const uint64_t uptr = static_cast<uint64_t>( i0 ) << 32 | i1;
0015     void*           ptr = reinterpret_cast<void*>( uptr ); 
0016     return ptr;
0017 }
0018 
0019 static __forceinline__ __device__ void  packPointer( void* ptr, uint32_t& i0, uint32_t& i1 )
0020 {
0021     const uint64_t uptr = reinterpret_cast<uint64_t>( ptr );
0022     i0 = uptr >> 32;
0023     i1 = uptr & 0x00000000ffffffff;
0024 }
0025 
0026 /**
0027 getPRD
0028 --------
0029 
0030 An arbitrary payload is associated with each ray that is initialized with the optixTrace call. 
0031 The payload is passed to all the IS, AH, CH and MS programs that are executed during this invocation of trace. 
0032 The payload can be read and written by each program 
0033 
0034 **/
0035 
0036 template<typename T> static __forceinline__ __device__ T *getPRD()
0037 { 
0038     const uint32_t u0 = optixGetPayload_0();
0039     const uint32_t u1 = optixGetPayload_1();
0040     return reinterpret_cast<T*>( unpackPointer( u0, u1 ) );
0041 }
0042 
0043