summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-02-03 12:29:12 -0800
committerGitHub <noreply@github.com>2024-02-03 12:29:12 -0800
commit6dca7e39292e6c5672440f6f1dbfb204a79b90d2 (patch)
tree8f6d3c51bf0195d94c34043db5c8b29f18c16b2e /tests
parent14764896c34b230a5563f48d8b8e565de2f3aa10 (diff)
Fix spirv emit that leads to pathological downstream time. (#3546)
Diffstat (limited to 'tests')
-rw-r--r--tests/spirv/array-param-gep.slang34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/spirv/array-param-gep.slang b/tests/spirv/array-param-gep.slang
new file mode 100644
index 000000000..1a0de0c39
--- /dev/null
+++ b/tests/spirv/array-param-gep.slang
@@ -0,0 +1,34 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -entry computeMain -stage compute -emit-spirv-directly
+
+// Check that we are not generating spirv that loads a global resource array into a SSA register,
+// instead, these arrays should always be accessed via direct OpAccessChain operations to avoid
+// creating a lot of local load/stores in the driver compiler.
+
+struct Scene
+{
+ SamplerState samplers[256];
+ Texture2D textures[100];
+}
+
+ParameterBlock<Scene> scene;
+struct Material
+{
+ int sampler;
+ int texture;
+}
+
+RWStructuredBuffer<float4> result;
+
+float4 shade(Scene scene, Material mat)
+{
+ return scene.textures[mat.texture].SampleLevel(scene.samplers[mat.sampler], float2(0,0), 0);
+}
+
+[numthreads(1,1,1)]
+void computeMain(uniform Material mat)
+{
+ // CHECK: OpEntryPoint
+ // CHECK-NOT: OpLoad {{.*}} %scene{{.*}}samplers
+ // CHECK-NOT: OpLoad {{.*}} %scene{{.*}}textures
+ result[0] = shade(scene, mat);
+} \ No newline at end of file