d3d12: use 32-byte guest stride for Device11 inline descriptor arenas #184

Manually merged
github merged 1 commit from gh-pr/184/head into gh-pr/184/base 2026-11-26 06:36:57 +00:00
Owner

@⁠DrArroway on GitHub · 2026-11-25 17:54 UTC · original
DrArroway:fix/radv-inline-descriptor-stride → main · +99 −41 · 6 files · 1 commits · merged 2026-11-25 19:03 UTC

Summary

Fixes #182.

On hosts where vkd3d-proton reports a 64-byte native CBV_SRV_UAV descriptor handle increment (AMD RADV with VK_EXT_descriptor_heap or VK_EXT_descriptor_buffer), Device11 inline descriptor arenas previously mixed two strides: GetDescriptorHandleIncrementSize, Arena::author, and Arena::cpu stepped at native self.stride (64), while Arena::gpu_table walked inline records by INLINE_BYTES (32) and Arena::publish scaled slot offsets by self.stride / INLINE_BYTES. As a result, guests querying GetDescriptorHandleIncrementSize (such as lanes-selftest-descriptor-reclaim) only materialized slot 0 and left slots 1+ as null SRVs, while 32-byte inline table offsets misaligned against self.stride.

Separate the guest-visible logical stride (guest_stride(), 32 bytes when inline is active on Device11) from the host staging/visible heap stride (self.stride):

  • device.rs: add guest_increment_size returning INLINE_BYTES (32) for CBV_SRV_UAV when device11_queue is active and native stride is a nonzero multiple of INLINE_BYTES.
  • descriptor_paging.rs & lookup.rs: allocate guest arena memory, check Registry::find / copy_source / contains / resident_gpu / gpu_table, step author, map cpu() (guest_slot * self.stride in native staging), and publish() uniformly using guest_stride() (removing the self.stride / INLINE_BYTES scaling branch), while copy() uses native staging_cpu_start + src * self.stride.
  • descriptor_copy.rs & commands/descriptors.rs: step guest descriptor handles by guest_stride when copying into or reading scalar descriptors from an inline arena, leaving native descriptor tracking on native stride.
  • tests/device/descriptor_paging.rs: update addr_of and add inline_arena_uses_32_byte_guest_stride_on_64_byte_native_heap covering 64-byte native heaps with odd 32-byte table offsets, cpu(), author(), resolve_inline(), and publish().

On stride == 32 hosts, guest_stride() == self.stride, leaving behavior unchanged.

