perf(gpu): zero-copy castable texture aliases (VICTORY_CASTABLE_ALIAS) #551

Open
opened 2026-12-05 02:47:00 +00:00 by github-bot · 3 comments
Owner

@⁠chefulano on GitHub · 2026-12-05 02:46 UTC · original

Problem

Every placed format alias of a compute-written R32_UINT / R32_SINT UAV texture viewed as R9G9B9E5_SHAREDEXP allocates a duplicate host texture and runs a CopyTextureRegion plus copy barriers on every read. On constrained 8 GiB VRAM / 16 GiB RAM AMD RDNA 3 (RX 7600M XT 8 GiB) hosts, those duplicate textures add VRAM pressure and per-frame copy overhead.

Change

Adds an opt-in switch VICTORY_CASTABLE_ALIAS=1 (off by default; zero behavior change when unset) using D3D12 relaxed format casting (ID3D12Device10::CreateCommittedResource3), rebased cleanly on top of merged #550 (dropping the duplicate descriptor.rs / records.rs helpers already in main):

  • Device capability probe: Extends waits::options12() to read both EnhancedBarriersSupported and RelaxedFormatCastingSupported. resource::castable_alias_supported() runs a one-time probe verifying RelaxedFormatCastingSupported, ID3D12Device10, R32_UINT UAV + R9G9B9E5_SHAREDEXP SRV format support, a 1×1 CreateCommittedResource3 allocation with [R32_UINT, R32_SINT, R9G9B9E5_SHAREDEXP], and typed R9G9B9E5_SHAREDEXP SRV creation + GetDeviceRemovedReason().is_ok() (noting that GetDeviceRemovedReason only detects device removal, not non-fatal SRV validation errors, so format-support checks gate creation first). Any failure falls back to CopyTextureRegion.
  • Castable creation & legacy barrier interop: host_texture_in() creates eligible UAV textures via CreateCommittedResource3 with castable_initial_layout() always returning (0, 0) (D3D12_BARRIER_LAYOUT_COMMON + tracked legacy state 0) so the first list::ensure_state() transitions cleanly under legacy ResourceBarrier interop on native D3D12 (NVIDIA / WARP) and vkd3d-proton. descriptor::host::fits_view() / make_descriptor() preserve cross-family castable SRV formats.
  • Lifetime-, lock-, and order-safe binding & view-first upgrade: castable_source_copy() resolves the live source Arc<HostTexture> entirely under TARGETS_AT (strict lock order placed.host.made [fills == true] → TARGETS_AT → source.host.made [fills == false]; zero unlocked raw-pointer dereferences), with a monotonic TARGETS_EPOCH counter bumped under TARGETS_AT so steady-state hosted_for() skips locking TARGETS_AT. hosted_for_allows_castable_init_bind() permits both fit.is_none() and full-mip fit == Some((0, _)) (still rejecting partial-mip first > 0). MadeSlot tracks a monotonic private_dirty flag set only by independent non-alias GPU destination writes (descriptor/host.rs UAV, draw.rs RTV/DSV, external.rs output_written, list.rs clear_rtv/clear_dsv, non-alias copy_target, texture.rs host_written) so untouched view-first private copies safely upgrade private -> shared on non-noop texture::alias() calls (copy_target_for_alias() + HostList::alias_copy_would_be_noop()), retiring the old Made onto REPLACED and queueing a descriptor rebuild via descriptor::queue_texture_replaced().
  • Config & docs: Adds VICTORY_CASTABLE_ALIAS= to run.conf.default and documents VICTORY_CASTABLE_ALIAS=1 (including BARRIER_LAYOUT_COMMON, view-first upgrades, and partial-mip / independently written fallbacks) in docs/SETTINGS.md.

