diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-04-04 18:00:16 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-04 18:00:16 -0400 |
| commit | 68c7d5cda2d6f2eb7bfb3a7e15860eb3ded25424 (patch) | |
| tree | ac4e8384108e70109b084782b414296d015f92b8 /source | |
| parent | 7bb2de1bc40e535fae93940113db97b5ea44a6f2 (diff) | |
Preliminary support for realtime clock (#2772)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Initial support for realtime clock.
* Add realtime-clock render feature where seems appropriate.
* Fixes to make NVAPI compile properly.
Change realtime-clock.slang check to use maths that can't overflow.
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/hlsl.meta.slang | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 7774c0d01..8ad99d71b 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -6835,6 +6835,38 @@ __specialized_for_target(glsl) [[vk::spirv_instruction(1, "NonSemantic.DebugBreak")]] void debugBreak(); +// +// Realtime Clock support +// + +// https://github.com/KhronosGroup/GLSL/blob/master/extensions/ext/GL_EXT_shader_realtime_clock.txt + +[__requiresNVAPI] +__target_intrinsic(hlsl, "NvGetSpecial( NV_SPECIALOP_GLOBAL_TIMER_LO)") +__glsl_extension(GL_EXT_shader_realtime_clock) +__target_intrinsic(glsl, "clockRealtime2x32EXT().x") +__target_intrinsic(cuda, "clock") +uint getRealtimeClockLow(); + +__target_intrinsic(cuda, "clock64") +int64_t __cudaGetRealtimeClock(); + +[__requiresNVAPI] +__target_intrinsic(hlsl, "uint2(NvGetSpecial( NV_SPECIALOP_GLOBAL_TIMER_LO), NvGetSpecial( NV_SPECIALOP_GLOBAL_TIMER_HI)) ") +__glsl_extension(GL_EXT_shader_realtime_clock) +__target_intrinsic(glsl, "clockRealtime2x32EXT()") +uint2 getRealtimeClock(); + +__specialized_for_target(cuda) +uint2 getRealtimeClock() +{ + int64_t ticks = __cudaGetRealtimeClock(); + return uint2(uint(ticks), uint(uint64_t(ticks) >> 32)); +} + +// +// CUDA specific +// __target_intrinsic(cuda, "(threadIdx)") [__readNone] |
