Placed texture UAVs: land writes on the title resource, not a stand-in #97

Open
github-bot wants to merge 3 commits from github-bot/gh-97 into main AGit
Owner

@⁠kalijerry on GitHub · 2026-11-26 03:23 UTC · original
kalijerry:fix/placed-texture-uav → main · +219 −25 · 5 files · 3 commits · open

The bug

A placed texture bound as a UAV was mirrored to a stand-in resource nothing else read. Shader writes through it landed on the stand-in and were dropped, while every other view kept reading the title's memory.

The visible result: the ray-tracing structure builder ran, produced nothing useful, and the world's interiors rendered black - direct light only, no bounce, no shadow. Once writes landed on the right resource the picture was correct again.

The fix

Keep one resource per placed address. When several exist, the title's own allocation wins - a synthetic copy must never displace it. A descriptor made from a title resource holds a reference on it while it lives, so the object cannot be freed under an in-flight descriptor.

  • TARGETS_AT became per-address lists; the title's object is inserted first and looked up last.
  • writable_texture_at hands back the title resource when the description's shape matches and it carries the flags asked for.
  • A descriptor made from a title resource is View::Unordered instead of View::Shader, so writes go back to the title memory rather than a copy.
  • A stand-in is made only when the title has created none.
  • ResourceRef is the reference holder; object::try_add_ref refuses a resource already at zero refs (its destructor takes the same lock).

Verification

  • cargo test -p victory-gpu --lib: 326 passed, 0 failed.
  • RTX 3080, builder on, live: interiors render with real bounce light and shadow. Frame 1377 (bar shadow across the face) and frame 1630 (dark interior correctly lit) versus the same scene with the builder off, which is a flat black frame.
  • The 98 "not mirrored" warnings that used to print every frame now only cover genuinely unresolvable views (address 0 SRVs), kept as a separate follow-up.
**@⁠kalijerry** on GitHub · 2026-11-26 03:23 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/97) `kalijerry:fix/placed-texture-uav` → `main` · +219 −25 · 5 files · 3 commits · open ## The bug A placed texture bound as a UAV was mirrored to a **stand-in resource nothing else read**. Shader writes through it landed on the stand-in and were dropped, while every other view kept reading the title's memory. The visible result: the ray-tracing structure builder ran, produced nothing useful, and **the world's interiors rendered black** - direct light only, no bounce, no shadow. Once writes landed on the right resource the picture was correct again. ## The fix Keep one resource per placed address. When several exist, the **title's own allocation wins** - a synthetic copy must never displace it. A descriptor made from a title resource holds a reference on it while it lives, so the object cannot be freed under an in-flight descriptor. - `TARGETS_AT` became per-address lists; the title's object is inserted first and looked up last. - `writable_texture_at` hands back the title resource when the description's shape matches and it carries the flags asked for. - A descriptor made from a title resource is `View::Unordered` instead of `View::Shader`, so writes go back to the title memory rather than a copy. - A stand-in is made only when the title has created none. - `ResourceRef` is the reference holder; `object::try_add_ref` refuses a resource already at zero refs (its destructor takes the same lock). ## Verification - `cargo test -p victory-gpu --lib`: **326 passed**, 0 failed. - RTX 3080, builder on, live: interiors render with real bounce light and shadow. Frame 1377 (bar shadow across the face) and frame 1630 (dark interior correctly lit) versus the same scene with the builder off, which is a flat black frame. - The 98 "not mirrored" warnings that used to print every frame now only cover genuinely unresolvable views (address 0 SRVs), kept as a separate follow-up.
A placed texture's UAV was mirrored to a stand-in that nothing else read,
so shader writes through it were lost (the ray-tracing structure builder
came out empty and the world went black inside). Keep one resource per
placed address, the title's own last when several exist, and take a
reference on it while a descriptor made from it lives. A stand-in is made
only when the title has created no resource there.

