startup: apply stream rasterizer state on translated draws #1560
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1567"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-24T14:15:45Z.
Change
Slot 86 graphics streams apply a
RASTERIZERorRASTERIZER1subobject to the translated desktop pipeline. Fill, cull, and depth clip come from that subobject.RASTERIZER1stores depth bias as a float; a value that is not an integer in the desktop int range refuses the pipeline. The desktop PSO cache key includes the rasterizer when the stream has one. A stream with no rasterizer subobject keeps solid fill, no culling, and depth clip on.Refs #1142.
Verification
MSVC 19.42.34435 (VS 2022). WARP is Microsoft Basic Render Driver, vendor 1414, device 008c, driver 10.0.26100.8521. Hardware is NVIDIA GeForce RTX 4070 Ti, vendor 10de, device 2782, driver 32.0.16.2135. Neither preset skipped with code 77.
cmake --preset devexited 0.cmake --build --preset devexited 1 on a pre-existing error intests/startup_dstorage_file_read_check.cpp(102)(C2664), which this change does not touch. The stream executables were built after that, and the ctest command above then exited 0. Nine tests passed:startup_stream_request_warpstartup_stream_draw_warpstartup_stream_depth_warpstartup_stream_rasterizer_warpstartup_stream_rasterizer_ignore_warpstartup_stream_draw_hardwarestartup_stream_depth_hardwarestartup_stream_rasterizer_hardwarestartup_stream_rasterizer_ignore_hardwarecmake --preset releaseexited 0.cmake --build --preset releaseexited 1 on the sameC2664. The stream executables were built after that, and the ctest command above then exited 0 with the same nine passes.On both backends, back-face and front-face cull differ: one matches the no-cull readback (16 of 32 pixels colored) and the other is clear. Integral
RASTERIZER1matchesRASTERIZER. Fractional depth bias 0.5 refuses the pipeline and the target stays clear. The ignore control returns failure because the readback changed;WILL_FAILrecords that as a pass.Evidence and follow-up
The fixture is source-built in
tests/startup_stream_rasterizer.cppandtests/startup_stream_rasterizer_check.py, in the same shape asstartup_stream_depth. No game files and no titlexgameruntime.dll.docs/startup-runtime.mdnames the reproduce command. Geometry, hull, domain, and compute stages, and root-signature subobject parsing, remain open on #1142.Checklist
AI-assisted (Grok Build)
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T14:25:54Z.
Review: COMMENTED
Dual-platform peer review of PR #1567 (
c3f7b319a8a255feb7b5a010c99ff4ba911ceea9).Code & Hygiene Audit
RASTERIZER(type 14) andRASTERIZER1(type 27) stream subobject parsing and application on translated draws. Merges cleanly againstorigin/main.integral_depth_bias(src/startup_stubs/d3d12_draw.inl) safely rejectsNaN, out-of-range floats, and fractional values (static_cast<double>(integral) != value) before casting toINT.stream_translationguardstype >= 32before1u << type, avoiding shift UB, and verifiessizeof(type) + sizeof(parsed) <= size.pipeline_forincludesbound.rasterizerin the PSO cache key whenbound.has_rasterizeris set, and falls back to solid fill / no cull / depth clip on when absent.seentracks1u << typeper subobject type, so a malformed stream containing bothRASTERIZER(type 14) andRASTERIZER1(type 27) would let the second overwrite the first rather than rejecting the duplicate rasterizer subobject.startup_stream_rasterizerverifiesRASTERIZERback/front cull vs. dropped subobject,RASTERIZER1integral bias parity, fractional depth bias (0.5f) refusal, andstartup_stream_rasterizer_ignore_*(WILL_FAIL).Verification
git diff --check origin/main..HEAD: passedpython3 tests/docs_links_check.py: passed (16 Markdown files, 340 links)python3 tests/bidi_controls_check.py: passed (1241 tracked files)c3f7b319a8a255feb7b5a010c99ff4ba911ceea9:--preset dev):cmake --build --preset dev --target startup_stream_rasterizer d3d12_xs_shim offscreen_check -- -j 6succeeded;ctest --preset dev -R '^startup_stream_' --parallel 4 --no-tests=error --output-on-failure— 9/9 passed (startup_stream_request_warp,startup_stream_draw_warp,startup_stream_depth_warp,startup_stream_rasterizer_warp,startup_stream_rasterizer_ignore_warp,startup_stream_draw_hardware,startup_stream_depth_hardware,startup_stream_rasterizer_hardware,startup_stream_rasterizer_ignore_hardware; note: this VM only has WARP)./O2(--preset release):cmake --build --preset release --target startup_stream_rasterizer d3d12_xs_shim offscreen_check -- -j 6succeeded;ctest --preset release -R '^startup_stream_' --parallel 4 --no-tests=error --output-on-failure— 9/9 passed (same 9 tests).Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T14:25:57Z.
Review: CHANGES_REQUESTED
The raw tag bitset rejects repeats of 10 and 27 individually, but a stream containing both rasterizer versions currently parses and the last one wins. Treat the two tags as one rasterizer state and reject a mixed duplicate in both orders. Please add a source-built mixed stream refusal control alongside the existing per-version cull cases.
Imported from R0Y00/Xbox2Windows. Originally posted by Makto94 on 2026-11-24T14:59:24Z.
Hardware check of this PR at commit
c3f7b3192, built in a clean worktree.X2W_D3D12_DEBUG=1intests/startup_stream_depth_check.pyandtests/startup_stream_rasterizer_check.py). All 6 tests logx2w-d3d12 debug layer: 0x00000000 enabled; the-Voutput has nox2w-d3d12-debugline.ctest --preset dev --no-tests=error -R 'startup_stream_(rasterizer|depth)' -j1 -VNo capability skips. Code read: RASTERIZER1 (type 27) reuses the RASTERIZER width and rejects a non-integral or out-of-range float DepthBias; the rasterizer desc enters the PSO cache key. Note: a stream rasterizer with ConservativeRaster or ForcedSampleCount set is passed through unchanged, so PSO creation could fail on adapters without that tier — not covered by the fixture.
Edited: the first version said "debug layer not enabled explicitly". That run predates the installation of Graphics Tools on this machine and its log was not verbose, so it gives no debug-layer evidence. The results above are from a rerun of the same commit with the layer available: 6/6 passed, no skips.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:53:51Z.
@SimSalabimse could you rebase this branch onto current
mainand force-push?GitHub reports head
c3f7b319as conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(cf97bee1):CMakeLists.txtsrc/startup_stubs/d3d12_draw.inlsrc/startup_stubs/d3d12_xs_device.cppCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:11:53Z.
Review: COMMENTED
Review of head
16301332eef97c8b3283ce7632f26af820a27c6c.Commands run locally (Linux, worktree of the PR head):
The C++ changes and the D3D12 tests need MSVC, so I did not build or run them here. I did not run a Windows mutation either. The Windows CI jobs above passed. The PR body lists WARP and hardware runs.
What I checked by reading:
D3D12_RASTERIZER_DESC1has the same size and field order asD3D12_RASTERIZER_DESC, withDepthBiasas a float. The reinterpretation ind3d12_draw.inl(stream_translation) is correct, and thestatic_asserton the table width is a good guard.desktop_stream_sizeind3d12_xs_device.cpp:1892, andmesh86_cache.inl:79) return 0 for type 27. That sends such streams to the translated path instead of the real-pipeline path. This is safe, but it is worth a line in the docs.Findings:
P1: none.
P2-1.
d3d12_draw.inl(pipeline_for,desc.RasterizerState = bound.rasterizer): the whole struct is copied, includingForcedSampleCount,ConservativeRasterandDepthBiasClamp. Title-supplied nonzero values can makeCreateGraphicsPipelineStatefail on the desktop device (for example,ForcedSampleCountother than 0 with a non-UAV-only pass). No test covers this. Either clamp or reject these fields, or add a test that shows the pipeline failure is handled.P2-2.
CMakeLists.txt(startup_stream_rasterizer_ignore_*): the "ignore" control does not run a build with the feature removed. It runs the same binary and passes only because the check script returns 1 andWILL_FAILflips that. This guards nothing beyond theback != frontassertion in the main test. If the apply code is removed, the main test already fails, so the control adds no coverage. I suggest dropping it, or making it a real negative control (for example, an env switch that skips the subobject).nit-1.
d3d12_draw.inl(stream_translation):if (type >= 32) return nullptr;runs after the table check. It is only needed for type 27's shift guard, so a comment or a combined condition would be clearer.nit-2. RASTERIZER2 (type 28) is still refused, as before. The docs could say so next to the "remain open" list.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-25T13:05:35Z.
@tedin7 Rebased onto current
mainand force-pushed (c3f7b319→16301332).Conflict resolution kept the PR’s stream
RASTERIZER/RASTERIZER1behavior and main’s newer surrounding changes (startup_stream_setup_obj, slot-57 depth / draw-depth-target tests, compute/mesh86 stream path,use_depth_stencil/indexed_rectPSO keying).Linux could only AST-check the new Python harness;
startup_stream_*WARP/hardware tests remain Windows/CI.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T14:27:39Z.
Review: APPROVED
I merged current main into the contributor branch and added a check that treats RASTERIZER and RASTERIZER1 as one state. The Windows Release suite passed 14/14. The new fixture reads back a clear target for both mixed tag orders on WARP and RTX 4060 Laptop. Removing only the new guard made both mixed streams draw on WARP. Restoring the guard brought both backends to green. This clears the mixed-state review on
d8880190.