@@ -60,7 +60,10 @@ readDescriptorRanges(DXContainerYAML::RootParameterHeaderYaml &Header,
60
60
NewR.NumDescriptors = R.NumDescriptors ;
61
61
NewR.BaseShaderRegister = R.BaseShaderRegister ;
62
62
NewR.RegisterSpace = R.RegisterSpace ;
63
- NewR.RangeType = R.RangeType ;
63
+ if (!dxbc::isValidRangeType (R.RangeType ))
64
+ return createStringError (std::errc::invalid_argument,
65
+ " Invalid value for descriptor range type" );
66
+ NewR.RangeType = dxbc::DescriptorRangeType (R.RangeType );
64
67
if constexpr (std::is_same_v<T, dxbc::RTS0::v2::DescriptorRange>) {
65
68
// Set all flag fields for v2
66
69
#define DESCRIPTOR_RANGE_FLAG (Num, Enum, Flag ) \
@@ -94,15 +97,14 @@ DXContainerYAML::RootSignatureYamlDesc::create(
94
97
return createStringError (std::errc::invalid_argument,
95
98
" Invalid value for parameter type" );
96
99
97
- RootParameterHeaderYaml Header (PH.ParameterType );
100
+ RootParameterHeaderYaml Header (dxbc::RootParameterType ( PH.ParameterType ) );
98
101
Header.Offset = PH.ParameterOffset ;
99
- Header.Type = PH.ParameterType ;
100
102
101
103
if (!dxbc::isValidShaderVisibility (PH.ShaderVisibility ))
102
104
return createStringError (std::errc::invalid_argument,
103
105
" Invalid value for shader visibility" );
104
106
105
- Header.Visibility = PH.ShaderVisibility ;
107
+ Header.Visibility = dxbc::ShaderVisibility ( PH.ShaderVisibility ) ;
106
108
107
109
llvm::Expected<object::DirectX::RootParameterView> ParamViewOrErr =
108
110
Data.getParameter (PH);
@@ -162,15 +164,40 @@ DXContainerYAML::RootSignatureYamlDesc::create(
162
164
}
163
165
164
166
for (const auto &S : Data.samplers ()) {
167
+ if (!dxbc::isValidSamplerFilter (S.Filter ))
168
+ return createStringError (std::errc::invalid_argument,
169
+ " Invalid value for static sampler filter" );
170
+
171
+ if (!dxbc::isValidAddress (S.AddressU ))
172
+ return createStringError (std::errc::invalid_argument,
173
+ " Invalid value for static sampler AddressU" );
174
+
175
+ if (!dxbc::isValidAddress (S.AddressV ))
176
+ return createStringError (std::errc::invalid_argument,
177
+ " Invalid value for static sampler AddressV" );
178
+
179
+ if (!dxbc::isValidAddress (S.AddressW ))
180
+ return createStringError (std::errc::invalid_argument,
181
+ " Invalid value for static sampler AddressW" );
182
+
183
+ if (!dxbc::isValidComparisonFunc (S.ComparisonFunc ))
184
+ return createStringError (
185
+ std::errc::invalid_argument,
186
+ " Invalid value for static sampler ComparisonFunc" );
187
+
188
+ if (!dxbc::isValidBorderColor (S.BorderColor ))
189
+ return createStringError (std::errc::invalid_argument,
190
+ " Invalid value for static sampler BorderColor" );
191
+
165
192
StaticSamplerYamlDesc NewS;
166
- NewS.Filter = S.Filter ;
167
- NewS.AddressU = S.AddressU ;
168
- NewS.AddressV = S.AddressV ;
169
- NewS.AddressW = S.AddressW ;
193
+ NewS.Filter = dxbc::SamplerFilter ( S.Filter ) ;
194
+ NewS.AddressU = dxbc::TextureAddressMode ( S.AddressU ) ;
195
+ NewS.AddressV = dxbc::TextureAddressMode ( S.AddressV ) ;
196
+ NewS.AddressW = dxbc::TextureAddressMode ( S.AddressW ) ;
170
197
NewS.MipLODBias = S.MipLODBias ;
171
198
NewS.MaxAnisotropy = S.MaxAnisotropy ;
172
- NewS.ComparisonFunc = S.ComparisonFunc ;
173
- NewS.BorderColor = S.BorderColor ;
199
+ NewS.ComparisonFunc = dxbc::ComparisonFunc ( S.ComparisonFunc ) ;
200
+ NewS.BorderColor = dxbc::StaticBorderColor ( S.BorderColor ) ;
174
201
NewS.MinLOD = S.MinLOD ;
175
202
NewS.MaxLOD = S.MaxLOD ;
176
203
NewS.ShaderRegister = S.ShaderRegister ;
@@ -425,21 +452,21 @@ void MappingContextTraits<DXContainerYAML::RootParameterLocationYaml,
425
452
IO.mapRequired (" ShaderVisibility" , L.Header .Visibility );
426
453
427
454
switch (L.Header .Type ) {
428
- case llvm::to_underlying ( dxbc::RootParameterType::Constants32Bit) : {
455
+ case dxbc::RootParameterType::Constants32Bit: {
429
456
DXContainerYAML::RootConstantsYaml &Constants =
430
457
S.Parameters .getOrInsertConstants (L);
431
458
IO.mapRequired (" Constants" , Constants);
432
459
break ;
433
460
}
434
- case llvm::to_underlying ( dxbc::RootParameterType::CBV) :
435
- case llvm::to_underlying ( dxbc::RootParameterType::SRV) :
436
- case llvm::to_underlying ( dxbc::RootParameterType::UAV) : {
461
+ case dxbc::RootParameterType::CBV:
462
+ case dxbc::RootParameterType::SRV:
463
+ case dxbc::RootParameterType::UAV: {
437
464
DXContainerYAML::RootDescriptorYaml &Descriptor =
438
465
S.Parameters .getOrInsertDescriptor (L);
439
466
IO.mapRequired (" Descriptor" , Descriptor);
440
467
break ;
441
468
}
442
- case llvm::to_underlying ( dxbc::RootParameterType::DescriptorTable) : {
469
+ case dxbc::RootParameterType::DescriptorTable: {
443
470
DXContainerYAML::DescriptorTableYaml &Table =
444
471
S.Parameters .getOrInsertTable (L);
445
472
IO.mapRequired (" Table" , Table);
0 commit comments