yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1// realtime-clock.slang 2 3// TODO(JS): 4// Disable FXC DX11/DX12 because currently FXC can't compile nvHLSLExtns.h 5 6//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj 7//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-dx11 -slang -compute -output-using-type -nvapi-slot u0 -shaderobj 8//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -render-feature realtime-clock -output-using-type -shaderobj 9//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-d3d12 -compute -output-using-type -nvapi-slot u0 -shaderobj 10//TEST(compute):COMPARE_COMPUTE_EX:-d3d12 -compute -output-using-type -nvapi-slot u0 -shaderobj 11//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj 12 13// The test doesn't directly use this, but having this defined makes the 0 slot available if NVAPI is going to be used 14// Only strictly necessary on the D3D11/D3D12 paths 15//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):name=nvapiBuffer 16RWStructuredBuffer<int> nvapiBuffer; 17 18//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 19RWStructuredBuffer<int> outputBuffer; 20 21[numthreads(8, 1, 1)] 22void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 23{ 24 uint idx = dispatchThreadID.x; 25 26 uint ticksLow = getRealtimeClockLow(); 27 28 uint2 ticks = getRealtimeClock(); 29 30 outputBuffer[idx] = int(idx + ((ticksLow ^ ticks.x) ^ (ticks.x ^ ticksLow))); 31}