Skip to content

[DirectX] adding support in obj2yaml and yaml2obj to root constants #127840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 130 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
526b34a
adding rootsignature to obj2yaml
Jan 13, 2025
e84a8e1
adding test
Jan 13, 2025
f25fd64
removing old test
Jan 13, 2025
16552f0
remove useless includes
Jan 13, 2025
a6eb4c0
addressing comments
Jan 14, 2025
7d080b3
updating test
Jan 14, 2025
504527b
removing useless header
Jan 15, 2025
2425672
fix formating
Jan 15, 2025
08c17bb
renaming test
Jan 15, 2025
395a536
addressing pr comments
Jan 16, 2025
f93dff9
adding str to ROOT_ELEMENT_FLAG
Jan 16, 2025
1c1edb8
formating
Jan 17, 2025
5bef775
refactoring to follow llvm standards
Jan 18, 2025
628545a
addressing comments
Jan 27, 2025
c5c2ab6
clean up
Jan 27, 2025
b9db72c
remove version
Jan 30, 2025
f4af043
fix pr
Jan 30, 2025
496b922
adding dxil-dis test
Jan 31, 2025
422578f
adding compatibility test
Jan 31, 2025
b1423eb
addressing test concerns
Feb 3, 2025
b6262b6
clean up
Feb 3, 2025
16d0e8e
addressing comments
Feb 4, 2025
0a9e468
adding fail test
Feb 4, 2025
8295031
adding comment
Feb 4, 2025
c8e1e38
adding few more tests
Feb 4, 2025
434b862
format
Feb 4, 2025
2bfc5ad
cleanup
Feb 5, 2025
479422d
adding metadata extraction
Jan 15, 2025
f61ee77
moving root signature to it's own pass
Jan 16, 2025
499d879
formating
Jan 16, 2025
c4af535
removing useless imports
Jan 16, 2025
819fa0d
fixing pr changes
Jan 16, 2025
d347a87
adding some asserts
Jan 16, 2025
d8824ed
format
Jan 16, 2025
25c0384
fixing assert
Jan 18, 2025
5eb0ad2
cleaning
Jan 27, 2025
559427d
clean up
Jan 29, 2025
8ca5b2a
addressing comments
Jan 30, 2025
d52cd2c
removing version
Jan 30, 2025
5930dcb
fix test
Jan 30, 2025
fc72988
addressing PR Comments
Jan 31, 2025
2d1ee0d
fix test
Feb 3, 2025
92a85fe
filtering root signatures not associated with entry function
Feb 4, 2025
979ee91
separating parsing and validation
Feb 4, 2025
d089674
improve error handling
Feb 6, 2025
980e7d9
clean up
Feb 6, 2025
04667f3
clean up
Feb 6, 2025
8ec40aa
formating
Feb 6, 2025
b0ac6be
addressing comments and fix tests
Feb 7, 2025
6a36503
formating
Feb 7, 2025
f7d2c12
addressing pr comments
Feb 10, 2025
d6c98ed
addressing PR comments
Feb 11, 2025
36746f5
addressing pr comments
Feb 11, 2025
b5208e8
removing copies from root signature use in dx container globals
Feb 11, 2025
1fd6568
adding more tests
Feb 12, 2025
cde4634
maybe fix test?
Feb 12, 2025
4410e7b
try fix format
Feb 12, 2025
cbdb114
removing test
Feb 12, 2025
667ee17
adding llvm unreachable and testing test
Feb 12, 2025
d0dae8b
stopping compilation if root signature error were emitted
Feb 12, 2025
b1b28f8
making sure Error tests fail
Feb 12, 2025
0efd8cc
adding root constants
Feb 12, 2025
11256d8
refactoring root signature analysis to return a map instead
Feb 12, 2025
3c5046e
addressing pr comments
Feb 12, 2025
5d4505c
clean up
Feb 12, 2025
3117530
addressing pr comments
Feb 13, 2025
0af845c
implementing find interface for RootSignatureAnalysisWrapper
Feb 13, 2025
bf49a3a
adding test for null function
Feb 13, 2025
78826a5
fix root signature test error
Feb 14, 2025
4e689e9
fix other functions are checked
Feb 14, 2025
b0d0180
adding missing continue
Feb 14, 2025
3c6894f
adding few more tests
Feb 14, 2025
08f6ddc
adding yaml2obj support
Feb 15, 2025
b232967
adding support for obj2yaml and initial tests
Feb 18, 2025
1026a8e
multiple parameters support and more testing
Feb 19, 2025
00175bf
clean up
Feb 19, 2025
9ed2adc
fixing formating
Feb 19, 2025
e8252ba
reapply rebase fix
Feb 19, 2025
4de5c29
clean up
Feb 20, 2025
fe13b61
addressing pr comments
Feb 22, 2025
767b7d0
first working version
Feb 22, 2025
8434dc2
formating
Feb 22, 2025
d391727
moving the offset logic to it's own class
Feb 24, 2025
68c7513
refactoring to remove use of map and string
Feb 24, 2025
23069ab
addressing comments
Feb 25, 2025
d14471b
using buffer_ostream
Feb 25, 2025
216341c
remove getsize
Feb 25, 2025
85f012c
clean up
Feb 25, 2025
1e2bcf5
clean up
Feb 25, 2025
0e277d9
clean up
Feb 25, 2025
5cd0044
clean up
Feb 25, 2025
7a7c34d
addressing pr comments
Feb 25, 2025
d3fafab
clean up
Feb 25, 2025
15d1a8c
Merge branch 'refactor/improve-offset-calculation' into users/joaosaf…
Feb 25, 2025
7485640
clean up
Feb 26, 2025
17abc82
moving initializer arround
Feb 26, 2025
4b177e2
addressing pr comments
Feb 26, 2025
ec1dd87
addressing changes
Feb 26, 2025
eb9d7d3
Merge branch 'main' into users/joaosaffran/127840
Feb 26, 2025
f2a4f04
fix test
Feb 26, 2025
7c4236c
refactoring to change representations in binary format
Mar 1, 2025
2894f96
addressing pr comments
Mar 2, 2025
7b5e9d8
addressing comments and clean up
Mar 20, 2025
f0e6a46
moving RootSignatureValidations to out of BinaryFormat
Mar 24, 2025
4fe30df
addressing most pr comments
Mar 24, 2025
cbc334a
adding root parameter view
Mar 26, 2025
31bcd73
clean up
Mar 26, 2025
30098e1
addressing pr comments
Mar 29, 2025
1bf6408
wip: implementing comments
Mar 31, 2025
d1b32f3
removing old code
Apr 4, 2025
3b9bf27
address errors
Apr 4, 2025
89632a4
removing validations from obj2yaml
Apr 7, 2025
67da709
ac
Apr 8, 2025
3991c5d
address comments
Apr 8, 2025
cfc6bfb
clean up
Apr 8, 2025
82a31fa
removing param_header_begin and param_header_end
Apr 9, 2025
e6865a7
Revert "clean up"
Apr 9, 2025
021976d
Reapply "clean up"
Apr 9, 2025
102ff4b
removing unnecessary parameters
Apr 10, 2025
39d4b08
addressing pr comments
Apr 10, 2025
7343d95
adding more tests
Apr 11, 2025
6986945
adding more tests and addressing comments
Apr 11, 2025
c0ac522
adding tests and changing parameter type
Apr 14, 2025
8511fa9
address comments
Apr 14, 2025
330369a
changing back enums to enum class
Apr 15, 2025
d747bcc
addressing PR comments and adding more tests
Apr 16, 2025
6cef567
adding tests and fixing code
Apr 16, 2025
246d5d3
addressing comments
Apr 16, 2025
bb6c0cf
clean up
Apr 16, 2025
7885eed
addressing nits
Apr 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/include/llvm/Object/DXContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ class RootSignature {
public:
RootSignature(StringRef PD) : PartData(PD) {}

Error parse(StringRef Data);
Error parse();
uint32_t getVersion() const { return Version; }
uint32_t getNumParameters() const { return NumParameters; }
uint32_t getRootParametersOffset() const { return RootParametersOffset; }
uint32_t getNumStaticSamplers() const { return NumStaticSamplers; }
uint32_t getStaticSamplersOffset() const { return StaticSamplersOffset; }
uint32_t getNumRootParameters() const { return ParametersHeaders.size(); }
llvm::iterator_range<param_header_iterator> param_headers() const {
return llvm::make_range(ParametersHeaders.begin(), ParametersHeaders.end());
}
Expand Down
8 changes: 4 additions & 4 deletions llvm/include/llvm/ObjectYAML/DXContainerYAML.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ struct RootConstantsYaml {
};

struct RootParameterYamlDesc {
dxbc::RootParameterType Type;
dxbc::ShaderVisibility Visibility;
uint32_t Type;
uint32_t Visibility;
uint32_t Offset;

union {
Expand All @@ -95,6 +95,8 @@ struct RootSignatureYamlDesc {
RootSignatureYamlDesc() = default;

uint32_t Version;
uint32_t NumRootParameters;
uint32_t RootParametersOffset;
uint32_t NumStaticSamplers;
uint32_t StaticSamplersOffset;

Expand Down Expand Up @@ -224,8 +226,6 @@ LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::PSV::ResourceKind)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::D3DSystemValue)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::SigComponentType)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::SigMinPrecision)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::RootParameterType)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::ShaderVisibility)

