summaryrefslogtreecommitdiffstats
path: root/tests/spirv
diff options
context:
space:
mode:
Diffstat (limited to 'tests/spirv')
-rw-r--r--tests/spirv/array-uniform-param.slang4
-rw-r--r--tests/spirv/matrix-vertex-input.slang91
-rw-r--r--tests/spirv/nested-entrypoint.slang19
-rw-r--r--tests/spirv/optional-vertex-output.slang5
4 files changed, 102 insertions, 17 deletions
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