blob: 6cda1f4c9f1fb2aa1cdf5481ca1508fe3941cd67 (
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
|
//TEST:SIMPLE(filecheck=CHECK_SPIRV): -target spirv -entry computeMain -profile cs_6_2 -emit-spirv-via-glsl
//TEST:SIMPLE(filecheck=CHECK_SPIRV): -target spirv -entry computeMain -profile cs_6_2 -emit-spirv-directly
//TEST:CROSS_COMPILE: -target dxil-assembly -entry computeMain -profile cs_6_2
//TEST:SIMPLE(filecheck=CHECK_CUDA): -target cuda -entry computeMain -profile cs_6_2
//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=16):out
RWStructuredBuffer<int> outputBuffer;
//TEST_INPUT: Texture2D(size=4):
RWTexture2D<half> halfTexture;
//TEST_INPUT: Texture2D(size=4):
RWTexture2D<half2> halfTexture2;
//TEST_INPUT: Texture2D(size=4):
RWTexture2D<half4> halfTexture4;
//TEST_INPUT: Sampler:
SamplerState s;
[numthreads(4, 4, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
int2 pos = int2(dispatchThreadID.xy);
float2 uv = pos * (1.0f / 3.0f);
int2 pos2 = int2(3 - pos.y, 3 - pos.x);
#if 0
half h = halfTexture.Sample(s, uv);
half2 h2 = halfTexture2.Sample(s, uv);
half4 h4 = halfTexture4.Sample(s, uv);
#else
// CHECK_SPIRV: {{.*}} = OpImageRead
// CHECK_SPIRV: {{.*}} = OpFConvert
half h = halfTexture[pos2];
// CHECK_SPIRV: {{.*}} = OpImageRead
// CHECK_SPIRV: {{.*}} = OpFConvert
half2 h2 = halfTexture2[pos2];
// CHECK_SPIRV: {{.*}} = OpImageRead
// CHECK_SPIRV: {{.*}} = OpFConvert
half4 h4 = halfTexture4[pos2];
#endif
// Store a results
halfTexture[pos] = h2.x + h2.y;
halfTexture2[pos] = h4.xy;
halfTexture4[pos] = half4(h2, h, h);
int index = pos.x + pos.y * 4;
outputBuffer[index] = index;
}
// CHECK_CUDA: surf2Dread<__half>
// CHECK_CUDA: surf2Dread<__half2{{.*}}>
// CHECK_CUDA: surf2Dread<__half4{{.*}}>
// CHECK_CUDA: surf2Dwrite<__half>
// CHECK_CUDA: surf2Dwrite<__half2{{.*}}>
// CHECK_CUDA: surf2Dwrite<__half4{{.*}}>
|