DescriptorHeapVulkan has no heap-mode descriptor writers, so every per-frame heap write is copied by hand #177

Open
opened 2026-10-31 14:57:58 +00:00 by jorijnvdgraaf · 0 comments

Summary

DescriptorHeapVulkan has descriptor writers for descriptor-set mode (WriteImageSet, WriteImageSets, WriteBufferSets, WriteSamplerSets) but none for the heap. So every heap-mode write is spelled out by hand: copy the create-info per frame, address resourceHeap[f].value plus ImageByteOffset or BufferByteOffset (or the sampler heap plus SamplerByteOffset), call vkWriteResourceDescriptorsEXT or vkWriteSamplerDescriptorsEXT, flush. The sampler write alone exists in three places:

  • UIRenderer::RegisterSampler (implementations/Crafter.Graphics-UI.cpp:435).
  • tests/HeapDynamicIndexHit/main.cpp:332.
  • examples/Sponza/main.cpp:254-268, copied from the test in 6e94cc6.

The image and buffer writes recur in VulkanTriangle, Sponza, SponzaBench, RTVolume, HeapASRead and RTPassPushData.

The copies already differ: RegisterSampler flushes only the range it wrote, while Sponza flushes the whole heap (:267), which the coherent memory both local drivers use hides. If the per-frame replication or the addressing changes, every copy has to change with it. That is the kind of drift #163 removed for the heap-bind structs.

Line numbers refer to 6e94cc6.

Suggested fix

Heap-mode writers on DescriptorHeapVulkan, next to the descriptor-set-mode ones, that flush only what they write: WriteSampledImage, WriteStorageImage, WriteBuffer and WriteSampler. UIRenderer and the examples would use them, and Sponza's sampler write becomes one call. The manual's "writing a descriptor by hand" pattern changes with it.

Found in a code review of the #163 change.

## Summary `DescriptorHeapVulkan` has descriptor writers for descriptor-set mode (`WriteImageSet`, `WriteImageSets`, `WriteBufferSets`, `WriteSamplerSets`) but none for the heap. So every heap-mode write is spelled out by hand: copy the create-info per frame, address `resourceHeap[f].value` plus `ImageByteOffset` or `BufferByteOffset` (or the sampler heap plus `SamplerByteOffset`), call `vkWriteResourceDescriptorsEXT` or `vkWriteSamplerDescriptorsEXT`, flush. The sampler write alone exists in three places: - `UIRenderer::RegisterSampler` (`implementations/Crafter.Graphics-UI.cpp:435`). - `tests/HeapDynamicIndexHit/main.cpp:332`. - `examples/Sponza/main.cpp:254-268`, copied from the test in `6e94cc6`. The image and buffer writes recur in VulkanTriangle, Sponza, SponzaBench, RTVolume, HeapASRead and RTPassPushData. The copies already differ: `RegisterSampler` flushes only the range it wrote, while Sponza flushes the whole heap (`:267`), which the coherent memory both local drivers use hides. If the per-frame replication or the addressing changes, every copy has to change with it. That is the kind of drift #163 removed for the heap-bind structs. Line numbers refer to `6e94cc6`. ## Suggested fix Heap-mode writers on `DescriptorHeapVulkan`, next to the descriptor-set-mode ones, that flush only what they write: `WriteSampledImage`, `WriteStorageImage`, `WriteBuffer` and `WriteSampler`. `UIRenderer` and the examples would use them, and Sponza's sampler write becomes one call. The manual's "writing a descriptor by hand" pattern changes with it. Found in a code review of the #163 change.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Catcrafts/Crafter.Graphics#177
No description provided.