Verified on Lanes

  • python tuxbox.py check passed on this branch (with TUXBOX_DESCRIPTOR_HEAP_LIMIT=1000000 exported until #178 lands; unpinned passes Phases 1–4 of descriptor-reclaim and fails only at #178's Phase 5 E_OUTOFMEMORY limit check)
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below

lanes-selftest-descriptor-reclaim directly exercises this path on default RADV (VK_EXT_descriptor_heap, native stride 64): TUXBOX_LOG=1 now logs materialized 3 CPU-authored descriptor records (table length 8192, native stride 64) instead of 1, and descriptor-reclaim passes (lanes-selftest PASS pci=1002:73bf scenario=descriptor-reclaim passed=1). d3d12-mesh (tuxbox.py verify --only d3d12-mesh) and all 112 tuxbox-d3d12 Rust unit tests (cargo test --target x86_64-pc-windows-msvc -p tuxbox-d3d12 under Wine) also pass.

GPU, driver and backend: AMD Radeon RX 6900 XT (1002:73bf), Mesa RADV 26.3.1-arch3.4, Proton Experimental (1794497090 experimental-11.0-20261112-x86_64, vkd3d-proton 3.2.0), CachyOS Linux (Ryzen 9 7900X).

Summary from DXC=... TUXBOX_DESCRIPTOR_HEAP_LIMIT=1000000 python tuxbox.py check --backend proton --adapter 1002:73bf (64/64 verify gates passed):

Summary
  passed   Build the shader compiler (0s)
  passed   Python tests (3s)
  passed   Shader compiler tests (0s)
  passed   DXBC tests (0s)
  passed   XG layout tests (1s)
  passed   D3D12 Windows typecheck (1s)
  passed   Build (20s)
  passed   Lanes and fixtures on the GPU (128s)
  not run: pass --proton, --prefix and --windows-dxc D3D12 regression controls (0s)
  not run: pass --proton, --prefix and --windows-dxc Shader translator on the GPU (0s)

All checks that ran passed. Attach the GPU results to the pull request: /home/drarroway/TuxBox/build/check/results.json

(Note: D3D12 regression controls and Shader translator on the GPU were not run here because Windows dxcompiler.dll/dxil.dll and xvfb-run are not installed on this host.)

Checks

All CI checks in .github/workflows/ci.yml pass locally with 0 warnings (Python tests, Shader compiler tests, DXBC tests, XG layout tests, D3D12 Windows typecheck). No evidence/*.json files were modified.

**@⁠DrArroway** on GitHub · 2026-11-25 17:54 UTC · [original](https://github.com/brcly/TuxBox/pull/184) `DrArroway:fix/radv-inline-descriptor-stride` → `main` · +99 −41 · 6 files · 1 commits · merged 2026-11-25 19:03 UTC ## Summary Fixes #182. On hosts where `vkd3d-proton` reports a 64-byte native `CBV_SRV_UAV` descriptor handle increment (AMD RADV with `VK_EXT_descriptor_heap` or `VK_EXT_descriptor_buffer`), `Device11` inline descriptor arenas previously mixed two strides: `GetDescriptorHandleIncrementSize`, `Arena::author`, and `Arena::cpu` stepped at native `self.stride` (64), while `Arena::gpu_table` walked inline records by `INLINE_BYTES` (32) and `Arena::publish` scaled slot offsets by `self.stride / INLINE_BYTES`. As a result, guests querying `GetDescriptorHandleIncrementSize` (such as `lanes-selftest-descriptor-reclaim`) only materialized slot 0 and left slots 1+ as null SRVs, while 32-byte inline table offsets misaligned against `self.stride`. Separate the guest-visible logical stride (`guest_stride()`, 32 bytes when `inline` is active on `Device11`) from the host staging/visible heap stride (`self.stride`): - `device.rs`: add `guest_increment_size` returning `INLINE_BYTES` (32) for `CBV_SRV_UAV` when `device11_queue` is active and native stride is a nonzero multiple of `INLINE_BYTES`. - `descriptor_paging.rs` & `lookup.rs`: allocate guest arena memory, check `Registry::find` / `copy_source` / `contains` / `resident_gpu` / `gpu_table`, step `author`, map `cpu()` (`guest_slot * self.stride` in native staging), and `publish()` uniformly using `guest_stride()` (removing the `self.stride / INLINE_BYTES` scaling branch), while `copy()` uses native `staging_cpu_start + src * self.stride`. - `descriptor_copy.rs` & `commands/descriptors.rs`: step guest descriptor handles by `guest_stride` when copying into or reading scalar descriptors from an inline arena, leaving native descriptor tracking on native stride. - `tests/device/descriptor_paging.rs`: update `addr_of` and add `inline_arena_uses_32_byte_guest_stride_on_64_byte_native_heap` covering 64-byte native heaps with odd 32-byte table offsets, `cpu()`, `author()`, `resolve_inline()`, and `publish()`. On `stride == 32` hosts, `guest_stride() == self.stride`, leaving behavior unchanged. ## Verified on Lanes - [x] `python tuxbox.py check` passed on this branch *(with `TUXBOX_DESCRIPTOR_HEAP_LIMIT=1000000` exported until #178 lands; unpinned passes Phases 1–4 of `descriptor-reclaim` and fails only at #178's Phase 5 `E_OUTOFMEMORY` limit check)* - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below `lanes-selftest-descriptor-reclaim` directly exercises this path on default RADV (`VK_EXT_descriptor_heap`, native stride 64): `TUXBOX_LOG=1` now logs `materialized 3 CPU-authored descriptor records (table length 8192, native stride 64)` instead of `1`, and `descriptor-reclaim` passes (`lanes-selftest PASS pci=1002:73bf scenario=descriptor-reclaim passed=1`). `d3d12-mesh` (`tuxbox.py verify --only d3d12-mesh`) and all `112` `tuxbox-d3d12` Rust unit tests (`cargo test --target x86_64-pc-windows-msvc -p tuxbox-d3d12` under Wine) also pass. GPU, driver and backend: AMD Radeon RX 6900 XT (`1002:73bf`), Mesa RADV `26.3.1-arch3.4`, Proton Experimental (`1794497090 experimental-11.0-20261112-x86_64`, `vkd3d-proton 3.2.0`), CachyOS Linux (Ryzen 9 7900X). Summary from `DXC=... TUXBOX_DESCRIPTOR_HEAP_LIMIT=1000000 python tuxbox.py check --backend proton --adapter 1002:73bf` (64/64 verify gates passed): ```text Summary passed Build the shader compiler (0s) passed Python tests (3s) passed Shader compiler tests (0s) passed DXBC tests (0s) passed XG layout tests (1s) passed D3D12 Windows typecheck (1s) passed Build (20s) passed Lanes and fixtures on the GPU (128s) not run: pass --proton, --prefix and --windows-dxc D3D12 regression controls (0s) not run: pass --proton, --prefix and --windows-dxc Shader translator on the GPU (0s) All checks that ran passed. Attach the GPU results to the pull request: /home/drarroway/TuxBox/build/check/results.json ``` *(Note: `D3D12 regression controls` and `Shader translator on the GPU` were not run here because Windows `dxcompiler.dll`/`dxil.dll` and `xvfb-run` are not installed on this host.)* ## Checks All CI checks in `.github/workflows/ci.yml` pass locally with 0 warnings (`Python tests`, `Shader compiler tests`, `DXBC tests`, `XG layout tests`, `D3D12 Windows typecheck`). No `evidence/*.json` files were modified.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:36:54 +00:00
github manually merged commit cf427e816e into gh-pr/184/base 2026-11-26 06:36:57 +00:00
Author
Owner

@⁠postblink on GitHub · 2026-11-25 18:55 UTC · original

An independent reproduction of #182 from a different scenario, and this change fixes it.

I'm writing a Lanes scenario for #168 (raster-tables, not posted yet): a console pixel program reads one raw SRV from slot 2 of the second of two root tables, with views created at GetDescriptorHandleIncrementSize on a Device11 heap. Every other view holds a decoy naming its index, so a wrong slot shows up as a number.

Radeon 610M iGPU (1002:13c0, Mesa RADV 26.3.1, Proton Experimental 11.0-20261112) and RTX 5080 (10de:2c02, driver 620.73.04) on the same machine:

Build RADV NVIDIA
7b22d71 + scenario FAIL texel 0,0 read view 9, not table 1 slot 2 (view 10) PASS
7b22d71 + scenario + this branch (cf427e8) PASS PASS

On RADV the provider logged materialized 1 CPU-authored descriptor records (table length 3, native stride 64). Console slot 2 is read at table + 2 × 32 bytes, which with 64-byte authoring is the middle of the record for view 9 (table base 8, so 8 + 1). That's the same mix of strides your summary describes, seen from the table side rather than through reclaim.

**@⁠postblink** on GitHub · 2026-11-25 18:55 UTC · [original](https://github.com/brcly/TuxBox/pull/184#issuecomment-7171591616) An independent reproduction of #182 from a different scenario, and this change fixes it. I'm writing a Lanes scenario for #168 (`raster-tables`, not posted yet): a console pixel program reads one raw SRV from slot 2 of the second of two root tables, with views created at `GetDescriptorHandleIncrementSize` on a `Device11` heap. Every other view holds a decoy naming its index, so a wrong slot shows up as a number. Radeon 610M iGPU (`1002:13c0`, Mesa RADV 26.3.1, Proton Experimental 11.0-20261112) and RTX 5080 (`10de:2c02`, driver 620.73.04) on the same machine: | Build | RADV | NVIDIA | |---|---|---| | `7b22d71` + scenario | FAIL `texel 0,0 read view 9, not table 1 slot 2 (view 10)` | PASS | | `7b22d71` + scenario + this branch (`cf427e8`) | PASS | PASS | On RADV the provider logged `materialized 1 CPU-authored descriptor records (table length 3, native stride 64)`. Console slot 2 is read at table + 2 × 32 bytes, which with 64-byte authoring is the middle of the record for view 9 (table base 8, so 8 + 1). That's the same mix of strides your summary describes, seen from the table side rather than through reclaim.
This discussion has been locked. Commenting is limited to contributors.
No description provided.