From 117f5e554839efc13066517461eafaf8f2fd96c6 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 6 May 2022 16:35:15 -0400 Subject: Initial work around groupshared (#2224) * #include an absolute path didn't work - because paths were taken to always be relative. * Allow rate modifier on parameter. * Add test. * Disable test for now as breaks on source comparison because around nvAPI. --- tests/hlsl/simple/rate-param.hlsl | 30 ++++++++++++++++++ tests/hlsl/simple/rate-param.hlsl.expected | 49 ++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/hlsl/simple/rate-param.hlsl create mode 100644 tests/hlsl/simple/rate-param.hlsl.expected (limited to 'tests/hlsl') diff --git a/tests/hlsl/simple/rate-param.hlsl b/tests/hlsl/simple/rate-param.hlsl new file mode 100644 index 000000000..5a36ba30e --- /dev/null +++ b/tests/hlsl/simple/rate-param.hlsl @@ -0,0 +1,30 @@ +// rate-param.slang +//DISABLE_TEST:SIMPLE: -target hlsl -entry computeMain -stage compute + +//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):out,name outputBuffer +RWStructuredBuffer outputBuffer; + +groupshared uint gs_values[4]; + +void someFunction(inout groupshared uint a[4], int index, int value) +{ + a[index] += value; +} + +[shader("compute")] +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int index = (int)dispatchThreadID.x; + + // Initialize + gs_values[3 - index] = index; + + GroupMemoryBarrierWithGroupSync(); + + someFunction(gs_values, index, index * 2 + 1); + + GroupMemoryBarrierWithGroupSync(); + + outputBuffer[index] = gs_values[index]; +} diff --git a/tests/hlsl/simple/rate-param.hlsl.expected b/tests/hlsl/simple/rate-param.hlsl.expected new file mode 100644 index 000000000..fd99b3fc1 --- /dev/null +++ b/tests/hlsl/simple/rate-param.hlsl.expected @@ -0,0 +1,49 @@ +result code = 0 +standard error = { +} +standard output = { +#ifdef SLANG_HLSL_ENABLE_NVAPI +#include "nvHLSLExtns.h" +#endif + +#pragma pack_matrix(column_major) + +#line 7 "tests/hlsl/simple/rate-param.hlsl" +static groupshared uint gs_values_0[int(4)]; + +void someFunction_0(groupshared inout uint a_0[int(4)], int index_0, int value_0) +{ + a_0[index_0] = a_0[index_0] + (uint) value_0; + return; +} + + +#line 5 +RWStructuredBuffer outputBuffer_0 : register(u0); + + +#line 16 +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID_0 : SV_DISPATCHTHREADID) +{ + +#line 18 + int index_1 = (int) dispatchThreadID_0.x; + + + gs_values_0[int(3) - index_1] = (uint) index_1; + + GroupMemoryBarrierWithGroupSync(); + + someFunction_0(gs_values_0, index_1, index_1 * int(2) + int(1)); + + GroupMemoryBarrierWithGroupSync(); + + int _S1 = (int) gs_values_0[index_1]; + +#line 29 + outputBuffer_0[(uint) index_1] = _S1; + return; +} + +} -- cgit v1.2.3