Skip to content

GPU: mirror placed unordered texture views onto host textures - #114

Open
Kaivyyy wants to merge 1 commit into
fxceless:mainfrom
Kaivyyy:gpu/placed-uav-textures
Open

Kaivyyy wants to merge 1 commit into
fxceless:mainfrom
Kaivyyy:gpu/placed-uav-textures

Conversation

@Kaivyyy

@Kaivyyy Kaivyyy commented Nov 24, 2026

Copy link
Copy Markdown

Summary

  • Add resource::uav_texture_at for placed unordered texture views (View::Placed(true, ...) where dimension != BUFFER): reuses a compatible unordered-access texture already recorded in TARGETS_AT at that address when present, or creates a placed ALLOW_UNORDERED_ACCESS texture starting in D3D12_RESOURCE_STATE_UNORDERED_ACCESS (normalizing mismatched resource vs. UAV formats such as R9G9B9E5_SHAREDEXP viewed as R32_UINT) and records it in TARGETS_AT.
  • Route placed unordered texture views through descriptor::host::placed_texture and make instead of dropping them with placed unordered texture view not mirrored, and mirror them when written into shader-visible view heaps (View::is_buffer returns false for placed unordered textures, matching texture-object UAVs) so shaders indexing ResourceDescriptorHeap directly see them as well.
  • Strip target/UAV flags on placed shader-resource views (View::Placed(false, ...)) before texture_at so they never overwrite TARGETS_AT and continue to GPU-copy texels from TARGETS_AT via resource::alias_of / texture::alias.

Addresses WARN victory_gpu::descriptor::host: placed unordered texture view not mirrored in #26.

Testing

  • Added descriptor::host::tests::placed_unordered_texture_view_mirrors_and_aliases_to_shader_view, covering 3D placed UAV mirroring on a shader-visible heap, reuse of existing TARGETS_AT resources, and GPU texel aliasing from an R32_UINT placed UAV into an R9G9B9E5_SHAREDEXP placed SRV.
  • cargo test -p victory-gpu --locked -- descriptor
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo xtask policy

Give placed unordered texture views (2D, array and 3D) a host unordered-access texture at their placed address (reusing an existing compatible target at that address when present), mirror them immediately when written into shader-visible heaps, and keep TARGETS_AT intact when placed shader views carry target flags so cross-format placed SRVs alias the shader-written texels on the GPU.
@SkillIssueXO

Copy link
Copy Markdown

I tested d5c277e on an RTX 5070 Ti (621.24), Series X profile, with default renderer switches and VICTORY_DUMP_TARGETS=1 for the selected captures. The placed-UAV mirror/alias GPU test passed locally. The game reached Antonia’s dialogue, where the dark interior and missing wall/ceiling surfaces were still reproducible.

At frame 1900, the openings visible in the presented image were already visible in the 2560×1440 opaque depth and material targets. The main depth target was verified against the opaque draws in the same frame’s ops trace. It had stencil 0x08 set on 3,568,377 / 3,686,400 pixels (96.8%). At frame 2150 that was 3,684,729 / 3,686,400 (99.95%). The indoor marker survives on this run. The aggregate counts leave its per-surface accuracy open.

This was a PR-head verification of the remaining symptom. The run used no shader skips and no Relay. AI-assisted capture analysis (Codex, with Claude Code source review).

