Description
This is the explicit bindings part of the bindings approach originally described in #58051.
Binding information is recorded in HLSLResourceBinding attributes on declarations. We currently have logic to diagnose these bindings, but we don't store this information to later use in lowering to llvm.dx.handle.fromBinding
intrinsics. We need to gather all of the explicit resource binding information and create 1:1 mapping of FieldDecl or VarDecl to explicit HLSLResourceBindingAttr.
In order to share code with the binding diagnostics, we need a couple of adjustments:
-
SemaHLSL::handleResourceBindingAttr
can continue to diagnose the simple/local errors:err_hlsl_binding_type_invalid
- the type isn't valid at all, likex0
warn_hlsl_deprecated_register_type_i
- the type is deprecated/removed and ignoredwarn_hlsl_deprecated_register_type_b
- the type is deprecated/removed and ignoredwarn_hlsl_register_type_c_packoffset
- the type is in the wrong place (in acbuffer
)warn_hlsl_overlapping_binding
- the same binding type is applied more than once
These shouldn't need any traversal of types to diagnose, so keeping them here is simplest.
-
Add a data member,
Bindings
, toSemaHLSL
to track the ranges that are already bound and the list ofDecl
s that still need to be bound. -
In
Sema::ActOnVariableDeclarator
(inSemaDecl.cpp
) after the call toProcessDeclAttributes
, call intoSemaHLSL
:if (getLangOpts().HLSL && NewVD->hasGlobalStorage()) { HLSL()->handleBindings(NewVD);
This is where the recursive walk that diagnoses binding type mismatches should move. It can fill in the binding map as it goes.
-
The bindings for cbuffer/tbuffer can be diagnosed and applied in
SemaHLSL::ActOnFinishBuffer
.Note that doing this here simplifies the parts of the design that need to differentiate between
HLSLBufferDecl
andVarDecl
, since the two code paths are separate.
Metadata
Metadata
Assignees
Type
Projects
Status