Skip to content

Commit dfc376a

Browse files
authored
[DirectX] Removing dxbc RootSignature and RootDescriptor from mcbxdc (llvm#154585)
1 parent d394353 commit dfc376a

File tree

6 files changed

+29
-18
lines changed

6 files changed

+29
-18
lines changed

llvm/include/llvm/MC/DXContainerRootSignature.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ namespace llvm {
1919
class raw_ostream;
2020
namespace mcdxbc {
2121

22+
struct RootConstants {
23+
uint32_t ShaderRegister;
24+
uint32_t RegisterSpace;
25+
uint32_t Num32BitValues;
26+
};
27+
28+
struct RootDescriptor {
29+
uint32_t ShaderRegister;
30+
uint32_t RegisterSpace;
31+
uint32_t Flags;
32+
};
33+
2234
struct RootParameterInfo {
2335
dxbc::RootParameterType Type;
2436
dxbc::ShaderVisibility Visibility;
@@ -42,8 +54,8 @@ struct DescriptorTable {
4254
struct RootParametersContainer {
4355
SmallVector<RootParameterInfo> ParametersInfo;
4456

45-
SmallVector<dxbc::RTS0::v1::RootConstants> Constants;
46-
SmallVector<dxbc::RTS0::v2::RootDescriptor> Descriptors;
57+
SmallVector<RootConstants> Constants;
58+
SmallVector<RootDescriptor> Descriptors;
4759
SmallVector<DescriptorTable> Tables;
4860

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

5466
void addParameter(dxbc::RootParameterType Type,
55-
dxbc::ShaderVisibility Visibility,
56-
dxbc::RTS0::v1::RootConstants Constant) {
67+
dxbc::ShaderVisibility Visibility, RootConstants Constant) {
5768
addInfo(Type, Visibility, Constants.size());
5869
Constants.push_back(Constant);
5970
}
6071

6172
void addParameter(dxbc::RootParameterType Type,
6273
dxbc::ShaderVisibility Visibility,
63-
dxbc::RTS0::v2::RootDescriptor Descriptor) {
74+
RootDescriptor Descriptor) {
6475
addInfo(Type, Visibility, Descriptors.size());
6576
Descriptors.push_back(Descriptor);
6677
}
@@ -76,11 +87,11 @@ struct RootParametersContainer {
7687
return Info;
7788
}
7889

79-
const dxbc::RTS0::v1::RootConstants &getConstant(size_t Index) const {
90+
const RootConstants &getConstant(size_t Index) const {
8091
return Constants[Index];
8192
}
8293

83-
const dxbc::RTS0::v2::RootDescriptor &getRootDescriptor(size_t Index) const {
94+
const RootDescriptor &getRootDescriptor(size_t Index) const {
8495
return Descriptors[Index];
8596
}
8697

llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ Error MetadataParser::parseRootConstants(mcdxbc::RootSignatureDesc &RSD,
237237
if (auto E = Visibility.takeError())
238238
return Error(std::move(E));
239239

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

294-
dxbc::RTS0::v2::RootDescriptor Descriptor;
294+
mcdxbc::RootDescriptor Descriptor;
295295
if (std::optional<uint32_t> Val = extractMdIntValue(RootDescriptorNode, 2))
296296
Descriptor.ShaderRegister = *Val;
297297
else
@@ -541,7 +541,7 @@ Error MetadataParser::validateRootSignature(
541541
case dxbc::RootParameterType::CBV:
542542
case dxbc::RootParameterType::UAV:
543543
case dxbc::RootParameterType::SRV: {
544-
const dxbc::RTS0::v2::RootDescriptor &Descriptor =
544+
const mcdxbc::RootDescriptor &Descriptor =
545545
RSD.ParametersContainer.getRootDescriptor(Info.Location);
546546
if (!hlsl::rootsig::verifyRegisterValue(Descriptor.ShaderRegister))
547547
DeferredErrs =

llvm/lib/MC/DXContainerRootSignature.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
106106
const RootParameterInfo &Info = ParametersContainer.getInfo(I);
107107
switch (Info.Type) {
108108
case dxbc::RootParameterType::Constants32Bit: {
109-
const dxbc::RTS0::v1::RootConstants &Constants =
109+
const mcdxbc::RootConstants &Constants =
110110
ParametersContainer.getConstant(Info.Location);
111111
support::endian::write(BOS, Constants.ShaderRegister,
112112
llvm::endianness::little);
@@ -119,7 +119,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
119119
case dxbc::RootParameterType::CBV:
120120
case dxbc::RootParameterType::SRV:
121121
case dxbc::RootParameterType::UAV: {
122-
const dxbc::RTS0::v2::RootDescriptor &Descriptor =
122+
const mcdxbc::RootDescriptor &Descriptor =
123123
ParametersContainer.getRootDescriptor(Info.Location);
124124

125125
support::endian::write(BOS, Descriptor.ShaderRegister,

llvm/lib/ObjectYAML/DXContainerEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ Error DXContainerWriter::writeParts(raw_ostream &OS) {
286286
case dxbc::RootParameterType::Constants32Bit: {
287287
const DXContainerYAML::RootConstantsYaml &ConstantYaml =
288288
P.RootSignature->Parameters.getOrInsertConstants(L);
289-
dxbc::RTS0::v1::RootConstants Constants;
289+
mcdxbc::RootConstants Constants;
290290

291291
Constants.Num32BitValues = ConstantYaml.Num32BitValues;
292292
Constants.RegisterSpace = ConstantYaml.RegisterSpace;
@@ -300,7 +300,7 @@ Error DXContainerWriter::writeParts(raw_ostream &OS) {
300300
const DXContainerYAML::RootDescriptorYaml &DescriptorYaml =
301301
P.RootSignature->Parameters.getOrInsertDescriptor(L);
302302

303-
dxbc::RTS0::v2::RootDescriptor Descriptor;
303+
mcdxbc::RootDescriptor Descriptor;
304304
Descriptor.RegisterSpace = DescriptorYaml.RegisterSpace;
305305
Descriptor.ShaderRegister = DescriptorYaml.ShaderRegister;
306306
if (RS.Version > 1)

llvm/lib/Target/DirectX/DXILPostOptimizationValidation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static void validateRootSignature(Module &M,
182182
dxbc::RootParameterType ParamType = dxbc::RootParameterType(ParamInfo.Type);
183183
switch (ParamType) {
184184
case dxbc::RootParameterType::Constants32Bit: {
185-
dxbc::RTS0::v1::RootConstants Const =
185+
mcdxbc::RootConstants Const =
186186
RSD.ParametersContainer.getConstant(ParamInfo.Location);
187187
Builder.trackBinding(dxil::ResourceClass::CBuffer, Const.RegisterSpace,
188188
Const.ShaderRegister, Const.ShaderRegister,
@@ -193,7 +193,7 @@ static void validateRootSignature(Module &M,
193193
case dxbc::RootParameterType::SRV:
194194
case dxbc::RootParameterType::UAV:
195195
case dxbc::RootParameterType::CBV: {
196-
dxbc::RTS0::v2::RootDescriptor Desc =
196+
mcdxbc::RootDescriptor Desc =
197197
RSD.ParametersContainer.getRootDescriptor(ParamInfo.Location);
198198
Builder.trackBinding(toResourceClass(ParamInfo.Type), Desc.RegisterSpace,
199199
Desc.ShaderRegister, Desc.ShaderRegister,

llvm/lib/Target/DirectX/DXILRootSignature.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
182182
<< "\n";
183183
switch (Info.Type) {
184184
case dxbc::RootParameterType::Constants32Bit: {
185-
const dxbc::RTS0::v1::RootConstants &Constants =
185+
const mcdxbc::RootConstants &Constants =
186186
RS.ParametersContainer.getConstant(Info.Location);
187187
OS << " Register Space: " << Constants.RegisterSpace << "\n"
188188
<< " Shader Register: " << Constants.ShaderRegister << "\n"
@@ -192,7 +192,7 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
192192
case dxbc::RootParameterType::CBV:
193193
case dxbc::RootParameterType::UAV:
194194
case dxbc::RootParameterType::SRV: {
195-
const dxbc::RTS0::v2::RootDescriptor &Descriptor =
195+
const mcdxbc::RootDescriptor &Descriptor =
196196
RS.ParametersContainer.getRootDescriptor(Info.Location);
197197
OS << " Register Space: " << Descriptor.RegisterSpace << "\n"
198198
<< " Shader Register: " << Descriptor.ShaderRegister << "\n";

0 commit comments

Comments
 (0)