Crafter.Graphics/interfaces
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jorijn van der Graaf 852ae8abe3
fix(descriptor-heap): round the buffer region up, align the reserved range for buffers too, and never size a heap at zero
DescriptorHeapVulkan
- The buffer region started at images * imageDescriptorSize /
  bufferDescriptorSize, rounded down. A descriptor_heap array indexes
  the heap from byte 0 in strides of its descriptor size, so buffer slot
  0 has to sit on a whole buffer descriptor past the images. Where the
  image descriptors were not a whole number of buffer descriptors, the
  first buffer descriptors overwrote the last image descriptors. Where
  they were less than one, the start was bumped to descriptor 1, but the
  heap was still sized as if the buffers began right after the images,
  so the last buffer descriptors went into the implementation's reserved
  range. Every descriptor size is a power of two, so both cases need
  image descriptors smaller than buffer descriptors, which NVIDIA (32
  and 16 bytes) and llvmpipe (64 and 16) do not have. The start now
  rounds up and the heap is sized from it (#163).
- The reserved range sat at a multiple of imageDescriptorAlignment only,
  where vkCmdBindResourceHeapEXT also wants bufferDescriptorAlignment
  (VUID-vkCmdBindResourceHeapEXT-pBindInfo-11435 and -11436). It now
  starts on a multiple of the larger. The buffer descriptors need no more
  than the rounding: each alignment is at most its descriptor size, so a
  whole number of descriptors is aligned.
- bufferStartElement is 16 bits and took the division unchecked, so an
  image region past 65535 buffer descriptors (16384 images on llvmpipe)
  wrapped the buffer region around onto the images. Slot counts whose
  buffer indices do not fit 16 bits, 0xFFFF being the empty slot, now
  throw, naming the counts. A heap without buffer slots has no buffer
  region, which starts at 0 as in descriptor-set mode, so image-only
  heaps have no index to fit.
- On a driver that reserves nothing (llvmpipe), a heap without sampler
  slots was a zero-size buffer, which every Initialize(1, 1, 0) made,
  and Window::Render bound its address each frame. Each heap now holds at
  least one descriptor, as each binding does in descriptor-set mode. That
  grows NVIDIA's sampler heap by one descriptor when no sampler slots are
  asked for; the resource heaps of the slot counts in the tree keep their
  layouts byte for byte.
- ComputeLayout holds the arithmetic, pure over the descriptor-heap
  properties, and Initialize goes through it. GetBufferOffset and
  GetBufferOffsetElement, which had their own copies of the old
  arithmetic and never had a caller, are gone.
- Bind(cmd, frame) binds a frame's heaps with the reserved ranges
  Initialize stored, or in descriptor-set mode the frame's descriptor
  set. Window::Render and the RTVolume example worked the reserved-range
  offset out from the heap's size with the image-alignment mask, and
  call Bind now. The window's per-heap cache of bind structs goes with
  it: keyed on the heap pointer, it kept binding the old buffers after a
  re-Initialize that reallocated them. The heap still ends with its
  reserved range, so code that derives the offset from the size keeps
  getting the right one.

Tests
- DescriptorHeapLayout: the issue's two layouts, the reserved range where
  buffer descriptors are aligned more strictly than image ones, every
  legal combination of descriptor sizes and alignments up to 256 bytes,
  no heap empty, the NVIDIA and llvmpipe layouts, the 16-bit limit and
  image-only heaps. Pure CPU, no device. Against the old arithmetic it
  fails 12 of its 18 checks.

Docs
- README.md's heap bullet and AGENTS.consumer.md say how to bind the
  heap outside the frame loop, and the consumer notes that Initialize
  throws when buffer indices would pass 16 bits. AGENTS.md lists
  ComputeLayout among the functions the pure-logic tests drive.

Closes #163.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 16:06:44 +01:00
..
Crafter.Graphics-Animation.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Clipboard.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-ComputeShader.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-Decompress.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-DescriptorHeapVulkan.cppm fix(descriptor-heap): round the buffer region up, align the reserved range for buffers too, and never size a heap at zero 2026-10-31 16:06:44 +01:00
Crafter.Graphics-DescriptorHeapWebGPU.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Device.cppm fix(wayland): open windows on compositors without xdg-decoration, viewporter or fractional scale 2026-10-31 09:59:13 +01:00
Crafter.Graphics-Dom.cppm wasm improvements 2026-08-05 04:08:13 +02:00
Crafter.Graphics-DomEvents.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Font.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-FontAtlas.cppm fix(font-atlas): wait for the GPU before the image goes; DOM stubs for SetAppId and SetTextInput 2026-10-18 03:28:11 +02:00
Crafter.Graphics-ForwardDeclarations.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Gamepad.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-GraphicsTypes.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Image2D.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-ImageVulkan.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-Input.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-InputField.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Keys.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Mesh.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-PipelineRTVulkan.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-PipelineRTWebGPU.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-PlainComputeShader.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-RenderingElement3D.cppm fix(rt): rebuild TLASes in place, after earlier traces, and queue their handles like a Mesh's 2026-10-31 02:32:48 +01:00
Crafter.Graphics-RenderPass.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-Router.cppm wasm improvements 2026-08-05 04:08:13 +02:00
Crafter.Graphics-RT.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-RTPass.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-SamplerVulkan.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-ShaderBindingTableVulkan.cppm feat(vulkan): run the compute/UI path without VK_EXT_descriptor_heap 2026-10-06 17:28:46 +02:00
Crafter.Graphics-ShaderBindingTableWebGPU.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-ShaderVulkan.cppm feat(device): applications ask for the device features their shaders use 2026-10-31 06:40:02 +01:00
Crafter.Graphics-Types.cppm feat(wayland): text input through zwp_text_input_v3 2026-10-18 01:57:09 +02:00
Crafter.Graphics-UI.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-UIComponents.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-VulkanBuffer.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-VulkanTransition.cppm feat(vulkan): run the compute/UI path without VK_EXT_descriptor_heap 2026-10-06 17:28:46 +02:00
Crafter.Graphics-WebGPU.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-WebGPUBuffer.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-WebGPUComputeShader.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Window.cppm fix(descriptor-heap): round the buffer region up, align the reserved range for buffers too, and never size a heap at zero 2026-10-31 16:06:44 +01:00
Crafter.Graphics.cppm SPDX license update 2026-07-22 18:09:06 +02:00