yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Jay KwakTest binding index for combined and not-combined textures (#4180)0a5908dc9

master
1.6 KiB49 linesraw
1//TEST:SIMPLE(filecheck=METAL): -stage compute -entry computeMain -target metal
2//TEST:REFLECTION(filecheck=REFLECT): -stage compute -entry computeMain  -target metal
3
4// ------------------------
5Sampler2D sampler;
6
7// METAL-DAG: {{sampler_texture_[1-9]}} {{\[\[}}texture(0)]]
8// METAL-DAG: {{sampler_sampler_[1-9]}} {{\[\[}}sampler(0)]]
9
10// REFLECT: "name": "sampler"
11// REFLECT-NOT:}
12// REFLECT: {"kind": "shaderResource", "index": 0}
13// REFLECT-NOT:}
14// REFLECT: {"kind": "samplerState", "index": 0}
15
16// ------------------------
17Texture2D followingTexture;
18
19// METAL-DAG: {{followingTexture_[1-9]}} {{\[\[}}texture(1)]]
20
21// REFLECT: "name": "followingTexture"
22// REFLECT-NOT:}
23// REFLECT: "binding": {"kind": "shaderResource", "index": 1}
24
25// ------------------------
26SamplerState followingSamplerState;
27
28// METAL-DAG: {{followingSamplerState_[1-9]}} {{\[\[}}sampler(1)]]
29
30// REFLECT: "name": "followingSamplerState"
31// REFLECT-NOT:}
32// REFLECT: "binding": {"kind": "samplerState", "index": 1}
33
34// ------------------------
35Sampler2D explicitBindingSampler : register(t4): register(s3);
36
37// METAL-DAG: {{explicitBindingSampler_texture_[1-9]}} {{\[\[}}texture(4)]]
38// METAL-DAG: {{explicitBindingSampler_sampler_[1-9]}} {{\[\[}}sampler(3)]]
39
40// REFLECT: "name": "explicitBindingSampler"
41// REFLECT-NOT:}
42// REFLECT: {"kind": "shaderResource", "index": 4}
43// REFLECT-NOT:}
44// REFLECT: {"kind": "samplerState", "index": 3}
45
46float4 computeMain() : SV_Target
47{
48    return sampler.Sample(float2(0, 0)) + explicitBindingSampler.Sample(float2(0, 0)) + followingTexture.Sample(followingSamplerState, float2(0,0));
49}