Add a DescriptorType to GetDescriptors query

* This will be optional in many cases but for some situations might be required
  when type information is not implicitly available in the descriptor store.
  Generally it should always be available unless the descriptor store is being
  viewed 'blank' purely from its contents with no other context.
This commit is contained in:
baldurk
2025-07-30 22:10:23 +01:00
parent f896f8a2e2
commit ceb062b658
16 changed files with 156 additions and 71 deletions
+3 -4
View File
@@ -653,8 +653,8 @@ struct DescriptorAccess
}
bool operator==(const ShaderDirectAccess &o) const
{
return CategoryForDescriptorType(type) == o.category && descriptorStore == o.descriptorStore &&
byteOffset == o.byteOffset && byteSize == o.byteSize;
return type == o.type && descriptorStore == o.descriptorStore && byteOffset == o.byteOffset &&
byteSize == o.byteSize;
}
bool operator==(const DescriptorAccess &o) const
{
@@ -746,8 +746,7 @@ inline ShaderBindIndex::ShaderBindIndex(const DescriptorAccess &access)
}
inline ShaderDirectAccess::ShaderDirectAccess(const DescriptorAccess &access)
: ShaderDirectAccess(CategoryForDescriptorType(access.type), access.descriptorStore,
access.byteOffset, access.byteSize)
: ShaderDirectAccess(access.type, access.descriptorStore, access.byteOffset, access.byteSize)
{
}
+10 -1
View File
@@ -643,6 +643,7 @@ struct DescriptorRange
{
offset = access.byteOffset;
descriptorSize = access.byteSize;
type = access.type;
}
DOCUMENT("The offset in the descriptor storage where the descriptor range starts.");
@@ -651,11 +652,17 @@ struct DescriptorRange
uint32_t descriptorSize = 1;
DOCUMENT("The number of descriptors in this range.");
uint32_t count = 1;
DOCUMENT(R"(The type of descriptor in the descriptor range.
:type: DescriptorType
)");
DescriptorType type = DescriptorType::Unknown;
DOCUMENT("");
bool operator==(const DescriptorRange &o) const
{
return offset == o.offset && descriptorSize == o.descriptorSize && count == o.count;
return offset == o.offset && descriptorSize == o.descriptorSize && count == o.count &&
type == o.type;
}
bool operator<(const DescriptorRange &o) const
{
@@ -665,6 +672,8 @@ struct DescriptorRange
return descriptorSize < o.descriptorSize;
if(!(count == o.count))
return count < o.count;
if(!(type == o.type))
return type < o.type;
return false;
}
};
+12 -15
View File
@@ -136,7 +136,7 @@ struct ShaderDirectAccess
DOCUMENT("");
ShaderDirectAccess()
{
category = DescriptorCategory::Unknown;
type = DescriptorType::Unknown;
descriptorStore = ResourceId();
byteOffset = 0;
byteSize = 0;
@@ -144,20 +144,17 @@ struct ShaderDirectAccess
ShaderDirectAccess(const ShaderDirectAccess &) = default;
ShaderDirectAccess &operator=(const ShaderDirectAccess &) = default;
ShaderDirectAccess(DescriptorCategory category, ResourceId descriptorStore, uint32_t byteOffset,
ShaderDirectAccess(DescriptorType type, ResourceId descriptorStore, uint32_t byteOffset,
uint32_t byteSize)
: category(category),
descriptorStore(descriptorStore),
byteOffset(byteOffset),
byteSize(byteSize)
: type(type), descriptorStore(descriptorStore), byteOffset(byteOffset), byteSize(byteSize)
{
}
ShaderDirectAccess(const DescriptorAccess &access);
bool operator<(const ShaderDirectAccess &o) const
{
if(category != o.category)
return category < o.category;
if(type != o.type)
return type < o.type;
if(descriptorStore != o.descriptorStore)
return descriptorStore < o.descriptorStore;
if(byteOffset != o.byteOffset)
@@ -166,15 +163,15 @@ struct ShaderDirectAccess
}
bool operator==(const ShaderDirectAccess &o) const
{
return category == o.category && descriptorStore == o.descriptorStore &&
byteOffset == o.byteOffset && byteSize == o.byteSize;
return type == o.type && descriptorStore == o.descriptorStore && byteOffset == o.byteOffset &&
byteSize == o.byteSize;
}
DOCUMENT(R"(The category of the resource being accessed.
DOCUMENT(R"(The type of the resource being accessed.
:type: DescriptorCategory
:type: DescriptorType
)");
DescriptorCategory category;
DescriptorType type;
DOCUMENT(R"(The backing storage of the descriptor.
@@ -509,7 +506,7 @@ The :class:`ShaderDirectAccess` uniquely refers to a resource descriptor.
)");
inline void SetDirectAccess(const ShaderDirectAccess &access)
{
value.u32v[0] = (uint32_t)access.category;
value.u32v[0] = (uint32_t)access.type;
value.u32v[1] = access.byteOffset;
value.u32v[2] = access.byteSize;
// This marks the variable as ShaderDirectAccess and not ShaderBindIndex
@@ -532,7 +529,7 @@ The :class:`ShaderDirectAccess` uniquely refers to a resource descriptor.
{
ResourceId descriptorStore;
memcpy(&descriptorStore, &value.u64v[2], sizeof(descriptorStore));
return ShaderDirectAccess((DescriptorCategory)value.u64v[0], descriptorStore, value.u32v[1],
return ShaderDirectAccess((DescriptorType)value.u64v[0], descriptorStore, value.u32v[1],
value.u32v[2]);
}