Debian Codegraph @

llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp

raw
1 //===- DXContainerTest.cpp - Tests for DXContainerFile --------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/ADT/StringRef.h"
10 #include "llvm/ADT/Twine.h"
11 #include "llvm/ObjectYAML/ObjectYAML.h"
12 #include "llvm/ObjectYAML/yaml2obj.h"
13 #include "llvm/Support/MemoryBufferRef.h"
14 #include "llvm/Support/YAMLTraits.h"
15 #include "llvm/Support/raw_ostream.h"
16 #include "llvm/Testing/Support/Error.h"
17 #include "gtest/gtest.h"
18
19 using namespace llvm;
20 using namespace llvm::object;
21
22 static bool convert(SmallVectorImpl<char> &Output, const char *YAML) {
23 raw_svector_ostream OS(Output);
24 yaml::Input YIn(YAML);
25 return convertYAML(YIn, OS, [](const Twine &Err) { errs() << Err; });
26 }
27
28 TEST(DXCFile, ParseEmptyParts) {
29 SmallString<128> Storage;
30
31 // First read a fully explicit yaml with all sizes and offsets provided
32 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer
33 Header:
34 Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
35 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
36 Version:
37 Major: 1
38 Minor: 0
39 FileSize: 116
40 PartCount: 7
41 PartOffsets: [ 60, 68, 76, 84, 92, 100, 108 ]
42 Parts:
43 - Name: FKE0
44 Size: 0
45 - Name: FKE1
46 Size: 0
47 - Name: FKE2
48 Size: 0
49 - Name: FKE3
50 Size: 0
51 - Name: FKE4
52 Size: 0
53 - Name: FKE5
54 Size: 0
55 - Name: FKE6
56 Size: 0
57 ...
58 )"));
59
60 // Result
61 char Buffer[] = {
62 0x44, 0x58, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
64 0x74, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00,
65 0x44, 0x00, 0x00, 0x00, 0x4C, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00,
66 0x5C, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00,
67 0x46, 0x4B, 0x45, 0x30, 0x00, 0x00, 0x00, 0x00, 0x46, 0x4B, 0x45, 0x31,
68 0x00, 0x00, 0x00, 0x00, 0x46, 0x4B, 0x45, 0x32, 0x00, 0x00, 0x00, 0x00,
69 0x46, 0x4B, 0x45, 0x33, 0x00, 0x00, 0x00, 0x00, 0x46, 0x4B, 0x45, 0x34,
70 0x00, 0x00, 0x00, 0x00, 0x46, 0x4B, 0x45, 0x35, 0x00, 0x00, 0x00, 0x00,
71 0x46, 0x4B, 0x45, 0x36, 0x00, 0x00, 0x00, 0x00,
72 };
73
74 EXPECT_EQ(Storage.size(), 116u);
75 EXPECT_TRUE(memcmp(Buffer, Storage.data(), 116) == 0);
76
77 Storage.clear();
78
79 // Next, read the same file without the part offsets or file size. Both cases
80 // should result in the same final output.
81 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer
82 Header:
83 Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
84 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
85 Version:
86 Major: 1
87 Minor: 0
88 PartCount: 7
89 Parts:
90 - Name: FKE0
91 Size: 0
92 - Name: FKE1
93 Size: 0
94 - Name: FKE2
95 Size: 0
96 - Name: FKE3
97 Size: 0
98 - Name: FKE4
99 Size: 0
100 - Name: FKE5
101 Size: 0
102 - Name: FKE6
103 Size: 0
104 ...
105 )"));
106
107 EXPECT_EQ(Storage.size(), 116u);
108 EXPECT_TRUE(memcmp(Buffer, Storage.data(), 116) == 0);
109 }
110
111 TEST(RootSignature, ParseRootFlags) {
112 SmallString<128> Storage;
113
114 // First read a fully explicit yaml with all sizes and offsets provided
115 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer
116 Header:
117 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5,
118 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]
119 Version:
120 Major: 1
121 Minor: 0
122 FileSize: 68
123 PartCount: 1
124 PartOffsets: [ 36 ]
125 Parts:
126 - Name: RTS0
127 Size: 24
128 RootSignature:
129 Version: 2
130 NumRootParameters: 0
131 RootParametersOffset: 24
132 NumStaticSamplers: 0
133 StaticSamplersOffset: 0
134 Parameters: []
135 AllowInputAssemblerInputLayout: true
136 )"));
137
138 uint8_t Buffer[] = {
139 0x44, 0x58, 0x42, 0x43, 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F,
140 0x05, 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1, 0x01, 0x00, 0x00, 0x00,
141 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
142 0x52, 0x54, 0x53, 0x30, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
143 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
144 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
145 };
146
147 EXPECT_EQ(Storage.size(), 68u);
148 EXPECT_TRUE(memcmp(Buffer, Storage.data(), 68u) == 0);
149 }
150
151 TEST(RootSignature, HeaderData) {
152 SmallString<128> Storage;
153
154 // First read a fully explicit yaml with all sizes and offsets provided
155 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer
156 Header:
157 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5,
158 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]
159 Version:
160 Major: 1
161 Minor: 0
162 FileSize: 133
163 PartCount: 1
164 PartOffsets: [ 36 ]
165 Parts:
166 - Name: RTS0
167 Size: 89
168 RootSignature:
169 Version: 2
170 NumRootParameters: 1
171 RootParametersOffset: 255
172 NumStaticSamplers: 0
173 StaticSamplersOffset: 0
174 Parameters:
175 - ParameterType: 1
176 ShaderVisibility: 2
177 Constants:
178 Num32BitValues: 16
179 ShaderRegister: 15
180 RegisterSpace: 14
181 AllowInputAssemblerInputLayout: true
182 DenyGeometryShaderRootAccess: true
183 )"));
184
185 uint8_t Buffer[] = {
186 0x44, 0x58, 0x42, 0x43, 0x32, 0x9a, 0x53, 0xd8, 0xec, 0xbe, 0x35, 0x6f,
187 0x05, 0x39, 0xe1, 0xfe, 0x31, 0x20, 0xf0, 0xc1, 0x01, 0x00, 0x00, 0x00,
188 0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
189 0x52, 0x54, 0x53, 0x30, 0x59, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
190 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
191 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
192 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
193 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
194 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
195 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
197 0x00};
198
199 EXPECT_EQ(Storage.size(), 133u);
200 EXPECT_TRUE(memcmp(Buffer, Storage.data(), 133u) == 0);
201 }
202
203 TEST(RootSignature, ParseRootConstants) {
204 SmallString<128> Storage;
205
206 // First read a fully explicit yaml with all sizes and offsets provided
207 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer
208 Header:
209 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5,
210 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]
211 Version:
212 Major: 1
213 Minor: 0
214 FileSize: 133
215 PartCount: 1
216 PartOffsets: [ 36 ]
217 Parts:
218 - Name: RTS0
219 Size: 89
220 RootSignature:
221 Version: 2
222 NumRootParameters: 1
223 RootParametersOffset: 36
224 NumStaticSamplers: 0
225 StaticSamplersOffset: 0
226 Parameters:
227 - ParameterType: 1
228 ShaderVisibility: 2
229 Constants:
230 Num32BitValues: 16
231 ShaderRegister: 15
232 RegisterSpace: 14
233 AllowInputAssemblerInputLayout: true
234 DenyGeometryShaderRootAccess: true
235 )"));
236
237 uint8_t Buffer[] = {
238 0x44, 0x58, 0x42, 0x43, 0x32, 0x9a, 0x53, 0xd8, 0xec, 0xbe, 0x35, 0x6f,
239 0x05, 0x39, 0xe1, 0xfe, 0x31, 0x20, 0xf0, 0xc1, 0x01, 0x00, 0x00, 0x00,
240 0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
241 0x52, 0x54, 0x53, 0x30, 0x59, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
242 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
243 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
244 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
245 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
246 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
247 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
248 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
249 0x00};
250
251 EXPECT_EQ(Storage.size(), 133u);
252 EXPECT_TRUE(memcmp(Buffer, Storage.data(), 133u) == 0);
253 }
254
255 TEST(RootSignature, ParseRootDescriptorsV10) {
256 SmallString<128> Storage;
257
258 // First read a fully explicit yaml with all sizes and offsets provided
259 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer
260 Header:
261 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5,
262 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]
263 Version:
264 Major: 1
265 Minor: 0
266 FileSize: 133
267 PartCount: 1
268 PartOffsets: [ 36 ]
269 Parts:
270 - Name: RTS0
271 Size: 89
272 RootSignature:
273 Version: 1
274 NumRootParameters: 1
275 RootParametersOffset: 24
276 NumStaticSamplers: 0
277 StaticSamplersOffset: 60
278 Parameters:
279 - ParameterType: 2 # SRV
280 ShaderVisibility: 3 # Domain
281 Descriptor:
282 ShaderRegister: 31
283 RegisterSpace: 32
284 AllowInputAssemblerInputLayout: true
285 DenyGeometryShaderRootAccess: true
286 )"));
287
288 uint8_t Buffer[] = {
289 0x44, 0x58, 0x42, 0x43, 0x32, 0x9a, 0x53, 0xd8, 0xec, 0xbe, 0x35, 0x6f,
290 0x05, 0x39, 0xe1, 0xfe, 0x31, 0x20, 0xf0, 0xc1, 0x01, 0x00, 0x00, 0x00,
291 0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
292 0x52, 0x54, 0x53, 0x30, 0x59, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
293 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
294 0x3c, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
295 0x03, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00,
296 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
297 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
298 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
299 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
300 0x00};
301
302 EXPECT_EQ(Storage.size(), 133u);
303 EXPECT_TRUE(memcmp(Buffer, Storage.data(), 133u) == 0);
304 }
305
306 TEST(RootSignature, ParseRootDescriptorsV11) {
307 SmallString<128> Storage;
308
309 // First read a fully explicit yaml with all sizes and offsets provided
310 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer
311 Header:
312 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5,
313 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]
314 Version:
315 Major: 1
316 Minor: 0
317 FileSize: 133
318 PartCount: 1
319 PartOffsets: [ 36 ]
320 Parts:
321 - Name: RTS0
322 Size: 89
323 RootSignature:
324 Version: 2
325 NumRootParameters: 1
326 RootParametersOffset: 24
327 NumStaticSamplers: 0
328 StaticSamplersOffset: 60
329 Parameters:
330 - ParameterType: 2 # SRV
331 ShaderVisibility: 3 # Domain
332 Descriptor:
333 ShaderRegister: 31
334 RegisterSpace: 32
335 DATA_STATIC_WHILE_SET_AT_EXECUTE: true
336 AllowInputAssemblerInputLayout: true
337 DenyGeometryShaderRootAccess: true
338 )"));
339
340 uint8_t Buffer[] = {
341 0x44, 0x58, 0x42, 0x43, 0x32, 0x9a, 0x53, 0xd8, 0xec, 0xbe, 0x35, 0x6f,
342 0x05, 0x39, 0xe1, 0xfe, 0x31, 0x20, 0xf0, 0xc1, 0x01, 0x00, 0x00, 0x00,
343 0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
344 0x52, 0x54, 0x53, 0x30, 0x59, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
345 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
346 0x3c, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
347 0x03, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00,
348 0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
349 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
350 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
351 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
352 0x00};
353
354 EXPECT_EQ(Storage.size(), 133u);
355 EXPECT_TRUE(memcmp(Buffer, Storage.data(), 133u) == 0);
356 }
357
358 TEST(RootSignature, ParseDescriptorTableV10) {
359 SmallString<128> Storage;
360
361 // First read a fully explicit yaml with all sizes and offsets provided
362 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer
363 Header:
364 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5,
365 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]
366 Version:
367 Major: 1
368 Minor: 0
369 FileSize: 133
370 PartCount: 1
371 PartOffsets: [ 36 ]
372 Parts:
373 - Name: RTS0
374 Size: 89
375 RootSignature:
376 Version: 1
377 NumRootParameters: 1
378 RootParametersOffset: 24
379 NumStaticSamplers: 0
380 StaticSamplersOffset: 60
381 Parameters:
382 - ParameterType: 0 # SRV
383 ShaderVisibility: 3 # Domain
384 Table:
385 NumRanges: 1
386 Ranges:
387 - RangeType: 0
388 NumDescriptors: 41
389 BaseShaderRegister: 42
390 RegisterSpace: 43
391 OffsetInDescriptorsFromTableStart: 44
392 AllowInputAssemblerInputLayout: true
393 DenyGeometryShaderRootAccess: true
394 )"));
395
396 uint8_t Buffer[] = {
397 0x44, 0x58, 0x42, 0x43, 0x32, 0x9a, 0x53, 0xd8, 0xec, 0xbe, 0x35, 0x6f,
398 0x05, 0x39, 0xe1, 0xfe, 0x31, 0x20, 0xf0, 0xc1, 0x01, 0x00, 0x00, 0x00,
399 0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
400 0x52, 0x54, 0x53, 0x30, 0x59, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
401 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
402 0x3c, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
403 0x03, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
404 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00,
405 0x2a, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
406 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
407 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
408 0x00};
409
410 EXPECT_EQ(Storage.size(), 133u);
411 EXPECT_TRUE(memcmp(Buffer, Storage.data(), 133u) == 0);
412 }
413
414 TEST(RootSignature, ParseDescriptorTableV11) {
415 SmallString<128> Storage;
416
417 // First read a fully explicit yaml with all sizes and offsets provided
418 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer
419 Header:
420 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5,
421 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]
422 Version:
423 Major: 1
424 Minor: 0
425 FileSize: 133
426 PartCount: 1
427 PartOffsets: [ 36 ]
428 Parts:
429 - Name: RTS0
430 Size: 89
431 RootSignature:
432 Version: 2
433 NumRootParameters: 1
434 RootParametersOffset: 24
435 NumStaticSamplers: 0
436 StaticSamplersOffset: 60
437 Parameters:
438 - ParameterType: 0 # Descriptor Table
439 ShaderVisibility: 3 # Domain
440 Table:
441 NumRanges: 1
442 Ranges:
443 - RangeType: 0
444 NumDescriptors: -1
445 BaseShaderRegister: 42
446 RegisterSpace: 43
447 OffsetInDescriptorsFromTableStart: 41
448 DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS: true
449 AllowInputAssemblerInputLayout: true
450 DenyGeometryShaderRootAccess: true
451 )"));
452
453 uint8_t Buffer[] = {
454 0x44, 0x58, 0x42, 0x43, 0x32, 0x9a, 0x53, 0xd8, 0xec, 0xbe, 0x35, 0x6f,
455 0x05, 0x39, 0xe1, 0xfe, 0x31, 0x20, 0xf0, 0xc1, 0x01, 0x00, 0x00, 0x00,
456 0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
457 0x52, 0x54, 0x53, 0x30, 0x59, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
458 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
459 0x3c, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
460 0x03, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
461 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
462 0x2a, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
463 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
464 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
465 0x00};
466
467 EXPECT_EQ(Storage.size(), 133u);
468 EXPECT_TRUE(memcmp(Buffer, Storage.data(), 133u) == 0);
469 }
470
471 TEST(RootSignature, ParseStaticSamplers) {
472 SmallString<128> Storage;
473
474 // First read a fully explicit yaml with all sizes and offsets provided
475 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer
476 Header:
477 Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
478 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
479 Version:
480 Major: 1
481 Minor: 0
482 PartCount: 1
483 PartOffsets: [ 60 ]
484 Parts:
485 - Name: RTS0
486 Size: 76
487 RootSignature:
488 Version: 2
489 NumRootParameters: 0
490 RootParametersOffset: 0
491 NumStaticSamplers: 1
492 StaticSamplersOffset: 24
493 Parameters: []
494 Samplers:
495 - Filter: 10
496 AddressU: 1
497 AddressV: 2
498 AddressW: 5
499 MipLODBias: 1.23
500 MaxAnisotropy: 20
501 ComparisonFunc: 4
502 BorderColor: 0
503 MinLOD: 4.56
504 MaxLOD: 8.90
505 ShaderRegister: 31
506 RegisterSpace: 32
507 ShaderVisibility: 7
508 AllowInputAssemblerInputLayout: true
509 DenyGeometryShaderRootAccess: true
510 )"));
511
512 uint8_t Buffer[] = {
513 0x44, 0x58, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
514 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
515 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
516 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
517 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
518 0x52, 0x54, 0x53, 0x30, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
519 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
520 0x18, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
521 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
522 0xa4, 0x70, 0x9d, 0x3f, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
523 0x00, 0x00, 0x00, 0x00, 0x85, 0xeb, 0x91, 0x40, 0x66, 0x66, 0x0e, 0x41,
524 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00};
525
526 EXPECT_EQ(Storage.size(), 144u);
527 EXPECT_TRUE(memcmp(Buffer, Storage.data(), 144u) == 0);
528 }