Skip to content

Commit 7e57fa2

Browse files
author
joaosaffran
committed
adding test
1 parent 999933e commit 7e57fa2

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

llvm/include/llvm/Object/DXContainer.h

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "llvm/TargetParser/Triple.h"
2626
#include <array>
2727
#include <cstddef>
28+
#include <cstdint>
2829
#include <variant>
2930

3031
namespace llvm {
@@ -121,9 +122,10 @@ template <typename T> struct ViewArray {
121122
namespace DirectX {
122123
struct RootParameterView {
123124
const dxbc::RootParameterHeader &Header;
125+
uint32_t Version;
124126
StringRef ParamData;
125-
RootParameterView(const dxbc::RootParameterHeader &H, StringRef P)
126-
: Header(H), ParamData(P) {}
127+
RootParameterView(uint32_t V, const dxbc::RootParameterHeader &H, StringRef P)
128+
: Header(H), Version(V), ParamData(P) {}
127129

128130
template <typename T> Expected<T> readParameter() {
129131
T Struct;
@@ -152,12 +154,13 @@ struct RootConstantView : RootParameterView {
152154

153155
struct RootDescriptorView_V1_0 : RootParameterView {
154156
static bool classof(const RootParameterView *V) {
155-
return (V->Header.ParameterType ==
156-
llvm::to_underlying(dxbc::RootParameterType::CBV) ||
157-
V->Header.ParameterType ==
158-
llvm::to_underlying(dxbc::RootParameterType::SRV) ||
159-
V->Header.ParameterType ==
160-
llvm::to_underlying(dxbc::RootParameterType::UAV));
157+
return (V->Version == 1 &&
158+
(V->Header.ParameterType ==
159+
llvm::to_underlying(dxbc::RootParameterType::CBV) ||
160+
V->Header.ParameterType ==
161+
llvm::to_underlying(dxbc::RootParameterType::SRV) ||
162+
V->Header.ParameterType ==
163+
llvm::to_underlying(dxbc::RootParameterType::UAV)));
161164
}
162165

163166
llvm::Expected<dxbc::RootDescriptor_V1_0> read() {
@@ -167,12 +170,13 @@ struct RootDescriptorView_V1_0 : RootParameterView {
167170

168171
struct RootDescriptorView_V1_1 : RootParameterView {
169172
static bool classof(const RootParameterView *V) {
170-
return (V->Header.ParameterType ==
171-
llvm::to_underlying(dxbc::RootParameterType::CBV) ||
172-
V->Header.ParameterType ==
173-
llvm::to_underlying(dxbc::RootParameterType::SRV) ||
174-
V->Header.ParameterType ==
175-
llvm::to_underlying(dxbc::RootParameterType::UAV));
173+
return (V->Version == 2 &&
174+
(V->Header.ParameterType ==
175+
llvm::to_underlying(dxbc::RootParameterType::CBV) ||
176+
V->Header.ParameterType ==
177+
llvm::to_underlying(dxbc::RootParameterType::SRV) ||
178+
V->Header.ParameterType ==
179+
llvm::to_underlying(dxbc::RootParameterType::UAV)));
176180
}
177181

178182
llvm::Expected<dxbc::RootDescriptor_V1_1> read() {
@@ -240,7 +244,7 @@ class RootSignature {
240244
return parseFailed("Reading structure out of file bounds");
241245

242246
StringRef Buff = PartData.substr(Header.ParameterOffset, DataSize);
243-
RootParameterView View = RootParameterView(Header, Buff);
247+
RootParameterView View = RootParameterView(Version, Header, Buff);
244248
return View;
245249
}
246250
};

llvm/lib/ObjectYAML/DXContainerYAML.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ DXContainerYAML::RootSignatureYamlDesc::create(
8181
NewP.Constants.RegisterSpace = Constants.RegisterSpace;
8282
}
8383

84-
if (V == 1) {
8584
if (auto *RDV =
8685
dyn_cast<object::DirectX::RootDescriptorView_V1_0>(&ParamView)) {
8786
llvm::Expected<dxbc::RootDescriptor_V1_0> DescriptorOrErr = RDV->read();
@@ -92,9 +91,7 @@ DXContainerYAML::RootSignatureYamlDesc::create(
9291
NewP.Descriptor.ShaderRegister = Descriptor.ShaderRegister;
9392
NewP.Descriptor.RegisterSpace = Descriptor.RegisterSpace;
9493
}
95-
}
9694

97-
if (V == 2) {
9895
if (auto *RDV =
9996
dyn_cast<object::DirectX::RootDescriptorView_V1_1>(&ParamView)) {
10097
llvm::Expected<dxbc::RootDescriptor_V1_1> DescriptorOrErr = RDV->read();
@@ -109,7 +106,6 @@ DXContainerYAML::RootSignatureYamlDesc::create(
109106
llvm::to_underlying(dxbc::RootDescriptorFlag::Val)) > 0;
110107
#include "llvm/BinaryFormat/DXContainerConstants.def"
111108
}
112-
}
113109

114110
RootSigDesc.Parameters.push_back(NewP);
115111
}

0 commit comments

Comments
 (0)