diff options
| author | Darren <65404740+fairywreath@users.noreply.github.com> | 2024-12-10 13:12:19 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-10 10:12:19 -0800 |
| commit | 523e9f012e42608df1f7dd91f5625f8171b6ca3d (patch) | |
| tree | f0ba1940c442ae85e03769047125a1fe73900fb7 /tests | |
| parent | 34497ae6d779b16b75003c7d9b6ca04e58b4dc70 (diff) | |
Enable exprs for GLSL binding layout qualifiers (#5807)
* Allow glsl set and binding layout qualifiers to be compile time integer exprs
* add new tests
* add comments
* cleanup on asserts
* addressed review comments and cleanup
* fix missing set expr in test
* fixed tests and cleanup
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests')
8 files changed, 71 insertions, 7 deletions
diff --git a/tests/bugs/glsl-layout-define.hlsl.expected b/tests/bugs/glsl-layout-define.hlsl.expected index e97928b47..028c80325 100644 --- a/tests/bugs/glsl-layout-define.hlsl.expected +++ b/tests/bugs/glsl-layout-define.hlsl.expected @@ -1,11 +1,15 @@ result code = -1 standard error = { -tests/bugs/glsl-layout-define.hlsl(4): error 20001: unexpected identifier, expected integer literal +tests/bugs/glsl-layout-define.hlsl(4): error 30015: undefined identifier 'UNDEFINED_VK_BINDING'. binding = UNDEFINED_VK_BINDING, ^~~~~~~~~~~~~~~~~~~~ -tests/bugs/glsl-layout-define.hlsl(5): error 20001: unexpected identifier, expected integer literal +tests/bugs/glsl-layout-define.hlsl(5): error 30015: undefined identifier 'UNDEFINED_VK_SET'. set = UNDEFINED_VK_SET) ^~~~~~~~~~~~~~~~ +(0): error 30015: undefined identifier 'main'. +tests/bugs/glsl-layout-define.hlsl(3): error 38000: no function found matching entry point name 'main' +layout( +^~~~~~ } standard output = { } diff --git a/tests/diagnostics/unrecognized-glsl-layout-modifiers.slang b/tests/diagnostics/unrecognized-glsl-layout-modifiers.slang new file mode 100644 index 000000000..3012a8828 --- /dev/null +++ b/tests/diagnostics/unrecognized-glsl-layout-modifiers.slang @@ -0,0 +1,23 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -target spirv -stage vertex -entry main -allow-glsl +#version 310 es +layout(location = 0) in highp vec4 a_position; +layout(location = 1) in highp vec4 a_coords; +layout(location = 0) out mediump vec3 v_color; + + +// CHECK: error 31216 +layout(std140, not_a_set = 0, binding = 0) uniform buff0 { + mediump int ui_zero; +}; + +void main() +{ + gl_Position = a_position; + mediump vec4 coords = a_coords; + mediump vec4 res = coords; + mediump int i = 0; + for (;;) { res = res.yzwx + vec4(1.0); if (i == 1) break; i++; } + res -= vec4(2); + v_color = res.rgb; +} + diff --git a/tests/glsl-intrinsic/atomic/atomicCounterTestMultiple.slang b/tests/glsl-intrinsic/atomic/atomicCounterTestMultiple.slang index ec296968c..e6a3ae7e9 100644 --- a/tests/glsl-intrinsic/atomic/atomicCounterTestMultiple.slang +++ b/tests/glsl-intrinsic/atomic/atomicCounterTestMultiple.slang @@ -9,7 +9,10 @@ buffer MyBlockName layout(binding = 1, offset = 12) uniform atomic_uint one; layout(binding = 1) uniform atomic_uint two; -layout(binding = 1, offset = 4) uniform atomic_uint three; + +// Layout qualifiers can be specified in any order. +layout(offset = 4, binding = 1) uniform atomic_uint three; + layout(binding = 1) uniform atomic_uint four; layout(binding = 2) uniform atomic_uint five; diff --git a/tests/glsl-intrinsic/atomic/atomicErrorTest1.slang b/tests/glsl-intrinsic/atomic/atomicErrorTest1.slang index 0512d598e..daf3c0c0f 100644 --- a/tests/glsl-intrinsic/atomic/atomicErrorTest1.slang +++ b/tests/glsl-intrinsic/atomic/atomicErrorTest1.slang @@ -2,7 +2,7 @@ //DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly -DTARGET_SPIRV #version 430 -// CHECK: error 20001 +// CHECK: error 20002 //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0], stride=4):name=one layout(binding = 1, offset = ) uniform atomic_uint one; diff --git a/tests/glsl-intrinsic/atomic/atomicErrorTest3.slang b/tests/glsl-intrinsic/atomic/atomicErrorTest3.slang index b21d27f6d..70d6bb266 100644 --- a/tests/glsl-intrinsic/atomic/atomicErrorTest3.slang +++ b/tests/glsl-intrinsic/atomic/atomicErrorTest3.slang @@ -5,7 +5,7 @@ // CHECK: error 20016 //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0], stride=4):name=one -layout(offset ) uniform atomic_uint one; +layout(offset = 4) uniform atomic_uint one; void computeMain() { diff --git a/tests/glsl-intrinsic/atomic/atomicErrorTest4.slang b/tests/glsl-intrinsic/atomic/atomicErrorTest4.slang index 404e2338c..5b2435c41 100644 --- a/tests/glsl-intrinsic/atomic/atomicErrorTest4.slang +++ b/tests/glsl-intrinsic/atomic/atomicErrorTest4.slang @@ -2,7 +2,7 @@ //DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly -DTARGET_SPIRV #version 430 -// CHECK: error 20001 +// CHECK: error 31217 //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0], stride=4):name=one layout(binding = 1, offset) uniform atomic_uint one; diff --git a/tests/glsl/layout-qualifier-exprs.slang b/tests/glsl/layout-qualifier-exprs.slang new file mode 100644 index 000000000..442497261 --- /dev/null +++ b/tests/glsl/layout-qualifier-exprs.slang @@ -0,0 +1,34 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry computeMain -allow-glsl + +#version 450 + +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; + +static const uint BINDING_BASE = 3; +static const uint BINDING_STRIDE = 2; + +static const uint SET_BASE = 1; +static const uint SET_STRIDE = 4; + +//TEST_INPUT:ubuffer(data=[2 2 2 2], stride=4):name=a +layout(set = SET_BASE, binding = BINDING_BASE * BINDING_STRIDE) buffer InputA { + float a[]; +}; + +//TEST_INPUT:ubuffer(data=[2 2 2 2], stride=4):name=b +layout(set = SET_BASE + SET_STRIDE, binding = BINDING_BASE * BINDING_STRIDE * 2) buffer InputB { + float b[]; +}; + +layout(set = SET_BASE + SET_STRIDE * 2, binding = BINDING_BASE * BINDING_STRIDE * 3) buffer Output { + float result[]; +}; + +void computeMain() { + uint index = gl_GlobalInvocationID.x; + + result[index] = a[index] * b[index]; + + // CHECK: OpEntryPoint +} + diff --git a/tests/hlsl-intrinsic/image-swizzle-write.slang b/tests/hlsl-intrinsic/image-swizzle-write.slang index e8a006314..3a4f233bc 100644 --- a/tests/hlsl-intrinsic/image-swizzle-write.slang +++ b/tests/hlsl-intrinsic/image-swizzle-write.slang @@ -1,7 +1,7 @@ //TEST:SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target spirv -emit-spirv-directly //TEST:SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target spirv -layout(rgba6f) +layout(rgba8) RWTexture2D<float4> texture; [numthreads(4, 1, 1)] |
