summaryrefslogtreecommitdiffstats
path: root/tests/bindings/resources-in-cbuffer.hlsl
blob: ec35943cce61c1a8b34856be86b2255a6f36bb46 (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
57
58
59
60
61
62
63
64
65
66
67
68
//TEST:COMPARE_HLSL: -target dxbc-assembly -profile ps_4_0 -entry main

// Confirm that resources inside constant buffers get correct locations,
// including the case where there are *multiple* constant buffers
// with reosurces.

#ifdef __SPIRE__
#define R(X) /**/
#else
#define R(X) X
#endif

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

cbuffer CA R(: register(b0))
{
	float4 caa R(: packoffset(c0));
	float3 cab R(: packoffset(c1.x));
	float  cac R(: packoffset(c1.w));
	float2 cad R(: packoffset(c2.x));
	float2 cae R(: packoffset(c2.z));

	Texture2D ta R(: register(t0));
	SamplerState sa R(: register(s0));
}

cbuffer CB R(: register(b1))
{
	float4 cba R(: packoffset(c0));
	float3 cbb R(: packoffset(c1.x));
	float  cbc R(: packoffset(c1.w));
	float2 cbd R(: packoffset(c2.x));
	float2 cbe R(: packoffset(c2.z));

	Texture2D tbx R(: register(t1));
	Texture2D tby R(: register(t2));
	SamplerState sb R(: register(s1));
}

cbuffer CC R(: register(b2))
{
	float4 cca R(: packoffset(c0));
	float3 ccb R(: packoffset(c1.x));
	float  ccc R(: packoffset(c1.w));
	float2 ccd R(: packoffset(c2.x));
	float2 cce R(: packoffset(c2.z));

	Texture2D tc R(: register(t3));
	SamplerState scx R(: register(s2));
	SamplerState scy R(: register(s3));
}

float4 main() : SV_Target
{
	// Go ahead and use everything in this case:
	return use(ta,  sa)
		+  use(tbx, sb)
		+  use(tby, scx)
		+  use(tc,  scy)
		+  use(cae)
		+  use(cbe)
		+  use(cce)
		;
}