Skip to content

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
AgneyaK wants to merge 2 commits into
Marvisak:mainfrom
AgneyaK:fix/rtv-without-render-target-use
Open

AgneyaK wants to merge 2 commits into
Marvisak:mainfrom
AgneyaK:fix/rtv-without-render-target-use

Conversation

@AgneyaK

@AgneyaK AgneyaK commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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.

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 (comment)

  • 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)

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

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. Update after your reply (head 736fa79): this now fixes a real slot shift on main. State::set_targets (draw.rs) skipped any target with no recorded view or no host texture, which moved every later target down one SV_Target slot. Such slots now get Host::null_rtv (host.rs) in the title's view format when the host can render to it (renders_format, cached per format), and R8G8B8A8_UNORM otherwise. Textures whose host copy lacks ALLOW_RENDER_TARGET get a null view too, and clear_rtv (list.rs) skips them with no view or barrier, which also covers the problem raised on #1630's ladder. The new test checks that slot 1 still receives SV_Target1, both with no view and with a typed null view in slot 0. This overlaps #450, which handles only the typed-null case, so only one should land.

Not checked with the debug layer: a view recorded without a description gets the R8G8B8A8_UNORM fallback, which may not match the pipeline's RTVFormats. CI passes.


Generated by Claude Code

AgneyaK and others added 2 commits November 24, 2026 19:38
…e render-target use

A host texture made without ALLOW_RENDER_TARGET (Marvisak#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 <noreply@anthropic.com>
…view

`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 (Marvisak#1754, Marvisak#1758, Marvisak#1781), so the targets after it get the wrong
outputs. The title's typed null views (no resource) took the same path
(Marvisak#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 <noreply@anthropic.com>
@AgneyaK
AgneyaK force-pushed the fix/rtv-without-render-target-use branch from e3d76bd to 736fa79 Compare November 25, 2026 03:46
@AgneyaK AgneyaK changed the title GPU: no render-target view, barrier or clear for a texture without the render-target use GPU: render targets keep their slots (null views for targets the host cannot bind), and no RTV or clear without the render-target use Nov 25, 2026
@AgneyaK

AgneyaK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

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 (NVIDIA RTX 4070 SUPER on 70564ae: device removed (INVALID_CALL, 0x887A0001) at frame 128, before the menus #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: GPU: preserve typed null render target slots #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.

0xkn0wh3r3 added a commit to 0xkn0wh3r3/VIctory that referenced this pull request Nov 25, 2026
…mmit

Marvisak#2130 was rewritten on top of Marvisak#2120's update, so layering it on the old
merges kept two versions of it. This tree is upstream main (940d32f) with
all 32 open PRs of 0xkn0wh3r3 at their current commits, the upstream
fixes Marvisak#1887, Marvisak#1717, Marvisak#1832, Marvisak#1630, Marvisak#1763 and Marvisak#1613, and the demo-only
conformance list; the old history stays as this merge's first parent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants