-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[DirectX] Refactor RootSignature Backend to remove to_underlying
from Root Parameter Header
#154249
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
Changes from 2 commits
31ec5e5
1690a9c
f6f2e61
6539364
1d29111
8eb82fd
d38c00d
3b25b34
567a3d4
fb248da
dc436d5
8353fe0
3a30581
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 |
---|---|---|
|
@@ -19,13 +19,19 @@ namespace llvm { | |
class raw_ostream; | ||
namespace mcdxbc { | ||
|
||
struct RootParameterHeader { | ||
dxbc::RootParameterType ParameterType; | ||
dxbc::ShaderVisibility ShaderVisibility; | ||
uint32_t ParameterOffset; | ||
}; | ||
|
||
|
||
struct RootParameterInfo { | ||
dxbc::RTS0::v1::RootParameterHeader Header; | ||
RootParameterHeader Header; | ||
size_t Location; | ||
|
||
RootParameterInfo() = default; | ||
|
||
|
||
RootParameterInfo(dxbc::RTS0::v1::RootParameterHeader Header, size_t Location) | ||
RootParameterInfo(RootParameterHeader Header, size_t Location) | ||
: Header(Header), Location(Location) {} | ||
}; | ||
|
||
|
||
|
@@ -46,39 +52,36 @@ struct RootParametersContainer { | |
SmallVector<dxbc::RTS0::v2::RootDescriptor> Descriptors; | ||
SmallVector<DescriptorTable> Tables; | ||
|
||
void addInfo(dxbc::RTS0::v1::RootParameterHeader Header, size_t Location) { | ||
void addInfo(RootParameterHeader Header, size_t Location) { | ||
ParametersInfo.push_back(RootParameterInfo(Header, Location)); | ||
} | ||
|
||
void addParameter(dxbc::RTS0::v1::RootParameterHeader Header, | ||
void addParameter(RootParameterHeader Header, | ||
dxbc::RTS0::v1::RootConstants Constant) { | ||
addInfo(Header, Constants.size()); | ||
Constants.push_back(Constant); | ||
} | ||
|
||
void addInvalidParameter(dxbc::RTS0::v1::RootParameterHeader Header) { | ||
addInfo(Header, -1); | ||
} | ||
void addInvalidParameter(RootParameterHeader Header) { addInfo(Header, -1); } | ||
|
||
void addParameter(dxbc::RTS0::v1::RootParameterHeader Header, | ||
void addParameter(RootParameterHeader Header, | ||
dxbc::RTS0::v2::RootDescriptor Descriptor) { | ||
addInfo(Header, Descriptors.size()); | ||
Descriptors.push_back(Descriptor); | ||
} | ||
|
||
void addParameter(dxbc::RTS0::v1::RootParameterHeader Header, | ||
DescriptorTable Table) { | ||
void addParameter(RootParameterHeader Header, DescriptorTable Table) { | ||
addInfo(Header, Tables.size()); | ||
Tables.push_back(Table); | ||
} | ||
|
||
std::pair<uint32_t, uint32_t> | ||
std::pair<dxbc::RootParameterType, uint32_t> | ||
getTypeAndLocForParameter(uint32_t Location) const { | ||
const RootParameterInfo &Info = ParametersInfo[Location]; | ||
return {Info.Header.ParameterType, Info.Location}; | ||
} | ||
|
||
const dxbc::RTS0::v1::RootParameterHeader &getHeader(size_t Location) const { | ||
const RootParameterHeader &getHeader(size_t Location) const { | ||
const RootParameterInfo &Info = ParametersInfo[Location]; | ||
return Info.Header; | ||
} | ||
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. Could probably replace both of these with a |
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -51,6 +51,17 @@ static std::optional<StringRef> extractMdStringValue(MDNode *Node, | |||||
return NodeText->getString(); | ||||||
} | ||||||
|
||||||
static Expected<dxbc::ShaderVisibility> | ||||||
extractShaderVisibility(MDNode *Node, unsigned int OpId) { | ||||||
if (std::optional<uint32_t> Val = extractMdIntValue(Node, OpId)) { | ||||||
if (!dxbc::isValidShaderVisibility(*Val)) | ||||||
return make_error<RootSignatureValidationError<uint32_t>>( | ||||||
"ShaderVisibility", *Val); | ||||||
return static_cast<dxbc::ShaderVisibility>(*Val); | ||||||
|
return static_cast<dxbc::ShaderVisibility>(*Val); | |
return dxbc::ShaderVisibility(*Val); |
Outdated
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.
No longer used - please check your compiler warnings
Outdated
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.
Nitpick: I don't think the "OrErr" in this name is adding anything - that's usually used when we immediately store to something without the suffix (So we have Foo = *FooOrErr
). Just Visibility
is fine for all of these.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -275,11 +275,14 @@ void DXContainerWriter::writeParts(raw_ostream &OS) { | |
|
||
for (DXContainerYAML::RootParameterLocationYaml &L : | ||
P.RootSignature->Parameters.Locations) { | ||
dxbc::RTS0::v1::RootParameterHeader Header{L.Header.Type, L.Header.Visibility, | ||
L.Header.Offset}; | ||
|
||
switch (L.Header.Type) { | ||
case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit): { | ||
mcdxbc::RootParameterHeader Header{ | ||
static_cast<dxbc::RootParameterType>(L.Header.Type), | ||
static_cast<dxbc::ShaderVisibility>(L.Header.Visibility), | ||
L.Header.Offset}; | ||
|
||
|
||
switch (Header.ParameterType) { | ||
|
||
case dxbc::RootParameterType::Constants32Bit: { | ||
const DXContainerYAML::RootConstantsYaml &ConstantYaml = | ||
P.RootSignature->Parameters.getOrInsertConstants(L); | ||
dxbc::RTS0::v1::RootConstants Constants; | ||
|
@@ -289,9 +292,9 @@ void DXContainerWriter::writeParts(raw_ostream &OS) { | |
RS.ParametersContainer.addParameter(Header, Constants); | ||
break; | ||
} | ||
case llvm::to_underlying(dxbc::RootParameterType::CBV): | ||
case llvm::to_underlying(dxbc::RootParameterType::SRV): | ||
case llvm::to_underlying(dxbc::RootParameterType::UAV): { | ||
case dxbc::RootParameterType::CBV: | ||
case dxbc::RootParameterType::SRV: | ||
case dxbc::RootParameterType::UAV: { | ||
const DXContainerYAML::RootDescriptorYaml &DescriptorYaml = | ||
P.RootSignature->Parameters.getOrInsertDescriptor(L); | ||
|
||
|
@@ -303,7 +306,7 @@ void DXContainerWriter::writeParts(raw_ostream &OS) { | |
RS.ParametersContainer.addParameter(Header, Descriptor); | ||
break; | ||
} | ||
case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable): { | ||
case dxbc::RootParameterType::DescriptorTable: { | ||
const DXContainerYAML::DescriptorTableYaml &TableYaml = | ||
P.RootSignature->Parameters.getOrInsertTable(L); | ||
mcdxbc::DescriptorTable Table; | ||
|
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.
IIUC, this pr is meant to remove any dependency from
MC
ontoObject/DXContainer.h
?Shouldn't that mean that some include is removed?
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.
It not from
Object/DXContainer.h
, it is from some values defined insideBinaryFormat/DXContainer.h
mainly theRTS0
namespace