@@ -277,29 +277,27 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
277
277
auto Header = dxbc::RootParameterHeader{Param.Type , Param.Visibility ,
278
278
Param.Offset };
279
279
280
- if (std::holds_alternative<DXContainerYAML::RootConstantsYaml>(
281
- Param.Data )) {
282
- auto ConstantYaml =
283
- std::get<DXContainerYAML::RootConstantsYaml>(Param.Data );
284
-
280
+ if (auto *ConstantYaml =
281
+ std::get_if<DXContainerYAML::RootConstantsYaml>(&Param.Data )) {
285
282
dxbc::RootConstants Constants;
286
- Constants.Num32BitValues = ConstantYaml. Num32BitValues ;
287
- Constants.RegisterSpace = ConstantYaml. RegisterSpace ;
288
- Constants.ShaderRegister = ConstantYaml. ShaderRegister ;
283
+ Constants.Num32BitValues = ConstantYaml-> Num32BitValues ;
284
+ Constants.RegisterSpace = ConstantYaml-> RegisterSpace ;
285
+ Constants.ShaderRegister = ConstantYaml-> ShaderRegister ;
289
286
RS.ParametersContainer .addParameter (Header, Constants);
290
- } else if (std::holds_alternative<DXContainerYAML::RootDescriptorYaml>(
291
- Param.Data )) {
292
- auto DescriptorYaml =
293
- std::get<DXContainerYAML::RootDescriptorYaml>(Param.Data );
287
+ } else if (auto *DescriptorYaml =
288
+ std::get_if<DXContainerYAML::RootDescriptorYaml>(
289
+ &Param.Data )) {
294
290
dxbc::RTS0::v2::RootDescriptor Descriptor;
295
- Descriptor.RegisterSpace = DescriptorYaml. RegisterSpace ;
296
- Descriptor.ShaderRegister = DescriptorYaml. ShaderRegister ;
291
+ Descriptor.RegisterSpace = DescriptorYaml-> RegisterSpace ;
292
+ Descriptor.ShaderRegister = DescriptorYaml-> ShaderRegister ;
297
293
if (RS.Version > 1 )
298
- Descriptor.Flags = DescriptorYaml. getEncodedFlags ();
294
+ Descriptor.Flags = DescriptorYaml-> getEncodedFlags ();
299
295
RS.ParametersContainer .addParameter (Header, Descriptor);
300
296
} else {
301
- // Handling invalid parameter type edge case
302
- RS.ParametersContainer .addInfo (Header, -1 );
297
+ // Handling invalid parameter type edge case. We intentionally let
298
+ // obj2yaml/yaml2obj parse and emit invalid dxcontainer data, in order
299
+ // for that to be used as a testing tool more effectively.
300
+ RS.ParametersContainer .addInvalidParameter (Header);
303
301
}
304
302
}
305
303
0 commit comments