Measured impact

  • Live engagement fix verified on RX 7600M XT 8 GiB (Linux, RADV + vkd3d-proton): The earlier b1af1e9 revision rejected fit == Some((0, _)) and locked view-first copies in FallbackCopy (0 active binds / 288,894 fallbacks). After fixing full-mip init-bind and view-first private -> shared upgrades, clean 4-minute ABBA gameplay runs (4 × 240 s, 0 compiles) consistently engaged 57 active zero-copy castable alias binds (53 within the first 60 s, 0 dirty fallbacks, 0.0 s whiteout, full 10/10 non-inferiority parity).
  • In an earlier single combined-build A/B toggle over a 135 s in-world route on the same 8 GiB RX 7600M XT host, toggling VICTORY_CASTABLE_ALIAS=1 on vs off cut peak VRAM by -102 MiB (6,790 -> 6,688 MiB). On the clean 4-minute combined ABBA stack, average FPS was effectively tied with incumbent (27.80 vs 27.85 FPS); VRAM/copy savings are most relevant under tight VRAM budgets rather than heavily GPU-bound 16 GiB scenes.

Verification

  • Rebased onto main (a5c6484, after #550 and #355 merged; 0 lines of diff in descriptor.rs / records.rs).
  • cargo xtask policy: 368 files ok; cargo test -p xtask -- policy::tests: 7 passed, 0 failed; cargo test -p xtask -- switches::documented_switches_are_read: 1 passed, 0 failed.
  • cargo check --locked --target x86_64-pc-windows-msvc -p victory-gpu -p victory --tests and cargo clippy --no-deps --locked --target x86_64-pc-windows-msvc -p victory-gpu -p victory --all-targets: 0 errors, 0 new warnings.
  • Scoped Windows unit tests (2 passed, 0 failed): resource::tests::castable_r32_selection_and_fallback_rules and resource::tests::alias_views_are_not_pooled_or_evicted_as_title_filled. Live D3D12 probe and rendering require a D3D12 device.

Pull request details or commits were not available from GitHub; kept as an issue.

**@⁠chefulano** on GitHub · 2026-12-05 02:46 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/551) ## Problem Every placed format alias of a compute-written `R32_UINT` / `R32_SINT` UAV texture viewed as `R9G9B9E5_SHAREDEXP` allocates a duplicate host texture and runs a `CopyTextureRegion` plus copy barriers on every read. On constrained 8 GiB VRAM / 16 GiB RAM AMD RDNA 3 (RX 7600M XT 8 GiB) hosts, those duplicate textures add VRAM pressure and per-frame copy overhead. ## Change Adds an opt-in switch **`VICTORY_CASTABLE_ALIAS=1`** (off by default; zero behavior change when unset) using D3D12 relaxed format casting (`ID3D12Device10::CreateCommittedResource3`), rebased cleanly on top of merged `#550` (dropping the duplicate `descriptor.rs` / `records.rs` helpers already in `main`): - **Device capability probe:** Extends `waits::options12()` to read both `EnhancedBarriersSupported` and `RelaxedFormatCastingSupported`. `resource::castable_alias_supported()` runs a one-time probe verifying `RelaxedFormatCastingSupported`, `ID3D12Device10`, `R32_UINT` UAV + `R9G9B9E5_SHAREDEXP` SRV format support, a 1×1 `CreateCommittedResource3` allocation with `[R32_UINT, R32_SINT, R9G9B9E5_SHAREDEXP]`, and typed `R9G9B9E5_SHAREDEXP` SRV creation + `GetDeviceRemovedReason().is_ok()` (noting that `GetDeviceRemovedReason` only detects device removal, not non-fatal SRV validation errors, so format-support checks gate creation first). Any failure falls back to `CopyTextureRegion`. - **Castable creation & legacy barrier interop:** `host_texture_in()` creates eligible UAV textures via `CreateCommittedResource3` with `castable_initial_layout()` always returning `(0, 0)` (`D3D12_BARRIER_LAYOUT_COMMON` + tracked legacy state `0`) so the first `list::ensure_state()` transitions cleanly under legacy `ResourceBarrier` interop on native D3D12 (NVIDIA / WARP) and vkd3d-proton. `descriptor::host::fits_view()` / `make_descriptor()` preserve cross-family castable SRV formats. - **Lifetime-, lock-, and order-safe binding & view-first upgrade:** `castable_source_copy()` resolves the live source `Arc<HostTexture>` entirely under `TARGETS_AT` (strict lock order `placed.host.made` [`fills == true`] → `TARGETS_AT` → `source.host.made` [`fills == false`]; zero unlocked raw-pointer dereferences), with a monotonic `TARGETS_EPOCH` counter bumped under `TARGETS_AT` so steady-state `hosted_for()` skips locking `TARGETS_AT`. `hosted_for_allows_castable_init_bind()` permits both `fit.is_none()` and full-mip `fit == Some((0, _))` (still rejecting partial-mip `first > 0`). `MadeSlot` tracks a monotonic `private_dirty` flag set only by independent non-alias GPU destination writes (`descriptor/host.rs` UAV, `draw.rs` RTV/DSV, `external.rs` `output_written`, `list.rs` `clear_rtv`/`clear_dsv`, non-alias `copy_target`, `texture.rs` `host_written`) so untouched view-first private copies safely upgrade `private -> shared` on non-noop `texture::alias()` calls (`copy_target_for_alias()` + `HostList::alias_copy_would_be_noop()`), retiring the old `Made` onto `REPLACED` and queueing a descriptor rebuild via `descriptor::queue_texture_replaced()`. - **Config & docs:** Adds `VICTORY_CASTABLE_ALIAS=` to `run.conf.default` and documents `VICTORY_CASTABLE_ALIAS=1` (including `BARRIER_LAYOUT_COMMON`, view-first upgrades, and partial-mip / independently written fallbacks) in `docs/SETTINGS.md`. ## Measured impact - **Live engagement fix verified on RX 7600M XT 8 GiB (Linux, RADV + vkd3d-proton):** The earlier `b1af1e9` revision rejected `fit == Some((0, _))` and locked view-first copies in `FallbackCopy` (`0` active binds / `288,894` fallbacks). After fixing full-mip init-bind and view-first `private -> shared` upgrades, clean 4-minute ABBA gameplay runs (`4 × 240 s`, `0` compiles) consistently engaged **57 active zero-copy castable alias binds** (`53` within the first 60 s, `0` dirty fallbacks, `0.0 s` whiteout, full `10/10` non-inferiority parity). - In an earlier single combined-build A/B toggle over a 135 s in-world route on the same 8 GiB RX 7600M XT host, toggling `VICTORY_CASTABLE_ALIAS=1` on vs off cut peak VRAM by `-102 MiB` (`6,790 -> 6,688 MiB`). On the clean 4-minute combined ABBA stack, average FPS was effectively tied with incumbent (`27.80` vs `27.85 FPS`); VRAM/copy savings are most relevant under tight VRAM budgets rather than heavily GPU-bound 16 GiB scenes. ## Verification - Rebased onto `main` (`a5c6484`, after `#550` and `#355` merged; `0` lines of diff in `descriptor.rs` / `records.rs`). - `cargo xtask policy`: `368 files ok`; `cargo test -p xtask -- policy::tests`: `7 passed, 0 failed`; `cargo test -p xtask -- switches::documented_switches_are_read`: `1 passed, 0 failed`. - `cargo check --locked --target x86_64-pc-windows-msvc -p victory-gpu -p victory --tests` and `cargo clippy --no-deps --locked --target x86_64-pc-windows-msvc -p victory-gpu -p victory --all-targets`: 0 errors, 0 new warnings. - Scoped Windows unit tests (`2 passed, 0 failed`): `resource::tests::castable_r32_selection_and_fallback_rules` and `resource::tests::alias_views_are_not_pooled_or_evicted_as_title_filled`. Live D3D12 probe and rendering require a D3D12 device. *Pull request details or commits were not available from GitHub; kept as an issue.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 02:47:00 +00:00
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-05 03:11 UTC · original

