@@ -545,25 +545,13 @@ Error MetadataParser::parseRootSignatureElement(mcdxbc::RootSignatureDesc &RSD,
545545
546546Error validateDescriptorTableSamplerMixin (mcdxbc::DescriptorTable Table,
547547 uint32_t Location) {
548- bool HasSampler = false ;
549- bool HasOtherRangeType = false ;
550- dxil::ResourceClass OtherRangeType;
551-
548+ dxil::ResourceClass CurrRC = dxil::ResourceClass::Sampler;
552549 for (const mcdxbc::DescriptorRange &Range : Table.Ranges ) {
553- dxil::ResourceClass RangeType =
554- static_cast <dxil::ResourceClass>(Range.RangeType );
555-
556- if (RangeType == dxil::ResourceClass::Sampler) {
557- HasSampler = true ;
558- } else {
559- HasOtherRangeType = true ;
560- OtherRangeType = RangeType;
561- }
550+ if (Range.RangeType == dxil::ResourceClass::Sampler &&
551+ CurrRC != dxil::ResourceClass::Sampler)
552+ return make_error<TableSamplerMixinError>(CurrRC, Location);
553+ CurrRC = Range.RangeType ;
562554 }
563-
564- // Samplers cannot be mixed with other resources in a descriptor table.
565- if (HasSampler && HasOtherRangeType)
566- return make_error<TableSamplerMixinError>(OtherRangeType, Location);
567555 return Error::success ();
568556}
569557
@@ -573,31 +561,29 @@ Error validateDescriptorTableRegisterOverflow(mcdxbc::DescriptorTable Table,
573561
574562 for (const mcdxbc::DescriptorRange &Range : Table.Ranges ) {
575563 // Validation of NumDescriptors should have happened by this point.
576- if (Range.NumDescriptors < = 0 )
564+ if (Range.NumDescriptors = = 0 )
577565 continue ;
578- const dxil::ResourceClass &RangeType =
579- static_cast <dxil::ResourceClass>(Range.RangeType );
580566
581567 if (Range.OffsetInDescriptorsFromTableStart != DescriptorTableOffsetAppend)
582568 Offset = Range.OffsetInDescriptorsFromTableStart ;
583569
584570 if (!verifyNoOverflowedOffset (Offset))
585571 return make_error<OffsetOverflowError>(
586- RangeType, Range.BaseShaderRegister , Range.RegisterSpace );
572+ Range. RangeType , Range.BaseShaderRegister , Range.RegisterSpace );
587573
588574 const uint64_t RangeBound = llvm::hlsl::rootsig::computeRangeBound (
589575 Range.BaseShaderRegister , Range.NumDescriptors );
590576
591577 if (!verifyNoOverflowedOffset (RangeBound))
592578 return make_error<ShaderRegisterOverflowError>(
593- RangeType, Range.BaseShaderRegister , Range.RegisterSpace );
579+ Range. RangeType , Range.BaseShaderRegister , Range.RegisterSpace );
594580
595581 const uint64_t OffsetBound =
596582 llvm::hlsl::rootsig::computeRangeBound (Offset, Range.NumDescriptors );
597583
598584 if (!verifyNoOverflowedOffset (OffsetBound))
599585 return make_error<DescriptorRangeOverflowError>(
600- RangeType, Range.BaseShaderRegister , Range.RegisterSpace );
586+ Range. RangeType , Range.BaseShaderRegister , Range.RegisterSpace );
601587 Offset = updateOngoingOffset (Offset, Range.NumDescriptors ,
602588 Range.OffsetInDescriptorsFromTableStart );
603589 }
0 commit comments