GPU: render targets keep their slots (null views for targets the host cannot bind), and no RTV or clear without the render-target use #1613

Open
github-bot wants to merge 2 commits from github-bot/gh-1613 into main AGit
Owner

@⁠AgneyaK on GitHub · 2026-11-24 19:47 UTC · original
AgneyaK:fix/rtv-without-render-target-use → main · +201 −1 · 3 files · 2 commits · open

Two commits, rebased onto main 940d32f. The second one (added 2026-11-25) makes this useful on main by itself, not only with #55.

1. Render targets keep their slots (736fa79, useful on main now)

State::set_targets skipped a target it couldn't bind (continue): one with no recorded view, or one with no host texture. Every later target then moved down a slot, so a draw's SV_Target1 landed in the texture bound as target 0, and so on.

  • On NVIDIA this happens on main today. The title's 2560x1440 B4G4R4A4_UNORM (format 115) render target is refused by the host (no host texture, #1754 / #1758 / #1781 / #1952), so any pass that binds it before other targets writes them to the wrong outputs.
  • The title's own typed null views (a record with no resource) took the same path. #450 fixes that case alone (it needs a rebase, and with no description it still skips the slot). This change covers it too, so the two overlap there.

Now every such slot gets a null view and keeps its position: no recorded view, no host texture, a typed null view, or a copy made without the render-target use (part 2).

