Debian Codegraph @

clang/test/CodeGenHLSL/resources/RWBuffer-imageformat.hlsl

raw
1 // RUN: %clang_cc1 -triple spirv-pc-vulkan-compute -finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s
2
3 // Signed integers
4 // CHECK: %"class.hlsl::RWBuffer" = type { target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 24) }
5 RWBuffer<int> rwb_int;
6 // CHECK: %"class.hlsl::RWBuffer.0" = type { target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 25) }
7 RWBuffer<int2> rwb_int2;
8 // CHECK: %"class.hlsl::RWBuffer.1" = type { target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 0) }
9 RWBuffer<int3> rwb_int3;
10 // CHECK: %"class.hlsl::RWBuffer.2" = type { target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 21) }
11 RWBuffer<int4> rwb_int4;
12
13 // Unsigned integers
14 // CHECK: %"class.hlsl::RWBuffer.3" = type { target("spirv.Image", i32, 5, 2, 0, 0, 2, 33) }
15 RWBuffer<uint> rwb_uint;
16 // CHECK: %"class.hlsl::RWBuffer.4" = type { target("spirv.Image", i32, 5, 2, 0, 0, 2, 35) }
17 RWBuffer<uint2> rwb_uint2;
18 // CHECK: %"class.hlsl::RWBuffer.5" = type { target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) }
19 RWBuffer<uint3> rwb_uint3;
20 // CHECK: %"class.hlsl::RWBuffer.6" = type { target("spirv.Image", i32, 5, 2, 0, 0, 2, 30) }
21 RWBuffer<uint4> rwb_uint4;
22
23 // 64-bit integers
24 // CHECK: %"class.hlsl::RWBuffer.7" = type { target("spirv.SignedImage", i64, 5, 2, 0, 0, 2, 41) }
25 RWBuffer<int64_t> rwb_i64;
26 // CHECK: %"class.hlsl::RWBuffer.8" = type { target("spirv.SignedImage", i64, 5, 2, 0, 0, 2, 0) }
27 RWBuffer<int64_t2> rwb_i64_2;
28 // CHECK: %"class.hlsl::RWBuffer.9" = type { target("spirv.Image", i64, 5, 2, 0, 0, 2, 40) }
29 RWBuffer<uint64_t> rwb_u64;
30 // CHECK: %"class.hlsl::RWBuffer.10" = type { target("spirv.Image", i64, 5, 2, 0, 0, 2, 0) }
31 RWBuffer<uint64_t2> rwb_u64_2;
32
33 // Floats
34 // CHECK: %"class.hlsl::RWBuffer.11" = type { target("spirv.Image", float, 5, 2, 0, 0, 2, 3) }
35 RWBuffer<float> rwb_float;
36 // CHECK: %"class.hlsl::RWBuffer.12" = type { target("spirv.Image", float, 5, 2, 0, 0, 2, 6) }
37 RWBuffer<float2> rwb_float2;
38 // CHECK: %"class.hlsl::RWBuffer.13" = type { target("spirv.Image", float, 5, 2, 0, 0, 2, 0) }
39 RWBuffer<float3> rwb_float3;
40 // CHECK: %"class.hlsl::RWBuffer.14" = type { target("spirv.Image", float, 5, 2, 0, 0, 2, 1) }
41 RWBuffer<float4> rwb_float4;
42
43 // Other types that should get Unknown format
44 // CHECK: %"class.hlsl::RWBuffer.15" = type { target("spirv.Image", half, 5, 2, 0, 0, 2, 0) }
45 RWBuffer<half> rwb_half;
46 // CHECK: %"class.hlsl::RWBuffer.16" = type { target("spirv.Image", double, 5, 2, 0, 0, 2, 0) }
47 RWBuffer<double> rwb_double;
48
49 // Non-UAV resource
50 // CHECK: %"class.hlsl::Buffer" = type { target("spirv.SignedImage", i32, 5, 2, 0, 0, 1, 0) }
51 Buffer<int> b_int;
52
53 [numthreads(1,1,1)]
54 void main(int GI : SV_GroupIndex) {
55 rwb_int[GI] = 0;
56 rwb_int2[GI] = 0;
57 rwb_int3[GI] = 0;
58 rwb_int4[GI] = 0;
59 rwb_uint[GI] = 0;
60 rwb_uint2[GI] = 0;
61 rwb_uint3[GI] = 0;
62 rwb_uint4[GI] = 0;
63 rwb_i64[GI] = 0;
64 rwb_i64_2[GI] = 0;
65 rwb_u64[GI] = 0;
66 rwb_u64_2[GI] = 0;
67 rwb_float[GI] = 0;
68 rwb_float2[GI] = 0;
69 rwb_float3[GI] = 0;
70 rwb_float4[GI] = 0;
71 rwb_half[GI] = 0;
72 rwb_double[GI] = 0;
73 int val = b_int[GI];
74 }