diff options
| author | Nathan V. Morrical <natemorrical@gmail.com> | 2021-05-25 11:06:54 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-25 10:06:54 -0700 |
| commit | fbf00dd54d787c6e22b0f1785a64dfb2fb1e300a (patch) | |
| tree | dd7e6f32eea789e3288dc8a937e92f256ea0b8e9 /prelude | |
| parent | 34a1ff5226a526cc17c5baecd63637f69c324fc7 (diff) | |
OptiX ray payload read/write support in raytracing pipeline shaders (#1853)
* OptiX ray payload can now be read from and written to using the two payload register pointer method
* changing op to more descriptive name
* fixup: comment change to re-trigger CI
Co-authored-by: T. Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'prelude')
| -rw-r--r-- | prelude/slang-cuda-prelude.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/prelude/slang-cuda-prelude.h b/prelude/slang-cuda-prelude.h index 4df60e965..a6c4f70dc 100644 --- a/prelude/slang-cuda-prelude.h +++ b/prelude/slang-cuda-prelude.h @@ -1612,3 +1612,29 @@ found via reflection or defined such that it matches the shader appropriately. */ struct UniformEntryPointParams; struct UniformState; + +// ---------------------- OptiX Ray Payload -------------------------------------- +#ifdef SLANG_CUDA_ENABLE_OPTIX +static __forceinline__ __device__ +void *unpackOptiXRayPayloadPointer(uint32_t i0, uint32_t i1) +{ + const uint64_t uptr = static_cast<uint64_t>(i0) << 32 | i1; + void* ptr = reinterpret_cast<void*>(uptr); + return ptr; +} + +static __forceinline__ __device__ +void packOptiXRayPayloadPointer(void* ptr, uint32_t& i0, uint32_t& i1) +{ + const uint64_t uptr = reinterpret_cast<uint64_t>(ptr); + i0 = uptr >> 32; + i1 = uptr & 0x00000000ffffffff; +} + +static __forceinline__ __device__ void *getOptiXRayPayloadPtr() +{ + const uint32_t u0 = optixGetPayload_0(); + const uint32_t u1 = optixGetPayload_1(); + return unpackOptiXRayPayloadPointer(u0, u1); +} +#endif |
