GPU: say when a draw's render target has no host copy or lost its permission #1700

Open
github-bot wants to merge 1 commit from github-bot/gh-1700 into main AGit
Owner

@⁠fiestorra on GitHub · 2026-11-24 20:52 UTC · original
fiestorra:fix/target-without-permission → main · +38 −1 · 1 files · 1 commits · open

A draw that renders into nothing now says so

crates/victory-gpu/src/draw.rs, set_targets (the title's OMSetRenderTargets): two ways a render target can be lost were silent.

            let Some(texture) = crate::resource::host_resource(record.resource) else {
                continue;                                  // <- nothing logged
            };
            ...
            rtvs.push(host.rtv(texture, record.desc().as_ref()));   // <- no permission checked
  • A render target whose resource has no host copy was skipped without a word, while the arm just above it ("render target without a recorded view") already warns once.
  • A host copy that lost ALLOW_RENDER_TARGET got a render target view anyway: CreateRenderTargetView returns void, so a refusal is invisible, D3D12 binds an empty descriptor, and the draw renders into nothing. The same for depth and ALLOW_DEPTH_STENCIL, where ? skipped the depth buffer silently.

Why it is worth naming now: resource::host_texture deliberately gives up what the host refuses (that is the point of #1630), and on the RTX 4090 the title's two 2560×1440 targets come out exactly like that — the B4G4R4A4_UNORM one is made as plain memory (flags_made=0) because that adapter refuses it as a render target at all (#1600). So a target can exist, be named by a draw, and be unrenderable, with the only trace being one line at creation time.

The change:

  • both arms warn once, with the resource handle, in the same shape as the existing arm;
  • a target without the permission is skipped rather than bound as an empty descriptor, and depth without ALLOW_DEPTH_STENCIL is skipped with its own line instead of ?.

Verification

  • No new line on either adapter of this machine in boots of 45, 60 and 75 seconds: integrated GPU 1,024 frames, RTX 4090 1,024 and 2,048 frames — so the check does not fire where nothing is wrong.
  • cargo test -p victory-gpu --locked → 50 passed, 1 ignored; cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings clean; rustfmt --check clean for the lines added.

What I did not capture: a live draw binding one of those targets in a run. The title only creates those two 2560×1440 targets in some runs (they appear in one 60-second run and not in the next two on the same adapter), so the positive path is reasoned from the creation-time fallback line rather than observed here. If someone can run it where those targets appear, the new line names the resource.

No game data is involved: resource handles and flags only.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-11-24 20:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/1700) `fiestorra:fix/target-without-permission` → `main` · +38 −1 · 1 files · 1 commits · open **A draw that renders into nothing now says so** `crates/victory-gpu/src/draw.rs`, `set_targets` (the title's `OMSetRenderTargets`): two ways a render target can be lost were silent. ```rust let Some(texture) = crate::resource::host_resource(record.resource) else { continue; // <- nothing logged }; ... rtvs.push(host.rtv(texture, record.desc().as_ref())); // <- no permission checked ``` - A render target whose resource has **no host copy** was skipped without a word, while the arm just above it ("render target without a recorded view") already warns once. - A host copy that **lost `ALLOW_RENDER_TARGET`** got a render target view anyway: `CreateRenderTargetView` returns `void`, so a refusal is invisible, D3D12 binds an empty descriptor, and the draw renders into nothing. The same for depth and `ALLOW_DEPTH_STENCIL`, where `?` skipped the depth buffer silently. Why it is worth naming now: `resource::host_texture` deliberately gives up what the host refuses (that is the point of https://git.gtahub.st/github/Marvisak--VIctory/pulls/1630), and on the **RTX 4090** the title's two 2560×1440 targets come out exactly like that — the `B4G4R4A4_UNORM` one is made as plain memory (`flags_made=0`) because that adapter refuses it as a render target at all (https://git.gtahub.st/github/Marvisak--VIctory/issues/1600). So a target can exist, be named by a draw, and be unrenderable, with the only trace being one line at creation time. The change: - both arms warn once, with the resource handle, in the same shape as the existing arm; - a target without the permission is **skipped** rather than bound as an empty descriptor, and depth without `ALLOW_DEPTH_STENCIL` is skipped with its own line instead of `?`. ### Verification - No new line on either adapter of this machine in boots of 45, 60 and 75 seconds: integrated GPU 1,024 frames, RTX 4090 1,024 and 2,048 frames — so the check does not fire where nothing is wrong. - `cargo test -p victory-gpu --locked` → 50 passed, 1 ignored; `cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings` clean; `rustfmt --check` clean for the lines added. **What I did not capture:** a live draw binding one of those targets in a run. The title only creates those two 2560×1440 targets in some runs (they appear in one 60-second run and not in the next two on the same adapter), so the positive path is reasoned from the creation-time fallback line rather than observed here. If someone can run it where those targets appear, the new line names the resource. No game data is involved: resource handles and flags only. Written with an AI assistant.
set_targets skipped a render target whose resource has no host copy in
silence, and made a render target view for one that lost
ALLOW_RENDER_TARGET anyway: CreateRenderTargetView returns nothing, D3D12
binds an empty descriptor, and the draw renders into nothing with no line
saying so. That is now reachable: resource::host_texture gives up the
permissions a host refuses (on the RTX 4090 the title's 2560x1440
B4G4R4A4_UNORM target is made as plain memory, flags 0), and the only trace
was the fallback line at creation.

Both arms now warn once, as the missing-view arm already did, and a target
without the permission is skipped instead of bound empty. Depth checks
ALLOW_DEPTH_STENCIL the same way.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:42:06 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:34 UTC · original

Automated triage for the maintainers.

Needs work. The new warning for a render target with no host copy (State::set_targets, draw.rs) is useful. Two problems with the permission check:

  1. Skipping a view with continue compacts rtvs, so every later target moves down a slot and the shader's SV_TargetN writes land in the wrong texture. Binding a null RTV in that slot would keep the indices.
  2. The case it guards depends on a fallback that drops ALLOW_RENDER_TARGET. main has no resource::host_texture and nothing that removes that flag; that fallback is #1630.

To change the verdict: keep the warnings, put a null descriptor in a skipped slot instead of compacting, and either rebase onto the fallback once it lands or show where main produces such a texture. CI passes.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1700#issuecomment-7152040014) <!-- victory-triage v1 head=c0f73dff7f1ece27bc59b96ecc8fc85c72a3d64c verdict=needs-work at=2026-11-25T03:38:40Z --> Automated triage for the maintainers. **Needs work.** The new warning for a render target with no host copy (`State::set_targets`, `draw.rs`) is useful. Two problems with the permission check: 1. Skipping a view with `continue` compacts `rtvs`, so every later target moves down a slot and the shader's `SV_TargetN` writes land in the wrong texture. Binding a null RTV in that slot would keep the indices. 2. The case it guards depends on a fallback that drops `ALLOW_RENDER_TARGET`. `main` has no `resource::host_texture` and nothing that removes that flag; that fallback is #1630. To change the verdict: keep the warnings, put a null descriptor in a skipped slot instead of compacting, and either rebase onto the fallback once it lands or show where `main` produces such a texture. CI passes. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fiestorra on GitHub · 2026-11-26 12:19 UTC · original

The slot is no longer compacted, and the change no longer depends on a fallback that main does not have

Head 9ef0e429, rebuilt on 842b0cb7; the earlier head was based on a main from two days ago, which is why the diff looked like it reverted files it does not touch.

  • No compaction. Every handle now keeps its index: a handle with no recorded view, no host copy, or a host copy without ALLOW_RENDER_TARGET pushes a null D3D12_CPU_DESCRIPTOR_HANDLE into rtvs instead of continue. SV_TargetN therefore lands in slot N whatever happened to its neighbours, and a null descriptor is a slot D3D12 discards writes to — which is what the draw was doing silently. The resource list used for barriers and the debug line still holds only real resources.
  • Depth follows the same rule: no depth view when the copy lost ALLOW_DEPTH_STENCIL, one warn! and the draw runs without depth.
  • The dependency. Fair point: on main nothing drops ALLOW_RENDER_TARGET, so the permission arm guards a state main does not produce today. I kept it because it is one if on a GetDesc() and it is the only thing that would say so if a later fallback (#1630 or a widening PR) starts dropping it — but it costs nothing when it never fires, and the warnings for the two arms that are reachable (no recorded view, no host copy) are the value here. If you would rather have only those, say so and I will cut the permission arm.

Measured: cargo test -p victory-gpu --lib → 231 passed, 0 failed; cargo clippy -p victory-gpu --all-targets -- -D warnings clean.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-11-26 12:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1700#issuecomment-7191856147) **The slot is no longer compacted, and the change no longer depends on a fallback that main does not have** Head `9ef0e429`, rebuilt on `842b0cb7`; the earlier head was based on a main from two days ago, which is why the diff looked like it reverted files it does not touch. - **No compaction.** Every handle now keeps its index: a handle with no recorded view, no host copy, or a host copy without `ALLOW_RENDER_TARGET` pushes a **null `D3D12_CPU_DESCRIPTOR_HANDLE`** into `rtvs` instead of `continue`. `SV_TargetN` therefore lands in slot N whatever happened to its neighbours, and a null descriptor is a slot D3D12 discards writes to — which is what the draw was doing silently. The resource list used for barriers and the debug line still holds only real resources. - **Depth** follows the same rule: no depth view when the copy lost `ALLOW_DEPTH_STENCIL`, one `warn!` and the draw runs without depth. - **The dependency.** Fair point: on `main` nothing drops `ALLOW_RENDER_TARGET`, so the permission arm guards a state main does not produce today. I kept it because it is one `if` on a `GetDesc()` and it is the only thing that would say so if a later fallback (#1630 or a widening PR) starts dropping it — but it costs nothing when it never fires, and the warnings for the two arms that *are* reachable (no recorded view, no host copy) are the value here. If you would rather have only those, say so and I will cut the permission arm. Measured: `cargo test -p victory-gpu --lib` → **231 passed, 0 failed**; `cargo clippy -p victory-gpu --all-targets -- -D warnings` clean. Written with an AI assistant.
github-bot force-pushed github-bot/gh-1700 from c0f73dff7f to 9ef0e429fd 2026-11-26 12:25:06 +00:00 Compare
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-24 20:56 UTC · original · approved these changes

Verified locally merged onto origin/main (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu — 50 passed, 0 failed (1 ignored) on both RTX 5090 hardware and VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean diagnostic logging when a draw's render target lacks a host copy or render-target permission. Looks good.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-24 20:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/1700#pullrequestreview-6047271076) · **approved these changes** Verified locally merged onto `origin/main` (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu` — 50 passed, 0 failed (1 ignored) on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean diagnostic logging when a draw's render target lacks a host copy or render-target permission. Looks good. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠mercuryVM on GitHub · 2026-11-24 21:28 UTC · original · requested changes

Read only, not built (read against set_targets):

The warnings are welcome, but the new render-target arm changes which slot each target lands in (crates/victory-gpu/src/draw.rs, in set_targets):

  • rtvs goes to OMSetRenderTargets as a dense array, so rtvs[i] is bound to slot i.
  • Before this PR, a host copy without ALLOW_RENDER_TARGET still got host.rtv(..). That made an empty descriptor in its slot, so its writes were dropped and the targets after it kept their slots.
  • With continue, the targets after a skipped one move down a slot. A pixel shader writing SV_Target1 then lands in what the title bound as target 0.
  • The "no host copy" arm just above has the same shift. That predates this PR, but it is the same bug.

Fix: keep the warning, but hold the slot. Push the empty view as before, or a null-resource RTV made with CreateRenderTargetView(None, Some(&desc), handle) and the target's format, instead of continue, in both arms.

The depth arm is fine: there is only one DSV, so None loses only depth.

AI-assisted (Claude Code).

**@⁠mercuryVM** on GitHub · 2026-11-24 21:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1700#pullrequestreview-6047709206) · **requested changes** Read only, not built (read against `set_targets`): The warnings are welcome, but the new render-target arm changes which slot each target lands in (`crates/victory-gpu/src/draw.rs`, in `set_targets`): - `rtvs` goes to `OMSetRenderTargets` as a dense array, so `rtvs[i]` is bound to slot `i`. - Before this PR, a host copy without `ALLOW_RENDER_TARGET` still got `host.rtv(..)`. That made an empty descriptor *in its slot*, so its writes were dropped and the targets after it kept their slots. - With `continue`, the targets after a skipped one move down a slot. A pixel shader writing `SV_Target1` then lands in what the title bound as target 0. - The "no host copy" arm just above has the same shift. That predates this PR, but it is the same bug. Fix: keep the warning, but hold the slot. Push the empty view as before, or a null-resource RTV made with `CreateRenderTargetView(None, Some(&desc), handle)` and the target's format, instead of `continue`, in both arms. The depth arm is fine: there is only one DSV, so `None` loses only depth. AI-assisted (Claude Code).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 22:19 UTC · original · reviewed

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Draws whose render target has no host counterpart are now reported explicitly instead of silently skipped (draw.rs, 2.4K). Small observability fix.

**@⁠catminou4** on GitHub · 2026-11-24 22:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1700#pullrequestreview-6048312134) · **reviewed** Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Draws whose render target has no host counterpart are now reported explicitly instead of silently skipped (draw.rs, 2.4K). Small observability fix.
Author
Owner

@⁠fiestorra on GitHub · 2026-11-26 14:50 UTC · original

Already done in the head you are reading: the slot is held with a null descriptor

Thanks — that is exactly the fix, and it is in 9ef0e429, the head this PR has had since yesterday: none of the three arms continues any more. Each handle pushes a view into rtvs, and a handle that yields none (no recorded view, no host copy, or a host copy without ALLOW_RENDER_TARGET) pushes a null D3D12_CPU_DESCRIPTOR_HANDLE instead, so SV_TargetN stays in slot N. The resource list used for the barriers and the debug line still holds only real resources.

The depth arm is as you say: one DSV, so None loses only depth, and that is what it does.

The suggestion of CreateRenderTargetView(None, Some(&desc), handle) is a different trade: it would make a real descriptor for a resource that has none, and D3D12 discards writes to a null descriptor anyway, so it buys nothing over the null handle while adding a call that can itself fail. If a case appears where an empty view is needed rather than a null one, say so and I will switch.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-11-26 14:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/1700#issuecomment-7195408476) **Already done in the head you are reading: the slot is held with a null descriptor** Thanks — that is exactly the fix, and it is in `9ef0e429`, the head this PR has had since yesterday: none of the three arms `continue`s any more. Each handle pushes a view into `rtvs`, and a handle that yields none (no recorded view, no host copy, or a host copy without `ALLOW_RENDER_TARGET`) pushes a **null `D3D12_CPU_DESCRIPTOR_HANDLE`** instead, so `SV_TargetN` stays in slot N. The resource list used for the barriers and the debug line still holds only real resources. The depth arm is as you say: one DSV, so `None` loses only depth, and that is what it does. The suggestion of `CreateRenderTargetView(None, Some(&desc), handle)` is a different trade: it would make a real descriptor for a resource that has none, and D3D12 discards writes to a null descriptor anyway, so it buys nothing over the null handle while adding a call that can itself fail. If a case appears where an empty view is needed rather than a null one, say so and I will switch. Written with an AI assistant.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1700'
git switch 'github-bot/gh-1700'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1700'
git switch 'github-bot/gh-1700'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1700'
git switch 'main'
git merge --squash 'github-bot/gh-1700'
git switch 'main'
git merge --ff-only 'github-bot/gh-1700'
git switch 'main'
git merge 'github-bot/gh-1700'
git push origin 'main'
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!1700
No description provided.