580 lines · cpp
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-exception6//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 19using namespace llvm;20using namespace llvm::object;21 22static 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 28TEST(DXCFile, ParseEmptyParts) {29 SmallString<128> Storage;30 31 // First read a fully explicit yaml with all sizes and offsets provided32 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer33Header:34 Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 35 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]36 Version:37 Major: 138 Minor: 039 FileSize: 11640 PartCount: 741 PartOffsets: [ 60, 68, 76, 84, 92, 100, 108 ]42Parts:43 - Name: FKE044 Size: 045 - Name: FKE146 Size: 047 - Name: FKE248 Size: 049 - Name: FKE350 Size: 051 - Name: FKE452 Size: 053 - Name: FKE554 Size: 055 - Name: FKE656 Size: 057...58 )"));59 60 // Result61 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 cases80 // should result in the same final output.81 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer82Header:83 Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 84 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]85 Version:86 Major: 187 Minor: 088 PartCount: 789Parts:90 - Name: FKE091 Size: 092 - Name: FKE193 Size: 094 - Name: FKE295 Size: 096 - Name: FKE397 Size: 098 - Name: FKE499 Size: 0100 - Name: FKE5101 Size: 0102 - Name: FKE6103 Size: 0104...105 )"));106 107 EXPECT_EQ(Storage.size(), 116u);108 EXPECT_TRUE(memcmp(Buffer, Storage.data(), 116) == 0);109}110 111TEST(RootSignature, ParseRootFlags) {112 SmallString<128> Storage;113 114 // First read a fully explicit yaml with all sizes and offsets provided115 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer116 Header:117 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5, 118 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]119 Version:120 Major: 1121 Minor: 0122 FileSize: 68123 PartCount: 1124 PartOffsets: [ 36 ]125 Parts:126 - Name: RTS0127 Size: 24128 RootSignature:129 Version: 2130 NumRootParameters: 0131 RootParametersOffset: 24132 NumStaticSamplers: 0133 StaticSamplersOffset: 24134 Parameters: []135 AllowInputAssemblerInputLayout: true136 )"));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 0x18, 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 151TEST(RootSignature, HeaderData) {152 SmallString<128> Storage;153 154 // First read a fully explicit yaml with all sizes and offsets provided155 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer156 Header:157 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5, 158 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]159 Version:160 Major: 1161 Minor: 0162 FileSize: 133163 PartCount: 1164 PartOffsets: [ 36 ]165 Parts:166 - Name: RTS0167 Size: 89168 RootSignature:169 Version: 2170 NumRootParameters: 1171 RootParametersOffset: 24172 NumStaticSamplers: 0173 StaticSamplersOffset: 48174 Parameters:175 - ParameterType: Constants32Bit176 ShaderVisibility: Hull177 Constants:178 Num32BitValues: 16179 ShaderRegister: 15180 RegisterSpace: 14181 AllowInputAssemblerInputLayout: true182 DenyGeometryShaderRootAccess: true183 )"));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, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,191 0x30, 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 203TEST(RootSignature, ParseRootConstants) {204 SmallString<128> Storage;205 206 // First read a fully explicit yaml with all sizes and offsets provided207 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer208 Header:209 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5, 210 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]211 Version:212 Major: 1213 Minor: 0214 FileSize: 133215 PartCount: 1216 PartOffsets: [ 36 ]217 Parts:218 - Name: RTS0219 Size: 89220 RootSignature:221 Version: 2222 NumRootParameters: 1223 RootParametersOffset: 24224 NumStaticSamplers: 0225 StaticSamplersOffset: 48226 Parameters:227 - ParameterType: Constants32Bit228 ShaderVisibility: Hull229 Constants:230 Num32BitValues: 16231 ShaderRegister: 15232 RegisterSpace: 14233 AllowInputAssemblerInputLayout: true234 DenyGeometryShaderRootAccess: true235 )"));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, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,243 0x30, 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 255TEST(RootSignature, ParseRootDescriptorsV10) {256 SmallString<128> Storage;257 258 // First read a fully explicit yaml with all sizes and offsets provided259 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer260 Header:261 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5, 262 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]263 Version:264 Major: 1265 Minor: 0266 FileSize: 133267 PartCount: 1268 PartOffsets: [ 36 ]269 Parts:270 - Name: RTS0271 Size: 89272 RootSignature:273 Version: 1274 NumRootParameters: 1275 RootParametersOffset: 24276 NumStaticSamplers: 0277 StaticSamplersOffset: 44278 Parameters: 279 - ParameterType: CBV 280 ShaderVisibility: Domain 281 Descriptor:282 ShaderRegister: 31283 RegisterSpace: 32284 AllowInputAssemblerInputLayout: true285 DenyGeometryShaderRootAccess: true286 )"));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 0x2c, 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 306TEST(RootSignature, ParseRootDescriptorsV11) {307 SmallString<128> Storage;308 309 // First read a fully explicit yaml with all sizes and offsets provided310 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer311 Header:312 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5, 313 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]314 Version:315 Major: 1316 Minor: 0317 FileSize: 133318 PartCount: 1319 PartOffsets: [ 36 ]320 Parts:321 - Name: RTS0322 Size: 89323 RootSignature:324 Version: 2325 NumRootParameters: 1326 RootParametersOffset: 24327 NumStaticSamplers: 0328 StaticSamplersOffset: 48329 Parameters: 330 - ParameterType: CBV331 ShaderVisibility: Domain332 Descriptor:333 ShaderRegister: 31334 RegisterSpace: 32335 DATA_STATIC_WHILE_SET_AT_EXECUTE: true336 AllowInputAssemblerInputLayout: true337 DenyGeometryShaderRootAccess: true338 )"));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 0x30, 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 358TEST(RootSignature, ParseDescriptorTableV10) {359 SmallString<128> Storage;360 361 // First read a fully explicit yaml with all sizes and offsets provided362 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer363 Header:364 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5, 365 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]366 Version:367 Major: 1368 Minor: 0369 FileSize: 133370 PartCount: 1371 PartOffsets: [ 36 ]372 Parts:373 - Name: RTS0374 Size: 89375 RootSignature:376 Version: 1377 NumRootParameters: 1378 RootParametersOffset: 24379 NumStaticSamplers: 0380 StaticSamplersOffset: 64381 Parameters: 382 - ParameterType: DescriptorTable383 ShaderVisibility: Domain384 Table:385 NumRanges: 1386 Ranges:387 - RangeType: SRV388 NumDescriptors: 41389 BaseShaderRegister: 42390 RegisterSpace: 43391 OffsetInDescriptorsFromTableStart: 44392 AllowInputAssemblerInputLayout: true393 DenyGeometryShaderRootAccess: true394 )"));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 0x40, 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 414TEST(RootSignature, ParseDescriptorTableV11) {415 SmallString<128> Storage;416 417 // First read a fully explicit yaml with all sizes and offsets provided418 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer419 Header:420 Hash: [ 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F, 0x5, 421 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1 ]422 Version:423 Major: 1424 Minor: 0425 FileSize: 133426 PartCount: 1427 PartOffsets: [ 36 ]428 Parts:429 - Name: RTS0430 Size: 89431 RootSignature:432 Version: 2433 NumRootParameters: 1434 RootParametersOffset: 24435 NumStaticSamplers: 0436 StaticSamplersOffset: 68437 Parameters: 438 - ParameterType: DescriptorTable439 ShaderVisibility: Domain440 Table:441 NumRanges: 1442 Ranges:443 - RangeType: SRV444 NumDescriptors: -1445 BaseShaderRegister: 42446 RegisterSpace: 43447 OffsetInDescriptorsFromTableStart: 41448 DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS: true449 AllowInputAssemblerInputLayout: true450 DenyGeometryShaderRootAccess: true451 )"));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 0x44, 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 471TEST(RootSignature, ParseStaticSamplers) {472 SmallString<128> Storage;473 474 // First read a fully explicit yaml with all sizes and offsets provided475 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer476Header:477 Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 478 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]479 Version:480 Major: 1481 Minor: 0482 PartCount: 1483 PartOffsets: [ 60 ]484Parts:485 - Name: RTS0486 Size: 76487 RootSignature:488 Version: 2489 NumRootParameters: 0490 RootParametersOffset: 24491 NumStaticSamplers: 1492 StaticSamplersOffset: 24493 Parameters: []494 Samplers: 495 - Filter: MinLinearMagMipPoint 496 AddressU: Wrap497 AddressV: Mirror498 AddressW: MirrorOnce499 MipLODBias: 1.23500 MaxAnisotropy: 20501 ComparisonFunc: LessEqual502 BorderColor: TransparentBlack503 MinLOD: 4.56504 MaxLOD: 8.90505 ShaderRegister: 31 506 RegisterSpace: 32507 ShaderVisibility: Mesh508 AllowInputAssemblerInputLayout: true509 DenyGeometryShaderRootAccess: true510 )"));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, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,520 0x18, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 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}529 530TEST(RootSignature, ParseStaticSamplersV13) {531 SmallString<128> Storage;532 533 // First read a fully explicit yaml with all sizes and offsets provided534 ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer535Header:536 Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 537 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]538 Version:539 Major: 1540 Minor: 0541 PartCount: 1542 PartOffsets: [ 60 ]543Parts:544 - Name: RTS0545 Size: 76546 RootSignature:547 Version: 3548 NumRootParameters: 0549 RootParametersOffset: 24550 NumStaticSamplers: 1551 StaticSamplersOffset: 24552 Parameters: []553 Samplers: 554 - ShaderRegister: 31 555 RegisterSpace: 32556 ShaderVisibility: All557 SAMPLER_FLAG_UINT_BORDER_COLOR: true558 AllowInputAssemblerInputLayout: true559 DenyGeometryShaderRootAccess: true560 )"));561 562 uint8_t Buffer[] = {563 0x44, 0x58, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,564 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,565 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,566 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,567 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,568 0x52, 0x54, 0x53, 0x30, 0x4c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,569 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,570 0x18, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00,571 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,572 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,573 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x7f,574 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,575 0x01, 0x00, 0x00, 0x00};576 577 EXPECT_EQ(Storage.size(), 148U);578 EXPECT_TRUE(memcmp(Buffer, Storage.data(), 148U) == 0);579}580