The address table became per-address lists so a synthetic copy made before
the title's object can never displace it, and a descriptor made from a
title resource is now a UAV (`View::Unordered`) so writes go back to it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:32:08 +00:00
Author
Owner

@⁠avatarmanz on GitHub · 2026-11-26 07:33 UTC · original

Not merged: the not-mirrored warning copies 24 words from before the view description (desc.sub(24)) in every build, and the diagnostics probes read 64 words around a title pointer. The placed-UAV change itself would need an in-game check.

**@⁠avatarmanz** on GitHub · 2026-11-26 07:33 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/97#issuecomment-7185585926) Not merged: the not-mirrored warning copies 24 words from before the view description (desc.sub(24)) in every build, and the diagnostics probes read 64 words around a title pointer. The placed-UAV change itself would need an in-game check.
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-26 18:36 UTC · original

I sent a fix to this PR’s source branch for the out-of-bounds diagnostic reads. Both messages now use only the descriptors passed to the API. The placed-view identity test and all eight descriptor tests passed under Wine with diagnostics enabled and disabled. The in-game check for the UAV change is still open. Source branch PR

**@⁠UwUCammie** on GitHub · 2026-11-26 18:36 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/97#issuecomment-7200649328) I sent a fix to this PR’s source branch for the out-of-bounds diagnostic reads. Both messages now use only the descriptors passed to the API. The placed-view identity test and all eight descriptor tests passed under Wine with diagnostics enabled and disabled. The in-game check for the UAV change is still open. [Source branch PR](https://github.com/kalijerry/VIctory-RTX3080/pull/1)
Author
Owner

@⁠akimfomin on GitHub · 2026-11-26 23:42 UTC · original

The #97 port onto 014d52dedf837d1ac660a0bd256c4704be9eeb40 needs one change beyond resolving draw.rs. I merged 856b6f87ea7b08b092a57b95796e962f0a703b2e locally and retained main's host_heaps_set. Git merged descriptor/host.rs automatically, but the new begun_before match then failed with E0308: one arm yielded PlacedTexture, the other View.

A local resolution kept let placed; alive through pool::begun_before, borrowed &placed.view in the placed arm, and returned view directly in the View::Shader arm. This keeps #97's resource owner alive during the lookup. On tree e7d0b88fbea83194211b1df36bbf7964ea85aa2e, cargo test --locked -p victory-gpu --lib placed_texture -- --test-threads=1 --nocapture built and all 4 tests passed on Windows. This is focused rebase evidence, with the full suite and the gameplay case still open. PortBridge · AI-assisted source and test report.

**@⁠akimfomin** on GitHub · 2026-11-26 23:42 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/97#issuecomment-7205775800) The #97 port onto `014d52dedf837d1ac660a0bd256c4704be9eeb40` needs one change beyond resolving `draw.rs`. I merged `856b6f87ea7b08b092a57b95796e962f0a703b2e` locally and retained main's `host_heaps_set`. Git merged `descriptor/host.rs` automatically, but the [new `begun_before` match](https://github.com/avatarmanz/VIctory-7900XTX/blob/014d52dedf837d1ac660a0bd256c4704be9eeb40/crates/victory-gpu/src/descriptor/host.rs#L371-L385) then failed with E0308: one arm yielded `PlacedTexture`, the other `View`. A local resolution kept `let placed;` alive through `pool::begun_before`, borrowed `&placed.view` in the placed arm, and returned `view` directly in the `View::Shader` arm. This keeps #97's resource owner alive during the lookup. On tree `e7d0b88fbea83194211b1df36bbf7964ea85aa2e`, `cargo test --locked -p victory-gpu --lib placed_texture -- --test-threads=1 --nocapture` built and all 4 tests passed on Windows. This is focused rebase evidence, with the full suite and the gameplay case still open. [PortBridge](https://github.com/akimfomin/PortBridge/issues/98) · AI-assisted source and test report.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/draw.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/97/head:github-bot/gh-97'
git switch 'github-bot/gh-97'

Merge

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