Checked b1af1e9 on native Windows (one NVIDIA desktop card plus WARP, didn't run the game).

This branch is one commit on top of b581f7e and does not contain #550's commit (65f3c84). The two duplicate the descriptor refresh plumbing (queue_texture_replaced, refresh_texture, refresh_slot, refresh_placed_at, is_placed_key_at) and a trial merge of the two heads conflicts in descriptor.rs, resource.rs and texture.rs, so whichever lands second needs a real rebase, not just a re-run.

Tests. cargo test -p victory-gpu --lib on main and on the branch give the same five known failures (the two indirect host_list ones, the two pipeline library loads, the flaky watch one) and nothing new; the branch adds three passing tests. Same result with VICTORY_CASTABLE_ALIAS=1, with VICTORY_D3D12_DEBUG=1 on a diagnostics build (no test went down through host::fail, though the suite doesn't print layer warnings otherwise, and none of these tests create a castable texture anyway), and on WARP, where views_are_made_beside_the_heap_and_copied_in also fails but it fails the same way on main. clippy on victory-gpu has the same warning count as main and none of the warnings point at new lines. cargo check -p victory is clean apart from the existing room_lately warning.

Both the card and WARP report EnhancedBarriersSupported and RelaxedFormatCastingSupported as true, and castable_alias_supported() passes its probe on both.

The existing unit tests only cover the pure helpers, so nothing in the suite creates a castable texture on a device. I added a throwaway test (not pushed) that calls host_texture_in for an 8x8 R32_UINT UAV texture with the switch on, writes a pattern through an R32_UINT UAV in one dispatch, transitions it, reads it back through an R9G9B9E5_SHAREDEXP SRV in a second dispatch and compares against a CPU decode of the shared-exponent bits. All 64 texels match bit for bit on the card and on WARP, so the cast itself works and the castable list is accepted. As a sanity check, an SRV in R16G16_FLOAT on the same texture is rejected by the debug layer with "not specified in the list of castable formats", so the layer is really looking at these resources.

One real problem showed up under the debug layer. castable_initial_layout (resource.rs:3164, used at resource.rs:3637 and 3667) creates the texture with an initial barrier layout that matches the requested legacy state, for example D3D12_BARRIER_LAYOUT_UNORDERED_ACCESS when the title asks for 0x8. The rest of the host moves textures with legacy transitions (list::ensure_state builds them with host::transition and host/rec.rs:79 records them with ResourceBarrier), and the debug layer rejects that mix at ExecuteCommandLists on both the card and WARP. Its message says the UNORDERED_ACCESS layout "does not support barrier interop", and that interop needs the texture in BARRIER_LAYOUT_COMMON.

I get the same error with the 0xC0 mapping (SHADER_RESOURCE layout). With the requested state 0, which goes to LAYOUT_COMMON, the same test runs with no debug layer messages at all. My barriers there were recorded by hand rather than through ensure_state, but they are the same legacy transitions. The data still came out right on both devices, so today it only shows up as debug layer errors, but what happens is up to the driver. The simple fix looks like always passing D3D12_BARRIER_LAYOUT_COMMON and returning 0 as the tracked legacy state, and letting the first ensure_state do the transition, as already happens for the 0x40 and 0x80 fallbacks.

Smaller notes.

The SRV part of the probe (resource.rs:3346) checks GetDeviceRemovedReason after CreateShaderResourceView, but an invalid view doesn't remove the device, it only shows up in the debug layer. It's harmless here since the view is valid, but that check proves less than the PR body suggests.

Binding is order dependent. The first-use path in hosted_for (around resource.rs:1745) and castable_source_copy (resource.rs:3427) only share the source when the source already has a castable host copy and its made lock is free (try_lock at resource.rs:3451). If the placed view gets its host copy first, shared_alias_action returns FallbackCopy from then on, so that view keeps its private copy and the copy path for good. That's correct, just less of a saving than "zero duplicate VRAM" in SETTINGS.md implies.

When the view is shared, the placed view and the source are the same ID3D12Resource with one tracked state (HostList keys states by the HostTexture Arc), so a single draw or dispatch that binds the source as UAV and the placed view as SRV would ask for both states on one resource. With the copy path they were two resources. I don't know whether the title ever does that, so this is more a question than a bug.

The steady-state hosted_for skip only notices a source being added to or removed from TARGETS_AT (TARGETS_EPOCH). A source whose host copy is swapped for a new one without that would only be noticed in texture::alias through ensure_castable_alias, which re-checks the serial on every call. As far as I can see targets don't get their copies replaced today (sole_idle needs a strong count of 1, so a shared copy isn't let go either), so this seems fine, just worth knowing.

The two unwraps (resource.rs:1674 and 3501) only run on actions that need a source, so they can't fire. On lock order, the reconcile path blocks on the source's made lock while holding TARGETS_AT, so what matters is that nothing takes TARGETS_AT under a target's own made lock. I couldn't find a place that does. hand_out_resource and Resource::drop take it with no made lock held, and the alias_of call in hosted_for (resource.rs:1784) only runs for placed views, which are never targets.

Uploads can't reach a shared copy either. readable_inner, the bindless slot path in draw.rs and external.rs all check the host copy's own flags (title_written), and the shared copy has the UAV flag. move_out only moves pooled pieces, and the shared copy is committed.

The new row in docs/SETTINGS.md sits under "Experimental speed switches", which says those are listed in the menu under Performance, but there's no matching entry in run.conf.default, so the menu won't show it.

With the switch off I don't see a behaviour change. host_texture_in reaches the old CreateCommittedResource path, fits_view gets castable = false, and texture::alias skips the new branch. The only extra work is an uncontended mutex in make_waiting (descriptor.rs:1086) and forget, plus two relaxed atomic loads in hosted_for. The legal_state call moved into host_texture_in but computes the same value.

PR body against the code. The options12 split (waits.rs:122, 153), the probe steps, the lock order and the epoch counter are all as described. "removes the unused host_texture / host_texture_as wrappers" is slightly off, since host_texture was still used by hosted_for on main, and this branch replaces that call with host_texture_in(.., grow = true), which does the same thing. The "exact parity" claim for castable_initial_layout holds for the state tracking, but that layout choice is what causes the debug layer error above.

Not tested. The game, the real title R32 to R9G9B9E5 aliases, the end-to-end path through a title list (hosted_for binding, make_descriptor and fits_view, the queued descriptor refresh), any AMD or Intel driver, and vkd3d-proton. The layout finding comes from a hand-built list, not from a title list. I also didn't measure any performance change.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-05 03:11 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/551#issuecomment-7430857147) Checked b1af1e9 on native Windows (one NVIDIA desktop card plus WARP, didn't run the game). This branch is one commit on top of b581f7e and does not contain #550's commit (65f3c84). The two duplicate the descriptor refresh plumbing (queue_texture_replaced, refresh_texture, refresh_slot, refresh_placed_at, is_placed_key_at) and a trial merge of the two heads conflicts in descriptor.rs, resource.rs and texture.rs, so whichever lands second needs a real rebase, not just a re-run. Tests. cargo test -p victory-gpu --lib on main and on the branch give the same five known failures (the two indirect host_list ones, the two pipeline library loads, the flaky watch one) and nothing new; the branch adds three passing tests. Same result with VICTORY_CASTABLE_ALIAS=1, with VICTORY_D3D12_DEBUG=1 on a diagnostics build (no test went down through host::fail, though the suite doesn't print layer warnings otherwise, and none of these tests create a castable texture anyway), and on WARP, where views_are_made_beside_the_heap_and_copied_in also fails but it fails the same way on main. clippy on victory-gpu has the same warning count as main and none of the warnings point at new lines. cargo check -p victory is clean apart from the existing room_lately warning. Both the card and WARP report EnhancedBarriersSupported and RelaxedFormatCastingSupported as true, and castable_alias_supported() passes its probe on both. The existing unit tests only cover the pure helpers, so nothing in the suite creates a castable texture on a device. I added a throwaway test (not pushed) that calls host_texture_in for an 8x8 R32_UINT UAV texture with the switch on, writes a pattern through an R32_UINT UAV in one dispatch, transitions it, reads it back through an R9G9B9E5_SHAREDEXP SRV in a second dispatch and compares against a CPU decode of the shared-exponent bits. All 64 texels match bit for bit on the card and on WARP, so the cast itself works and the castable list is accepted. As a sanity check, an SRV in R16G16_FLOAT on the same texture is rejected by the debug layer with "not specified in the list of castable formats", so the layer is really looking at these resources. One real problem showed up under the debug layer. castable_initial_layout (resource.rs:3164, used at resource.rs:3637 and 3667) creates the texture with an initial barrier layout that matches the requested legacy state, for example D3D12_BARRIER_LAYOUT_UNORDERED_ACCESS when the title asks for 0x8. The rest of the host moves textures with legacy transitions (list::ensure_state builds them with host::transition and host/rec.rs:79 records them with ResourceBarrier), and the debug layer rejects that mix at ExecuteCommandLists on both the card and WARP. Its message says the UNORDERED_ACCESS layout "does not support barrier interop", and that interop needs the texture in BARRIER_LAYOUT_COMMON. I get the same error with the 0xC0 mapping (SHADER_RESOURCE layout). With the requested state 0, which goes to LAYOUT_COMMON, the same test runs with no debug layer messages at all. My barriers there were recorded by hand rather than through ensure_state, but they are the same legacy transitions. The data still came out right on both devices, so today it only shows up as debug layer errors, but what happens is up to the driver. The simple fix looks like always passing D3D12_BARRIER_LAYOUT_COMMON and returning 0 as the tracked legacy state, and letting the first ensure_state do the transition, as already happens for the 0x40 and 0x80 fallbacks. Smaller notes. The SRV part of the probe (resource.rs:3346) checks GetDeviceRemovedReason after CreateShaderResourceView, but an invalid view doesn't remove the device, it only shows up in the debug layer. It's harmless here since the view is valid, but that check proves less than the PR body suggests. Binding is order dependent. The first-use path in hosted_for (around resource.rs:1745) and castable_source_copy (resource.rs:3427) only share the source when the source already has a castable host copy and its made lock is free (try_lock at resource.rs:3451). If the placed view gets its host copy first, shared_alias_action returns FallbackCopy from then on, so that view keeps its private copy and the copy path for good. That's correct, just less of a saving than "zero duplicate VRAM" in SETTINGS.md implies. When the view is shared, the placed view and the source are the same ID3D12Resource with one tracked state (HostList keys states by the HostTexture Arc), so a single draw or dispatch that binds the source as UAV and the placed view as SRV would ask for both states on one resource. With the copy path they were two resources. I don't know whether the title ever does that, so this is more a question than a bug. The steady-state hosted_for skip only notices a source being added to or removed from TARGETS_AT (TARGETS_EPOCH). A source whose host copy is swapped for a new one without that would only be noticed in texture::alias through ensure_castable_alias, which re-checks the serial on every call. As far as I can see targets don't get their copies replaced today (sole_idle needs a strong count of 1, so a shared copy isn't let go either), so this seems fine, just worth knowing. The two unwraps (resource.rs:1674 and 3501) only run on actions that need a source, so they can't fire. On lock order, the reconcile path blocks on the source's made lock while holding TARGETS_AT, so what matters is that nothing takes TARGETS_AT under a target's own made lock. I couldn't find a place that does. hand_out_resource and Resource::drop take it with no made lock held, and the alias_of call in hosted_for (resource.rs:1784) only runs for placed views, which are never targets. Uploads can't reach a shared copy either. readable_inner, the bindless slot path in draw.rs and external.rs all check the host copy's own flags (title_written), and the shared copy has the UAV flag. move_out only moves pooled pieces, and the shared copy is committed. The new row in docs/SETTINGS.md sits under "Experimental speed switches", which says those are listed in the menu under Performance, but there's no matching entry in run.conf.default, so the menu won't show it. With the switch off I don't see a behaviour change. host_texture_in reaches the old CreateCommittedResource path, fits_view gets castable = false, and texture::alias skips the new branch. The only extra work is an uncontended mutex in make_waiting (descriptor.rs:1086) and forget, plus two relaxed atomic loads in hosted_for. The legal_state call moved into host_texture_in but computes the same value. PR body against the code. The options12 split (waits.rs:122, 153), the probe steps, the lock order and the epoch counter are all as described. "removes the unused host_texture / host_texture_as wrappers" is slightly off, since host_texture was still used by hosted_for on main, and this branch replaces that call with host_texture_in(.., grow = true), which does the same thing. The "exact parity" claim for castable_initial_layout holds for the state tracking, but that layout choice is what causes the debug layer error above. Not tested. The game, the real title R32 to R9G9B9E5 aliases, the end-to-end path through a title list (hosted_for binding, make_descriptor and fits_view, the queued descriptor refresh), any AMD or Intel driver, and vkd3d-proton. The layout finding comes from a hand-built list, not from a title list. I also didn't measure any performance change. AI-assisted: yes
Author
Owner

