[clang] [HLSL] Adjust resource binding diagnostic flags code (PR #106657)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 30 13:11:48 PDT 2024


================
@@ -480,6 +480,9 @@ struct RegisterBindingFlags {
 
   bool ContainsNumeric = false;
   bool DefaultGlobals = false;
+
+  // used only when Resource == true
+  llvm::dxil::ResourceClass ResourceClass = llvm::dxil::ResourceClass::UAV;
----------------
hekota wrote:

Yes, the individual `SRV`, `UAV`, `CBV`, `Sampler` flags are used only when `UDT` is set, and the `ResourceClass` is only used when `Resource` is set. I will update `ResourceClass` to use `<srd::optional>` to avoid the explicit initialization, but if that's ok with you I'd like to leave the rest as is.

The reason is that I have another change in mind that would remove the need to have the Flags struct in the first place. We only need to make sure there is a resource that matches the provided register type, so we might as well embed the diagnostics right where we are currently setting the flags without building up the struct. And we can bail out early if we find a matching resource class without needing to scan the whole type.

https://github.com/llvm/llvm-project/pull/106657


More information about the cfe-commits mailing list