summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/spirv/large-struct-pack.slang29
-rw-r--r--tests/spirv/large-struct-ptr.slang20
-rw-r--r--tests/spirv/large-struct.slang32
3 files changed, 81 insertions, 0 deletions
diff --git a/tests/spirv/large-struct-pack.slang b/tests/spirv/large-struct-pack.slang
new file mode 100644
index 000000000..df15ac67c
--- /dev/null
+++ b/tests/spirv/large-struct-pack.slang
@@ -0,0 +1,29 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -profile glsl_460
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute
+
+// Check that when generating spirv directly, we use a loop
+// to copy large arrays in a local variable to a buffer, instead of emitting
+// unrolled code that reads each element of the array individually.
+
+struct WorkData
+{
+ int B[1024];
+};
+
+//TEST_INPUT:set resultBuffer = out ubuffer(data=[0 0 0 0], stride=4, count=1024)
+RWStructuredBuffer<WorkData> resultBuffer;
+
+// CHECK: OpLoopMerge
+// CHECK: OpLoopMerge
+
+// BUF: 0
+// BUF: 1
+[numthreads(1, 1, 1)]
+void computeMain(uint3 tid: SV_DispatchThreadID)
+{
+ WorkData wd;
+ for (int i = 0; i < 1024; i++)
+ wd.B[i] = i;
+ resultBuffer[0] = wd;
+}
diff --git a/tests/spirv/large-struct-ptr.slang b/tests/spirv/large-struct-ptr.slang
new file mode 100644
index 000000000..131ccdbb9
--- /dev/null
+++ b/tests/spirv/large-struct-ptr.slang
@@ -0,0 +1,20 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -profile glsl_460
+
+struct WorkData {
+ float A[2048 * 2048];
+ float B[2048 * 2048];
+};
+struct PushData {
+ WorkData* Input;
+ float* Dest;
+};
+
+[vk::push_constant] ConstantBuffer<PushData> cb;
+
+// CHECK: OpEntryPoint
+
+[numthreads(64, 1, 1)]
+void ComputeMain(uint tid: SV_DispatchThreadID)
+{
+ cb.Dest[tid] = cb.Input->A[tid] * cb.Input->B[tid];
+} \ No newline at end of file
diff --git a/tests/spirv/large-struct.slang b/tests/spirv/large-struct.slang
new file mode 100644
index 000000000..7738a5fcf
--- /dev/null
+++ b/tests/spirv/large-struct.slang
@@ -0,0 +1,32 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -profile glsl_460
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-d3d12 -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -output-using-type
+
+// Check that when generating spirv directly, we use a loop
+// to copy large arrays in input data out into a local variable, instead of emitting
+// unrolled code that reads each element of the array individually.
+
+struct WorkData
+{
+ float A[2*2];
+ float B[1024];
+
+ float Foo(uint i) { return A[i] * B[i]; }
+};
+
+//TEST_INPUT:set input = new WorkData{[1.0, 2.0, 3.0, 4.0], [10.0, 20.0, 30.0, 40.0]}
+ConstantBuffer<WorkData> input;
+
+//TEST_INPUT:set resultBuffer = out ubuffer(data=[0 0 0 0], stride=4)
+RWStructuredBuffer<float> resultBuffer;
+
+// CHECK: OpLoopMerge
+
+[numthreads(2, 1, 1)]
+void computeMain(uint3 tid: SV_DispatchThreadID)
+{
+ // BUF: 10.0
+ // BUF: 40.0
+ resultBuffer[tid.x] = input.Foo(tid.x);
+} \ No newline at end of file