summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2024-05-17 16:29:23 -0700
committerGitHub <noreply@github.com>2024-05-17 16:29:23 -0700
commit0a5908dc9a0cde87dcb14176b9053c2fbaf31cfd (patch)
tree4760ac514ae9318126abcc70ee9faa00acd1dc86 /tests
parent42b0248272a549f8d81fa95cf30712b93879c009 (diff)
Test binding index for combined and not-combined textures (#4180)
Diffstat (limited to 'tests')
-rw-r--r--tests/metal/texture-binding-index.slang49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/metal/texture-binding-index.slang b/tests/metal/texture-binding-index.slang
new file mode 100644
index 000000000..d061b1789
--- /dev/null
+++ b/tests/metal/texture-binding-index.slang
@@ -0,0 +1,49 @@
+//TEST:SIMPLE(filecheck=METAL): -stage compute -entry computeMain -target metal
+//TEST:REFLECTION(filecheck=REFLECT): -stage compute -entry computeMain -target metal
+
+// ------------------------
+Sampler2D sampler;
+
+// METAL-DAG: {{sampler_texture_[1-9]}} {{\[\[}}texture(0)]]
+// METAL-DAG: {{sampler_sampler_[1-9]}} {{\[\[}}sampler(0)]]
+
+// REFLECT: "name": "sampler"
+// REFLECT-NOT:}
+// REFLECT: {"kind": "shaderResource", "index": 0}
+// REFLECT-NOT:}
+// REFLECT: {"kind": "samplerState", "index": 0}
+
+// ------------------------
+Texture2D followingTexture;
+
+// METAL-DAG: {{followingTexture_[1-9]}} {{\[\[}}texture(1)]]
+
+// REFLECT: "name": "followingTexture"
+// REFLECT-NOT:}
+// REFLECT: "binding": {"kind": "shaderResource", "index": 1}
+
+// ------------------------
+SamplerState followingSamplerState;
+
+// METAL-DAG: {{followingSamplerState_[1-9]}} {{\[\[}}sampler(1)]]
+
+// REFLECT: "name": "followingSamplerState"
+// REFLECT-NOT:}
+// REFLECT: "binding": {"kind": "samplerState", "index": 1}
+
+// ------------------------
+Sampler2D explicitBindingSampler : register(t4): register(s3);
+
+// METAL-DAG: {{explicitBindingSampler_texture_[1-9]}} {{\[\[}}texture(4)]]
+// METAL-DAG: {{explicitBindingSampler_sampler_[1-9]}} {{\[\[}}sampler(3)]]
+
+// REFLECT: "name": "explicitBindingSampler"
+// REFLECT-NOT:}
+// REFLECT: {"kind": "shaderResource", "index": 4}
+// REFLECT-NOT:}
+// REFLECT: {"kind": "samplerState", "index": 3}
+
+float4 computeMain() : SV_Target
+{
+ return sampler.Sample(float2(0, 0)) + explicitBindingSampler.Sample(float2(0, 0)) + followingTexture.Sample(followingSamplerState, float2(0,0));
+}