Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 18 additions & 7 deletions llvm/include/llvm/MC/DXContainerRootSignature.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ namespace llvm {
class raw_ostream;
namespace mcdxbc {

struct RootConstants {
uint32_t ShaderRegister;
uint32_t RegisterSpace;
uint32_t Num32BitValues;
};

struct RootDescriptor {
uint32_t ShaderRegister;
uint32_t RegisterSpace;
uint32_t Flags;
};

struct RootParameterInfo {
dxbc::RootParameterType Type;
dxbc::ShaderVisibility Visibility;
Expand All @@ -42,8 +54,8 @@ struct DescriptorTable {
struct RootParametersContainer {
SmallVector<RootParameterInfo> ParametersInfo;

SmallVector<dxbc::RTS0::v1::RootConstants> Constants;
SmallVector<dxbc::RTS0::v2::RootDescriptor> Descriptors;
SmallVector<RootConstants> Constants;
SmallVector<RootDescriptor> Descriptors;
SmallVector<DescriptorTable> Tables;

void addInfo(dxbc::RootParameterType Type, dxbc::ShaderVisibility Visibility,
Expand All @@ -52,15 +64,14 @@ struct RootParametersContainer {
}

void addParameter(dxbc::RootParameterType Type,
dxbc::ShaderVisibility Visibility,
dxbc::RTS0::v1::RootConstants Constant) {
dxbc::ShaderVisibility Visibility, RootConstants Constant) {
addInfo(Type, Visibility, Constants.size());
Constants.push_back(Constant);
}

void addParameter(dxbc::RootParameterType Type,
dxbc::ShaderVisibility Visibility,
dxbc::RTS0::v2::RootDescriptor Descriptor) {
RootDescriptor Descriptor) {
addInfo(Type, Visibility, Descriptors.size());
Descriptors.push_back(Descriptor);
}
Expand All @@ -76,11 +87,11 @@ struct RootParametersContainer {
return Info;
}

const dxbc::RTS0::v1::RootConstants &getConstant(size_t Index) const {
const RootConstants &getConstant(size_t Index) const {
return Constants[Index];
}

const dxbc::RTS0::v2::RootDescriptor &getRootDescriptor(size_t Index) const {
const RootDescriptor &getRootDescriptor(size_t Index) const {
return Descriptors[Index];
}

Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ Error MetadataParser::parseRootConstants(mcdxbc::RootSignatureDesc &RSD,
if (auto E = Visibility.takeError())
return Error(std::move(E));

dxbc::RTS0::v1::RootConstants Constants;
mcdxbc::RootConstants Constants;
if (std::optional<uint32_t> Val = extractMdIntValue(RootConstantNode, 2))
Constants.ShaderRegister = *Val;
else
Expand Down Expand Up @@ -291,7 +291,7 @@ Error MetadataParser::parseRootDescriptors(
if (auto E = Visibility.takeError())
return Error(std::move(E));

dxbc::RTS0::v2::RootDescriptor Descriptor;
mcdxbc::RootDescriptor Descriptor;
if (std::optional<uint32_t> Val = extractMdIntValue(RootDescriptorNode, 2))
Descriptor.ShaderRegister = *Val;
else
Expand Down Expand Up @@ -541,7 +541,7 @@ Error MetadataParser::validateRootSignature(
case dxbc::RootParameterType::CBV:
case dxbc::RootParameterType::UAV:
case dxbc::RootParameterType::SRV: {
const dxbc::RTS0::v2::RootDescriptor &Descriptor =
const mcdxbc::RootDescriptor &Descriptor =
RSD.ParametersContainer.getRootDescriptor(Info.Location);
if (!hlsl::rootsig::verifyRegisterValue(Descriptor.ShaderRegister))
DeferredErrs =
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/MC/DXContainerRootSignature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
const RootParameterInfo &Info = ParametersContainer.getInfo(I);
switch (Info.Type) {
case dxbc::RootParameterType::Constants32Bit: {
const dxbc::RTS0::v1::RootConstants &Constants =
const mcdxbc::RootConstants &Constants =
ParametersContainer.getConstant(Info.Location);
support::endian::write(BOS, Constants.ShaderRegister,
llvm::endianness::little);
Expand All @@ -110,7 +110,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
case dxbc::RootParameterType::CBV:
case dxbc::RootParameterType::SRV:
case dxbc::RootParameterType::UAV: {
const dxbc::RTS0::v2::RootDescriptor &Descriptor =
const mcdxbc::RootDescriptor &Descriptor =
ParametersContainer.getRootDescriptor(Info.Location);

support::endian::write(BOS, Descriptor.ShaderRegister,
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/ObjectYAML/DXContainerEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
case dxbc::RootParameterType::Constants32Bit: {
const DXContainerYAML::RootConstantsYaml &ConstantYaml =
P.RootSignature->Parameters.getOrInsertConstants(L);
dxbc::RTS0::v1::RootConstants Constants;
mcdxbc::RootConstants Constants;

Constants.Num32BitValues = ConstantYaml.Num32BitValues;
Constants.RegisterSpace = ConstantYaml.RegisterSpace;
Expand All @@ -302,7 +302,7 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
const DXContainerYAML::RootDescriptorYaml &DescriptorYaml =
P.RootSignature->Parameters.getOrInsertDescriptor(L);

dxbc::RTS0::v2::RootDescriptor Descriptor;
mcdxbc::RootDescriptor Descriptor;
Descriptor.RegisterSpace = DescriptorYaml.RegisterSpace;
Descriptor.ShaderRegister = DescriptorYaml.ShaderRegister;
if (RS.Version > 1)
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/DirectX/DXILPostOptimizationValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ static void validateRootSignature(Module &M,
dxbc::RootParameterType ParamType = dxbc::RootParameterType(ParamInfo.Type);
switch (ParamType) {
case dxbc::RootParameterType::Constants32Bit: {
dxbc::RTS0::v1::RootConstants Const =
mcdxbc::RootConstants Const =
RSD.ParametersContainer.getConstant(ParamInfo.Location);
Builder.trackBinding(dxil::ResourceClass::CBuffer, Const.RegisterSpace,
Const.ShaderRegister, Const.ShaderRegister,
Expand All @@ -182,7 +182,7 @@ static void validateRootSignature(Module &M,
case dxbc::RootParameterType::SRV:
case dxbc::RootParameterType::UAV:
case dxbc::RootParameterType::CBV: {
dxbc::RTS0::v2::RootDescriptor Desc =
mcdxbc::RootDescriptor Desc =
RSD.ParametersContainer.getRootDescriptor(ParamInfo.Location);
Builder.trackBinding(toResourceClass(ParamInfo.Type), Desc.RegisterSpace,
Desc.ShaderRegister, Desc.ShaderRegister,
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/DirectX/DXILRootSignature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
<< "\n";
switch (Info.Type) {
case dxbc::RootParameterType::Constants32Bit: {
const dxbc::RTS0::v1::RootConstants &Constants =
const mcdxbc::RootConstants &Constants =
RS.ParametersContainer.getConstant(Info.Location);
OS << " Register Space: " << Constants.RegisterSpace << "\n"
<< " Shader Register: " << Constants.ShaderRegister << "\n"
Expand All @@ -192,7 +192,7 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
case dxbc::RootParameterType::CBV:
case dxbc::RootParameterType::UAV:
case dxbc::RootParameterType::SRV: {
const dxbc::RTS0::v2::RootDescriptor &Descriptor =
const mcdxbc::RootDescriptor &Descriptor =
RS.ParametersContainer.getRootDescriptor(Info.Location);
OS << " Register Space: " << Descriptor.RegisterSpace << "\n"
<< " Shader Register: " << Descriptor.ShaderRegister << "\n";
Expand Down