Keep structured buffer reads raw on heaps without descriptor twins #23

Manually merged
github merged 2 commits from github-bot/gh-23 into main 2026-11-26 08:21:47 +00:00 AGit
Owner

@⁠gomeaw on GitHub · 2026-11-25 23:42 UTC · original
gomeaw:fix/raw-buffer-views-without-twins → main · +49 −16 · 1 files · 2 commits · merged 2026-11-26 08:17 UTC

Fix

The shader translator reads untyped structured buffers as raw bytes. On a heap without raw descriptor twins, a structured view can start on one of its own elements but miss D3D12's 16-byte raw alignment. A stride-56 view with FirstElement=1 is one example. The host currently accepts a structured descriptor in that slot, and a raw shader read through it can return zero on NVIDIA.

Use the existing copy of a view's own bytes for this alignment case when the heap has no twins. The slot can then use a raw descriptor starting at byte zero. Both descriptor creation and refresh select the same copy. This covers SRVs and UAVs and uses the existing copy limits and lifetime tracking.

The related RTX 5090 investigation found a raw/structured descriptor mismatch in the hit-detection shader eeed82b877b44b5f. This fork already uses raw reads and, where supported, raw twins. This PR addresses the case where the heap cannot provide a twin. It needs a targeted retest of that shader on this fork. RTX 5090 investigation

Verification

The Windows check disables raw twins on WARP and uses a registered buffer with a deliberately misaligned first element. With the old placement strategy the regression kept the whole registered buffer and failed the view-span assertion. With the change it selected the exact view span and both descriptor creation and refresh used the same D3D12 resource. All 33 descriptor tests and the asset policy passed. Windows comparison

AI-assisted with Codex. The tests use synthetic data.

**@⁠gomeaw** on GitHub · 2026-11-25 23:42 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/23) `gomeaw:fix/raw-buffer-views-without-twins` → `main` · +49 −16 · 1 files · 2 commits · merged 2026-11-26 08:17 UTC ## Fix The shader translator reads untyped structured buffers as raw bytes. On a heap without raw descriptor twins, a structured view can start on one of its own elements but miss D3D12's 16-byte raw alignment. A stride-56 view with `FirstElement=1` is one example. The host currently accepts a structured descriptor in that slot, and a raw shader read through it can return zero on NVIDIA. Use the existing copy of a view's own bytes for this alignment case when the heap has no twins. The slot can then use a raw descriptor starting at byte zero. Both descriptor creation and refresh select the same copy. This covers SRVs and UAVs and uses the existing copy limits and lifetime tracking. The related RTX 5090 investigation found a raw/structured descriptor mismatch in the hit-detection shader `eeed82b877b44b5f`. This fork already uses raw reads and, where supported, raw twins. This PR addresses the case where the heap cannot provide a twin. It needs a targeted retest of that shader on this fork. [RTX 5090 investigation](https://github.com/Marvisak/VIctory/pull/984) ## Verification The Windows check disables raw twins on WARP and uses a registered buffer with a deliberately misaligned first element. With the old placement strategy the regression kept the whole registered buffer and failed the view-span assertion. With the change it selected the exact view span and both descriptor creation and refresh used the same D3D12 resource. All 33 descriptor tests and the asset policy passed. [Windows comparison](https://github.com/gomeaw/VIctory-7900XTX/actions/runs/45723270101) AI-assisted with Codex. The tests use synthetic data.
When a structured view starts on one of its elements but off the raw alignment, use the existing view-relative copy. This covers native NVIDIA descriptor heaps that cannot allocate a second raw slot for every view.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:31:25 +00:00
Author
Owner

@⁠avatarmanz on GitHub · 2026-11-26 07:55 UTC · original

Merged into main in the next push (tests pass); thanks.

**@⁠avatarmanz** on GitHub · 2026-11-26 07:55 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/23#issuecomment-7185993463) Merged into main in the next push (tests pass); thanks.
github manually merged commit 86bb00ecd3 into main 2026-11-26 08:21:47 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.