From 68c7d5cda2d6f2eb7bfb3a7e15860eb3ded25424 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 4 Apr 2023 18:00:16 -0400 Subject: 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. --- tests/slang-extension/realtime-clock.slang | 31 ++++++++++++++++++++++ .../realtime-clock.slang.expected.txt | 5 ++++ 2 files changed, 36 insertions(+) create mode 100644 tests/slang-extension/realtime-clock.slang create mode 100644 tests/slang-extension/realtime-clock.slang.expected.txt (limited to 'tests') diff --git a/tests/slang-extension/realtime-clock.slang b/tests/slang-extension/realtime-clock.slang new file mode 100644 index 000000000..67d6e2ab0 --- /dev/null +++ b/tests/slang-extension/realtime-clock.slang @@ -0,0 +1,31 @@ +// realtime-clock.slang + +// TODO(JS): +// Disable FXC DX11/DX12 because currently FXC can't compile nvHLSLExtns.h + +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-dx11 -slang -compute -output-using-type -nvapi-slot u0 -shaderobj +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -render-feature realtime-clock -output-using-type -shaderobj +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-d3d12 -compute -output-using-type -nvapi-slot u0 -shaderobj +//TEST(compute):COMPARE_COMPUTE_EX:-d3d12 -compute -use-dxil -output-using-type -nvapi-slot u0 -shaderobj +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj + +// The test doesn't directly use this, but having this defined makes the 0 slot available if NVAPI is going to be used +// Only strictly necessary on the D3D11/D3D12 paths +//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):name=nvapiBuffer +RWStructuredBuffer nvapiBuffer; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(8, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint idx = dispatchThreadID.x; + + uint ticksLow = getRealtimeClockLow(); + + uint2 ticks = getRealtimeClock(); + + outputBuffer[idx] = int(idx + ((ticksLow ^ ticks.x) ^ (ticks.x ^ ticksLow))); +} \ No newline at end of file diff --git a/tests/slang-extension/realtime-clock.slang.expected.txt b/tests/slang-extension/realtime-clock.slang.expected.txt new file mode 100644 index 000000000..9d029e9f2 --- /dev/null +++ b/tests/slang-extension/realtime-clock.slang.expected.txt @@ -0,0 +1,5 @@ +type: int32_t +0 +1 +2 +3 -- cgit v1.2.3