summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authordavli-nv <davli@nvidia.com>2025-08-06 12:29:28 -0700
committerGitHub <noreply@github.com>2025-08-06 19:29:28 +0000
commit5074c4948d73b451c74bd21ac139d69eaeb390f3 (patch)
treeb87d103868d14f1cfed946984a079164c38c5d26 /tests
parentd107327422b69777d41f1077c58d46c6bcf579c4 (diff)
Fix noperspective modifier for SV_Barycentrics in SPIRV and GLSL (#8067)
* Fix noperspective modifier for SV_Barycentrics in SPIRV and GLSL - Added test case with both regular and noperspective SV_Barycentrics inputs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: davli-nv <davli-nv@users.noreply.github.com> * fixup format * address review https://github.com/shader-slang/slang/pull/8067#pullrequestreview-3090037501 * address review https://github.com/shader-slang/slang/pull/8067#discussion_r2255818595 * add test case from review --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: davli-nv <davli-nv@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/pipeline/rasterization/get-attribute-at-vertex-struct.slang38
-rw-r--r--tests/pipeline/rasterization/get-attribute-at-vertex.slang25
2 files changed, 55 insertions, 8 deletions
diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex-struct.slang b/tests/pipeline/rasterization/get-attribute-at-vertex-struct.slang
new file mode 100644
index 000000000..a63be1718
--- /dev/null
+++ b/tests/pipeline/rasterization/get-attribute-at-vertex-struct.slang
@@ -0,0 +1,38 @@
+// get-attribute-at-vertex-struct.slang
+
+// Test GetAttributeAtVertex and SV_Barycentrics on struct members
+
+//TEST:SIMPLE(filecheck=CHECK-SPIRV):-target spirv -entry main -stage fragment -profile glsl_450+GL_EXT_fragment_shader_barycentric
+//TEST:SIMPLE(filecheck=CHECK-GLSL):-target glsl -entry main -stage fragment -profile glsl_450+GL_EXT_fragment_shader_barycentric
+
+// CHECK-SPIRV: OpCapability FragmentBarycentricKHR
+// CHECK-SPIRV: OpExtension "SPV_KHR_fragment_shader_barycentric"
+
+// CHECK-SPIRV: OpEntryPoint Fragment %main "main"
+// CHECK-SPIRV: OpDecorate %{{.*}} BuiltIn BaryCoordKHR
+// CHECK-SPIRV: OpDecorate %{{.*}} BuiltIn BaryCoordNoPerspKHR
+// CHECK-SPIRV: %{{.*}} = OpAccessChain %_ptr_Input_{{.*}} %{{.*}} %uint_0
+// CHECK-SPIRV: %{{.*}} = OpAccessChain %_ptr_Input_{{.*}} %{{.*}} %uint_1
+// CHECK-SPIRV: %{{.*}} = OpAccessChain %_ptr_Input_{{.*}} %{{.*}} %uint_2
+
+// CHECK-GLSL: #extension GL_EXT_fragment_shader_barycentric : require
+// CHECK-GLSL-DAG: gl_BaryCoordEXT
+// CHECK-GLSL-DAG: gl_BaryCoordNoPerspEXT
+
+struct Input
+{
+ pervertex float4 color : COLOR;
+ float3 bary : SV_Barycentrics;
+ noperspective float3 baryNoPerspective : SV_Barycentrics;
+}
+
+[shader("fragment")]
+void main(
+ Input input,
+ out float4 result : SV_Target)
+{
+ result = input.bary.x * GetAttributeAtVertex(input.color, 0)
+ + input.bary.y * GetAttributeAtVertex(input.color, 1)
+ + input.bary.z * GetAttributeAtVertex(input.color, 2)
+ + input.baryNoPerspective.x * 0.1f;
+} \ No newline at end of file
diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex.slang b/tests/pipeline/rasterization/get-attribute-at-vertex.slang
index c334200fb..342796b90 100644
--- a/tests/pipeline/rasterization/get-attribute-at-vertex.slang
+++ b/tests/pipeline/rasterization/get-attribute-at-vertex.slang
@@ -2,23 +2,32 @@
// Basic test for `GetAttributeAtVertex` function
-//TEST:SIMPLE(filecheck=CHECK):-emit-spirv-directly -target spirv -entry main -stage fragment -profile glsl_450+GL_EXT_fragment_shader_barycentric
+//TEST:SIMPLE(filecheck=CHECK-SPIRV):-target spirv -entry main -stage fragment -profile glsl_450+GL_EXT_fragment_shader_barycentric
+//TEST:SIMPLE(filecheck=CHECK-GLSL):-target glsl -entry main -stage fragment -profile glsl_450+GL_EXT_fragment_shader_barycentric
-// CHECK: OpCapability FragmentBarycentricKHR
-// CHECK: OpExtension "SPV_KHR_fragment_shader_barycentric"
+// CHECK-SPIRV: OpCapability FragmentBarycentricKHR
+// CHECK-SPIRV: OpExtension "SPV_KHR_fragment_shader_barycentric"
-// CHECK: OpEntryPoint Fragment %main "main"
-// CHECK: %{{.*}} = OpAccessChain %_ptr_Input_{{.*}} %{{.*}} %uint_0
-// CHECK: %{{.*}} = OpAccessChain %_ptr_Input_{{.*}} %{{.*}} %uint_1
-// CHECK: %{{.*}} = OpAccessChain %_ptr_Input_{{.*}} %{{.*}} %uint_2
+// CHECK-SPIRV: OpEntryPoint Fragment %main "main"
+// CHECK-SPIRV: OpDecorate %{{.*}} BuiltIn BaryCoordKHR
+// CHECK-SPIRV: OpDecorate %{{.*}} BuiltIn BaryCoordNoPerspKHR
+// CHECK-SPIRV: %{{.*}} = OpAccessChain %_ptr_Input_{{.*}} %{{.*}} %uint_0
+// CHECK-SPIRV: %{{.*}} = OpAccessChain %_ptr_Input_{{.*}} %{{.*}} %uint_1
+// CHECK-SPIRV: %{{.*}} = OpAccessChain %_ptr_Input_{{.*}} %{{.*}} %uint_2
+
+// CHECK-GLSL: #extension GL_EXT_fragment_shader_barycentric : require
+// CHECK-GLSL-DAG: gl_BaryCoordEXT
+// CHECK-GLSL-DAG: gl_BaryCoordNoPerspEXT
[shader("fragment")]
void main(
pervertex float4 color : COLOR,
float3 bary : SV_Barycentrics,
+ noperspective float3 baryNoPerspective : SV_Barycentrics,
out float4 result : SV_Target)
{
result = bary.x * GetAttributeAtVertex(color, 0)
+ bary.y * GetAttributeAtVertex(color, 1)
- + bary.z * GetAttributeAtVertex(color, 2);
+ + bary.z * GetAttributeAtVertex(color, 2)
+ + baryNoPerspective.x * 0.1f;
}