-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[DirectX] Updating Root Signature YAML representation to use Enums instead of uint #154827
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 all commits
31ec5e5
1690a9c
f6f2e61
6539364
1d29111
8eb82fd
d38c00d
3b25b34
567a3d4
fb248da
dc436d5
8353fe0
f3ecd8a
8c143ba
e57236c
a4d77d7
4b9991d
04df258
19ec1c3
182c817
f9d16d2
42f8f11
7ada31b
fa60959
e065a82
17dbe9f
5c23b7e
1c539f0
716acfb
43582d2
44bfe7a
6757986
3ebaa29
e84f811
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 |
---|---|---|
|
@@ -60,7 +60,10 @@ readDescriptorRanges(DXContainerYAML::RootParameterHeaderYaml &Header, | |
NewR.NumDescriptors = R.NumDescriptors; | ||
NewR.BaseShaderRegister = R.BaseShaderRegister; | ||
NewR.RegisterSpace = R.RegisterSpace; | ||
NewR.RangeType = R.RangeType; | ||
if (!dxbc::isValidRangeType(R.RangeType)) | ||
return createStringError(std::errc::invalid_argument, | ||
"Invalid value for descriptor range type"); | ||
NewR.RangeType = dxil::ResourceClass(R.RangeType); | ||
if constexpr (std::is_same_v<T, dxbc::RTS0::v2::DescriptorRange>) { | ||
// Set all flag fields for v2 | ||
#define DESCRIPTOR_RANGE_FLAG(Num, Enum, Flag) \ | ||
|
@@ -94,15 +97,14 @@ DXContainerYAML::RootSignatureYamlDesc::create( | |
return createStringError(std::errc::invalid_argument, | ||
"Invalid value for parameter type"); | ||
|
||
RootParameterHeaderYaml Header(PH.ParameterType); | ||
RootParameterHeaderYaml Header(dxbc::RootParameterType(PH.ParameterType)); | ||
Header.Offset = PH.ParameterOffset; | ||
Header.Type = PH.ParameterType; | ||
|
||
if (!dxbc::isValidShaderVisibility(PH.ShaderVisibility)) | ||
return createStringError(std::errc::invalid_argument, | ||
"Invalid value for shader visibility"); | ||
|
||
Header.Visibility = PH.ShaderVisibility; | ||
Header.Visibility = dxbc::ShaderVisibility(PH.ShaderVisibility); | ||
|
||
llvm::Expected<object::DirectX::RootParameterView> ParamViewOrErr = | ||
Data.getParameter(PH); | ||
|
@@ -162,20 +164,50 @@ DXContainerYAML::RootSignatureYamlDesc::create( | |
} | ||
|
||
for (const auto &S : Data.samplers()) { | ||
if (!dxbc::isValidSamplerFilter(S.Filter)) | ||
return createStringError(std::errc::invalid_argument, | ||
"Invalid value for static sampler filter"); | ||
|
||
if (!dxbc::isValidAddress(S.AddressU)) | ||
return createStringError(std::errc::invalid_argument, | ||
"Invalid value for static sampler AddressU"); | ||
|
||
if (!dxbc::isValidAddress(S.AddressV)) | ||
return createStringError(std::errc::invalid_argument, | ||
"Invalid value for static sampler AddressV"); | ||
|
||
if (!dxbc::isValidAddress(S.AddressW)) | ||
return createStringError(std::errc::invalid_argument, | ||
"Invalid value for static sampler AddressW"); | ||
|
||
if (!dxbc::isValidComparisonFunc(S.ComparisonFunc)) | ||
return createStringError( | ||
std::errc::invalid_argument, | ||
"Invalid value for static sampler ComparisonFunc"); | ||
|
||
if (!dxbc::isValidBorderColor(S.BorderColor)) | ||
return createStringError(std::errc::invalid_argument, | ||
"Invalid value for static sampler BorderColor"); | ||
|
||
if (!dxbc::isValidShaderVisibility(S.ShaderVisibility)) | ||
return createStringError( | ||
std::errc::invalid_argument, | ||
"Invalid value for static sampler ShaderVisibility"); | ||
|
||
StaticSamplerYamlDesc NewS; | ||
NewS.Filter = S.Filter; | ||
NewS.AddressU = S.AddressU; | ||
NewS.AddressV = S.AddressV; | ||
NewS.AddressW = S.AddressW; | ||
NewS.Filter = dxbc::SamplerFilter(S.Filter); | ||
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. I think you missed removing these casts 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. Those castings are required here. They are coming from the binary representation, so they are actually 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. I also ran |
||
NewS.AddressU = dxbc::TextureAddressMode(S.AddressU); | ||
NewS.AddressV = dxbc::TextureAddressMode(S.AddressV); | ||
NewS.AddressW = dxbc::TextureAddressMode(S.AddressW); | ||
NewS.MipLODBias = S.MipLODBias; | ||
NewS.MaxAnisotropy = S.MaxAnisotropy; | ||
NewS.ComparisonFunc = S.ComparisonFunc; | ||
NewS.BorderColor = S.BorderColor; | ||
NewS.ComparisonFunc = dxbc::ComparisonFunc(S.ComparisonFunc); | ||
NewS.BorderColor = dxbc::StaticBorderColor(S.BorderColor); | ||
NewS.MinLOD = S.MinLOD; | ||
NewS.MaxLOD = S.MaxLOD; | ||
NewS.ShaderRegister = S.ShaderRegister; | ||
NewS.RegisterSpace = S.RegisterSpace; | ||
NewS.ShaderVisibility = S.ShaderVisibility; | ||
NewS.ShaderVisibility = dxbc::ShaderVisibility(S.ShaderVisibility); | ||
|
||
RootSigDesc.StaticSamplers.push_back(NewS); | ||
} | ||
|
@@ -425,21 +457,21 @@ void MappingContextTraits<DXContainerYAML::RootParameterLocationYaml, | |
IO.mapRequired("ShaderVisibility", L.Header.Visibility); | ||
|
||
switch (L.Header.Type) { | ||
case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit): { | ||
case dxbc::RootParameterType::Constants32Bit: { | ||
DXContainerYAML::RootConstantsYaml &Constants = | ||
S.Parameters.getOrInsertConstants(L); | ||
IO.mapRequired("Constants", 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: { | ||
DXContainerYAML::RootDescriptorYaml &Descriptor = | ||
S.Parameters.getOrInsertDescriptor(L); | ||
IO.mapRequired("Descriptor", Descriptor); | ||
break; | ||
} | ||
case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable): { | ||
case dxbc::RootParameterType::DescriptorTable: { | ||
DXContainerYAML::DescriptorTableYaml &Table = | ||
S.Parameters.getOrInsertTable(L); | ||
IO.mapRequired("Table", Table); | ||
|
@@ -585,6 +617,55 @@ 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<dxil::ResourceClass>::enumeration( | ||
IO &IO, dxil::ResourceClass &Value) { | ||
const EnumEntry<dxil::ResourceClass> ResourceClasses[] = { | ||
{"CBuffer", dxil::ResourceClass::CBuffer}, | ||
{"SRV", dxil::ResourceClass::SRV}, | ||
{"UAV", dxil::ResourceClass::UAV}, | ||
{"Sampler", dxil::ResourceClass::Sampler}, | ||
}; | ||
|
||
for (const auto &E : ResourceClasses) | ||
IO.enumCase(Value, E.Name.str().c_str(), E.Value); | ||
} | ||
|
||
void ScalarEnumerationTraits<dxbc::SamplerFilter>::enumeration( | ||
IO &IO, dxbc::SamplerFilter &Value) { | ||
for (const auto &E : dxbc::getSamplerFilters()) | ||
IO.enumCase(Value, E.Name.str().c_str(), E.Value); | ||
} | ||
|
||
void ScalarEnumerationTraits<dxbc::StaticBorderColor>::enumeration( | ||
IO &IO, dxbc::StaticBorderColor &Value) { | ||
for (const auto &E : dxbc::getStaticBorderColors()) | ||
IO.enumCase(Value, E.Name.str().c_str(), E.Value); | ||
} | ||
|
||
void ScalarEnumerationTraits<dxbc::TextureAddressMode>::enumeration( | ||
IO &IO, dxbc::TextureAddressMode &Value) { | ||
for (const auto &E : dxbc::getTextureAddressModes()) | ||
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); | ||
} | ||
|
||
void ScalarEnumerationTraits<dxbc::ComparisonFunc>::enumeration( | ||
IO &IO, dxbc::ComparisonFunc &Value) { | ||
for (const auto &E : dxbc::getComparisonFuncs()) | ||
IO.enumCase(Value, E.Name.str().c_str(), E.Value); | ||
} | ||
|
||
} // namespace yaml | ||
|
||
void DXContainerYAML::PSVInfo::mapInfoForVersion(yaml::IO &IO) { | ||
|
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.
Since those are now enums, they are validated during enum parsing, therefore, these values don't require validation anymore.