The null view's format (the triage question): it now takes the title's view format where the host renders to that format (host::renders_format, D3D12_FORMAT_SUPPORT1_RENDER_TARGET, asked once per format). So it matches the pipeline's RTVFormats for the slot. Only where the host can't render the format at all (or there's no record) is it R8G8B8A8_UNORM. In that case the pipeline with that format is refused by the host anyway, so no draw pairs the two.

2. No RTV, barrier or clear for a copy without the render-target use (7b8c8e3, needed by #55)

#55 makes a host texture without a use the host refuses, which on NVIDIA hits format 115 as a render target. The title still clears that texture and binds it, and host.rtv, the barrier to RENDER_TARGET and ClearRenderTargetView are invalid calls on a resource without ALLOW_RENDER_TARGET. With #55 on an RTX 3050, 3 of 3 runs lost the device 1:41–1:58 in (The application made a call that is invalid); with this, two runs had no invalid call (5:51 and 8:37). Details: #55

  • host::renders_to(texture): whether the host copy has ALLOW_RENDER_TARGET.
  • The clear skips such a texture (one-time warning); set_targets binds a null view for it (part 1).

Tested (on 940d32f + this)

  • New test a_target_that_cannot_be_bound_keeps_the_others_in_their_slots: a pipeline writes SV_Target0 red and SV_Target1 green, slot 0 can't be bound, and the slot-1 texture is read back.
    • Two cases for slot 0: no recorded view, and a typed null view.
    • Passes on the Intel Iris Xe (the default adapter here), WARP (--features diagnostics, VICTORY_D3D12_WARP=1) and the RTX 3050 6 GB (with a local adapter patch, not in this PR).
    • With main's set_targets it fails in both cases: left: [1.0, 0.0, 0.0, 1.0] (red), right: [0.0, 1.0, 0.0, 1.0].
  • cargo test -p victory-gpu --locked: 141 passed, 3 failed. The 3 fail on main the same way on this Intel iGPU: the 2 heap-cap tests of #1744, and the castable test #1765 fixes.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and with --all-features: clean. cargo xtask policy: ok.
  • Title, RTX 3050 6 GB laptop: main + #1763 (NVIDIA stops at boot without it, #1754) + this, diag build, 55 s from launch. No device removal (frame 611). The refused format-115 texture appears (no host texture), but it isn't bound as a target within 55 s, so the null-view path didn't run in the title there. This laptop can't go further safely (it runs out of memory in the story load).

Not tested: the debug layer (not installed here), so whether it has an opinion on a format-matched null view isn't checked; AMD, where nothing is refused, so the new paths only run for the title's typed null views.

No game data. AI use: Claude Code (Claude Opus 5.5) found the causes, wrote the changes and tests, ran the checks and the title on my machine, and drafted this description.

🤖 Generated with Claude Code

**@⁠AgneyaK** on GitHub · 2026-11-24 19:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/1613) `AgneyaK:fix/rtv-without-render-target-use` → `main` · +201 −1 · 3 files · 2 commits · open Two commits, rebased onto `main` `940d32f`. The second one (added 2026-11-25) makes this useful on `main` by itself, not only with #55. ## 1. Render targets keep their slots (`736fa79`, useful on `main` now) `State::set_targets` skipped a target it couldn't bind (`continue`): one with no recorded view, or one with no host texture. Every later target then moved down a slot, so a draw's `SV_Target1` landed in the texture bound as target 0, and so on. - **On NVIDIA this happens on `main` today.** The title's 2560x1440 `B4G4R4A4_UNORM` (format 115) render target is refused by the host (`no host texture`, #1754 / #1758 / #1781 / #1952), so any pass that binds it before other targets writes them to the wrong outputs. - The title's own **typed null views** (a record with no resource) took the same path. #450 fixes that case alone (it needs a rebase, and with no description it still skips the slot). This change covers it too, so the two overlap there. Now every such slot gets a **null view** and keeps its position: no recorded view, no host texture, a typed null view, or a copy made without the render-target use (part 2). **The null view's format** (the triage question): it now takes the title's view format where the host renders to that format (`host::renders_format`, `D3D12_FORMAT_SUPPORT1_RENDER_TARGET`, asked once per format). So it matches the pipeline's `RTVFormats` for the slot. Only where the host can't render the format at all (or there's no record) is it `R8G8B8A8_UNORM`. In that case the pipeline with that format is refused by the host anyway, so no draw pairs the two. ## 2. No RTV, barrier or clear for a copy without the render-target use (`7b8c8e3`, needed by #55) #55 makes a host texture without a use the host refuses, which on NVIDIA hits format 115 as a render target. The title still clears that texture and binds it, and `host.rtv`, the barrier to `RENDER_TARGET` and `ClearRenderTargetView` are invalid calls on a resource without `ALLOW_RENDER_TARGET`. With #55 on an RTX 3050, 3 of 3 runs lost the device 1:41–1:58 in (`The application made a call that is invalid`); with this, two runs had no invalid call (5:51 and 8:37). Details: https://git.gtahub.st/github/Marvisak--VIctory/pulls/55 - `host::renders_to(texture)`: whether the host copy has `ALLOW_RENDER_TARGET`. - The clear skips such a texture (one-time warning); `set_targets` binds a null view for it (part 1). ## Tested (on `940d32f` + this) - **New test `a_target_that_cannot_be_bound_keeps_the_others_in_their_slots`:** a pipeline writes `SV_Target0` red and `SV_Target1` green, slot 0 can't be bound, and the slot-1 texture is read back. - Two cases for slot 0: no recorded view, and a typed null view. - Passes on the Intel Iris Xe (the default adapter here), WARP (`--features diagnostics`, `VICTORY_D3D12_WARP=1`) and the RTX 3050 6 GB (with a local adapter patch, not in this PR). - **With `main`'s `set_targets` it fails in both cases:** `left: [1.0, 0.0, 0.0, 1.0]` (red), `right: [0.0, 1.0, 0.0, 1.0]`. - `cargo test -p victory-gpu --locked`: 141 passed, 3 failed. The 3 fail on `main` the same way on this Intel iGPU: the 2 heap-cap tests of #1744, and the castable test #1765 fixes. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and with `--all-features`: clean. `cargo xtask policy`: ok. - **Title, RTX 3050 6 GB laptop:** `main` + #1763 (NVIDIA stops at boot without it, #1754) + this, diag build, 55 s from launch. No device removal (frame 611). The refused format-115 texture appears (`no host texture`), but it isn't bound as a target within 55 s, so the null-view path didn't run in the title there. This laptop can't go further safely (it runs out of memory in the story load). Not tested: the debug layer (not installed here), so whether it has an opinion on a format-matched null view isn't checked; AMD, where nothing is refused, so the new paths only run for the title's typed null views. No game data. AI use: Claude Code (Claude Opus 5.5) found the causes, wrote the changes and tests, ran the checks and the title on my machine, and drafted this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A host texture made without ALLOW_RENDER_TARGET (#55 drops a use the host
refuses for the format, e.g. B4G4R4A4_UNORM on NVIDIA) was still cleared
and bound as a render target: CreateRenderTargetView, a barrier to
RENDER_TARGET and ClearRenderTargetView on it are invalid calls, and the
device is removed with DXGI_ERROR_INVALID_CALL.

