GPU: non-stream graphics PSOs, stream subobjects 25..=28, texture-to-buffer readbacks, and sRGB view preservation #301
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!301
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-301"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@wbkepler on GitHub · 2026-11-24 02:09 UTC · original
wbkepler:gpu/graphics-pso-and-readback→main· +1364 −143 · 9 files · 2 commits · openSummary
Improves host D3D12 pipeline state capture, texture-to-buffer readbacks, and sRGB view fidelity across
victory-gpu:pipeline.rs):GraphicsStatefromD3D12_GRAPHICS_PIPELINE_STATE_DESCinpipeline::create_graphicsinstead of passingNone.25..=28(pipeline.rs):PC MS), 26 (DEPTH_STENCIL2), 27 (RASTERIZER1), and 28 (RASTERIZER2) with compile-time size assertions and stream bounds checks.list.rs):CopyTextureRegionreadbacks into the destination buffer'sShadowcopy with 512-byte placement alignment checks,shadow.refresh+shadow.gpu_writes, and copy-back to title memory.descriptor.rs,descriptor/host.rs,resource.rs,texture.rs,capture.rs):SRGBto all 7 UNORM/sRGB pairs (R8G8B8A8,B8G8R8A8,B8G8R8X8,BC1,BC2,BC3,BC7) and backs sRGB-castable host textures with typeless family formats so_SRGBSRVs/RTVs preserve sRGB conversion while UAVs map to linear UNORM.1D/2D/3D/Array/MSAA) for null/UNKNOWNdescriptors and passes concrete formats toGetCopyableFootprints.Verification
cargo clippy --workspace --all-targets— passed (zero new warnings)cargo clippy -p victory --features diagnostics --all-targets— passedcargo test --workspace— passed (including live D3D12 readback, PSO, and 2D/Array/MSAA sRGB view tests)cargo xtask policy— passed (151 files ok)Improve host D3D12 correctness across pipeline state creation, GPU-to-CPU texture readbacks, and sRGB view casting: - Non-stream graphics PSOs (`pipeline.rs`, `pipeline/host.rs`): - Capture `GraphicsState` from `D3D12_GRAPHICS_PIPELINE_STATE_DESC` in `pipeline::create_graphics` (blend, sample mask, rasterizer, depth- stencil, owned input layout, strip cut, topology, RTV/DSV formats, and sample desc) instead of passing `None`. - Stream PSO subobjects `25..=28` (`pipeline.rs`, `pipeline/host.rs`): - Size and parse standard D3D12 subobjects `25` (PC `MS`), `26` (`DEPTH_STENCIL2`), `27` (`RASTERIZER1`), and `28` (`RASTERIZER2`) with compile-time size assertions and explicit stream bounds checks (`at + size <= desc.size`) so later subobjects are not dropped. - Texture -> buffer `CopyTextureRegion` readbacks (`list.rs`, `resource.rs`): - Copy from the source `HostTexture` (transitioned to `COPY_SOURCE`) into the destination buffer's `Shadow` copy (checking 512-byte placement alignment, refreshing before snapshotting, and scheduling `shadow.gpu_writes`) so copied texture rows land back in title memory. - sRGB view format preservation (`resource.rs`, `descriptor.rs`, `descriptor/host.rs`, `texture.rs`, `capture.rs`): - Expand `SRGB` to all 7 sRGB/UNORM pairs (`R8G8B8A8`, `B8G8R8A8`, `B8G8R8X8`, `BC1`, `BC2`, `BC3`, `BC7`) and back sRGB-castable host textures with their typeless family format so `_SRGB` SRV/RTV views retain hardware sRGB conversion while UAVs map cleanly to linear UNORM. - Synthesize default concrete SRV/UAV/RTV view descriptions when titles omit the descriptor or pass `DXGI_FORMAT_UNKNOWN` on typeless host textures, and pass concrete non-typeless formats to `GetCopyableFootprints` in staging uploads and diagnostics captures. - Add unit and live D3D12 tests covering plain graphics PSO state capture, subobjects `25..=28` parsing, texture-to-buffer `CopyTextureRegion` readbacks, and sRGB SRV/UAV/RTV view creation on typeless host textures.@r4tedx on GitHub · 2026-11-24 03:30 UTC · original
Review note on subobject 26 (
DEPTH_STENCIL_DESC2), built onmaind2a4bae(tests pass on an RTX 5070). The description is narrowed to the plainD3D12_DEPTH_STENCIL_DESC:Two things are lost on the way:
DESC2has separate read and write masks per face; the back face's masks are dropped and the front face's used for both.DepthBoundsTestEnableis dropped, as it is for kind 21 onmain.The test uses a zeroed description, so neither shows. Creating the host pipeline from a stream with the
DEPTH_STENCIL2subobject as given would keep both.For (2) there is an open PR, #158, which keeps the flag for kind 21, creates the pipeline from a stream when it is set, and forwards
OMSetDepthBounds. The two touch the sameGraphicsState: merged together the build fails withE0063(the new initializer here lacksdepth_bounds), so whichever lands second needs the field carried through kind 26 as well.From reading and synthetic tests only; I have no copy of the title.
@wbkepler on GitHub · 2026-11-24 03:42 UTC · original
Thanks @r4tedx, good catch. Fixed in
1af4624:D3D12_DEPTH_STENCIL_DESC2as given inGraphicsState(a later kind 11/21 clears it). When stencil is on and the back-face read/write masks differ from the front ones, the host pipeline is created from a pipeline-state stream with theDEPTH_STENCIL2subobject, if the device reportsIndependentFrontAndBackStencilRefMaskSupported(OPTIONS14, probed once). Otherwise it falls back to the front masks with a once-logged warning. Equal masks keep the plain description, which is exact in that case.DepthBoundsTestEnableis kept in the captured state but still cleared for the host pipeline, as for kind 21, marked as ashortcut:. Bounds aren't forwarded here, and I've left that to #158. Whichever of the two lands second will need to carry #158'sdepth_boundsthrough kind 26 and set the flag in the stream path.Gate: clippy clean for the changed code,
cargo test --workspacepasses,cargo xtask policyok.cargo fmt --checkalready reports diffs in these files onmain, and this change adds none.@fuzeofficlal on GitHub · 2026-11-24 06:24 UTC · original
I tested a default DSV on a synthetic 4×4 D32_FLOAT texture with 4× MSAA and typeless host backing. The test uses the ordinary DSV creation and clear path, then resolves and reads back depth. An explicit
TEXTURE2DMSDSV was the positive control.On
d2a4bae, the default descriptor selectedTEXTURE2D, and D3D12 rejected it at view creation on both RTX 5090 and WARP. The explicit control passed. On1af4624, both the default and explicit views selectedTEXTURE2DMS. Both adapters read back all 16 depth texels as0.25, with zero D3D12 debug errors. This covers the non-array default D32 depth-view path.@Marvisak on GitHub · 2026-11-25 00:26 UTC · original
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-gpu/src/descriptor/host.rs,crates/victory-gpu/src/host.rs,crates/victory-gpu/src/pipeline.rs,crates/victory-gpu/src/pipeline/host.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
@r4tedx on GitHub · 2026-11-25 07:42 UTC · original
One interaction to settle before either lands, from reading
1af4624beside #158.In
pipeline/host.rsthis PR setsDepthBoundsTestEnable: falsewith the comment "bounds are not forwarded yet; carry it through when they are". #158 is the PR that forwards them: with it the depth bounds test reaches the host, on adapters that support it. It is onmain940d32fand merges cleanly.So whichever of the two goes in second has one line to change: if #158 is in first, this should carry the title's value through instead of clearing it; if this is in first, #158's rebase does the same. Otherwise the test is dropped again for every pipeline that takes this path, as it is on
maintoday.Nothing was run for this comment; I read both diffs.
AI-assisted (Claude Code).
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.Merge
Merge the changes and update on Forgejo.