summaryrefslogtreecommitdiffstats
path: root/tests/render
diff options
context:
space:
mode:
authorAnders Leino <aleino@nvidia.com>2024-11-25 15:40:47 +0200
committerGitHub <noreply@github.com>2024-11-25 21:40:47 +0800
commit044b52c3195edf3282a0b530a21ad54b87135cd9 (patch)
treec1bd9d9a916faf64629442baf2b4e05ea053c230 /tests/render
parentaaca2d2b615ce113ae9eff11a6fc01f579471b12 (diff)
Fix issue where inter-stage parameters without semantics don't get location attributes (#5670)
* wgsl: Make sure each shader input field has a semantic This closes #5633. * Add test for inter-stage variables without semantics This verifies the fix of the second issue identified in https://github.com/shader-slang/slang/issues/5633 * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tests/render')
-rw-r--r--tests/render/multiple-stage-io-locations-without-user-semantics.slang77
-rw-r--r--tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected5
-rw-r--r--tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected.pngbin0 -> 36676 bytes
3 files changed, 82 insertions, 0 deletions
diff --git a/tests/render/multiple-stage-io-locations-without-user-semantics.slang b/tests/render/multiple-stage-io-locations-without-user-semantics.slang
new file mode 100644
index 000000000..af0e3e39f
--- /dev/null
+++ b/tests/render/multiple-stage-io-locations-without-user-semantics.slang
@@ -0,0 +1,77 @@
+// TODO: Investigate failures on non-WebGPU backends
+//TEST(smoke,render):COMPARE_HLSL_RENDER: -wgpu
+
+cbuffer Uniforms
+{
+ float4x4 modelViewProjection;
+}
+
+struct AssembledVertex
+{
+ float3 position;
+ float3 color;
+};
+
+struct Fragment
+{
+ float4 color;
+};
+
+// Vertex Shader
+
+struct VertexStageInput
+{
+ AssembledVertex assembledVertex : A;
+};
+
+struct VertexStageOutput
+{
+ float3 color;
+ float3 localPosition;
+ float4 sv_position : SV_Position;
+};
+
+VertexStageOutput vertexMain(VertexStageInput input)
+{
+ VertexStageOutput output;
+
+ float3 position = input.assembledVertex.position;
+ float3 color = input.assembledVertex.color;
+
+ output.color = color;
+ output.sv_position = mul(modelViewProjection, float4(position, 1.0));
+ output.localPosition = position;
+
+ return output;
+}
+
+// Fragment Shader
+
+struct FragmentStageInput
+{
+ float3 color;
+ float3 localPosition;
+};
+
+struct FragmentStageOutput
+{
+ Fragment fragment : SV_Target;
+};
+
+FragmentStageOutput fragmentMain(FragmentStageInput input)
+{
+ FragmentStageOutput output;
+
+ float3 color = input.color;
+
+ if (input.color.y < input.color.z)
+ {
+ output.fragment.color = float4(input.localPosition, 1.0);
+ }
+ else
+ {
+ output.fragment.color = float4(input.color, 1.0);
+ }
+
+ return output;
+}
diff --git a/tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected b/tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected
new file mode 100644
index 000000000..4c32e2510
--- /dev/null
+++ b/tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected
@@ -0,0 +1,5 @@
+result code = 0
+standard error = {
+}
+standard output = {
+}
diff --git a/tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected.png b/tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected.png
new file mode 100644
index 000000000..3333a12d7
--- /dev/null
+++ b/tests/render/multiple-stage-io-locations-without-user-semantics.slang.expected.png
Binary files differ