summaryrefslogtreecommitdiff
path: root/tests/rewriter/type-splitting.hlsl
blob: b3cad1ce02d4d5f91022b366b4576c2a54a874ae (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
//TEST:COMPARE_HLSL: -split-mixed-types -no-checking -target dxbc-assembly -profile ps_4_0 -entry main

// Confirm that the `-split-mixed-types` flag works.

#ifdef __SLANG__

// HLSL input:
//
// - Uses at least one `import` of Slang code
// - Uses an aggregate type that mixes resource and non-resource types
//

__import type_splitting;

struct Foo
{
	Texture2D 		t;
	SamplerState 	s;
	float2 			u;
};

cbuffer C
{
	Foo foo;
}

float4 main() : SV_Target
{
	return foo.t.Sample(foo.s, foo.u);	
}

#else

// Equivalent raw HLSL:
//
// - Fields of resource type have been stripped from original type definition
// - Fields of resource type get hoisted out of variable declarations
//

struct Foo
{
	float2 u;
};

cbuffer C
{
	Foo foo;
}

Texture2D    SLANG_parameterGroup_C_foo_t;
SamplerState SLANG_parameterGroup_C_foo_s;

float4 main() : SV_Target
{
	return SLANG_parameterGroup_C_foo_t.Sample(SLANG_parameterGroup_C_foo_s, foo.u);	
}

#endif