`host::renders_to` tells. The clear skips such a texture (warned once);
`set_targets` binds a null RTV in its slot (`Host::null_rtv`), so the other
targets keep their slots and draws write nothing there. No change while
every texture keeps its render-target use, as on `main` today.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`set_targets` skipped a target with no recorded view or no host texture
(`continue`), so every later target moved down a slot: a draw writing
`SV_Target1` wrote it into the texture bound as target 1 only if target 0
existed on the host. On NVIDIA, `main` already has such a target: a
2560x1440 B4G4R4A4_UNORM render target the host refuses gets no host
texture (#1754, #1758, #1781), so the targets after it get the wrong
outputs. The title's typed null views (no resource) took the same path
(#450).

Each of those slots now gets a null view: no recorded view, no host
texture, a typed null view, or a copy made without the render-target use.
The null view takes the title's view format where the host renders to it
(`renders_format`, `D3D12_FORMAT_SUPPORT1_RENDER_TARGET`, asked once per
format), so it matches the pipeline's target formats; else
R8G8B8A8_UNORM.

Test `a_target_that_cannot_be_bound_keeps_the_others_in_their_slots`
draws SV_Target0 red and SV_Target1 green with slot 0 unbindable (no view;
a typed null view) and reads the slot-1 texture back: green. On `main`'s
`set_targets` it reads red in both cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:38:27 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:31 UTC · original · edited 2026-11-25 15:54 UTC

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/list.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (merge candidate) was for an older state of main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/1613#issuecomment-7151993122) · edited 2026-11-25 15:54 UTC <!-- victory-triage v1 head=736fa790eec1f0d9a7a22290c4c77aef31fc1935 verdict=needs-rebase at=2026-11-25T15:54:30Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-gpu/src/list.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (merge candidate) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠AgneyaK on GitHub · 2026-11-25 03:47 UTC · original

Thanks for the triage. Updated (736fa79, description rewritten), so this no longer depends on #55:

  • It now fixes a slot shift on main today. set_targets skipped any target with no recorded view or no host texture, which moves every later target down a slot. On NVIDIA the title's 2560x1440 format-115 render target has no host texture on main (#1754 and the issues linked there), so this happens now. Those slots now get a null view too, and a new test shows main writes SV_Target0 into the slot-1 texture (fails on main for no view and for a typed null view, passes here on Intel, WARP and an RTX 3050).
  • Format: the null view now uses the title's view format where the host renders to it (D3D12_FORMAT_SUPPORT1_RENDER_TARGET), so it matches the pipeline's RTVFormats. It's R8G8B8A8_UNORM only when the host can't render that format, where such a pipeline is refused anyway. No debug layer here, so that's not checked against it.
  • Overlap: #450 fixes the typed-null-view case of the same skip; this covers it as well.

AI use: Claude Code (Claude Opus 5.5) wrote the change and this reply.

**@⁠AgneyaK** on GitHub · 2026-11-25 03:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/1613#issuecomment-7152241799) Thanks for the triage. Updated (`736fa79`, description rewritten), so this no longer depends on #55: - **It now fixes a slot shift on `main` today.** `set_targets` skipped any target with no recorded view or no host texture, which moves every later target down a slot. On NVIDIA the title's 2560x1440 format-115 render target has no host texture on `main` (#1754 and the issues linked there), so this happens now. Those slots now get a null view too, and a new test shows `main` writes `SV_Target0` into the slot-1 texture (fails on `main` for no view and for a typed null view, passes here on Intel, WARP and an RTX 3050). - **Format:** the null view now uses the title's view format where the host renders to it (`D3D12_FORMAT_SUPPORT1_RENDER_TARGET`), so it matches the pipeline's `RTVFormats`. It's `R8G8B8A8_UNORM` only when the host can't render that format, where such a pipeline is refused anyway. No debug layer here, so that's not checked against it. - Overlap: #450 fixes the typed-null-view case of the same skip; this covers it as well. AI use: Claude Code (Claude Opus 5.5) wrote the change and this reply.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/list.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/1613/head:github-bot/gh-1613'
git switch 'github-bot/gh-1613'

Merge

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