Korsuma added a commit to RicerBoy/DropItLikeItsHot that referenced this pull request Nov 24, 2026
… (#82), core/VRAM scaling (#49/#38/#42/#45/#47), scatter batching (#108), prelude textures (#80), and shader/UAV fixes

Integrates 15 upstream PRs orthogonal to Issue #2's default speed-switch measurements:
- GPU culling & compute cap:
  - Marvisak/VIctory#1731: real host D3D12 occlusion queries (wired into read_backs for both sync execute and async VICTORY_RELAY/LATE_WAIT flights)
  - fxceless/victory-fork#82: hardware depth-bounds test pass-through in pipelines and command lists
  - fxceless/victory-fork#66: lower default compute shader loop cap (4096 -> 256)
- CPU multicore, streaming & memory/VRAM scaling:
  - fxceless/victory-fork#49: scale shadow, pipeline (keeping VICTORY_PIPELINE_THREADS override), and DirectStorage workers with CPU cores
  - fxceless/victory-fork#38: default-on parallel host-copy refreshes on >=4 logical CPUs (VICTORY_WIDE_REFRESH=0 opts out)
  - fxceless/victory-fork#108: batch adjacent zero-page unmaps in XMemMapPhysicalPagesScatter
  - fxceless/victory-fork#67: release directly indexed buffer ranges with their heap
  - fxceless/victory-fork#42, #45, #47: auto-scale card buffers, texture staging/floor, and snapshot/scratch/list pools from VRAM and RAM
- Rendering smoothness & correctness:
  - fxceless/victory-fork#80: upload dirty title textures in HostList::prelude
  - fxceless/victory-fork#114: mirror placed unordered texture views onto host textures
  - fxceless/victory-fork#121: preserve VGPR slots observed by relative reads
  - fxceless/victory-fork#122: recompute ISG1 input usage and barycentrics flag after bitcode opt
  - fxceless/victory-fork#112: fix DXIL signature ordering for packed semantics

Verified:
- cargo xtask policy --staged: 21 files ok
- cargo clippy --workspace --all-features --lib --tests -- -D warnings: 0 warnings
- cargo test --workspace: 0 failures (140 victory-gpu incl. host occlusion query + depth-bounds tests; 226/226 victory-shader)
- Live 2560x1440 run (RTX 4080, VICTORY_RELAY=2 + VICTORY_INPLACE=1): reached 3D world (frame 1285), 77 in-place windows (364 MB, 0 refused), 0.0 ms texture remap waits, 0 crashes, 0 D3D12 errors

Fixes #10

Copy link
Copy Markdown

Linux/NVIDIA integration test of d5c277e on 4e17478b + #20 (14a1f07) + #98 (e8cad1e). RTX 5090 / Linux NVIDIA 620.73.4 / GE-Proton11-14. All title and GPU tests offline.

The new placed_unordered_texture_view_mirrors_and_aliases_to_shader_view test passes here. Complete GPU suite: 119 passed, 2 known vkd3d pipeline-library failures, 3 ignored (two ignored tests are local diagnostics). Diagnostic build, workspace all-target/all-feature Clippy with -D warnings, and native asset policy pass. The full workspace before adding this PR had 501 passes and 6 existing compatibility failures; only the affected GPU suite was rerun after adding it.

Runtime evidence:

  • With Cap the host view heap on every GPU: AMD page-faulted at view slot 2^23 #98 alone, the world-loading run logs placed unordered texture view not mirrored dimension=3 once.
  • With this PR added, that warning is absent. The normal run still ends in Xid 13 / MMU fault after 101.1 s (exit 5). Per-command timestamp readback reaches an indirect dispatch of 0452fc2d2e2fc4c3; the next marker remains zero. 893/893 dumped SPIR-V modules validate for Vulkan 1.3 with scalar block layout.
  • A second run of the same binary, adding shader and render-target capture, advances farther and ends after 233.1 s (exit 5, Xid 109). Its last reached marker is before direct dispatch 55679a0547649d0b; the next marker remains zero. 1461/1461 dumped modules validate. The missing placed-UAV warning remains absent.

The final captures are still story-card/blank output, and sampled intermediate targets do not establish recognizable world geometry. This verifies the added texture path and removes the observed warning, but does not demonstrate a crash fix or normal world visuals. Capture readbacks and warm caches change timing, so the longer second run is not a stability claim. The timeout/marker instrumentation is local, opt-in diagnostic code; timestamps locate an interval rather than proving the cause of corruption. Normal shaders, loop limit 256, no shader skips.

Heap-clamp findings and baseline details: #98 (comment). No game data, images, or raw crash logs attached.

@ryotdev

ryotdev commented Nov 25, 2026

Copy link
Copy Markdown

I found an address-reuse case where the SRV loses its source. On d5c277e, I created a placed UAV and its paired SRV, used the same address for a temporary target with a different width, then released that target. Looking up the original UAV returned its cached resource, but alias_of returned None for the paired SRV.

The fix restores the cached resource to TARGETS_AT when its entry is vacant. The regression also repeats the lookup while the temporary target is alive and verifies that it keeps its own SRV alias. Fix and regression test

The regression failed on the PR head and passed with the fix on Windows. The full victory-gpu library suite passed 112 tests with one ignored, including the existing placed-UAV texel-readback test. The asset-policy check passed. AI-assisted. The effect on game lighting is unmeasured.

Copy link
Copy Markdown

I tested the 2D placed-UAV path against the texture readback now on main. The synthetic resource was a 256×256 R32_FLOAT texture with one mip and a sentinel in title memory. The test creates the placed UAV, mirrors its descriptor, records a GPU clear to 4.0 through that descriptor, submits the list, and checks each texel in its tiled CPU layout with VICTORY_TEXTURE_BACK=1.

Build Adapter Result
9c184b3 WARP The placed view had no host UAV. The title allocation retained its sentinel.
9c184b3 + d5c277e WARP All 65,536 texels read back as 4.0.
Same patched build RTX 4080, driver 621.14 All 65,536 texels read back as 4.0.

The opt-in test is available as a single commit on top of that merge. Run cargo test -p victory-gpu --locked --features diagnostics placed_water_feedback -- --ignored --nocapture. Set VICTORY_D3D12_WARP=1 for software or leave it unset for hardware. Test source and commit

This exercises the 2D view type seen in #26 and a format used by the water readback. The game report does not identify that particular texture's format. Gameplay impact remains unverified.

nullexxx pushed a commit to nullexxx/victory-fork that referenced this pull request Nov 25, 2026
…less#114)

XAsyncComplete held the call's `done` lock while the title's provider
ran OP_CLEANUP. A cleanup that waits for a worker thread which is itself
completing the same call (it took the call before the cleanup removed
it) deadlocked: the worker blocks on `done`. The first completion now
claims the call with an atomic flag and runs unlocked; the status is
still published after the cleanup, while the block is valid, and `done`
is set only for the waiters.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
dkdknight added a commit to dkdknight/victory-fork that referenced this pull request Nov 26, 2026
From avatarmanz/VIctory-7900XTX PR fxceless#114 (secure-silicon), re-implemented
on this tree, which also lacked its prerequisite (VIctory 4243a96: the
kind of a view picked from the heap).

The face network keeps its 16-bit halves in R16_UINT views held in
descriptor tables and reads and writes them with `_d16` typed accesses.
The translator took all d16 data as f16 through a float path: an
integer's bits taken as a float are a denormal, whose f16 is 0, so the
network's results were all zero, a face at rest.

- victory-shader: the word of the table of strides (SLOT_STRIDES) now
  holds the stride in its low 30 bits (VIEW_STRIDE_BITS) and the view's
  kind in the top two (VIEW_INTEGER, VIEW_SIGNED). `integer_view` reads
  that word for a view picked from the heap and for a view in a table
  (`slot_word(src, tables)`); d16 typed loads of an integer view keep the
  low 16 bits, d16 typed stores zero- or sign-extend them. Other views:
  f16 <-> f32 as before. (The handle stays a float one, whose bits the
  drivers pass.)
- victory-gpu: `view_kind` / `stride_word` give the word for a view;
  title slots get it when the title writes them (note_buffer), and the
  dynamic slots of a table made afresh in `State::tables` get it through
  `HostHeap::dynamic_word` (they had no word before). The table may live
  in a GPU upload heap (VICTORY_TABLES_ON_CARD): only written, never read
  on the CPU.

Tests: emit::memory_tests::d16_reads_of_an_integer_view_in_a_table_keep_
their_bits (GPU and WARP: an R16_UINT view in a table read with
buffer_load_format_d16_x; all zeros without the change, the halves with
it), descriptor::tests::a_fresh_table_writes_its_slots_words_of_the_table_
of_strides, descriptor::host::tests::integer_typed_buffer_views_are_
marked_in_the_table_of_strides.

Programs with d16 typed accesses to views in tables now bind the table
of strides, so they ask for the heap pass (once a frame), as programs
that pick views from the heap already do. Every shader is translated
anew (the translator changed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants