GPU: drop a texture's clear value the host cannot take #3063

Open
Halfect wants to merge 1 commit from upstream-pr/3065 into main
Halfect commented 2026-11-26 05:59:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-26T05:59:47Z.


What

victory-gpu's host_desc masks a title texture's flags to the PC set (PC_FLAGS), but make_texture forwarded the title's optimized clear value to CreateCommittedResource/CreateCommittedResource3 unconditionally. PC D3D12 refuses a clear value when the flags name neither ALLOW_RENDER_TARGET nor ALLOW_DEPTH_STENCIL — verified on this machine: E_INVALIDARG (0x80070057) with flags 0, success with ALLOW_RENDER_TARGET — so such a texture got no host copy at all (a "no host texture" warning, then every use of it failed).

Drop the clear value when the masked flags have neither use, keeping it for render targets and depth buffers as before.

Refs #1242 (VIC-BT-022).

Testing

  • New regression test resource::tests::a_clear_value_on_a_plain_texture_does_not_break_creation: a 64x64 R8G8B8A8_UNORM texture with flags 0 and a clear value. It fails on main (creation refused) and passes with the change. Skips cleanly when the test host has no D3D12 device.
  • cargo test --locked -p victory-gpu --lib: 229 passed; the 3 failures (descriptor::host::tests::dynamic_slots_are_held_until_released, draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view, memory::tests::lists_share_a_table_and_copies_keep_their_views) fail identically on unmodified main on this machine (NVIDIA).
  • cargo clippy --locked -p victory-gpu --lib --tests -- -D warnings: clean.
  • cargo xtask policy: ok.

Limitations

Verified on one Windows host; the rule the fix relies on is the D3D12 runtime's own parameter validation, not a driver quirk. cargo fmt shows pre-existing differences with this toolchain version on untouched parts of the crate; the changed lines follow the file's style.

No game data. AI-assisted (Kimi).

<!-- greyfinch-sync:Marvisak/VIctory:issue:6620562862 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3065). Originally posted by [Halfect](https://github.com/Halfect) on 2026-11-26T05:59:47Z. --- ## What `victory-gpu`'s `host_desc` masks a title texture's flags to the PC set (`PC_FLAGS`), but `make_texture` forwarded the title's optimized clear value to `CreateCommittedResource`/`CreateCommittedResource3` unconditionally. PC D3D12 refuses a clear value when the flags name neither `ALLOW_RENDER_TARGET` nor `ALLOW_DEPTH_STENCIL` — verified on this machine: `E_INVALIDARG` (0x80070057) with flags 0, success with `ALLOW_RENDER_TARGET` — so such a texture got no host copy at all (a "no host texture" warning, then every use of it failed). Drop the clear value when the masked flags have neither use, keeping it for render targets and depth buffers as before. Refs #1242 (`VIC-BT-022`). ## Testing - New regression test `resource::tests::a_clear_value_on_a_plain_texture_does_not_break_creation`: a 64x64 R8G8B8A8_UNORM texture with flags 0 and a clear value. It fails on main (creation refused) and passes with the change. Skips cleanly when the test host has no D3D12 device. - `cargo test --locked -p victory-gpu --lib`: 229 passed; the 3 failures (`descriptor::host::tests::dynamic_slots_are_held_until_released`, `draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view`, `memory::tests::lists_share_a_table_and_copies_keep_their_views`) fail identically on unmodified main on this machine (NVIDIA). - `cargo clippy --locked -p victory-gpu --lib --tests -- -D warnings`: clean. - `cargo xtask policy`: ok. ## Limitations Verified on one Windows host; the rule the fix relies on is the D3D12 runtime's own parameter validation, not a driver quirk. `cargo fmt` shows pre-existing differences with this toolchain version on untouched parts of the crate; the changed lines follow the file's style. No game data. AI-assisted (Kimi).
Dukestar69 commented 2026-11-26 07:01:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T06:07:31Z.

Review: APPROVED


Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):

  • Diff review: Guarding clear_value in make_texture with d.flags & (USES & !UNORDERED) != 0 cleanly drops console-supplied clear values on textures that are neither render targets nor depth-stencil buffers, avoiding PC D3D12 E_INVALIDARG creation failures.
  • cargo test -p victory-gpu resource::tests -- --test-threads=1 (RTX 5090 & WARP): 19 passed, 0 failed on both (including a_clear_value_on_a_plain_texture_does_not_break_creation).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6069297956 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3065#pullrequestreview-6069297956). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T06:07:31Z. **Review:** APPROVED --- Tested locally merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP): - Diff review: Guarding `clear_value` in `make_texture` with `d.flags & (USES & !UNORDERED) != 0` cleanly drops console-supplied clear values on textures that are neither render targets nor depth-stencil buffers, avoiding PC D3D12 `E_INVALIDARG` creation failures. - `cargo test -p victory-gpu resource::tests -- --test-threads=1` (RTX 5090 & WARP): 19 passed, 0 failed on both (including `a_clear_value_on_a_plain_texture_does_not_break_creation`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-26 07:01:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T06:09:13Z.