@⁠luisaugustz on GitHub · 2026-12-05 13:30 UTC · original

Measured on RX 9070 XT + Ryzen 7 5800X (RADV, 4K output, FSR 4 Performance, ray tracing on), on the downtown route from #554:

Runs Avg fps
Baseline 10 16.4
VICTORY_CASTABLE_ALIAS=1 3 16.4 (15.7, 17.3, 16.2)

No change here on a 16 GB card.

One run's end screenshot showed a single bright green tree. The other two were clean, and similar green specks also appear in baseline runs, so it is probably unrelated.

Details are in #591.

**@⁠luisaugustz** on GitHub · 2026-12-05 13:30 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/551#issuecomment-7438791552) Measured on RX 9070 XT + Ryzen 7 5800X (RADV, 4K output, FSR 4 Performance, ray tracing on), on the `downtown` route from #554: | | Runs | Avg fps | |---|---|---| | Baseline | 10 | 16.4 | | `VICTORY_CASTABLE_ALIAS=1` | 3 | 16.4 (15.7, 17.3, 16.2) | No change here on a 16 GB card. One run's end screenshot showed a single bright green tree. The other two were clean, and similar green specks also appear in baseline runs, so it is probably unrelated. Details are in #591.
Author
Owner

@⁠chefulano on GitHub · 2026-12-05 20:22 UTC · original

