summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
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;
}