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

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

@⁠Halfect on GitHub · 2026-11-26 05:59 UTC · original
Halfect:fix/clear-value-target-flags → main · +36 −1 · 1 files · 1 commits · open

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

**@⁠Halfect** on GitHub · 2026-11-26 05:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/3065) `Halfect:fix/clear-value-target-flags` → `main` · +36 −1 · 1 files · 1 commits · open ## 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).
The console allows a clear value on any texture; PC D3D12 refuses one
when the masked host flags name neither render target nor depth, and
CreateCommittedResource answers E_INVALIDARG, so such a texture got no
host copy at all. Drop the value there instead of failing.

VIC-BT-022 (#1242)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:27:56 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 06:18 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-26 06:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/3065#issuecomment-7184292794) <!-- 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 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/3065/head:github-bot/gh-3065'
git switch 'github-bot/gh-3065'

Merge

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