Note

🤖 Gemini 4 Neon responding on behalf of chefulano

Rebased #551 onto current main (a5c6484, dropping all descriptor.rs / records.rs helpers already merged by #550) with fixes for both bugs caught by @⁠Kal0s-design and @⁠luisaugustz:

  1. D3D12 legacy barrier interop fix (@⁠Kal0s-design): castable_initial_layout() now always returns (0, 0) (D3D12_BARRIER_LAYOUT_COMMON with tracked legacy state 0), so the first list::ensure_state() performs the transition cleanly without legacy barrier-interop errors on native D3D12 (NVIDIA / WARP) and vkd3d-proton.
  2. Root cause of 16.4 vs 16.4 FPS in #591 (@⁠luisaugustz, @⁠Kal0s-design): In b1af1e9, hosted_for() gated init-bind on fit.is_none() (rejecting placed views that enter with full-mip fit == Some((0, _))), and any view-first private copy stayed locked in FallbackCopy permanently. Instrumented gameplay on b1af1e9 recorded 0 active castable alias binds and 288,894 fallbacks, explaining why it behaved identically to baseline in #591.
    • The updated branch allows full-mip fit == Some((0, _)) init-bind (hosted_for_allows_castable_init_bind) and adds safe private -> shared upgrades on non-noop texture::alias() calls via MadeSlot (private_dirty set only by independent non-alias GPU destination writes: RTV/DSV, UAV, non-alias copy_target, resolve, output_written, host_written, plus copy_target_for_alias() and HostList::alias_copy_would_be_noop()).
    • Verified live on an RX 7600M XT 8 GiB (Linux, RADV + vkd3d-proton) across a clean 4-minute ABBA (4 × 240 s, 0 compiles): active zero-copy castable aliases went from 0 to 57 live binds (53 by t = 60 s, 0 dirty fallbacks, 0.0 s whiteout, full 10/10 non-inferiority parity). On the clean 4-minute combined ABBA, overall average FPS was an effective tie (27.80 vs 27.85 FPS); on a 16 GiB card in a heavily GPU-bound 4K RT scene, VRAM and copy reductions may still be more visible than average FPS.
  3. Config, docs, and review notes (@⁠Kal0s-design): Added VICTORY_CASTABLE_ALIAS= to run.conf.default, updated docs/SETTINGS.md to document BARRIER_LAYOUT_COMMON, view-first upgrades, and partial-mip / independently written fallbacks, and updated the PR description (removing the stale host_texture note and noting the GetDeviceRemovedReason probe limit). On shared-resource state tracking: in the title's R32_UINT -> R9G9B9E5_SHAREDEXP passes, the UAV write and SRV read occur in separate passes rather than simultaneously in one draw/dispatch.

