Debian Codegraph @

clang/test/CodeGenHLSL/resources/resource-bindings.hlsl

raw
1 // RUN: %clang_cc1 -triple dxil--shadermodel6.6-compute -x hlsl -finclude-default-header \
2 // RUN: -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
3
4 // CHECK: %"class.hlsl::RWBuffer" = type { target("dx.TypedBuffer", <4 x float>, 1, 0, 0) }
5 // CHECK: %"class.hlsl::RWBuffer.0" = type { target("dx.TypedBuffer", float, 1, 0, 0) }
6 // CHECK: %"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", i32, 0, 0) }
7 // CHECK: %"class.hlsl::RWStructuredBuffer" = type { target("dx.RawBuffer", %struct.S, 1, 0), target("dx.RawBuffer", %struct.S, 1, 0) }
8 // CHECK: %"class.hlsl::RWBuffer.1" = type { target("dx.TypedBuffer", double, 1, 0, 0) }
9
10 // CHECK: @_ZL4U0S0 = internal global %"class.hlsl::RWBuffer" poison, align 4
11 // CHECK: @_ZL4U5S3 = internal global %"class.hlsl::RWBuffer.0" poison, align 4
12 // CHECK: @_ZL4T2S2 = internal global %"class.hlsl::StructuredBuffer" poison, align 4
13 // CHECK: @_ZL4T3S0 = internal global %"class.hlsl::RWStructuredBuffer" poison, align 4
14 // CHECK: @_ZL5Array = internal global [10 x %"class.hlsl::RWBuffer.1"] poison, align 4
15
16 // CHECK: call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
17 // CHECK-SAME: @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f32_1_0_0t(
18 RWBuffer<float4> U0S0 : register(u0);
19
20 // CHECK: call target("dx.TypedBuffer", float, 1, 0, 0)
21 // CHECK-SAME: @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f32_1_0_0t(
22 RWBuffer<float> U5S3 : register(u5, space3);
23
24 // CHECK: call target("dx.RawBuffer", i32, 0, 0)
25 // CHECK-SAME: @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i32_0_0t(
26 StructuredBuffer<int> T2S2 : register(t2, space2);
27
28 // CHECK: call target("dx.RawBuffer", %struct.S, 1, 0)
29 // CHECK-SAME: @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_s_struct.Ss_1_0t(
30 struct S {
31 float4 f;
32 int i;
33 };
34 RWStructuredBuffer<S> T3S0 : register(u3);
35
36 // Resource array elements are initialized on access; make sure there is no call
37 // to initialize RWBuffer<double>.
38 // CHECK-NOT: call target("dx.TypedBuffer", double, 1, 0, 0) @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f64_1_0_0t(
39 RWBuffer<double> Array[10] : register(u4, space0);
40
41 [numthreads(4,1,1)]
42 void main() {
43 // Reference Array to ensure it is emitted and we can test that it is initialized
44 // to poison, but do not index it.
45 // Non-array resources are always emitted because they have a constructor initializer.
46 (void)Array;
47 }