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

Merged
gomeaw merged 2 commits from upstream-pr/23 into main 2026-11-26 08:17:50 +00:00
gomeaw commented 2026-11-25 23:42:15 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by gomeaw on 2026-11-25T23:42:15Z.


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.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6616075238 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/23). Originally posted by [gomeaw](https://github.com/gomeaw) on 2026-11-25T23:42:15Z. --- ## 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.
avatarmanz commented 2026-11-26 07:55:56 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by avatarmanz on 2026-11-26T07:55:56Z.


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7185993463 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/23#issuecomment-7185993463). Originally posted by [avatarmanz](https://github.com/avatarmanz) on 2026-11-26T07:55:56Z. --- Merged into main in the next push (tests pass); thanks.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
avatarmanz/VIctory-7900XTX!23
No description provided.