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

Open
AgneyaK wants to merge 2 commits from upstream-pr/1613 into main
AgneyaK commented 2026-11-24 19:47:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AgneyaK on 2026-11-24T19:47:09Z.


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://github.com/Marvisak/VIctory/pull/55#issuecomment-7138320867

  • 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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6590041637 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1613). Originally posted by [AgneyaK](https://github.com/AgneyaK) on 2026-11-24T19:47:09Z. --- 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://github.com/Marvisak/VIctory/pull/55#issuecomment-7138320867 - `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)
DenRakEiw commented 2026-11-24 20:02:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T19:56:48Z.

Review: APPROVED


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 renders_to guard and null_rtv() fallback preventing invalid RTV creation, barriers, or clears on textures without D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6046367072 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1613#pullrequestreview-6046367072). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T19:56:48Z. **Review:** APPROVED --- 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 `renders_to` guard and `null_rtv()` fallback preventing invalid RTV creation, barriers, or clears on textures without `D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET`. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-24 21:02:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:06:14Z.

Review: COMMENTED


Static review only: victory-gpu/victory-hle/apps are Windows-only (D3D12/windows_sys), so nothing here compiles or runs on macOS — please rely on the Windows CI leg.

Textures whose host copy lacks ALLOW_RENDER_TARGET now get a null RTV in their slot instead of a view the host cannot render to: draw.rs pushes host.null_rtv() (ring slot preserved so target indices stay aligned) and clear_rtv skips with a once-per-resource warning. renders_to checks the resource flag, which matches how host_texture masks d.flags &= PC_FLAGS. Sound; OMSetRenderTargets with a null RTV is valid D3D12 and draws simply discard those outputs.

<!-- greyfinch-sync:Marvisak/VIctory:review:6046506077 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1613#pullrequestreview-6046506077). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T20:06:14Z. **Review:** COMMENTED --- Static review only: victory-gpu/victory-hle/apps are Windows-only (D3D12/windows_sys), so nothing here compiles or runs on macOS — please rely on the Windows CI leg. Textures whose host copy lacks `ALLOW_RENDER_TARGET` now get a null RTV in their slot instead of a view the host cannot render to: `draw.rs` pushes `host.null_rtv()` (ring slot preserved so target indices stay aligned) and `clear_rtv` skips with a once-per-resource warning. `renders_to` checks the resource flag, which matches how `host_texture` masks `d.flags &= PC_FLAGS`. Sound; OMSetRenderTargets with a null RTV is valid D3D12 and draws simply discard those outputs.
upstream-sync changed title from [PR #1613] GPU: no render-target view, barrier or clear for a texture without the render-target use to [PR #1613] GPU: render targets keep their slots (null views for targets the host cannot bind), and no RTV or clear without the render-target use 2026-11-25 04:05:31 +00:00
Marvisak commented 2026-11-25 04:06:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:31:23Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7151993122 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1613#issuecomment-7151993122). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T03:31:23Z. --- <!-- 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)_
AgneyaK commented 2026-11-25 04:07:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AgneyaK on 2026-11-25T03:47:18Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152241799 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1613#issuecomment-7152241799). Originally posted by [AgneyaK](https://github.com/AgneyaK) on 2026-11-25T03:47:18Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1613:upstream-pr/1613'
git switch 'upstream-pr/1613'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1613'
git switch 'upstream-pr/1613'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1613'
git switch 'upstream-pr/1613'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1613'
git switch 'main'
git merge --squash 'upstream-pr/1613'
git switch 'main'
git merge --ff-only 'upstream-pr/1613'
git switch 'main'
git merge 'upstream-pr/1613'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1612
No description provided.