GPU: cache immutable HostTexture flags/format and descriptor heap start handles #2215

Closed
github-bot wants to merge 1 commit from gh-pr/2215/head into gh-pr/2215/base
Owner

@⁠RVZO6 on GitHub · 2026-11-25 08:05 UTC · original
RVZO6:rvzo/cache-texture-meta → main · +323 −79 · 7 files · 1 commits · closed without merging

Hot per-draw, barrier, descriptor, and texture-upload paths in victory-gpu currently repeat immutable COM queries (ID3D12Resource::GetDesc(), GetCPUDescriptorHandleForHeapStart(), GetGPUDescriptorHandleForHeapStart()), clone Arc<HostTexture> on every barrier/lookup, and compute legal_state() twice per resource barrier:

  1. HostTexture::new() already calls GetDesc() once, yet legal_state, view_format, takes, and title_written re-issue GetDesc() through D3D12 COM on every barrier, render-target/depth bind, and texture refresh.
  2. HostList::transition() and list.rs barriers each call legal_state() separately and clone Arc<HostTexture> just to read immutable fields.
  3. Host::rtv(), Host::dsv(), Host::cpu_view(), and HostHeap::gpu() invoke Get{CPU,GPU}DescriptorHandleForHeapStart() on every descriptor allocation/lookup even though a heap's start handle is immutable for its lifetime.

Claimed on #1633 (https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7155911614).

The change

  • crates/victory-gpu/src/resource.rs:
    • Cache immutable flags: D3D12_RESOURCE_FLAGS and format: DXGI_FORMAT on HostTexture from its existing GetDesc() in HostTexture::new().
    • Add host_copy_ref() to borrow HostTexture without hot-path Arc::clone where callers only inspect metadata/resource handles.
    • Use cached flags/format via pure helpers view_format_for and takes_meta, adding tests view_format_for_reports_own_pc_format_only_when_host_differs and takes_meta_checks_required_uses_and_format_compatibility.
  • crates/victory-gpu/src/host.rs, crates/victory-gpu/src/list.rs, crates/victory-gpu/src/draw.rs, crates/victory-gpu/src/texture.rs, crates/victory-gpu/src/bindless.rs:
    • Compute legal_for(flags, state) once inside HostList::transition() and return the resolved target state to barrier callers, eliminating duplicate GetDesc() calls and extra Arc clones.
    • Cache rtv_start, dsv_start, and cpu_view_start handles on Host (using pure ring_handle helper).
    • Add tests host::tests::legal_for_strips_only_states_forbidden_by_resource_flags, host::tests::ring_handle_offsets_and_wraps_across_rtv_ring, and texture::tests::title_written_flags_accepts_only_non_writable_textures.
  • crates/victory-gpu/src/descriptor/host.rs:
    • Cache gpu: u64 start handle on HostHeap and compute slot handles via pure gpu_handle arithmetic.
    • Add test descriptor::host::tests::gpu_handle_offsets_by_index_and_step.

Not a duplicate of

