2525#include " llvm/TargetParser/Triple.h"
2626#include < array>
2727#include < cstddef>
28+ #include < cstdint>
2829#include < variant>
2930
3031namespace llvm {
@@ -121,9 +122,10 @@ template <typename T> struct ViewArray {
121122namespace DirectX {
122123struct 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
153155struct 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
168171struct 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};
0 commit comments