Debian Codegraph @

clang/test/CodeGenHLSL/RootSignature.hlsl

raw
1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -o - %s | FileCheck %s
2
3 // CHECK: !dx.rootsignatures = !{![[#EMPTY_ENTRY:]], ![[#DT_ENTRY:]],
4 // CHECK-SAME: ![[#RF_ENTRY:]], ![[#RC_ENTRY:]], ![[#RD_ENTRY:]], ![[#SS_ENTRY:]]}
5
6 // CHECK: ![[#EMPTY_ENTRY]] = !{ptr @EmptyEntry, ![[#EMPTY:]], i32 2}
7 // CHECK: ![[#EMPTY]] = !{}
8
9 [shader("compute"), RootSignature("")]
10 [numthreads(1,1,1)]
11 void EmptyEntry() {}
12
13 // CHECK: ![[#DT_ENTRY]] = !{ptr @DescriptorTableEntry, ![[#DT_RS:]], i32 2}
14 // CHECK: ![[#DT_RS]] = !{![[#TABLE:]]}
15 // CHECK: ![[#TABLE]] = !{!"DescriptorTable", i32 0, ![[#CBV:]], ![[#SRV:]]}
16 // CHECK: ![[#CBV]] = !{!"CBV", i32 1, i32 0, i32 0, i32 -1, i32 4}
17 // CHECK: ![[#SRV]] = !{!"SRV", i32 4, i32 42, i32 3, i32 32, i32 0}
18
19 #define SampleDescriptorTable \
20 "DescriptorTable( " \
21 " CBV(b0), " \
22 " SRV(t42, space = 3, offset = 32, numDescriptors = 4, flags = 0) " \
23 ")"
24 [shader("compute"), RootSignature(SampleDescriptorTable)]
25 [numthreads(1,1,1)]
26 void DescriptorTableEntry() {}
27
28 // CHECK: ![[#RF_ENTRY]] = !{ptr @RootFlagsEntry, ![[#RF_RS:]], i32 2}
29 // CHECK: ![[#RF_RS]] = !{![[#ROOT_FLAGS:]]}
30 // CHECK: ![[#ROOT_FLAGS]] = !{!"RootFlags", i32 2114}
31
32 #define SampleRootFlags \
33 "RootFlags( " \
34 " Deny_Vertex_Shader_Root_Access | Allow_Stream_Output | " \
35 " sampler_heap_directly_indexed " \
36 ")"
37 [shader("compute"), RootSignature(SampleRootFlags)]
38 [numthreads(1,1,1)]
39 void RootFlagsEntry() {}
40
41 // CHECK: ![[#RC_ENTRY]] = !{ptr @RootConstantsEntry, ![[#RC_RS:]], i32 2}
42 // CHECK: ![[#RC_RS]] = !{![[#ROOT_CONSTANTS:]]}
43 // CHECK: ![[#ROOT_CONSTANTS]] = !{!"RootConstants", i32 5, i32 1, i32 2, i32 1}
44
45 #define SampleRootConstants \
46 "RootConstants(" \
47 " space = 2, " \
48 " visibility = Shader_Visibility_Pixel, " \
49 " b1, num32BitConstants = 1 " \
50 ")"
51 [shader("compute"), RootSignature(SampleRootConstants)]
52 [numthreads(1,1,1)]
53 void RootConstantsEntry() {}
54
55 // CHECK: ![[#RD_ENTRY]] = !{ptr @RootDescriptorsEntry, ![[#RD_RS:]], i32 2}
56 // CHECK: ![[#RD_RS]] = !{![[#ROOT_CBV:]], ![[#ROOT_UAV:]], ![[#ROOT_SRV:]]}
57 // CHECK: ![[#ROOT_CBV]] = !{!"RootCBV", i32 0, i32 0, i32 0, i32 4}
58 // CHECK: ![[#ROOT_UAV]] = !{!"RootUAV", i32 0, i32 42, i32 3, i32 2}
59 // CHECK: ![[#ROOT_SRV]] = !{!"RootSRV", i32 4, i32 0, i32 0, i32 2}
60
61 #define SampleRootDescriptors \
62 "CBV(b0), " \
63 "UAV(space = 3, u42), " \
64 "SRV(t0, visibility = Shader_Visibility_Geometry, flags = Data_Volatile)"
65 [shader("compute"), RootSignature(SampleRootDescriptors)]
66 [numthreads(1,1,1)]
67 void RootDescriptorsEntry() {}
68
69 // CHECK: ![[#SS_ENTRY]] = !{ptr @StaticSamplerEntry, ![[#SS_RS:]], i32 2}
70 // CHECK: ![[#SS_RS]] = !{![[#STATIC_SAMPLER:]]}
71
72 // checking filter = 0x4
73 // CHECK: ![[#STATIC_SAMPLER]] = !{!"StaticSampler", i32 4,
74
75 // checking texture address[U|V|W]
76 // CHECK-SAME: i32 2, i32 3, i32 5,
77
78 // checking mipLODBias, maxAnisotropy, comparisonFunc, borderColor
79 // note: the hex value is the float bit representation of 12.45
80 // CHECK-SAME: float 0x4028E66660000000, i32 9, i32 3, i32 2,
81
82 // checking minLOD, maxLOD
83 // CHECK-SAME: float -1.280000e+02, float 1.280000e+02,
84
85 // checking register, space, visibility and flag
86 // CHECK-SAME: i32 42, i32 0, i32 0, i32 1}
87
88 #define SampleStaticSampler \
89 "StaticSampler(s42, " \
90 " filter = FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT, " \
91 " addressU = TEXTURE_ADDRESS_MIRROR, " \
92 " addressV = TEXTURE_ADDRESS_CLAMP, " \
93 " addressW = TEXTURE_ADDRESS_MIRRORONCE, " \
94 " mipLODBias = 12.45f, maxAnisotropy = 9, " \
95 " comparisonFunc = COMPARISON_EQUAL, " \
96 " borderColor = STATIC_BORDER_COLOR_OPAQUE_WHITE, " \
97 " minLOD = -128.f, maxLOD = 128.f, " \
98 " space = 0, visibility = SHADER_VISIBILITY_ALL, " \
99 " flags = UINT_BORDER_COLOR" \
100 ")"
101 [shader("compute"), RootSignature(SampleStaticSampler)]
102 [numthreads(1,1,1)]
103 void StaticSamplerEntry() {}
104
105 // Sanity test to ensure no root is added for this function as there is only
106 // two entries in !dx.roosignatures
107 [shader("compute")]
108 [numthreads(1,1,1)]
109 void NoRSEntry() {}