-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[HLSL] Add descriptor table metadata parsing #142492
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
base: main
Are you sure you want to change the base?
Changes from all commits
0abacfc
8b8c02a
7ac9641
c105458
efe76aa
a928e9d
a38f10b
9a7c359
d6c2b55
93e4cf2
b45b1b6
f804a23
15eb6f5
b9d7f07
46cc8c1
1b3e10a
1f31957
e8fbfce
a31e5a5
a394ad0
ad415a7
8ff4845
f875555
4f7f998
3eb5e10
58e1789
81915ad
a515e28
0d54162
7f70dc5
3e6b07e
bb1a61f
8979ab7
be60d51
0c570c8
c3d24b6
d1ca37d
cb0780b
eeffded
3cbe0cf
92b766b
0259cf7
8732594
fdb8b98
8b61ffd
0b3e16b
750a6d5
72b8dbc
8f069c7
440566c
72ca44b
90f7403
7a4382e
1c608f4
3b8b2e1
e0bc5e3
35a2e0b
655b3b4
91346a7
e8066df
15f4f49
638d961
8b831f8
5c677a5
bce790c
fefe820
e577503
746c54a
c5a1009
a66e6a3
351eee2
4a0a955
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,16 @@ DESCRIPTOR_RANGE_FLAG(0x10000, DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS) | |
#undef DESCRIPTOR_RANGE_FLAG | ||
#endif // DESCRIPTOR_RANGE_FLAG | ||
|
||
// DESCRIPTOR_RANGE(value, name). | ||
#ifdef DESCRIPTOR_RANGE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the other ifdef blocks have a new line after the ifdef. |
||
|
||
DESCRIPTOR_RANGE(0, SRV) | ||
DESCRIPTOR_RANGE(1, UAV) | ||
DESCRIPTOR_RANGE(2, CBV) | ||
DESCRIPTOR_RANGE(3, Sampler) | ||
#undef DESCRIPTOR_RANGE | ||
#endif // DESCRIPTOR_RANGE | ||
|
||
#ifdef ROOT_PARAMETER | ||
|
||
ROOT_PARAMETER(0, DescriptorTable) | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -174,6 +174,93 @@ static bool parseRootDescriptors(LLVMContext *Ctx, | |||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
static bool parseDescriptorRange(LLVMContext *Ctx, | ||||||||||||||||||||||||||
mcdxbc::DescriptorTable &Table, | ||||||||||||||||||||||||||
MDNode *RangeDescriptorNode) { | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (RangeDescriptorNode->getNumOperands() != 6) | ||||||||||||||||||||||||||
return reportError(Ctx, "Invalid format for Descriptor Range"); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
dxbc::RTS0::v2::DescriptorRange Range; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
std::optional<StringRef> ElementText = | ||||||||||||||||||||||||||
extractMdStringValue(RangeDescriptorNode, 0); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (!ElementText.has_value()) | ||||||||||||||||||||||||||
return reportError(Ctx, "Descriptor Range, first element is not a string."); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Range.RangeType = | ||||||||||||||||||||||||||
StringSwitch<uint32_t>(*ElementText) | ||||||||||||||||||||||||||
.Case("CBV", llvm::to_underlying(dxbc::DescriptorRangeType::CBV)) | ||||||||||||||||||||||||||
.Case("SRV", llvm::to_underlying(dxbc::DescriptorRangeType::SRV)) | ||||||||||||||||||||||||||
.Case("UAV", llvm::to_underlying(dxbc::DescriptorRangeType::UAV)) | ||||||||||||||||||||||||||
.Case("Sampler", | ||||||||||||||||||||||||||
llvm::to_underlying(dxbc::DescriptorRangeType::Sampler)) | ||||||||||||||||||||||||||
.Default(~0U); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (Range.RangeType == ~0U) | ||||||||||||||||||||||||||
return reportError(Ctx, "Invalid Descriptor Range type: " + *ElementText); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (std::optional<uint32_t> Val = extractMdIntValue(RangeDescriptorNode, 1)) | ||||||||||||||||||||||||||
Range.NumDescriptors = *Val; | ||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||
return reportError(Ctx, "Invalid value for Number of Descriptor in Range"); | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could probably have a function like Something like "Parameter: ... expected metadata node of type ... but got ..." I am not sure if you can retrieve the type of an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have addressed this in a separate branch, will send a follow-up PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the PR: #144425 |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (std::optional<uint32_t> Val = extractMdIntValue(RangeDescriptorNode, 2)) | ||||||||||||||||||||||||||
Range.BaseShaderRegister = *Val; | ||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||
return reportError(Ctx, "Invalid value for BaseShaderRegister"); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (std::optional<uint32_t> Val = extractMdIntValue(RangeDescriptorNode, 3)) | ||||||||||||||||||||||||||
Range.RegisterSpace = *Val; | ||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||
return reportError(Ctx, "Invalid value for RegisterSpace"); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (std::optional<uint32_t> Val = extractMdIntValue(RangeDescriptorNode, 4)) | ||||||||||||||||||||||||||
Range.OffsetInDescriptorsFromTableStart = *Val; | ||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||
return reportError(Ctx, | ||||||||||||||||||||||||||
"Invalid value for OffsetInDescriptorsFromTableStart"); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (std::optional<uint32_t> Val = extractMdIntValue(RangeDescriptorNode, 5)) | ||||||||||||||||||||||||||
Range.Flags = *Val; | ||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||
return reportError(Ctx, "Invalid value for Descriptor Range Flags"); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Table.Ranges.push_back(Range); | ||||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
static bool parseDescriptorTable(LLVMContext *Ctx, | ||||||||||||||||||||||||||
mcdxbc::RootSignatureDesc &RSD, | ||||||||||||||||||||||||||
MDNode *DescriptorTableNode) { | ||||||||||||||||||||||||||
const unsigned int NumOperands = DescriptorTableNode->getNumOperands(); | ||||||||||||||||||||||||||
if (NumOperands < 2) | ||||||||||||||||||||||||||
joaosaffran marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
return reportError(Ctx, "Invalid format for Descriptor Table"); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
dxbc::RTS0::v1::RootParameterHeader Header; | ||||||||||||||||||||||||||
if (std::optional<uint32_t> Val = extractMdIntValue(DescriptorTableNode, 1)) | ||||||||||||||||||||||||||
Header.ShaderVisibility = *Val; | ||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||
return reportError(Ctx, "Invalid value for ShaderVisibility"); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
mcdxbc::DescriptorTable Table; | ||||||||||||||||||||||||||
Header.ParameterType = | ||||||||||||||||||||||||||
llvm::to_underlying(dxbc::RootParameterType::DescriptorTable); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
for (unsigned int I = 2; I < NumOperands; I++) { | ||||||||||||||||||||||||||
MDNode *Element = dyn_cast<MDNode>(DescriptorTableNode->getOperand(I)); | ||||||||||||||||||||||||||
if (Element == nullptr) | ||||||||||||||||||||||||||
return reportError(Ctx, "Missing Root Element Metadata Node."); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (parseDescriptorRange(Ctx, Table, Element)) | ||||||||||||||||||||||||||
return true; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
RSD.ParametersContainer.addParameter(Header, Table); | ||||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
static bool parseRootSignatureElement(LLVMContext *Ctx, | ||||||||||||||||||||||||||
mcdxbc::RootSignatureDesc &RSD, | ||||||||||||||||||||||||||
MDNode *Element) { | ||||||||||||||||||||||||||
|
@@ -188,6 +275,7 @@ static bool parseRootSignatureElement(LLVMContext *Ctx, | |||||||||||||||||||||||||
.Case("RootCBV", RootSignatureElementKind::CBV) | ||||||||||||||||||||||||||
.Case("RootSRV", RootSignatureElementKind::SRV) | ||||||||||||||||||||||||||
.Case("RootUAV", RootSignatureElementKind::UAV) | ||||||||||||||||||||||||||
.Case("DescriptorTable", RootSignatureElementKind::DescriptorTable) | ||||||||||||||||||||||||||
.Default(RootSignatureElementKind::Error); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
switch (ElementKind) { | ||||||||||||||||||||||||||
|
@@ -200,6 +288,8 @@ static bool parseRootSignatureElement(LLVMContext *Ctx, | |||||||||||||||||||||||||
case RootSignatureElementKind::SRV: | ||||||||||||||||||||||||||
case RootSignatureElementKind::UAV: | ||||||||||||||||||||||||||
return parseRootDescriptors(Ctx, RSD, Element, ElementKind); | ||||||||||||||||||||||||||
case RootSignatureElementKind::DescriptorTable: | ||||||||||||||||||||||||||
return parseDescriptorTable(Ctx, RSD, Element); | ||||||||||||||||||||||||||
case RootSignatureElementKind::Error: | ||||||||||||||||||||||||||
return reportError(Ctx, "Invalid Root Signature Element: " + *ElementText); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
@@ -241,6 +331,75 @@ static bool verifyRegisterSpace(uint32_t RegisterSpace) { | |||||||||||||||||||||||||
|
||||||||||||||||||||||||||
static bool verifyDescriptorFlag(uint32_t Flags) { return (Flags & ~0xE) == 0; } | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
static bool verifyRangeType(uint32_t Type) { | ||||||||||||||||||||||||||
switch (Type) { | ||||||||||||||||||||||||||
case llvm::to_underlying(dxbc::DescriptorRangeType::CBV): | ||||||||||||||||||||||||||
case llvm::to_underlying(dxbc::DescriptorRangeType::SRV): | ||||||||||||||||||||||||||
case llvm::to_underlying(dxbc::DescriptorRangeType::UAV): | ||||||||||||||||||||||||||
case llvm::to_underlying(dxbc::DescriptorRangeType::Sampler): | ||||||||||||||||||||||||||
return true; | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
static bool verifyDescriptorRangeFlag(uint32_t Version, uint32_t Type, | ||||||||||||||||||||||||||
uint32_t FlagsVal) { | ||||||||||||||||||||||||||
using FlagT = dxbc::DescriptorRangeFlag; | ||||||||||||||||||||||||||
FlagT Flags = FlagT(FlagsVal); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const bool IsSampler = | ||||||||||||||||||||||||||
(Type == llvm::to_underlying(dxbc::DescriptorRangeType::Sampler)); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
joaosaffran marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
if (Version == 1) { | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably worth a comment.
Suggested change
|
||||||||||||||||||||||||||
if (IsSampler) | ||||||||||||||||||||||||||
return Flags == FlagT::DESCRIPTORS_VOLATILE; | ||||||||||||||||||||||||||
return Flags == (FlagT::DATA_VOLATILE | FlagT::DESCRIPTORS_VOLATILE); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// The data-specific flags are mutually exclusive. | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the descriptor flags are also mutually exclusive. Do we want an explicit check for this? It seems like it is covered below. Maybe it is good for clarity? |
||||||||||||||||||||||||||
FlagT DataFlags = FlagT::DATA_VOLATILE | FlagT::DATA_STATIC | | ||||||||||||||||||||||||||
FlagT::DATA_STATIC_WHILE_SET_AT_EXECUTE; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (popcount(llvm::to_underlying(Flags & DataFlags)) > 1) | ||||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// The descriptor-specific flags are mutually exclusive. | ||||||||||||||||||||||||||
FlagT DescriptorFlags = | ||||||||||||||||||||||||||
FlagT::DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS | | ||||||||||||||||||||||||||
FlagT::DESCRIPTORS_VOLATILE; | ||||||||||||||||||||||||||
if (popcount(llvm::to_underlying(Flags & DescriptorFlags)) > 1) | ||||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// For volatile descriptors, DATA_STATIC is never valid. | ||||||||||||||||||||||||||
if ((Flags & FlagT::DESCRIPTORS_VOLATILE) == FlagT::DESCRIPTORS_VOLATILE) { | ||||||||||||||||||||||||||
FlagT Mask = FlagT::DESCRIPTORS_VOLATILE; | ||||||||||||||||||||||||||
if (!IsSampler) { | ||||||||||||||||||||||||||
Mask |= FlagT::DATA_VOLATILE; | ||||||||||||||||||||||||||
Mask |= FlagT::DATA_STATIC_WHILE_SET_AT_EXECUTE; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
return (Flags & ~Mask) == FlagT::NONE; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// For "STATIC_KEEPING_BUFFER_BOUNDS_CHECKS" descriptors, | ||||||||||||||||||||||||||
// the other data-specific flags may all be set. | ||||||||||||||||||||||||||
if ((Flags & FlagT::DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS) == | ||||||||||||||||||||||||||
FlagT::DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS) { | ||||||||||||||||||||||||||
FlagT Mask = FlagT::DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS; | ||||||||||||||||||||||||||
if (!IsSampler) { | ||||||||||||||||||||||||||
Mask |= FlagT::DATA_VOLATILE; | ||||||||||||||||||||||||||
Mask |= FlagT::DATA_STATIC; | ||||||||||||||||||||||||||
Mask |= FlagT::DATA_STATIC_WHILE_SET_AT_EXECUTE; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
return (Flags & ~Mask) == FlagT::NONE; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// When no descriptor flag is set, any data flag is allowed. | ||||||||||||||||||||||||||
if (!IsSampler) | ||||||||||||||||||||||||||
return (Flags & ~DataFlags) == FlagT::NONE; | ||||||||||||||||||||||||||
return (Flags & ~FlagT::NONE) == FlagT::NONE; | ||||||||||||||||||||||||||
Comment on lines
+397
to
+400
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels weird to do this case differently than above, since they're doing the same thing. Technically we could simplify this just by removing the
Suggested change
|
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
static bool validate(LLVMContext *Ctx, const mcdxbc::RootSignatureDesc &RSD) { | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (!verifyVersion(RSD.Version)) { | ||||||||||||||||||||||||||
|
@@ -279,6 +438,22 @@ static bool validate(LLVMContext *Ctx, const mcdxbc::RootSignatureDesc &RSD) { | |||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable): { | ||||||||||||||||||||||||||
const mcdxbc::DescriptorTable &Table = | ||||||||||||||||||||||||||
RSD.ParametersContainer.getDescriptorTable(Info.Location); | ||||||||||||||||||||||||||
for (const dxbc::RTS0::v2::DescriptorRange &Range : Table) { | ||||||||||||||||||||||||||
if (!verifyRangeType(Range.RangeType)) | ||||||||||||||||||||||||||
return reportValueError(Ctx, "RangeType", Range.RangeType); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (!verifyRegisterSpace(Range.RegisterSpace)) | ||||||||||||||||||||||||||
return reportValueError(Ctx, "RegisterSpace", Range.RegisterSpace); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (!verifyDescriptorRangeFlag(RSD.Version, Range.RangeType, | ||||||||||||||||||||||||||
Range.Flags)) | ||||||||||||||||||||||||||
return reportValueError(Ctx, "DescriptorFlag", Range.Flags); | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this differentiate from non-range DescriptorFlag?
Suggested change
|
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
@@ -388,67 +563,67 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M, | |||||||||||||||||||||||||
|
||||||||||||||||||||||||||
OS << "Root Signature Definitions" | ||||||||||||||||||||||||||
<< "\n"; | ||||||||||||||||||||||||||
uint8_t Space = 0; | ||||||||||||||||||||||||||
for (const Function &F : M) { | ||||||||||||||||||||||||||
auto It = RSDMap.find(&F); | ||||||||||||||||||||||||||
if (It == RSDMap.end()) | ||||||||||||||||||||||||||
continue; | ||||||||||||||||||||||||||
const auto &RS = It->second; | ||||||||||||||||||||||||||
OS << "Definition for '" << F.getName() << "':\n"; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// start root signature header | ||||||||||||||||||||||||||
Space++; | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These don't seem like a related change? I guess it is to conform to use explicit idents everywhere instead of incremeting/decrementing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it is just to add consistency in the idents |
||||||||||||||||||||||||||
OS << indent(Space) << "Flags: " << format_hex(RS.Flags, 8) << "\n"; | ||||||||||||||||||||||||||
OS << indent(Space) << "Version: " << RS.Version << "\n"; | ||||||||||||||||||||||||||
OS << indent(Space) << "RootParametersOffset: " << RS.RootParameterOffset | ||||||||||||||||||||||||||
<< "\n"; | ||||||||||||||||||||||||||
OS << indent(Space) << "NumParameters: " << RS.ParametersContainer.size() | ||||||||||||||||||||||||||
<< "\n"; | ||||||||||||||||||||||||||
Space++; | ||||||||||||||||||||||||||
OS << "Flags: " << format_hex(RS.Flags, 8) << "\n" | ||||||||||||||||||||||||||
<< "Version: " << RS.Version << "\n" | ||||||||||||||||||||||||||
<< "RootParametersOffset: " << RS.RootParameterOffset << "\n" | ||||||||||||||||||||||||||
<< "NumParameters: " << RS.ParametersContainer.size() << "\n"; | ||||||||||||||||||||||||||
for (size_t I = 0; I < RS.ParametersContainer.size(); I++) { | ||||||||||||||||||||||||||
const auto &[Type, Loc] = | ||||||||||||||||||||||||||
RS.ParametersContainer.getTypeAndLocForParameter(I); | ||||||||||||||||||||||||||
const dxbc::RTS0::v1::RootParameterHeader Header = | ||||||||||||||||||||||||||
RS.ParametersContainer.getHeader(I); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
OS << indent(Space) << "- Parameter Type: " << Type << "\n"; | ||||||||||||||||||||||||||
OS << indent(Space + 2) | ||||||||||||||||||||||||||
<< "Shader Visibility: " << Header.ShaderVisibility << "\n"; | ||||||||||||||||||||||||||
OS << "- Parameter Type: " << Type << "\n" | ||||||||||||||||||||||||||
<< " Shader Visibility: " << Header.ShaderVisibility << "\n"; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
switch (Type) { | ||||||||||||||||||||||||||
case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit): { | ||||||||||||||||||||||||||
const dxbc::RTS0::v1::RootConstants &Constants = | ||||||||||||||||||||||||||
RS.ParametersContainer.getConstant(Loc); | ||||||||||||||||||||||||||
OS << indent(Space + 2) << "Register Space: " << Constants.RegisterSpace | ||||||||||||||||||||||||||
<< "\n"; | ||||||||||||||||||||||||||
OS << indent(Space + 2) | ||||||||||||||||||||||||||
<< "Shader Register: " << Constants.ShaderRegister << "\n"; | ||||||||||||||||||||||||||
OS << indent(Space + 2) | ||||||||||||||||||||||||||
<< "Num 32 Bit Values: " << Constants.Num32BitValues << "\n"; | ||||||||||||||||||||||||||
OS << " Register Space: " << Constants.RegisterSpace << "\n" | ||||||||||||||||||||||||||
<< " Shader Register: " << Constants.ShaderRegister << "\n" | ||||||||||||||||||||||||||
<< " Num 32 Bit Values: " << Constants.Num32BitValues << "\n"; | ||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
case llvm::to_underlying(dxbc::RootParameterType::CBV): | ||||||||||||||||||||||||||
case llvm::to_underlying(dxbc::RootParameterType::UAV): | ||||||||||||||||||||||||||
case llvm::to_underlying(dxbc::RootParameterType::SRV): { | ||||||||||||||||||||||||||
const dxbc::RTS0::v2::RootDescriptor &Descriptor = | ||||||||||||||||||||||||||
RS.ParametersContainer.getRootDescriptor(Loc); | ||||||||||||||||||||||||||
OS << indent(Space + 2) | ||||||||||||||||||||||||||
<< "Register Space: " << Descriptor.RegisterSpace << "\n"; | ||||||||||||||||||||||||||
OS << indent(Space + 2) | ||||||||||||||||||||||||||
<< "Shader Register: " << Descriptor.ShaderRegister << "\n"; | ||||||||||||||||||||||||||
OS << " Register Space: " << Descriptor.RegisterSpace << "\n" | ||||||||||||||||||||||||||
<< " Shader Register: " << Descriptor.ShaderRegister << "\n"; | ||||||||||||||||||||||||||
if (RS.Version > 1) | ||||||||||||||||||||||||||
OS << indent(Space + 2) << "Flags: " << Descriptor.Flags << "\n"; | ||||||||||||||||||||||||||
OS << " Flags: " << Descriptor.Flags << "\n"; | ||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable): { | ||||||||||||||||||||||||||
const mcdxbc::DescriptorTable &Table = | ||||||||||||||||||||||||||
RS.ParametersContainer.getDescriptorTable(Loc); | ||||||||||||||||||||||||||
OS << " NumRanges: " << Table.Ranges.size() << "\n"; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
for (const dxbc::RTS0::v2::DescriptorRange Range : Table) { | ||||||||||||||||||||||||||
OS << " - Range Type: " << Range.RangeType << "\n" | ||||||||||||||||||||||||||
<< " Register Space: " << Range.RegisterSpace << "\n" | ||||||||||||||||||||||||||
<< " Base Shader Register: " << Range.BaseShaderRegister << "\n" | ||||||||||||||||||||||||||
<< " Num Descriptors: " << Range.NumDescriptors << "\n" | ||||||||||||||||||||||||||
<< " Offset In Descriptors From Table Start: " | ||||||||||||||||||||||||||
<< Range.OffsetInDescriptorsFromTableStart << "\n"; | ||||||||||||||||||||||||||
if (RS.Version > 1) | ||||||||||||||||||||||||||
OS << " Flags: " << Range.Flags << "\n"; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
Space--; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
OS << indent(Space) << "NumStaticSamplers: " << 0 << "\n"; | ||||||||||||||||||||||||||
OS << indent(Space) << "StaticSamplersOffset: " << RS.StaticSamplersOffset | ||||||||||||||||||||||||||
<< "\n"; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Space--; | ||||||||||||||||||||||||||
// end root signature header | ||||||||||||||||||||||||||
OS << "NumStaticSamplers: " << 0 << "\n"; | ||||||||||||||||||||||||||
OS << "StaticSamplersOffset: " << RS.StaticSamplersOffset << "\n"; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
return PreservedAnalyses::all(); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review note: the value used in the macro is required to be the highest value