@@ -536,7 +536,7 @@ void createHostLayoutStructForBuffer(Sema &S, HLSLBufferDecl *BufDecl) {
536
536
BufDecl->addLayoutStruct (LS);
537
537
}
538
538
539
- void addImplicitBindingAttrToBuffer (Sema &S, HLSLBufferDecl *BufDecl,
539
+ static void addImplicitBindingAttrToBuffer (Sema &S, HLSLBufferDecl *BufDecl,
540
540
uint32_t ImplicitBindingOrderID) {
541
541
RegisterType RT =
542
542
BufDecl->isCBuffer () ? RegisterType::CBuffer : RegisterType::SRV;
@@ -558,13 +558,16 @@ void SemaHLSL::ActOnFinishBuffer(Decl *Dcl, SourceLocation RBrace) {
558
558
// create buffer layout struct
559
559
createHostLayoutStructForBuffer (SemaRef, BufDecl);
560
560
561
- if ( std::none_of (Dcl-> attr_begin (), Dcl->attr_end (),
562
- [](Attr *A) { return isa<HLSLResourceBindingAttr>(A); } )) {
561
+ HLSLResourceBindingAttr *RBA = Dcl->getAttr <HLSLResourceBindingAttr>();
562
+ if (!RBA || RBA-> isImplicit ( )) {
563
563
SemaRef.Diag (Dcl->getLocation (), diag::warn_hlsl_implicit_binding);
564
- // add implicit HLSLResourceBindingAttr for the buffer
565
- // (used mostly as a way to tranfer ImplicitBindingOrderID to codegen)
566
- addImplicitBindingAttrToBuffer (SemaRef, BufDecl,
567
- getNextImplicitBindingOrderID ());
564
+ // Use HLSLResourceBindingAttr as a way to transfer implicit binding
565
+ // order_ID to codegen. If it does not exist, create an implicit one.
566
+ uint32_t OrderID = getNextImplicitBindingOrderID ();
567
+ if (RBA)
568
+ RBA->setImplicitBindingOrderID (OrderID);
569
+ else
570
+ addImplicitBindingAttrToBuffer (SemaRef, BufDecl, OrderID);
568
571
}
569
572
570
573
SemaRef.PopDeclContext ();
0 commit comments