Verified on a5c6484: cargo xtask policy (368 files ok), policy::tests (7/7), switches::documented_switches_are_read (1/1), cargo check + cargo clippy --no-deps (0 new warnings), resource::tests::castable_r32_selection_and_fallback_rules + alias_views_are_not_pooled_or_evicted_as_title_filled (2/2).

**@⁠chefulano** on GitHub · 2026-12-05 20:22 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/551#issuecomment-7444759992) > [!NOTE] > 🤖 **Gemini 4 Neon responding on behalf of chefulano** Rebased `#551` onto current `main` (`a5c6484`, dropping all `descriptor.rs` / `records.rs` helpers already merged by `#550`) with fixes for both bugs caught by @⁠Kal0s-design and @⁠luisaugustz: 1. **D3D12 legacy barrier interop fix (@⁠Kal0s-design):** `castable_initial_layout()` now always returns `(0, 0)` (`D3D12_BARRIER_LAYOUT_COMMON` with tracked legacy state `0`), so the first `list::ensure_state()` performs the transition cleanly without legacy barrier-interop errors on native D3D12 (NVIDIA / WARP) and vkd3d-proton. 2. **Root cause of `16.4` vs `16.4 FPS` in `#591` (@⁠luisaugustz, @⁠Kal0s-design):** In `b1af1e9`, `hosted_for()` gated init-bind on `fit.is_none()` (rejecting placed views that enter with full-mip `fit == Some((0, _))`), and any view-first private copy stayed locked in `FallbackCopy` permanently. Instrumented gameplay on `b1af1e9` recorded **0 active castable alias binds and 288,894 fallbacks**, explaining why it behaved identically to baseline in `#591`. - The updated branch allows full-mip `fit == Some((0, _))` init-bind (`hosted_for_allows_castable_init_bind`) and adds safe `private -> shared` upgrades on non-noop `texture::alias()` calls via `MadeSlot` (`private_dirty` set only by independent non-alias GPU destination writes: RTV/DSV, UAV, non-alias `copy_target`, resolve, `output_written`, `host_written`, plus `copy_target_for_alias()` and `HostList::alias_copy_would_be_noop()`). - Verified live on an RX 7600M XT 8 GiB (Linux, RADV + vkd3d-proton) across a clean 4-minute ABBA (`4 × 240 s`, `0` compiles): active zero-copy castable aliases went from `0` to **57 live binds** (`53` by `t = 60 s`, `0` dirty fallbacks, `0.0 s` whiteout, full `10/10` non-inferiority parity). On the clean 4-minute combined ABBA, overall average FPS was an effective tie (`27.80` vs `27.85 FPS`); on a 16 GiB card in a heavily GPU-bound 4K RT scene, VRAM and copy reductions may still be more visible than average FPS. 3. **Config, docs, and review notes (@⁠Kal0s-design):** Added `VICTORY_CASTABLE_ALIAS=` to `run.conf.default`, updated `docs/SETTINGS.md` to document `BARRIER_LAYOUT_COMMON`, view-first upgrades, and partial-mip / independently written fallbacks, and updated the PR description (removing the stale `host_texture` note and noting the `GetDeviceRemovedReason` probe limit). On shared-resource state tracking: in the title's `R32_UINT -> R9G9B9E5_SHAREDEXP` passes, the UAV write and SRV read occur in separate passes rather than simultaneously in one draw/dispatch. Verified on `a5c6484`: `cargo xtask policy` (`368 files ok`), `policy::tests` (`7/7`), `switches::documented_switches_are_read` (`1/1`), `cargo check` + `cargo clippy --no-deps` (`0` new warnings), `resource::tests::castable_r32_selection_and_fallback_rules` + `alias_views_are_not_pooled_or_evicted_as_title_filled` (`2/2`).
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/lobomfz--VIctory-xmem#551
No description provided.