diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2020-07-24 12:07:39 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-24 12:07:39 -0700 |
| commit | eaf3f040bbdf1e8c32dbf328251b0c133ac4b250 (patch) | |
| tree | 533ca42c991866aba7c4d555c1f534514ed321b6 /tests/language-feature | |
| parent | ef9d76cf88282030c0ed269f73ab8f332f784437 (diff) | |
Handle case of no global parameters for CPU/CUDA (#1457)
The IR pass that introduces an explicit `KernelContext` for the CPU/CUDA back-ends was also responsible for adding an explicit parameter to the kernel entry point to receive the constant buffer (pointer) with all the global uniform parameters. However, if there were no global uniform parameters, this parameter wasn't getting introduced, which changed the signature/ABI of the generated entry point function.
This change makes it so that the pass unconditionally adds a parameter. In the case where there are no global uniforms it just adds a `void*` parameter that never gets used.
In order to avoid future regressions, this change also adds a test case to confirm that things work correctly when a kernel has only entry-point parameters and no global parameters.
Diffstat (limited to 'tests/language-feature')
| -rw-r--r-- | tests/language-feature/shader-params/entry-point-uniform-params.slang | 38 | ||||
| -rw-r--r-- | tests/language-feature/shader-params/entry-point-uniform-params.slang.expected.txt | 4 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/language-feature/shader-params/entry-point-uniform-params.slang b/tests/language-feature/shader-params/entry-point-uniform-params.slang new file mode 100644 index 000000000..b94fc4556 --- /dev/null +++ b/tests/language-feature/shader-params/entry-point-uniform-params.slang @@ -0,0 +1,38 @@ +// entry-point-uniform-params.slang + +//TEST(compute):COMPARE_COMPUTE: +//TEST(compute):COMPARE_COMPUTE:-cuda +//TEST(compute):COMPARE_COMPUTE:-cpu + +// Test that a shader can be written that +// only uses entry point `uniform` parameters, +// without any global parameters. + +struct Data +{ + int a; + int b; +} + +int test(int val, int a, int b) +{ + return a*(val+1) + b*(val+2); +} + +[numthreads(4, 1, 1)] +[shader("compute")] +void computeMain( + +//TEST_INPUT:cbuffer(data=[256 1]):name=d + uniform Data d, + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer + uniform RWStructuredBuffer<int> outputBuffer, + + uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal, d.a, d.b); + outputBuffer[tid] = outVal; +} diff --git a/tests/language-feature/shader-params/entry-point-uniform-params.slang.expected.txt b/tests/language-feature/shader-params/entry-point-uniform-params.slang.expected.txt new file mode 100644 index 000000000..4cf6581b3 --- /dev/null +++ b/tests/language-feature/shader-params/entry-point-uniform-params.slang.expected.txt @@ -0,0 +1,4 @@ +102 +203 +304 +405 |