Review: APPROVED


Reviewed head 34761782 line-by-line (CI green):

  • Confirmed USES = 0x7 (render target 0x1, depth 0x2, unordered 0x4) and UNORDERED = 0x4, so d.flags & (USES & !UNORDERED) != 0 checks strictly ALLOW_RENDER_TARGET | ALLOW_DEPTH_STENCIL (0x3) and does not match DENY_SHADER_RESOURCE (0x8) or UAV-only textures.
  • Dropping clear_value when neither RTV nor DSV is set avoids D3D12 CreateCommittedResource returning E_INVALIDARG, and a_clear_value_on_a_plain_texture_does_not_break_creation directly verifies the fix through make_texture.

Clean and surgical.

<!-- greyfinch-sync:Marvisak/VIctory:review:6069314621 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3065#pullrequestreview-6069314621). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T06:09:13Z. **Review:** APPROVED --- Reviewed head `34761782` line-by-line (CI green): - Confirmed `USES = 0x7` (render target `0x1`, depth `0x2`, unordered `0x4`) and `UNORDERED = 0x4`, so `d.flags & (USES & !UNORDERED) != 0` checks strictly `ALLOW_RENDER_TARGET | ALLOW_DEPTH_STENCIL` (`0x3`) and does not match `DENY_SHADER_RESOURCE` (`0x8`) or UAV-only textures. - Dropping `clear_value` when neither RTV nor DSV is set avoids D3D12 `CreateCommittedResource` returning `E_INVALIDARG`, and `a_clear_value_on_a_plain_texture_does_not_break_creation` directly verifies the fix through `make_texture`. Clean and surgical.
kotekompotek commented 2026-11-26 07:01:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T06:33:24Z.

Review: APPROVED


Verified: USES&!UNORDERED = RT|DS (0x3) — D3D12 only accepts an optimized clear value on render-target/depth resources, so a clear value on a plain/UAV texture now gets dropped instead of failing CreateCommittedResource with E_INVALIDARG. Console semantics (clear allowed anywhere) preserved where the host can take it. Host test proves creation succeeds.

<!-- greyfinch-sync:Marvisak/VIctory:review:6069543518 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3065#pullrequestreview-6069543518). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T06:33:24Z. **Review:** APPROVED --- Verified: USES&!UNORDERED = RT|DS (0x3) — D3D12 only accepts an optimized clear value on render-target/depth resources, so a clear value on a plain/UAV texture now gets dropped instead of failing CreateCommittedResource with E_INVALIDARG. Console semantics (clear allowed anywhere) preserved where the host can take it. Host test proves creation succeeds.
Marvisak commented 2026-11-26 07:01:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T06:18:02Z.


Automated triage for the maintainers.

Merge candidate. make_texture (crates/victory-gpu/src/resource.rs) passed the title's optimized clear value to resource creation even when the host flags (masked to PC_FLAGS in host_desc) allow neither render-target nor depth-stencil use. PC D3D12 refuses that with E_INVALIDARG, so the texture got no host copy. The PR keeps the clear value only when d.flags & (USES & !UNORDERED) (render target or depth) is set. The d passed in is the host description, with uses merged from other title textures at the same memory, so render targets and depth buffers are unaffected. A side effect: such textures now also qualify for the placed-resource path (clear_value.is_none()), which is fine. The regression test creates a 64x64 RGBA8 texture with flags 0 and a clear value.

CI: check passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184292794 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3065#issuecomment-7184292794). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T06:18:02Z. --- <!-- victory-triage v1 head=34761782e55bd980799d9aa8e14559e0bdca41bd verdict=merge-candidate at=2026-11-26T06:20:50Z --> Automated triage for the maintainers. **Merge candidate.** `make_texture` (`crates/victory-gpu/src/resource.rs`) passed the title's optimized clear value to resource creation even when the host flags (masked to `PC_FLAGS` in `host_desc`) allow neither render-target nor depth-stencil use. PC D3D12 refuses that with `E_INVALIDARG`, so the texture got no host copy. The PR keeps the clear value only when `d.flags & (USES & !UNORDERED)` (render target or depth) is set. The `d` passed in is the host description, with uses merged from other title textures at the same memory, so render targets and depth buffers are unaffected. A side effect: such textures now also qualify for the placed-resource path (`clear_value.is_none()`), which is fine. The regression test creates a 64x64 RGBA8 texture with flags 0 and a clear value. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
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/3065:upstream-pr/3065'
git switch 'upstream-pr/3065'

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/3065'
git switch 'upstream-pr/3065'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3065'
git switch 'upstream-pr/3065'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3065'
git switch 'main'
git merge --squash 'upstream-pr/3065'
git switch 'main'
git merge --ff-only 'upstream-pr/3065'
git switch 'main'
git merge 'upstream-pr/3065'
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!3063
No description provided.