diff options
| author | Yong He <yonghe@outlook.com> | 2025-01-07 22:26:31 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-07 22:26:31 -0800 |
| commit | c43f6fa55aca23365c86c6ec1737d42be74d9d3e (patch) | |
| tree | 2c49bc1dbd12ae5f46d682a3f240465931471060 /tests | |
| parent | 1a56f58fdd0c704e6dc0fad0f0ec33a25a35e60b (diff) | |
Lower varying parameters as pointers instead of SSA values. (#5919)
* Add executable test on matrix-typed vertex input.
* Fix emit logic of matrix layout qualifier.
* Pass fragment shader varying input by constref to allow EvaluateAttributeAtCentroid etc. to be implemented correctly.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/gh-841.slang | 4 | ||||
| -rw-r--r-- | tests/bugs/vk-structured-buffer-load.hlsl | 5 | ||||
| -rw-r--r-- | tests/cross-compile/glsl-generic-in.slang | 6 | ||||
| -rw-r--r-- | tests/glsl-intrinsic/fragment-processing/fragment-processing.slang | 4 | ||||
| -rw-r--r-- | tests/glsl/matrix-mul.slang | 2 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/fragment-interpolate.slang | 17 | ||||
| -rw-r--r-- | tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang | 17 | ||||
| -rw-r--r-- | tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.glsl | 20 | ||||
| -rw-r--r-- | tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.hlsl | 16 | ||||
| -rw-r--r-- | tests/pipeline/rasterization/get-attribute-at-vertex.slang | 2 | ||||
| -rw-r--r-- | tests/pipeline/rasterization/varying-to-inout.slang | 22 | ||||
| -rw-r--r-- | tests/spirv/array-uniform-param.slang | 4 | ||||
| -rw-r--r-- | tests/spirv/matrix-vertex-input.slang | 91 | ||||
| -rw-r--r-- | tests/spirv/nested-entrypoint.slang | 19 | ||||
| -rw-r--r-- | tests/spirv/optional-vertex-output.slang | 5 | ||||
| -rw-r--r-- | tests/vkray/anyhit.slang | 2 | ||||
| -rw-r--r-- | tests/vkray/anyhit.slang.glsl | 17 |
17 files changed, 167 insertions, 86 deletions
diff --git a/tests/bugs/gh-841.slang b/tests/bugs/gh-841.slang index ba746984b..5f7e0c81f 100644 --- a/tests/bugs/gh-841.slang +++ b/tests/bugs/gh-841.slang @@ -11,8 +11,8 @@ struct RasterVertex float4 c : COLOR; // Make sure that the input value in location 1 is decorated as Flat - // SPV-DAG: [[VAL:%[_A-Za-z0-9]+]] = OpVariable {{.*}} Input - // SPV-DAG: OpDecorate [[VAL]] Location 1 + // SPV-DAG: OpDecorate [[VAL:%[_A-Za-z0-9]+]] Location 1 + // SPV-DAG: [[VAL]] = OpVariable {{.*}} Input // SPV-DAG: OpDecorate [[VAL]] Flat // // Likewise for GLSL diff --git a/tests/bugs/vk-structured-buffer-load.hlsl b/tests/bugs/vk-structured-buffer-load.hlsl index d9e54d925..ac8a86a5c 100644 --- a/tests/bugs/vk-structured-buffer-load.hlsl +++ b/tests/bugs/vk-structured-buffer-load.hlsl @@ -1,4 +1,9 @@ //TEST:CROSS_COMPILE: -profile glsl_460+GL_NV_ray_tracing -entry HitMain -stage closesthit -target spirv-assembly +//TEST:SIMPLE(filecheck=DXIL): -target dxil -entry HitMain -stage closesthit -profile sm_6_5 +//TEST:SIMPLE(filecheck=SPV): -target spirv + +// DXIL: define void @ +// SPV: OpEntryPoint #define USE_RCP 0 diff --git a/tests/cross-compile/glsl-generic-in.slang b/tests/cross-compile/glsl-generic-in.slang index a743c32cb..6bf2d28fb 100644 --- a/tests/cross-compile/glsl-generic-in.slang +++ b/tests/cross-compile/glsl-generic-in.slang @@ -1,9 +1,9 @@ //TEST:SIMPLE(filecheck=CHECK): -target spirv-assembly -entry main -profile vs_5_0 -emit-spirv-directly //TEST:SIMPLE(filecheck=CHECK): -target spirv-assembly -entry main -profile vs_5_0 -emit-spirv-via-glsl -// CHECK: vIn_field_v0{{.*}} = OpVariable %_ptr_Input_v4float Input -// CHECK: %vIn_field_v1{{.*}}= OpVariable %_ptr_Input_v2float Input -// CHECK: %vIn_p0{{.*}}= OpVariable %_ptr_Input_v3float Input +// CHECK-DAG: vIn_field_v0{{.*}} = OpVariable %_ptr_Input_v4float Input +// CHECK-DAG: %vIn_field_v1{{.*}}= OpVariable %_ptr_Input_v2float Input +// CHECK-DAG: %vIn_p0{{.*}}= OpVariable %_ptr_Input_v3float Input interface IField { diff --git a/tests/glsl-intrinsic/fragment-processing/fragment-processing.slang b/tests/glsl-intrinsic/fragment-processing/fragment-processing.slang index 909679bbe..c69752cd0 100644 --- a/tests/glsl-intrinsic/fragment-processing/fragment-processing.slang +++ b/tests/glsl-intrinsic/fragment-processing/fragment-processing.slang @@ -76,8 +76,8 @@ bool testFragmentProcessingDerivativeFunctionsVector() } bool testFragmentProcessingInterpolateFunctions() { -// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtCentroid %inDataV1 -// CHECK_GLSL: interpolateAtCentroid{{.*}}inDataV1 +// CHECK_SPV-DAG: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtCentroid %inDataV1 +// CHECK_GLSL-DAG: interpolateAtCentroid{{.*}}inDataV1 // CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtSample %inDataV1 {{.*}} // CHECK_GLSL: interpolateAtSample{{.*}}inDataV1 // CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtOffset %inDataV1 {{.*}} diff --git a/tests/glsl/matrix-mul.slang b/tests/glsl/matrix-mul.slang index 156673b87..3bdd1cb8d 100644 --- a/tests/glsl/matrix-mul.slang +++ b/tests/glsl/matrix-mul.slang @@ -1,6 +1,6 @@ //TEST:SIMPLE(filecheck=SPIRV): -target spirv -stage vertex -entry main -allow-glsl -emit-spirv-directly //TEST:SIMPLE(filecheck=SPIRV): -target spirv -stage vertex -entry main -allow-glsl -//TEST:SIMPLE(filecheck=METAL): -target metal -stage vertex -entry main -allow-glsl +//TEST:SIMPLE(filecheck=METAL): -target metal -stage vertex -entry main -allow-glsl -matrix-layout-row-major #version 310 es layout(location = 0) in highp vec4 a_position; diff --git a/tests/hlsl-intrinsic/fragment-interpolate.slang b/tests/hlsl-intrinsic/fragment-interpolate.slang new file mode 100644 index 000000000..f64e4e13b --- /dev/null +++ b/tests/hlsl-intrinsic/fragment-interpolate.slang @@ -0,0 +1,17 @@ +//TEST:SIMPLE(filecheck=CHECK_HLSL): -target hlsl -stage fragment -entry main +//TEST:SIMPLE(filecheck=CHECK_SPV): -target spirv -emit-spirv-directly -stage fragment -entry main + +struct VertexOut +{ + float4 pos : SV_Position; + float3 color; +} + +// CHECK_SPV: %v_color = OpVariable %_ptr_Input_v3float Input +// CHECK_SPV: %{{.*}} = OpExtInst %v3float %{{.*}} InterpolateAtCentroid %v_color +// CHECK_HLSL: EvaluateAttributeAtCentroid(v_0.color_0) + +float4 main(VertexOut v) : SV_Target +{ + return float4(EvaluateAttributeAtCentroid(v.color), 1.0); +}
\ No newline at end of file diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang b/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang deleted file mode 100644 index d7bdbc69c..000000000 --- a/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang +++ /dev/null @@ -1,17 +0,0 @@ -// get-attribute-at-vertex.slang - -// Basic test for `GetAttributeAtVertex` function - -//TEST:CROSS_COMPILE:-target dxil -capability GL_NV_fragment_shader_barycentric -entry main -stage fragment -profile sm_6_1 -//TEST:CROSS_COMPILE:-target spirv -capability GL_NV_fragment_shader_barycentric -entry main -stage fragment -profile glsl_450 - -[shader("fragment")] -void main( - pervertex float4 color : COLOR, - float3 bary : SV_Barycentrics, - out float4 result : SV_Target) -{ - result = bary.x * GetAttributeAtVertex(color, 0) - + bary.y * GetAttributeAtVertex(color, 1) - + bary.z * GetAttributeAtVertex(color, 2); -} diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.glsl b/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.glsl deleted file mode 100644 index 820918d8b..000000000 --- a/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.glsl +++ /dev/null @@ -1,20 +0,0 @@ -// get-attribute-at-vertex.slang.glsl -//TEST_IGNORE_FILE: - -#version 450 -#extension GL_EXT_fragment_shader_barycentric : require -layout(row_major) uniform; -layout(row_major) buffer; - -pervertexEXT layout(location = 0) -in vec4 color_0[3]; - -layout(location = 0) -out vec4 result_0; - -void main() -{ - result_0 = gl_BaryCoordEXT.x * ((color_0)[(0U)]) + gl_BaryCoordEXT.y * ((color_0)[(1U)]) + gl_BaryCoordEXT.z * ((color_0)[(2U)]); - return; -} - diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.hlsl b/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.hlsl deleted file mode 100644 index a6b45eab4..000000000 --- a/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// get-attribute-at-vertex.slang.hlsl - -//TEST_IGNORE_FILE: - -#pragma warning(disable: 3557) - -[shader("pixel")] -void main( - nointerpolation vector<float,4> color_0 : COLOR, - vector<float,3> bary_0 : SV_BARYCENTRICS, - out vector<float,4> result_0 : SV_TARGET) -{ - result_0 = bary_0.x * GetAttributeAtVertex(color_0, 0U) - + bary_0.y * GetAttributeAtVertex(color_0, 1U) - + bary_0.z * GetAttributeAtVertex(color_0, 2U); -} diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex.slang b/tests/pipeline/rasterization/get-attribute-at-vertex.slang index 9ae347a3a..c334200fb 100644 --- a/tests/pipeline/rasterization/get-attribute-at-vertex.slang +++ b/tests/pipeline/rasterization/get-attribute-at-vertex.slang @@ -2,8 +2,6 @@ // Basic test for `GetAttributeAtVertex` function -//TEST:CROSS_COMPILE:-target dxil -entry main -stage fragment -profile sm_6_1 -//TEST:CROSS_COMPILE:-target spirv -entry main -stage fragment -profile glsl_450+GL_EXT_fragment_shader_barycentric //TEST:SIMPLE(filecheck=CHECK):-emit-spirv-directly -target spirv -entry main -stage fragment -profile glsl_450+GL_EXT_fragment_shader_barycentric // CHECK: OpCapability FragmentBarycentricKHR diff --git a/tests/pipeline/rasterization/varying-to-inout.slang b/tests/pipeline/rasterization/varying-to-inout.slang new file mode 100644 index 000000000..7a54fd82f --- /dev/null +++ b/tests/pipeline/rasterization/varying-to-inout.slang @@ -0,0 +1,22 @@ +// Test passing a varying parameter direclty to an inout parameter. + +//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry main -stage fragment + +// CHECK: OpEntryPoint Fragment %main "main" +struct PS_IN +{ + float3 pos : SV_Position; + float4 color : COLOR; +} + +void test(inout PS_IN v) +{ + v.color = v.color + v.pos.x; +} + +[shader("fragment")] +float4 main(PS_IN psIn):SV_Target +{ + test(psIn); + return psIn.color; +} diff --git a/tests/spirv/array-uniform-param.slang b/tests/spirv/array-uniform-param.slang index 235e85bbd..672543b9a 100644 --- a/tests/spirv/array-uniform-param.slang +++ b/tests/spirv/array-uniform-param.slang @@ -1,8 +1,10 @@ // array-uniform-param.slang -//TESTD:SIMPLE:-target spirv -entry computeMain -stage compute -emit-spirv-directly -force-glsl-scalar-layout +//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry computeMain -stage compute -emit-spirv-directly -force-glsl-scalar-layout //TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUFFER):-vk -compute -output-using-type +// CHECK: OpEntryPoint + // Test direct SPIR-V emit on arrays in uniforms. //TEST_INPUT:set resultBuffer = out ubuffer(data=[0 0 0 0], stride=4) diff --git a/tests/spirv/matrix-vertex-input.slang b/tests/spirv/matrix-vertex-input.slang index fc4af8c61..b6277bead 100644 --- a/tests/spirv/matrix-vertex-input.slang +++ b/tests/spirv/matrix-vertex-input.slang @@ -1,23 +1,84 @@ -//TEST:SIMPLE(filecheck=CHECK): -target spirv -// CHECK: OpVectorTimesMatrix +//TEST(compute):COMPARE_RENDER_COMPUTE(filecheck-buffer=ROWMAJOR): -vk -output-using-type +//TEST(compute):COMPARE_RENDER_COMPUTE(filecheck-buffer=ROWMAJOR): -d3d11 -output-using-type -struct Vertex +//TEST(compute):COMPARE_RENDER_COMPUTE(filecheck-buffer=COLMAJOR): -vk -output-using-type -emit-spirv-directly -xslang -DCOLUMN_MAJOR +//TEST(compute):COMPARE_RENDER_COMPUTE(filecheck-buffer=COLMAJOR): -d3d11 -output-using-type -xslang -DCOLUMN_MAJOR + +// Check that row_major and column_major matrix typed vertex input are correctly handled. + +//TEST_INPUT: Texture2D(size=4, content = one):name t +//TEST_INPUT: Sampler:name s +//TEST_INPUT: ubuffer(data=[0], stride=4):out, name outputBuffer + +Texture2D t; +SamplerState s; +RWStructuredBuffer<float> outputBuffer; + +cbuffer Uniforms { - float4x4 m; - float4 pos; + float4x4 modelViewProjection; } -struct VertexOut +struct AssembledVertex +{ + float3 position; + float3 color; + float2 uv; +#ifdef COLUMN_MAJOR + column_major float4x4 m; +#else + row_major float4x4 m; +#endif +}; + +struct CoarseVertex +{ + float3 color; +}; + +struct Fragment +{ + float4 color; +}; + +// Vertex Shader + +struct VertexStageInput +{ + AssembledVertex assembledVertex : A; +}; + +struct VertexStageOutput +{ + CoarseVertex coarseVertex : CoarseVertex; + float4 sv_position : SV_Position; +}; + +VertexStageOutput vertexMain(VertexStageInput input) { - float4 pos : SV_Position; - float4 color; + VertexStageOutput output; + output.coarseVertex.color = input.assembledVertex.m[1][2]; + output.sv_position = mul(modelViewProjection, float4(input.assembledVertex.position, 1.0)); + return output; } -[shader("vertex")] -VertexOut vertMain(Vertex v) +struct FragmentStageInput { - VertexOut o; - o.pos = mul(v.m, v.pos); - o.color = v.pos; - return o; -}
\ No newline at end of file + CoarseVertex coarseVertex : CoarseVertex; +}; + +struct FragmentStageOutput +{ + Fragment fragment : SV_Target; +}; + +FragmentStageOutput fragmentMain(FragmentStageInput input) +{ + FragmentStageOutput output; + float3 color = input.coarseVertex.color; + output.fragment.color = float4(color, 1.0); + outputBuffer[0] = color.x; + // ROWMAJOR: 7.0 + // COLMAJOR: 10.0 + return output; +} diff --git a/tests/spirv/nested-entrypoint.slang b/tests/spirv/nested-entrypoint.slang new file mode 100644 index 000000000..28e9b9c4a --- /dev/null +++ b/tests/spirv/nested-entrypoint.slang @@ -0,0 +1,19 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -fvk-use-entrypoint-name + +// CHECK: OpEntryPoint + +RWStructuredBuffer<int> output; + +[shader("compute")] +[numthreads(1,1,1)] +void innerMain(int id : SV_DispatchThreadID) +{ + output[id] = id; +} + +[shader("compute")] +[numthreads(1,1,1)] +void outerMain(int id : SV_DispatchThreadID) +{ + innerMain(id); +}
\ No newline at end of file diff --git a/tests/spirv/optional-vertex-output.slang b/tests/spirv/optional-vertex-output.slang index df15befa2..7baf02d0b 100644 --- a/tests/spirv/optional-vertex-output.slang +++ b/tests/spirv/optional-vertex-output.slang @@ -20,7 +20,10 @@ struct VSOut { VSOut vertMain(VIn i) { VSOut o; - o.a = i.inA; + if (i.inA.hasValue) + o.a = i.inA; + else + o.a = 0.0; o.outputValues = { true, false, true }; return o; }
\ No newline at end of file diff --git a/tests/vkray/anyhit.slang b/tests/vkray/anyhit.slang index 45d35b1fa..8f5a6e597 100644 --- a/tests/vkray/anyhit.slang +++ b/tests/vkray/anyhit.slang @@ -57,7 +57,6 @@ void main( // SPIRV: OpEntryPoint // SPIRV: BuiltIn HitTriangleVertexPositionsKHR // SPIRV: OpTypePointer HitAttribute{{NV|KHR}} -// SPIRV: OpTypePointer HitAttribute{{NV|KHR}} // SPIRV: OpVariable{{.*}}HitAttribute{{NV|KHR}} // SPIRV: OpIgnoreIntersectionKHR // SPIRV: OpTerminateRayKHR @@ -70,7 +69,6 @@ void main( // GL_SPIRV: OpEntryPoint // GL_SPIRV: BuiltIn HitTriangleVertexPositionsKHR // GL_SPIRV-DAG: OpTypePointer HitAttribute{{NV|KHR}} -// GL_SPIRV-DAG: OpTypePointer HitAttribute{{NV|KHR}} // GL_SPIRV: OpTerminateRayKHR // GL_SPIRV: OpIgnoreIntersectionKHR // GL_SPIRV-DAG: %{{.*}} = OpAccessChain %{{.*}} %{{.*}} %{{.*}} diff --git a/tests/vkray/anyhit.slang.glsl b/tests/vkray/anyhit.slang.glsl index 8255599b9..4d2e5a0dd 100644 --- a/tests/vkray/anyhit.slang.glsl +++ b/tests/vkray/anyhit.slang.glsl @@ -8,7 +8,7 @@ struct Params_0 }; layout(binding = 0) -layout(std140) uniform _S1 +layout(std140) uniform block_Params_0 { int mode_0; }gParams_0; @@ -23,20 +23,21 @@ struct SphereHitAttributes_0 vec3 normal_0; }; -hitAttributeEXT SphereHitAttributes_0 _S2; +hitAttributeEXT SphereHitAttributes_0 _S1; struct ShadowRay_0 { vec4 hitDistance_0; + vec3 dummyOut_0; }; -rayPayloadInEXT ShadowRay_0 _S3; +rayPayloadInEXT ShadowRay_0 _S2; void main() { if(gParams_0.mode_0 != 0) { - if((textureLod(sampler2D(gParams_alphaMap_0,gParams_sampler_0), (_S2.normal_0.xy), (0.0)).x) > 0.0) + if((textureLod(sampler2D(gParams_alphaMap_0,gParams_sampler_0), (_S1.normal_0.xy), (0.0)).x) > 0.0) { terminateRayEXT;; } @@ -45,6 +46,14 @@ void main() ignoreIntersectionEXT;; } } + + vec3 _S3 = (gl_HitTriangleVertexPositionsEXT[(0U)]); + _S2.dummyOut_0 = _S3; + vec3 _S4 = (gl_HitTriangleVertexPositionsEXT[(1U)]); + vec3 _S5 = _S3 + _S4; + _S2.dummyOut_0 = _S5; + vec3 _S6 = (gl_HitTriangleVertexPositionsEXT[(2U)]); + _S2.dummyOut_0 = _S5 + _S6; return; } |