No open PR or CLAIMS.md entry caches immutable HostTexture flags/format, removes duplicate barrier GetDesc()/legal_state() calls, or caches Host / HostHeap descriptor-heap start handles. (#2187 addresses readable-texture sharing policy for shader-denied textures and is orthogonal.)

Tested

  • Fork windows-latest MSVC + Windows WARP SM 6.6 CI run 45572159221 (Clippy clean, Clippy, diagnostics build clean, Tests: 715 passed; 0 failed; 10 ignored, victory-gpu: 157 passed; 0 failed; 2 ignored + 1 passed, xtask: 6 passed; 0 failed):
    • descriptor::host::tests::gpu_handle_offsets_by_index_and_step ... ok
    • host::tests::legal_for_strips_only_states_forbidden_by_resource_flags ... ok
    • host::tests::ring_handle_offsets_and_wraps_across_rtv_ring ... ok
    • resource::tests::view_format_for_reports_own_pc_format_only_when_host_differs ... ok
    • resource::tests::takes_meta_checks_required_uses_and_format_compatibility ... ok
    • texture::tests::title_written_flags_accepts_only_non_writable_textures ... ok

Not run: the title; any hardware GPU. The title was not used in these tests.

AI-assisted: T3 Code (Antigravity, gemini-4-neon)

**@⁠RVZO6** on GitHub · 2026-11-25 08:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2215) `RVZO6:rvzo/cache-texture-meta` → `main` · +323 −79 · 7 files · 1 commits · closed without merging Hot per-draw, barrier, descriptor, and texture-upload paths in `victory-gpu` currently repeat immutable COM queries (`ID3D12Resource::GetDesc()`, `GetCPUDescriptorHandleForHeapStart()`, `GetGPUDescriptorHandleForHeapStart()`), clone `Arc<HostTexture>` on every barrier/lookup, and compute `legal_state()` twice per resource barrier: 1. `HostTexture::new()` already calls `GetDesc()` once, yet `legal_state`, `view_format`, `takes`, and `title_written` re-issue `GetDesc()` through D3D12 COM on every barrier, render-target/depth bind, and texture refresh. 2. `HostList::transition()` and `list.rs` barriers each call `legal_state()` separately and clone `Arc<HostTexture>` just to read immutable fields. 3. `Host::rtv()`, `Host::dsv()`, `Host::cpu_view()`, and `HostHeap::gpu()` invoke `Get{CPU,GPU}DescriptorHandleForHeapStart()` on every descriptor allocation/lookup even though a heap's start handle is immutable for its lifetime. Claimed on #1633 (`https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7155911614`). ## The change - `crates/victory-gpu/src/resource.rs`: - Cache immutable `flags: D3D12_RESOURCE_FLAGS` and `format: DXGI_FORMAT` on `HostTexture` from its existing `GetDesc()` in `HostTexture::new()`. - Add `host_copy_ref()` to borrow `HostTexture` without hot-path `Arc::clone` where callers only inspect metadata/resource handles. - Use cached `flags`/`format` via pure helpers `view_format_for` and `takes_meta`, adding tests `view_format_for_reports_own_pc_format_only_when_host_differs` and `takes_meta_checks_required_uses_and_format_compatibility`. - `crates/victory-gpu/src/host.rs`, `crates/victory-gpu/src/list.rs`, `crates/victory-gpu/src/draw.rs`, `crates/victory-gpu/src/texture.rs`, `crates/victory-gpu/src/bindless.rs`: - Compute `legal_for(flags, state)` once inside `HostList::transition()` and return the resolved target state to barrier callers, eliminating duplicate `GetDesc()` calls and extra `Arc` clones. - Cache `rtv_start`, `dsv_start`, and `cpu_view_start` handles on `Host` (using pure `ring_handle` helper). - Add tests `host::tests::legal_for_strips_only_states_forbidden_by_resource_flags`, `host::tests::ring_handle_offsets_and_wraps_across_rtv_ring`, and `texture::tests::title_written_flags_accepts_only_non_writable_textures`. - `crates/victory-gpu/src/descriptor/host.rs`: - Cache `gpu: u64` start handle on `HostHeap` and compute slot handles via pure `gpu_handle` arithmetic. - Add test `descriptor::host::tests::gpu_handle_offsets_by_index_and_step`. ## Not a duplicate of No open PR or `CLAIMS.md` entry caches immutable `HostTexture` `flags`/`format`, removes duplicate barrier `GetDesc()`/`legal_state()` calls, or caches `Host` / `HostHeap` descriptor-heap start handles. (`#2187` addresses readable-texture sharing policy for shader-denied textures and is orthogonal.) ## Tested - Fork `windows-latest` MSVC + Windows WARP SM 6.6 CI run [`45572159221`](https://github.com/RVZO6/VIctory/actions/runs/45572159221) (`Clippy` clean, `Clippy, diagnostics build` clean, `Tests`: **`715 passed; 0 failed; 10 ignored`**, `victory-gpu`: **`157 passed; 0 failed; 2 ignored`** + `1 passed`, `xtask`: **`6 passed; 0 failed`**): - `descriptor::host::tests::gpu_handle_offsets_by_index_and_step ... ok` - `host::tests::legal_for_strips_only_states_forbidden_by_resource_flags ... ok` - `host::tests::ring_handle_offsets_and_wraps_across_rtv_ring ... ok` - `resource::tests::view_format_for_reports_own_pc_format_only_when_host_differs ... ok` - `resource::tests::takes_meta_checks_required_uses_and_format_compatibility ... ok` - `texture::tests::title_written_flags_accepts_only_non_writable_textures ... ok` **Not run:** the title; any hardware GPU. The title was not used in these tests. AI-assisted: T3 Code (Antigravity, gemini-4-neon)
Cache immutable D3D12_RESOURCE_DESC flags/format on HostTexture from its existing GetDesc() in HostTexture::new(), borrow HostTexture via host_copy_ref() to avoid hot-path Arc clones, compute legal_for() once in HostList::transition() and return the resolved target state to barrier callers, and cache descriptor heap start handles on Host and HostHeap.

Assisted-by: T3 Code (Antigravity, gemini-4-neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:58:41 +00:00
github-bot closed this pull request 2026-11-26 04:58:41 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:30 UTC · original · edited 2026-11-25 16:04 UTC

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/bindless.rs, crates/victory-gpu/src/descriptor/host.rs, crates/victory-gpu/src/draw.rs, crates/victory-gpu/src/host.rs, crates/victory-gpu/src/list.rs, crates/victory-gpu/src/resource.rs, crates/victory-gpu/src/texture.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (needs-work) was for an older state of main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 13:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2215#issuecomment-7163867511) · edited 2026-11-25 16:04 UTC <!-- victory-triage v1 head=595a7da2327818d6c3b59b9fecce265fc102f1ba verdict=needs-rebase at=2026-11-25T16:15:00Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-gpu/src/bindless.rs`, `crates/victory-gpu/src/descriptor/host.rs`, `crates/victory-gpu/src/draw.rs`, `crates/victory-gpu/src/host.rs`, `crates/victory-gpu/src/list.rs`, `crates/victory-gpu/src/resource.rs`, `crates/victory-gpu/src/texture.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (needs-work) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠RVZO6 on GitHub · 2026-11-25 17:13 UTC · original

Closing to keep the queue clean: texture.rs/resource.rs/draw.rs were heavily updated on 13f91ca and I do not have a title run to profile this path.

**@⁠RVZO6** on GitHub · 2026-11-25 17:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2215#issuecomment-7169200680) Closing to keep the queue clean: `texture.rs`/`resource.rs`/`draw.rs` were heavily updated on `13f91ca` and I do not have a title run to profile this path.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/Marvisak--VIctory!2215
No description provided.