fix(gpu,wine): harden D3D12 alignment/RTV/copy-barrier paths and texevents byte accounting (#250) #447

Open
github-bot wants to merge 2 commits from github-bot/gh-447 into main AGit
Owner

@⁠ZerefDragnee1l on GitHub · 2026-12-06 01:00 UTC · original
ZerefDragnee1l:fix/proton-vkd3d-alignment-rtv-copy-barrier → main · +172 −34 · 6 files · 2 commits · open

Hardens several D3D12 / vkd3d-proton call sites and texture upload accounting related to #250 and #285:

Changes

  1. Skip 0x1000 small-texture alignment probing on Wine/vkd3d-proton (d3d12ma/shim.cpp, texheap.rs):
    • Adds try_4k to Heaps / larp_d3d12ma_create and sets it to !crate::host::on_wine(). Eliminates the d3d12_resource_validate_texture_alignment / GetResourceAllocationInfo3 warning storm and thousands of redundant 0x1000 probes during streaming under Proton.
  2. Pass valid pResourceAllocationInfo1 to GetResourceAllocationInfo3 (poolheap.rs):
    • Provides Some(&mut info1) instead of None in castable_info().
  3. Sanitize null fallback RTV descriptions (host.rs):
    • In Host::rtv, when in_texture() demotes resource to None, ensures Format / ViewDimension are never DXGI_FORMAT_UNKNOWN / D3D12_RTV_DIMENSION_UNKNOWN when creating typed null descriptors.
  4. COPY-queue Enhanced Barrier hardening (host.rs):
    • Includes D3D12_BARRIER_ACCESS_COPY_SOURCE alongside D3D12_BARRIER_ACCESS_COPY_DEST in copy_send_refs, and keeps the single-list list7.Barrier merge off on Wine/vkd3d-proton (!on_wine()) so overlapping copy runs use separate copy lists.
  5. Guard GetCachedBlob() pointers (pipeline/blobs.rs):
    • Checks !ptr.is_null() && len > 0 via blob_bytes() before constructing slices.
  6. Fix q.bytes leak in texevents::read_late (texevents.rs):
    • Subtracts f.total from q.bytes when !by_drain and settle(...) returns false due to concurrent release() dropping a Bytes::Reading entry.

Verification

  • Ran cargo check -p larp on this branch (exited 0, 0 errors, 0 warnings in modified files).

Regression test update

  • cargo test -p larp-gpu --lib texevents -> 1 passed; 0 failed; 30 filtered out (texevents::tests::read_late_release_during_read_restores_queue_bytes_without_affecting_unrelated_uploads)
**@⁠ZerefDragnee1l** on GitHub · 2026-12-06 01:00 UTC · [original](https://github.com/gamingwithhomie/larp/pull/447) `ZerefDragnee1l:fix/proton-vkd3d-alignment-rtv-copy-barrier` → `main` · +172 −34 · 6 files · 2 commits · open Hardens several D3D12 / vkd3d-proton call sites and texture upload accounting related to #250 and #285: ## Changes 1. **Skip `0x1000` small-texture alignment probing on Wine/vkd3d-proton (`d3d12ma/shim.cpp`, `texheap.rs`):** - Adds `try_4k` to `Heaps` / `larp_d3d12ma_create` and sets it to `!crate::host::on_wine()`. Eliminates the `d3d12_resource_validate_texture_alignment` / `GetResourceAllocationInfo3` warning storm and thousands of redundant `0x1000` probes during streaming under Proton. 2. **Pass valid `pResourceAllocationInfo1` to `GetResourceAllocationInfo3` (`poolheap.rs`):** - Provides `Some(&mut info1)` instead of `None` in `castable_info()`. 3. **Sanitize null fallback RTV descriptions (`host.rs`):** - In `Host::rtv`, when `in_texture()` demotes `resource` to `None`, ensures `Format` / `ViewDimension` are never `DXGI_FORMAT_UNKNOWN` / `D3D12_RTV_DIMENSION_UNKNOWN` when creating typed null descriptors. 4. **COPY-queue Enhanced Barrier hardening (`host.rs`):** - Includes `D3D12_BARRIER_ACCESS_COPY_SOURCE` alongside `D3D12_BARRIER_ACCESS_COPY_DEST` in `copy_send_refs`, and keeps the single-list `list7.Barrier` merge off on Wine/vkd3d-proton (`!on_wine()`) so overlapping copy runs use separate copy lists. 5. **Guard `GetCachedBlob()` pointers (`pipeline/blobs.rs`):** - Checks `!ptr.is_null() && len > 0` via `blob_bytes()` before constructing slices. 6. **Fix `q.bytes` leak in `texevents::read_late` (`texevents.rs`):** - Subtracts `f.total` from `q.bytes` when `!by_drain` and `settle(...)` returns `false` due to concurrent `release()` dropping a `Bytes::Reading` entry. ## Verification - Ran `cargo check -p larp` on this branch (exited `0`, 0 errors, 0 warnings in modified files). ### Regression test update - `cargo test -p larp-gpu --lib texevents` -> `1 passed; 0 failed; 30 filtered out` (`texevents::tests::read_late_release_during_read_restores_queue_bytes_without_affecting_unrelated_uploads`)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-06 01:02:48 +00:00
Author
Owner

@⁠vanya890 on GitHub · 2026-12-06 01:28 UTC · original · reviewed

One useful regression test would cover the newly fixed release-during-read accounting path in read_late(): reserve f.total in q.bytes, let the release transition the entry out of Bytes::Reading before settle(), then assert the queue byte count returns to its prior value and unrelated uploads remain accounted for. The code path is subtle because release intentionally does not subtract bytes while the entry is still Reading; a focused test would protect against reintroducing the queue-budget leak.

**@⁠vanya890** on GitHub · 2026-12-06 01:28 UTC · [original](https://github.com/gamingwithhomie/larp/pull/447#pullrequestreview-6207453768) · **reviewed** One useful regression test would cover the newly fixed release-during-read accounting path in read_late(): reserve f.total in q.bytes, let the release transition the entry out of Bytes::Reading before settle(), then assert the queue byte count returns to its prior value and unrelated uploads remain accounted for. The code path is subtle because release intentionally does not subtract bytes while the entry is still Reading; a focused test would protect against reintroducing the queue-budget leak.
Author
Owner

@⁠ZerefDragnee1l on GitHub · 2026-12-06 01:37 UTC · original

Added the focused unit test covering the read_late() release-during-read byte accounting path via extracted drop_for_release() and settle_reading() helpers:

  • texevents::tests::read_late_release_during_read_restores_queue_bytes_without_affecting_unrelated_uploads:
    • Reserves f.total alongside unrelated upload bytes in q.bytes, runs drop_for_release while the entry is in Bytes::Reading (verifying it transitions to Bytes::Dropped and returns Some(0) so q.bytes stays unchanged until settle), then calls settle_reading (by_drain = false) and verifies q.bytes returns to the exact prior unrelated upload byte count.
    • Also covers the by_drain = true path (never subtracts f.total) and the normal non-released Reading -> Read -> Dropped path.

Verified with cargo check -p larp (exited 0) and cargo test -p larp-gpu --lib texevents (1 passed; 0 failed; 30 filtered out).

**@⁠ZerefDragnee1l** on GitHub · 2026-12-06 01:37 UTC · [original](https://github.com/gamingwithhomie/larp/pull/447#issuecomment-7449321079) Added the focused unit test covering the `read_late()` release-during-read byte accounting path via extracted `drop_for_release()` and `settle_reading()` helpers: - `texevents::tests::read_late_release_during_read_restores_queue_bytes_without_affecting_unrelated_uploads`: - Reserves `f.total` alongside unrelated upload bytes in `q.bytes`, runs `drop_for_release` while the entry is in `Bytes::Reading` (verifying it transitions to `Bytes::Dropped` and returns `Some(0)` so `q.bytes` stays unchanged until `settle`), then calls `settle_reading` (`by_drain = false`) and verifies `q.bytes` returns to the exact prior unrelated upload byte count. - Also covers the `by_drain = true` path (never subtracts `f.total`) and the normal non-released `Reading -> Read -> Dropped` path. Verified with `cargo check -p larp` (exited 0) and `cargo test -p larp-gpu --lib texevents` (`1 passed; 0 failed; 30 filtered out`).
This pull request has changes conflicting with the target branch.
  • crates/larp-gpu/src/pipeline/blobs.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/447/head:github-bot/gh-447'
git switch 'github-bot/gh-447'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-447'
git switch 'github-bot/gh-447'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-447'
git switch 'github-bot/gh-447'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-447'
git switch 'main'
git merge --squash 'github-bot/gh-447'
git switch 'main'
git merge --ff-only 'github-bot/gh-447'
git switch 'main'
git merge 'github-bot/gh-447'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.