summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/vk-shift-uniform-issue.slang2
-rw-r--r--tests/reflection/binding-push-constant-gl.hlsl.expected2
-rw-r--r--tests/spirv/constant-buffer-layout.slang45
-rw-r--r--tests/spirv/push-constant-layout.slang26
-rw-r--r--tests/spirv/spec-constant-space.slang17
5 files changed, 90 insertions, 2 deletions
diff --git a/tests/bugs/vk-shift-uniform-issue.slang b/tests/bugs/vk-shift-uniform-issue.slang
index bc5963fe0..7f27d2c56 100644
--- a/tests/bugs/vk-shift-uniform-issue.slang
+++ b/tests/bugs/vk-shift-uniform-issue.slang
@@ -13,7 +13,7 @@
// CHECK-NEXT:uniform sampler sampler1_0;
// CHECK: layout(push_constant)
-// CHECK-NEXT: layout(std140) uniform
+// CHECK-NEXT: layout(std430) uniform
// CHECK:layout(binding = 1004)
// CHECK-NEXT:layout(std140) uniform
diff --git a/tests/reflection/binding-push-constant-gl.hlsl.expected b/tests/reflection/binding-push-constant-gl.hlsl.expected
index 13dfe2fcd..0b906d461 100644
--- a/tests/reflection/binding-push-constant-gl.hlsl.expected
+++ b/tests/reflection/binding-push-constant-gl.hlsl.expected
@@ -138,7 +138,7 @@ standard output = {
}
]
},
- "binding": {"kind": "uniform", "offset": 0, "size": 16}
+ "binding": {"kind": "uniform", "offset": 0, "size": 8}
}
}
},
diff --git a/tests/spirv/constant-buffer-layout.slang b/tests/spirv/constant-buffer-layout.slang
new file mode 100644
index 000000000..90aa1eef8
--- /dev/null
+++ b/tests/spirv/constant-buffer-layout.slang
@@ -0,0 +1,45 @@
+//TEST:SIMPLE(filecheck=SPIRV): -target spirv -emit-spirv-directly
+
+//SPIRV: ArrayStride 12
+
+struct Test
+{
+//SPIRV: Offset 0
+ uint v0;
+
+//SPIRV: Offset 4
+// matrix always start on a new register
+ float3x3 v1;
+//SPIRV: Offset 40
+// Non-matrix can pack with a partially filled register
+ uint v2;
+};
+
+ConstantBuffer<Test, ScalarDataLayout> buffer;
+
+//TEST_INPUT:ubuffer(data=[0], stride=4):out,name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+__generic<T : IArithmetic, let N : int>
+bool comp(vector<T,N> v1, vector<T,N> v2)
+{
+ for (uint i = 0; i < N; i++)
+ if (v1[i] != v2[i])
+ return false;
+
+ return true;
+}
+
+[shader("compute")]
+[numthreads(2, 2, 1)]
+void computeMain()
+{
+ // CHECK: 64
+ outputBuffer[0] = (true
+ && buffer.v0 == 1
+ && comp(buffer.v1[0], float3(2, 3, 4))
+ && comp(buffer.v1[1], float3(5, 6, 7))
+ && comp(buffer.v1[2], float3(8, 9, 10))
+ && buffer.v2 == 11
+ ) ? 100 : 0;
+} \ No newline at end of file
diff --git a/tests/spirv/push-constant-layout.slang b/tests/spirv/push-constant-layout.slang
new file mode 100644
index 000000000..eb7d80f75
--- /dev/null
+++ b/tests/spirv/push-constant-layout.slang
@@ -0,0 +1,26 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -fvk-use-entrypoint-name
+// CHECK-NOT: std140
+struct Transform
+{
+ float4 Tint;
+ float2x2 ScaleRot;
+ float2 Translation;
+};
+
+[[vk::push_constant]]
+ConstantBuffer<Transform> transform1;
+
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(1,1,1)]
+void computeMain1()
+{
+ outputBuffer[0] = transform1.Translation.x;
+}
+
+[numthreads(1,1,1)]
+void computeMain2(
+ [vk::push_constant] ConstantBuffer<Transform> transform2)
+{
+ outputBuffer[0] = transform2.Translation.x;
+} \ No newline at end of file
diff --git a/tests/spirv/spec-constant-space.slang b/tests/spirv/spec-constant-space.slang
new file mode 100644
index 000000000..b4dd865c7
--- /dev/null
+++ b/tests/spirv/spec-constant-space.slang
@@ -0,0 +1,17 @@
+// Test that use of specialization constants does not cause space 0 to be reserved.
+
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+// CHECK-NOT: DescriptorSet 1
+
+struct MyData { float4 val; RWStructuredBuffer<float> outputBuffer; }
+
+
+[vk::specialization_constant]
+const int kSpecializationConstant = 0;
+
+[NumThreads(1,1,1)]
+void main(ParameterBlock<MyData> g_data)
+{
+ g_data.outputBuffer[0] = g_data.val.x;
+} \ No newline at end of file