[llvm] [HLSL] Add descriptor table metadata parsing (PR #142492)
Finn Plummer via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 12 08:50:50 PDT 2025
================
@@ -241,6 +329,57 @@ static bool verifyRegisterSpace(uint32_t RegisterSpace) {
static bool verifyDescriptorFlag(uint32_t Flags) { return (Flags & ~0xE) == 0; }
+static bool verifyRangeType(uint32_t Type) {
+ switch (Type) {
+ case llvm::to_underlying(dxbc::DescriptorRangeType::CBV):
+ case llvm::to_underlying(dxbc::DescriptorRangeType::SRV):
+ case llvm::to_underlying(dxbc::DescriptorRangeType::UAV):
+ case llvm::to_underlying(dxbc::DescriptorRangeType::Sampler):
+ return true;
+ };
+
+ return false;
+}
+
+static bool verifyDescriptorRangeFlag(uint32_t Version, uint32_t Type,
+ uint32_t FlagsVal) {
+ using FlagT = dxbc::DescriptorRangeFlag;
+ FlagT Flags = FlagT(FlagsVal);
+
+ const bool IsSampler =
+ (Type == llvm::to_underlying(dxbc::DescriptorRangeType::Sampler));
+
+ // The data-specific flags are mutually exclusive.
+ FlagT DataFlags = FlagT::DATA_VOLATILE | FlagT::DATA_STATIC |
+ FlagT::DATA_STATIC_WHILE_SET_AT_EXECUTE;
+
+ if (popcount(llvm::to_underlying(Flags & DataFlags)) > 1)
+ return false;
+
+ if (popcount(llvm::to_underlying(Flags & DataFlags)) == 1)
+ return true;
----------------
inbelic wrote:
I don't think this is correct. It seems we would skip further validation.
If `Flags = DESCRIPTORS_VOLATILE | DATA_STATIC`, then this will return early as valid.
https://github.com/llvm/llvm-project/pull/142492
More information about the llvm-commits
mailing list