summaryrefslogtreecommitdiffstats
path: root/tests/cross-compile/unknown-image-format.slang
blob: 27eaee606b0d5aaee289bdf7c39243ecf42e417e (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
// unknown-image-format.slang

//TEST:SIMPLE(filecheck=CHECK):-target spirv-assembly -entry main -stage fragment -default-image-format-unknown

// Ensure that we can emit R/W images with an unknown format, when required.

// CHECK: OpTypeImage %float 2D 2 0 0 2 Unknown
// CHECK: OpTypeImage %float 2D 2 0 0 2 R32f
// CHECK: OpTypeImage %float 2D 2 0 0 2 Rgba8
// CHECK: OpTypeImage %float 2D 2 0 0 2 Rgba16f

// Global Scope:

RWTexture2D<float> gNoFormat;

[format("r32f")]
RWTexture2D<float> gExplicitFormat;

// Nested in a Parameter Block

struct PB
{
	RWTexture2D<float4> noFormat;

	[format("rgba8")]
	RWTexture2D<float4> explicitFormat;
}
ParameterBlock<PB> gBlock;

cbuffer C
{
	uint2 index;
}

float4 main(

	// In entry-point parameter list

	uniform RWTexture2D<float4> noFormat,

	[format("rgba16f")]
	uniform RWTexture2D<float4> explicitFormat
	) : SV_Target
{
    float4 result = 0;

#define USE(NAME) result += NAME[index]

	USE(gNoFormat);
	USE(gExplicitFormat);

	USE(gBlock.noFormat);
	USE(gBlock.explicitFormat);

	USE(noFormat);
	USE(explicitFormat);

#undef USE

    return result;
}