@@ -146,8 +146,7 @@ struct RootParameterView {
146146
147147struct RootConstantView : RootParameterView {
148148 static bool classof (const RootParameterView *V) {
149- return V->Header .ParameterType ==
150- (uint32_t )dxbc::RootParameterType::Constants32Bit;
149+ return V->Header .ParameterType == dxbc::RootParameterType::Constants32Bit;
151150 }
152151
153152 llvm::Expected<dxbc::RTS0::v1::RootConstants> read () {
@@ -157,25 +156,24 @@ struct RootConstantView : RootParameterView {
157156
158157struct RootDescriptorView : RootParameterView {
159158 static bool classof (const RootParameterView *V) {
160- return (V->Header .ParameterType ==
161- llvm::to_underlying (dxbc::RootParameterType::CBV) ||
162- V->Header .ParameterType ==
163- llvm::to_underlying (dxbc::RootParameterType::SRV) ||
164- V->Header .ParameterType ==
165- llvm::to_underlying (dxbc::RootParameterType::UAV));
159+ return (V->Header .ParameterType == dxbc::RootParameterType::CBV ||
160+ V->Header .ParameterType == dxbc::RootParameterType::SRV ||
161+ V->Header .ParameterType == dxbc::RootParameterType::UAV);
166162 }
167163
168- llvm::Expected<dxbc::RTS0::v2::RootDescriptor> read (uint32_t Version) {
169- if (Version == 1 ) {
164+ llvm::Expected<dxbc::RTS0::v2::RootDescriptor>
165+ read (dxbc::RootSignatureVersion Version) {
166+ if (Version == dxbc::RootSignatureVersion::V1_0) {
170167 auto Descriptor = readParameter<dxbc::RTS0::v1::RootDescriptor>();
171168 if (Error E = Descriptor.takeError ())
172169 return E;
173170 return dxbc::RTS0::v2::RootDescriptor (*Descriptor);
174171 }
175- if (Version != 2 )
176- return make_error<GenericBinaryError>(" Invalid Root Signature version: " +
177- Twine (Version),
178- object_error::parse_failed);
172+ if (Version != dxbc::RootSignatureVersion::V1_1)
173+ return make_error<GenericBinaryError>(
174+ " Invalid Root Signature version: " +
175+ Twine (static_cast <uint32_t >(Version)),
176+ object_error::parse_failed);
179177 return readParameter<dxbc::RTS0::v2::RootDescriptor>();
180178 }
181179};
@@ -192,7 +190,7 @@ template <typename T> struct DescriptorTable {
192190struct DescriptorTableView : RootParameterView {
193191 static bool classof (const RootParameterView *V) {
194192 return (V->Header .ParameterType ==
195- llvm::to_underlying ( dxbc::RootParameterType::DescriptorTable) );
193+ dxbc::RootParameterType::DescriptorTable);
196194 }
197195
198196 // Define a type alias to access the template parameter from inside classof
@@ -220,7 +218,7 @@ static Error parseFailed(const Twine &Msg) {
220218
221219class RootSignature {
222220private:
223- uint32_t Version;
221+ dxbc::RootSignatureVersion Version;
224222 uint32_t NumParameters;
225223 uint32_t RootParametersOffset;
226224 uint32_t NumStaticSamplers;
@@ -238,7 +236,7 @@ class RootSignature {
238236 RootSignature (StringRef PD) : PartData(PD) {}
239237
240238 LLVM_ABI Error parse ();
241- uint32_t getVersion () const { return Version; }
239+ dxbc::RootSignatureVersion getVersion () const { return Version; }
242240 uint32_t getNumParameters () const { return NumParameters; }
243241 uint32_t getRootParametersOffset () const { return RootParametersOffset; }
244242 uint32_t getNumStaticSamplers () const { return NumStaticSamplers; }
@@ -269,7 +267,7 @@ class RootSignature {
269267 case dxbc::RootParameterType::CBV:
270268 case dxbc::RootParameterType::SRV:
271269 case dxbc::RootParameterType::UAV:
272- if (Version == 1 )
270+ if (Version == dxbc::RootSignatureVersion::V1_0 )
273271 DataSize = sizeof (dxbc::RTS0::v1::RootDescriptor);
274272 else
275273 DataSize = sizeof (dxbc::RTS0::v2::RootDescriptor);
@@ -281,7 +279,7 @@ class RootSignature {
281279 uint32_t NumRanges =
282280 support::endian::read<uint32_t , llvm::endianness::little>(
283281 PartData.begin () + Header.ParameterOffset );
284- if (Version == 1 )
282+ if (Version == dxbc::RootSignatureVersion::V1_0 )
285283 DataSize = sizeof (dxbc::RTS0::v1::DescriptorRange) * NumRanges;
286284 else
287285 DataSize = sizeof (dxbc::RTS0::v2::DescriptorRange) * NumRanges;
0 commit comments