namespace llvm {

Expand Down
13 changes: 6 additions & 7 deletions llvm/lib/Object/DXContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Error DXContainer::parseRootSignature(StringRef Part) {
if (RootSignature)
return parseFailed("More than one RTS0 part is present in the file");
RootSignature = DirectX::RootSignature(Part);
if (Error Err = RootSignature->parse(Part))
if (Error Err = RootSignature->parse())
return Err;
return Error::success();
}
Expand Down Expand Up @@ -242,12 +242,11 @@ void DXContainer::PartIterator::updateIteratorImpl(const uint32_t Offset) {
IteratorState.Offset = Offset;
}

Error DirectX::RootSignature::parse(StringRef Data) {
const char *Begin = Data.begin();
const char *Current = Data.begin();
Error DirectX::RootSignature::parse() {
const char *Current = PartData.begin();

// Root Signature headers expects 6 integers to be present.
if (Data.size() < 6 * sizeof(uint32_t))
if (PartData.size() < 6 * sizeof(uint32_t))
return parseFailed(
"Invalid root signature, insufficient space for header.");

Expand All @@ -273,9 +272,9 @@ Error DirectX::RootSignature::parse(StringRef Data) {
Flags = support::endian::read<uint32_t, llvm::endianness::little>(Current);
Current += sizeof(uint32_t);

assert(Current == Begin + RootParametersOffset);
assert(Current == PartData.begin() + RootParametersOffset);

ParametersHeaders.Data = Data.substr(
ParametersHeaders.Data = PartData.substr(
RootParametersOffset, NumParameters * sizeof(dxbc::RootParameterHeader));

return Error::success();
Expand Down
20 changes: 6 additions & 14 deletions llvm/lib/ObjectYAML/DXContainerYAML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ DXContainerYAML::RootSignatureYamlDesc::create(
RootSigDesc.Version = Data.getVersion();
RootSigDesc.NumStaticSamplers = Data.getNumStaticSamplers();
RootSigDesc.StaticSamplersOffset = Data.getStaticSamplersOffset();
RootSigDesc.NumRootParameters = Data.getNumRootParameters();
RootSigDesc.RootParametersOffset = Data.getRootParametersOffset();

uint32_t Flags = Data.getFlags();
for (const auto &PH : Data.param_headers()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one too

Expand All @@ -51,13 +53,13 @@ DXContainerYAML::RootSignatureYamlDesc::create(
return createStringError(std::errc::invalid_argument,
"Invalid value for parameter type");

NewP.Type = (dxbc::RootParameterType)PH.ParameterType;
NewP.Type = PH.ParameterType;

if (!dxbc::isValidShaderVisibility(PH.ShaderVisibility))
return createStringError(std::errc::invalid_argument,
"Invalid value for shader visibility");

NewP.Visibility = (dxbc::ShaderVisibility)PH.ShaderVisibility;
NewP.Visibility = PH.ShaderVisibility;

llvm::Expected<object::DirectX::RootParameterView> ParamViewOrErr =
Data.getParameter(PH);
Expand Down Expand Up @@ -257,6 +259,8 @@ void MappingTraits<DXContainerYAML::Signature>::mapping(
void MappingTraits<DXContainerYAML::RootSignatureYamlDesc>::mapping(
IO &IO, DXContainerYAML::RootSignatureYamlDesc &S) {
IO.mapRequired("Version", S.Version);
IO.mapRequired("NumRootParameters", S.NumRootParameters);
IO.mapRequired("RootParametersOffset", S.RootParametersOffset);
IO.mapRequired("NumStaticSamplers", S.NumStaticSamplers);
IO.mapRequired("StaticSamplersOffset", S.StaticSamplersOffset);
IO.mapRequired("Parameters", S.Parameters);
Expand Down Expand Up @@ -385,18 +389,6 @@ void ScalarEnumerationTraits<dxbc::SigComponentType>::enumeration(
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
}

void ScalarEnumerationTraits<dxbc::RootParameterType>::enumeration(
IO &IO, dxbc::RootParameterType &Value) {
for (const auto &E : dxbc::getRootParameterTypes())
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
}

void ScalarEnumerationTraits<dxbc::ShaderVisibility>::enumeration(
IO &IO, dxbc::ShaderVisibility &Value) {
for (const auto &E : dxbc::getShaderVisibility())
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
}

} // namespace yaml

void DXContainerYAML::PSVInfo::mapInfoForVersion(yaml::IO &IO) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
; DXC-NEXT: Size: 24
; DXC-NEXT: RootSignature:
; DXC-NEXT: Version: 2
; DXC-NEXT: NumRootParameters: 0
; DXC-NEXT: RootParametersOffset: 24
; DXC-NEXT: NumStaticSamplers: 0
; DXC-NEXT: StaticSamplersOffset: 0
; DXC-NEXT: Parameters: []
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/ObjectYAML/DXContainer/RootSignature-Flags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Parts:
Size: 24
RootSignature:
Version: 2
NumRootParameters: 0
RootParametersOffset: 24
NumStaticSamplers: 4
StaticSamplersOffset: 5
Parameters: []
Expand All @@ -24,6 +26,8 @@ Parts:
# CHECK-NEXT: Size: 24
# CHECK-NEXT: RootSignature:
# CHECK-NEXT: Version: 2
# CHECK-NEXT: NumRootParameters: 0
# CHECK-NEXT: RootParametersOffset: 24
# CHECK-NEXT: NumStaticSamplers: 0
# CHECK-NEXT: StaticSamplersOffset: 0
# CHECK-NEXT: Parameters: []
Expand Down
29 changes: 29 additions & 0 deletions llvm/test/ObjectYAML/DXContainer/RootSignature-InvalidType.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# RUN: yaml2obj %s -o %t
# RUN: not obj2yaml 2>&1 %t | FileCheck %s -DFILE=%t

# CHECK: Error reading file: [[FILE]]: Invalid value for parameter type


--- !dxcontainer
Header:
Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
Version:
Major: 1
Minor: 0
PartCount: 1
PartOffsets: [ 60 ]
Parts:
- Name: RTS0
Size: 80
RootSignature:
Version: 2
NumRootParameters: 2
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 64
Parameters:
- ParameterType: 255 # INVALID
ShaderVisibility: 2 # Hull
AllowInputAssemblerInputLayout: true
DenyGeometryShaderRootAccess: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# RUN: yaml2obj %s -o %t
# RUN: not obj2yaml 2>&1 %t | FileCheck %s -DFILE=%t

# CHECK: Error reading file: [[FILE]]: Invalid value for shader visibility


--- !dxcontainer
Header:
Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
Version:
Major: 1
Minor: 0
PartCount: 1
PartOffsets: [ 60 ]
Parts:
- Name: RTS0
Size: 80
RootSignature:
Version: 2
NumRootParameters: 2
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 64
Parameters:
- ParameterType: 1 # Constants32Bit
ShaderVisibility: 255 # INVALID
Constants:
Num32BitValues: 21
ShaderRegister: 22
RegisterSpace: 23
AllowInputAssemblerInputLayout: true
DenyGeometryShaderRootAccess: true
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ Parts:
Size: 80
RootSignature:
Version: 2
NumRootParameters: 2
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 64
Parameters:
- ParameterType: Constants32Bit
ShaderVisibility: Hull
- ParameterType: 1 # Constants32Bit
ShaderVisibility: 2 # Hull
Constants:
Num32BitValues: 16
ShaderRegister: 15
RegisterSpace: 14
- ParameterType: Constants32Bit
ShaderVisibility: Geometry
- ParameterType: 1 # Constants32Bit
ShaderVisibility: 4 # Geometry
Constants:
Num32BitValues: 21
ShaderRegister: 22
Expand All @@ -36,17 +38,19 @@ Parts:
# CHECK-NEXT: Size: 80
# CHECK-NEXT: RootSignature:
# CHECK-NEXT: Version: 2
# CHECK-NEXT: NumRootParameters: 2
# CHECK-NEXT: RootParametersOffset: 24
# CHECK-NEXT: NumStaticSamplers: 0
# CHECK-NEXT: StaticSamplersOffset: 0
# CHECK-NEXT: Parameters:
# CHECK-NEXT: - ParameterType: Constants32Bit
# CHECK-NEXT: ShaderVisibility: Hull
# CHECK-NEXT: - ParameterType: 1
# CHECK-NEXT: ShaderVisibility: 2
# CHECK-NEXT: Constants:
# CHECK-NEXT: Num32BitValues: 16
# CHECK-NEXT: RegisterSpace: 14
# CHECK-NEXT: ShaderRegister: 15
# CHECK-NEXT: - ParameterType: Constants32Bit
# CHECK-NEXT: ShaderVisibility: Geometry
# CHECK-NEXT: - ParameterType: 1
# CHECK-NEXT: ShaderVisibility: 4
# CHECK-NEXT: Constants:
# CHECK-NEXT: Num32BitValues: 21
# CHECK-NEXT: RegisterSpace: 23
Expand Down
41 changes: 0 additions & 41 deletions llvm/unittests/Object/DXContainerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

#include "llvm/Object/DXContainer.h"
#include "../../tools/obj2yaml/dxcontainer2yaml.cpp"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/ObjectYAML/DXContainerYAML.h"
Expand Down Expand Up @@ -908,44 +907,4 @@ TEST(RootSignature, ParseRootConstant) {
ASSERT_EQ(Constants->RegisterSpace, 14u);
ASSERT_EQ(Constants->Num32BitValues, 16u);
}
{
uint8_t Buffer[] = {
0x44, 0x58, 0x42, 0x43, 0x32, 0x9a, 0x53, 0xd8, 0xec, 0xbe, 0x35, 0x6f,
0x05, 0x39, 0xe1, 0xfe, 0x31, 0x20, 0xf0, 0xc1, 0x01, 0x00, 0x00, 0x00,
0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
0x52, 0x54, 0x53, 0x30, 0x59, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x2c, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00};

SmallString<256> Storage;
raw_svector_ostream OS(Storage);
EXPECT_THAT_ERROR(dxcontainer2yaml(OS, getMemoryBuffer<133>(Buffer)),
FailedWithMessage("Invalid value for parameter type"));
}
{
uint8_t Buffer[] = {
0x44, 0x58, 0x42, 0x43, 0x32, 0x9a, 0x53, 0xd8, 0xec, 0xbe, 0x35, 0x6f,
0x05, 0x39, 0xe1, 0xfe, 0x31, 0x20, 0xf0, 0xc1, 0x01, 0x00, 0x00, 0x00,
0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
0x52, 0x54, 0x53, 0x30, 0x59, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x2c, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0xFF, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00};

SmallString<256> Storage;
raw_svector_ostream OS(Storage);
EXPECT_THAT_ERROR(dxcontainer2yaml(OS, getMemoryBuffer<133>(Buffer)),
FailedWithMessage("Invalid value for shader visibility"));
}
}
8 changes: 6 additions & 2 deletions llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ TEST(RootSignature, ParseRootFlags) {
Size: 24
RootSignature:
Version: 2
NumRootParameters: 0
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 0
Parameters: []
Expand Down Expand Up @@ -165,11 +167,13 @@ TEST(RootSignature, ParseRootConstants) {
Size: 89
RootSignature:
Version: 2
NumRootParameters: 1
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 56
Parameters:
- ParameterType: Constants32Bit
ShaderVisibility: Hull
- ParameterType: 1
ShaderVisibility: 2
Constants:
Num32BitValues: 16
ShaderRegister: 15
Expand Down
Loading