From ae04e604d43d169bcba7f24c8c23a0fdf4cbb483 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 18 Dec 2024 11:33:55 -0800 Subject: Allow `Optional`, `Tuple` and `bool` to be used in varying input/output. (#5889) * Allow `Optional` and `Tuple` to be used in varying input/output. * Fix. * format code * Fix. * Fix test. * Fix. * enhance test. * Fix. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- tests/spirv/matrix-vertex-input.slang | 23 +++++++++++++++++++++++ tests/spirv/optional-vertex-output.slang | 26 ++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/spirv/matrix-vertex-input.slang create mode 100644 tests/spirv/optional-vertex-output.slang (limited to 'tests') diff --git a/tests/spirv/matrix-vertex-input.slang b/tests/spirv/matrix-vertex-input.slang new file mode 100644 index 000000000..fc4af8c61 --- /dev/null +++ b/tests/spirv/matrix-vertex-input.slang @@ -0,0 +1,23 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv +// CHECK: OpVectorTimesMatrix + +struct Vertex +{ + float4x4 m; + float4 pos; +} + +struct VertexOut +{ + float4 pos : SV_Position; + float4 color; +} + +[shader("vertex")] +VertexOut vertMain(Vertex v) +{ + VertexOut o; + o.pos = mul(v.m, v.pos); + o.color = v.pos; + return o; +} \ No newline at end of file diff --git a/tests/spirv/optional-vertex-output.slang b/tests/spirv/optional-vertex-output.slang new file mode 100644 index 000000000..df15befa2 --- /dev/null +++ b/tests/spirv/optional-vertex-output.slang @@ -0,0 +1,26 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv + +// Test that we can use Optional or bool types in varying input or outputs. + +// CHECK: OpDecorate %i_inA_value Location 0 +// CHECK: OpDecorate %i_inA_hasValue Location 1 +// CHECK: OpDecorate %entryPointParam_vertMain_a_value Location 0 +// CHECK: OpDecorate %entryPointParam_vertMain_a_hasValue Location 1 + +struct VIn { + Optional inA; +} + +struct VSOut { + Optional a; + bool outputValues[3]; +}; + +[shader("vertex")] +VSOut vertMain(VIn i) +{ + VSOut o; + o.a = i.inA; + o.outputValues = { true, false, true }; + return o; +} \ No newline at end of file -- cgit v1.2.3