summaryrefslogtreecommitdiffstats
path: root/tests/bindings/binding1.hlsl
blob: 957d9614c0718724c61944514e1c7f67030b8291 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//TEST:COMPARE_HLSL: -profile ps_4_0 -entry main

// We want to make sure that the registers Slang generates
// are used, even if there are "dead" parameter earlier in the program.
//
// In this case, we declare two each of textures, samplers, and constant
// buffers, and then only use the second one.
// Left to its own devices, the HLSL compiler would usually shift the
// object that was used up to binding slot zero, and eliminate the one
// that wasn't used.
// We expect Slang to generate explicit annotations that stop this from
// happening.

#ifdef __SLANG__
#define R(X) /**/
#define BEGIN_CBUFFER(NAME) cbuffer NAME
#define END_CBUFFER(NAME, REG) /**/
#define CBUFFER_REF(NAME, FIELD) FIELD
#else
#define R(X) X
#define BEGIN_CBUFFER(NAME) struct SLANG_ParameterGroup_##NAME
#define END_CBUFFER(NAME, REG) ; cbuffer NAME : REG { SLANG_ParameterGroup_##NAME NAME; }
#define CBUFFER_REF(NAME, FIELD) NAME.FIELD

#define tB tB_0
#define sB sB_0

#define C1 C1_0
#define c1 c1_0

#endif

float4 use(float4 val) { return val; };
float4 use(Texture2D t, SamplerState s) { return t.Sample(s, 0.0); }

Texture2D 		tA R(: register(t0));
Texture2D 		tB R(: register(t1));
SamplerState 	sA R(: register(s0));
SamplerState 	sB R(: register(s1));

BEGIN_CBUFFER(C0)
{
	float c0;
}
END_CBUFFER(C0, register(b0))

BEGIN_CBUFFER(C1)
{
	float c1;
}
END_CBUFFER(C1, register(b1))

float4 main() : SV_TARGET
{
	return use(tB,sB) + use(CBUFFER_REF(C1,c1));
}