summaryrefslogtreecommitdiff
path: root/tests/spirv/scalar-buffer-packing.slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-09-26 23:56:06 -0700
committerGitHub <noreply@github.com>2023-09-27 14:56:06 +0800
commitebe8ddefc48478307d5f206cd3e40c41d28a36e3 (patch)
tree8e13977979909a26394eea532d8b95cd5ad0f6d1 /tests/spirv/scalar-buffer-packing.slang
parentc5c8cfbb360d9a763f549df48636effde839eacd (diff)
Various SPIRV fixes. (#3231)
* Various SPIRV fixes. - Geometry shader support (WIP). - Fix texture get dimension and load. - Fold global GetElement(MakeArray/MakeVector) insts. - Call spvopt to inline all functions. - Translate OpImageSubscript. - Emit struct member names and global variable names. - Fix lowering of OpBitNot -> OpNot, instead of OpBitReverse. * Fix test. * Fix geometry shader. * Fix geometry shader emit. * Add atomic Image access test. * Fix tests. * don't fail if spirv-opt fails. * Update comments. * Fix test. * Cleanups. * indentation --------- Co-authored-by: Yong He <yhe@nvidia.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'tests/spirv/scalar-buffer-packing.slang')
-rw-r--r--tests/spirv/scalar-buffer-packing.slang56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/spirv/scalar-buffer-packing.slang b/tests/spirv/scalar-buffer-packing.slang
new file mode 100644
index 000000000..bc42cfa39
--- /dev/null
+++ b/tests/spirv/scalar-buffer-packing.slang
@@ -0,0 +1,56 @@
+// scalar-buffer-packing.slang
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute
+//TEST:SIMPLE(filecheck=SPIRV): -stage compute -entry computeMain -target spirv -emit-spirv-directly -force-glsl-scalar-layout
+// Test ability to directly output SPIR-V
+
+//TEST_INPUT:set Uniforms.v0 = 1
+//TEST_INPUT:set Uniforms.v1 = { 1.0, 2.0, 3.0}
+
+cbuffer Uniforms
+{
+ bool v0;
+ float3 v1[3];
+}
+
+struct Val
+{
+ bool x;
+ int3 v1[2];
+ [mutating]
+ void set(bool v)
+ {
+ x = v;
+ v1[0].x = 1;
+ v1[0].y = 2;
+ v1[0].z = 3;
+ v1[1].x = 4;
+ v1[1].y = 5;
+ v1[1].z = 6;
+ }
+}
+
+//TEST_INPUT:set result = out ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0], stride=4)
+RWStructuredBuffer<Val> result;
+[numthreads(1,1,1)]
+void computeMain()
+{
+ // CHECK: 1
+ // CHECK: 0
+ // CHECK: 0
+ // CHECK: 0
+ // CHECK: 1
+ // CHECK: 2
+ // CHECK: 3
+ // CHECK: 0
+ // CHECK: 4
+ // CHECK: 5
+ // CHECK: 6
+
+ result[0].set(v0);
+}
+
+// SPIRV: OpEntryPoint GLCompute
+
+// SPIRV-DAG: %[[STRUCTNAME:[A-Za-z0-9_]+]] = OpTypeStruct %int %_Array_natural_int32
+
+// SPIRV-DAG: OpMemberDecorate %[[STRUCTNAME:[A-Za-z0-9_]+]] 1 Offset 4