Skip to content

GPU: bind explicitly null root buffers to null SRV and UAV descriptors - #192

Merged
pragyaangaur merged 1 commit into
pragyaangaur:mainfrom
gdemontalivet:fix/macos-null-root-buffer
Nov 26, 2026
Merged

pragyaangaur merged 1 commit into
pragyaangaur:mainfrom
gdemontalivet:fix/macos-null-root-buffer

Conversation

@gdemontalivet

Copy link
Copy Markdown
Contributor

An optional root buffer can be explicitly set to guest GPU address zero. The translated root SRV/UAV path currently asks for a shadow of that address and can allocate a 4 MiB loose buffer at zero. The shader then receives a descriptor for writable storage. An optional input in a BVH compute workload motivated this change.

Use the active heap’s null raw SRV or UAV and supply a zero byte offset. Skip the zero address when collecting shadows for the title-memory page table. When the host caps the heap below the usual permanent null slots, reserve a pair inside that heap for these bindings. Unset root slots still follow their existing diagnostic path.

The GPU fixture dispatches against a real output, then checks a null SRV reads sixteen zeros and rebinding a null UAV discards writes from a populated source. It also checks that only the real buffer takes a dynamic root view. On unmodified main at 485b230e, the same test fails with two dynamic views instead of one.

PR #158 separately distinguishes ordinary root constants from descriptor offsets. The gameplay comparison motivating this work used both changes alongside other address checks. The performance and visual effects of this patch alone have not been measured.

Verification

  • CrossOver Preview with D3DMetal on an M5 Max, using an isolated test bottle.
  • Native macOS workspace suite passed 454 tests. The Windows GPU suite with diagnostics passed 232 tests with one ignored.
  • cargo xtask policy and git diff --check passed. All test inputs are synthetic.

Keep the SRV and UAV in range even on hosts with capped heaps. Skip the address-zero shadow in title-memory lookup. Exercise zero reads and discarded writes using the existing GPU readback fixture.
@pragyaangaur
pragyaangaur merged commit 9646b19 into pragyaangaur:main Nov 26, 2026
1 check passed
@pragyaangaur pragyaangaur added area:gpu Host GPU runtime: resources, copies, presenting d3dmetal A difference in Apple's D3DMetal labels Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Host GPU runtime: resources, copies, presenting d3dmetal A difference in Apple's D3DMetal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants