From a67cb0609587c230746b52567ff5775cab215220 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Sat, 3 Feb 2024 10:14:04 +0800 Subject: GLSL Passthrough support for SSBO types (#3446) * GLSL Passthrough support for SSBO types * GLSL Passthrough support for SSBO types * Correctly apply glsl local size layout to entry points during lowering * Test for glsl layout correctness * typo * Reflect GLSL SSBO as raw buffers * Functional test for glsl ssbo * Allow allow glsl for render tests * Functional test for ssbo passthrough * Functional test for ssbo passthrough with spirv-direct * fix windows build error --------- Co-authored-by: Yong He --- tests/glsl/compute-shader-layout.slang | 11 +++-------- tests/glsl/ssbo-2.slang | 27 +++++++++++++++++---------- tests/glsl/ssbo-3.slang | 26 ++++++++++++++++++++++++++ tests/glsl/ssbo.slang | 25 ++++++++++++++++++------- 4 files changed, 64 insertions(+), 25 deletions(-) create mode 100644 tests/glsl/ssbo-3.slang (limited to 'tests/glsl') diff --git a/tests/glsl/compute-shader-layout.slang b/tests/glsl/compute-shader-layout.slang index b81a87aed..d7ff9b89c 100644 --- a/tests/glsl/compute-shader-layout.slang +++ b/tests/glsl/compute-shader-layout.slang @@ -1,5 +1,5 @@ -//TEST:SIMPLE(filecheck=CHECKGLSLANG): -target spirv -stage compute -entry main -allow-glsl -//TEST:SIMPLE(filecheck=CHECKDIRECT): -target spirv -stage compute -entry main -allow-glsl -emit-spirv-directly +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry main -allow-glsl +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry main -allow-glsl -emit-spirv-directly #version 430 precision highp float; precision highp int; @@ -9,12 +9,7 @@ layout(binding = 0) buffer MyBlockName vec4 data[]; } output_data; -// CHECKGLSLANG-DAG: [[x:%[^ ]+]] = OpConstant {{%[^ ]+}} 44 -// CHECKGLSLANG-DAG: [[y:%[^ ]+]] = OpConstant {{%[^ ]+}} 45 -// CHECKGLSLANG-DAG: [[z:%[^ ]+]] = OpConstant {{%[^ ]+}} 46 -// CHECKGLSLANG: %gl_WorkGroupSize = OpConstantComposite {{%[^ ]+}} [[x]] [[y]] [[z]] - -// CHECKDIRECT: OpExecutionMode %main LocalSize 44 45 46 +// CHECK: OpExecutionMode %main LocalSize 44 45 46 layout(local_size_x = 44, local_size_y = 45, local_size_z = 46) in; void main() { diff --git a/tests/glsl/ssbo-2.slang b/tests/glsl/ssbo-2.slang index 11542a539..0d6f1c1f6 100644 --- a/tests/glsl/ssbo-2.slang +++ b/tests/glsl/ssbo-2.slang @@ -1,20 +1,27 @@ -//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry main -allow-glsl +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly #version 430 precision highp float; precision highp int; +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer layout(binding = 0) buffer MyBlockName { - vec4 a; - float b; + int a; + int b; int c; -} output_data; + int d; +} outputBuffer; -layout(local_size_x = 4) in; -void main() +layout(local_size_x = 1) in; +void computeMain() { - output_data.a = vec4(gl_GlobalInvocationID, 1); - output_data.b = 10; - output_data.c = 20; - // CHECK: OpEntryPoint + outputBuffer.a = 1; + outputBuffer.b = 2; + outputBuffer.c = 3; + outputBuffer.d = 4; + // BUF: 1 + // BUF-NEXT: 2 + // BUF-NEXT: 3 + // BUF-NEXT: 4 } diff --git a/tests/glsl/ssbo-3.slang b/tests/glsl/ssbo-3.slang new file mode 100644 index 000000000..e5d9aaddc --- /dev/null +++ b/tests/glsl/ssbo-3.slang @@ -0,0 +1,26 @@ +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly +#version 430 +precision highp float; +precision highp int; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +buffer MyBlockName2 +{ + uint foo; + uint bar; + uint data[]; +} outputBuffer; + +layout(local_size_x = 1) in; +void computeMain() +{ + outputBuffer.foo = 1; + outputBuffer.bar = 2; + outputBuffer.data[0] = 3; + outputBuffer.data[1] = 4; + // BUF: 1 + // BUF-NEXT: 2 + // BUF-NEXT: 3 + // BUF-NEXT: 4 +} diff --git a/tests/glsl/ssbo.slang b/tests/glsl/ssbo.slang index 47084a823..4f4db07cd 100644 --- a/tests/glsl/ssbo.slang +++ b/tests/glsl/ssbo.slang @@ -1,16 +1,27 @@ -//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry main -allow-glsl +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly #version 430 precision highp float; precision highp int; -layout(binding = 0) buffer MyBlockName +//TEST_INPUT:ubuffer(data=[2 3 5 7], stride=4):name=inputBuffer +buffer MyBlockName { - vec4 data[]; -} output_data; + uint data[]; +} inputBuffer; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +buffer MyBlockName2 +{ + uint data[]; +} outputBuffer; layout(local_size_x = 4) in; -void main() +void computeMain() { - output_data.data[gl_GlobalInvocationID.x] = vec4(gl_GlobalInvocationID, 1); - // CHECK: OpEntryPoint + outputBuffer.data[gl_GlobalInvocationID.x] = inputBuffer.data[gl_GlobalInvocationID.x]; + // BUF: 2 + // BUF-NEXT: 3 + // BUF-NEXT: 5 + // BUF-NEXT: 7 } -- cgit v1.2.3