Bindless Resources API
-
namespace d3d
Functions
-
uint32_t register_bindless_sampler(SamplerHandle sampler)
Registers a sampler into the global bindless sampler table.
Multiple register calls with the same sampler may yield identical return values. Default sampler (mip linear, filter linear, address wrap, anisotropic = 1, mip bias = 0, transparent black border) is available at zero slot by default.
- Parameters:
sampler – Sampler that should be added.
- Returns:
Index in the global sampler table representing this sampler.
-
uint32_t allocate_bindless_resource_range(D3DResourceType type, uint32_t count)
Allocates a persistent bindless slot range of the given ‘type’ resource type.
- Parameters:
type – The type of resource to allocate the slot range for.
count – The number of slots to allocate. Must be larger than 0.
- Returns:
The first slot index into the bindless heap of the requested range.
-
uint32_t resize_bindless_resource_range(D3DResourceType type, uint32_t index, uint32_t current_count, uint32_t new_count)
Resizes a previously allocated bindless slot range.
It can shrink and enlarge a slot range. The contents of all slots of the old range are migrated to the new range, so only new entries have to be updated.
- Parameters:
type – The type of resource to resize the slot range for.
index – The index of the slot range to resize. Must be in a previously allocated bindless range, or any value if ‘current_count’ is 0.
current_count – The current count of slots in the range. Must be within a previously allocated bindless slot range or 0, when 0 then it behaves like ‘allocate_bindless_resource_range’.
new_count – The new count of slots in the range. Can be larger or smaller than ‘current_count’, shrinks or enlarges the slot range accordingly.
- Returns:
The first slot of the new range.
-
void free_bindless_resource_range(D3DResourceType type, uint32_t index, uint32_t count)
Frees a previously allocated slot range.
This can also be used to shrink ranges, similarly to ‘resize_bindless_resource_range’.
- Parameters:
type – The type of resource to free the slot range for.
index – The index of the slot range to free. Must be in a previously allocated bindless range, or any value if ‘count’ is 0.
count – The number of slots to free. Must not exceed the previously allocated bindless slot range. Can be 0 which will be a no-op.
-
bool update_bindless_resource(D3DResourceType type, uint32_t index, D3dResource *res)
Updates a given bindless slot with the reference to ‘res’.
The slot has to be allocated previously with the corresponding allocation methods with ‘type’ matching the getType() of ‘res’.
- Parameters:
index – The index of the bindless slot to update. Must be in a previously allocated bindless range.
type – The type of resource range to update with res.
res – Pointer to the D3dResource object.
- Returns:
true if actual update is occurred, or false if internal cache was used
-
void update_bindless_resources_to_null(D3DResourceType type, uint32_t index, uint32_t count)
Updates one or more bindless slots with a “null” resource of the given type.
Shader access to those slots will read all zeros and writes will be discarded.
- Parameters:
type – The type of resource to update with null.
index – The index of the bindless slot to update. Must be in a previously allocated bindless range.
count – The number of slots to update. Must not exceed the previously allocated bindless slot range.
-
uint32_t register_bindless_sampler(SamplerHandle sampler)