d3d12_xs: remap Xbox Series PSO stream subobjects (AS=23, MS=24, ext 25..30) #168
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!168
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/168/head"
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?
@GDAgent on GitHub · 2026-11-22 17:27 UTC · original
GDAgent:fix/d3d12-xbox-pso-stream-subobjects→main· +610 −24 · 1 files · 2 commits · closed without mergingLibrary / area: d3d12_xs (
mesh_pso.rs)Exports changed (exports.txt rows): none
Source of the behaviour: console debug UMD
xgs12_10d.dll10.0.22000.3160 (RVAs for that file):D3d12Device2_CreatePipelineState(0x8aa40) calls the stream parser0x8e100. Itsswitchover types0..=30gives the record sizes inCONSOLE_RECORD_SIZE.0..=22match PCd3d12.h;23= AS and24= MS (24 B each);25..30= 40/32/64/16/32/16 B.0x1f5070, handlers0x8a540(25),0x8a5f0(26),0x8a6d0(27),0x8a7f0(28),0x8a870(29),0x8ecb0(30). Each of 25-29 sets an extension bit only for a non-default payload; bits 0-3 become theCreateGraphicsPipelineStateXextended descs 0-3.0xc23c0(DB_DEPTH_CONTROL,DB_STENCILREFMASK(_BF)). Stencil-op table:0x2332d0. DepthBoundsDisable overwrite:0x8afe2. Shader-limit validators:0xa9660(graphics),0xa9850(compute).Changes:
26 DEPTH_STENCIL2,27 RASTERIZER1,28 RASTERIZER2and29 SERIALIZED_ROOT_SIGNATUREnow have PC layouts.E_INVALIDARG.23/24→ PCAS/MS(a null shader is omitted). For 25-30:25pixel-shader options and28tessellation parameters: dropped when default (console no-op), otherwise refused.26DEPTH_STENCIL_OPTIONS: default dropped, otherwise mapped.STENCILOPVAL 0turnsINCR/DECRops intoKEEP;BACKFACE_ENABLE 0copies the front-face state to the back face; back-face masks that differ from the front ones becomeDEPTH_STENCIL2whenIndependentFrontAndBackStencilRefMaskSupported. Colour-writes-on-depth bits, non-zero stencil test refs, other op values, and differing masks without device support are refused.27/29CU and wave scheduling limits: dropped, logged as hints.30(pointer, never read by the console build path): dropped and logged.pso_ext'sDsExtandBlockfield tables.mesh_dxil_topologynow shares the PSV0 walk with the new stage check.Tests:
cargo test -p d3d12_xs --lib mesh_pso: 14 passed, 0 failed.DEPTH_STENCIL2.cargo test -p d3d12_xs --lib: 553 passed, 4 failed. The same 4 fail on cleanmain(546/4):alias::msaa_depth_…,placed_offset::uneven_views_…,title_shadow::buffer_then_texture_…,xs_exports::console_fixed_tests.Not verified in a title: an earlier UE5 title run sent only extension 26, with back masks
0xff/0xffor0xff/0xf4and op values0/0or1/1. This build has not been run against a title. Rendering through the mapped stencil state is untested on hardware.cargo test -p d3d12_xs --lib mesh_psopasses@omonkeyz on GitHub · 2026-11-22 17:36 UTC · original
Thanks, the console stream numbering from the UMD parser is useful. We can't take the remap unconditionally yet, though.
xbox_to_pc_streamruns on every consoleCreatePipelineStatestream. We can't yet confirm that every title we run (Fortnite, XDefiant, Minecraft) sends console numbering. If one of them sends PC numbering, AS=24 / MS=25, its MS would be dropped as an extension and its AS treated as the MS.Please change it to:
Everything else is fine as written. Once it's updated I'll apply it with your authorship kept.
@GDAgent on GitHub · 2026-11-22 18:42 UTC · original
Updated per your review and rebased onto current
main:xbox_to_pc_streamnow remaps only when the stream is clearly console-numbered (contains23, any of26..=30, or24without25).24and25(PC-numbered) or nothing above22(as well as PC-sized25alone) pass through unchanged.25with23or26..=30(or a 40-byte25without console-only subobjects) are refused with an explicit error and logged inCreatePipelineState.CreatePipelineStatelogs the raw subobject type list and classification (console-remap,passthrough,ambiguous-refused) for the first 8 console stream PSOs.xbox_stream_remaps_as_ms_and_drops_console_extensions,xbox_stream_passes_through_pc_numbered_and_basic_streams,xbox_stream_refuses_ambiguous_subobject_25_mixes) alongside the existing record-size, duplicate, unknown-type, and truncation checks.Ready for re-review!
@omonkeyz on GitHub · 2026-11-22 18:54 UTC · original
Thanks for the update. It applies cleanly on current main, and the d3d12_xs lib tests pass (552/0). Because it changes every CreatePipelineState call, it is waiting on a go/no-go from the graphics lead. The open questions:
@omonkeyz on GitHub · 2026-11-22 18:55 UTC · original
The graphics lead has reviewed this, and it needs changes before it can land:
Thanks, the structure is close.
@GDAgent on GitHub · 2026-11-22 19:26 UTC · original
Thanks for the detailed review. Reworked in
49f8ed3(rebased onto currentmain,#176code kept). All evidence is from the console debug UMDxgs12_10d.dll10.0.22000.3160 (RVAs below are for that file).Where the table comes from.
D3d12Device2_CreatePipelineState(0x8aa40) runs the stream parser0x8e100: aswitchover types0..=30(anything above 30 is rejected) that hands each payload to a builder vtable (0x1f5070) and advances by a fixed record size. That size table is now theCONSOLE_RECORD_SIZEconstant:0:16, 1-6:24, 7:40, 8:336, 9:8, 10:48, 11:56, 12:24, 13:8, 14:8, 15:40, 16:8, 17:16, 18:8, 19:24, 20:8, 21:64, 22:32, 23:24 (AS), 24:24 (MS), 25:40, 26:32, 27:64, 28:16, 29:32, 30:16A test checks that
0..=22equals the PCd3d12.hlayout.1. Classification. The stream is parsed with both the PC and the console size tables (PC now includes Agility
26 DEPTH_STENCIL2 = 64,27 RASTERIZER1 = 48,28 RASTERIZER2 = 48,29 SERIALIZED_ROOT_SIGNATURE = 24; the console sizes for 25-30 are 40/32/64/16/32/16, so they differ):<= 22only → PC (identical); types<= 24→ decided by the type-24 shader's PSV0 stage (mesh → console MS, amplification → PC AS);E_INVALIDARGand the type list.2. Decision for each console subobject 25-30. Each handler copies the payload into the builder and sets bit
nof a flags word (+0x450) only when the payload differs from a fixed default.0x8aa40turns bits 0-3 into theCreateGraphicsPipelineStateXextended descs 0-3 (the same onespso_ext.rsmodels), and the stream code reusespso_ext'sDsExtandBlockfield tables.0x8a540D3D12XBOX_PIXEL_SHADER_OPTIONS_DESC0x8a5f0DEPTH_STENCIL_OPTIONS(name from the validator strings at0x252fb0)0xc23c0intoDB_DEPTH_CONTROL/DB_STENCILREFMASK/DB_STENCILREFMASK_BF. Dword +4 is overwritten afterwards by!DepthBoundsTestEnableof the depth-stencil subobject (0x8afe2)STENCILOPVAL 0:INCR_SAT/DECR_SAT/INCR/DECR→KEEP(op table0x2332d0maps those four toADD/SUB_CLAMP/WRAP; the other ops do not use the op value).BACKFACE_ENABLE 0: back-face state = front-face state. Back-face masks that differ from the front ones → PCDEPTH_STENCIL2whenIndependentFrontAndBackStencilRefMaskSupported, otherwise refused. Refused: colour-writes-on-depth bits, non-zeroStencilTestRefValueFront/Back, op values > 10x8a6d0D3D12XBOX_GRAPHICS_SHADER_LIMITS_DESC0xa9660)0x8a7f0D3D12XBOX_PIPELINE_TESSELLATION_PARAMETERS_DESC{0, 0.0f, 0}; field 0 is passed to the shader-stub generator0x159a000x8a870D3D12XBOX_COMPUTE_SHADER_LIMITS_DESC0x815f0→0x150a40, the same packer asCreateDerivedComputePipelineStateX)0x8ecb0+0x380, never read by0x8aa403. Record sizes come from that table (
CONSOLE_RECORD_SIZE,CONSOLE_EXTfor each payload's offset and length). The RVAs are listed here and in the PR body, not in code.4. Logging. The raw subobject type list of the first 8 console-numbered PSOs is logged, plus one line per distinct extension decision, with its payload and reason.
5. Tests (
cargo test -p d3d12_xs --lib mesh_pso: 14 passed, 0 failed):DEPTH_STENCIL2withDEPTH_STENCIL1bounds kept.The full
d3d12_xslib run shows 553 passed and 4 failed. The same 4 (alias::msaa_depth_…,placed_offset::uneven_views_…,title_shadow::buffer_then_texture_…,xs_exports::console_fixed_tests) also fail on a cleanmainhere (546/4), so they are environment-dependent and not related to this change.Not verified in a title yet. In earlier runs of a UE5 title, the only extension sent was 26, with back masks
0xff/0xff(and0xff/0xf4) and op values0/0or1/1. With this change those PSOs are mapped, or refused if the back masks differ from the front ones on a device without per-face mask support. I have not re-run the title with this build yet.@GDAgent on GitHub · 2026-11-22 19:35 UTC · original
Title check for
49f8ed3. The UE5 Xbox Series title ran for 180 s on native Windows 11 (not under Proton). The build was this PR'smesh_pso.rson top of local unrelated ray-tracing work.[20, 0, 12, 13, 14, 1, 5, 2, 8, 21, 16, 10, 15, 17, 9, 19, 26]: legacy VS/GS/PS,DEPTH_STENCIL1and console26. No 23/24/25/27-30 were seen.26payloads were mapped with no PC-visible change. In those PSOs stencil is off, or the masks and op values already match PC.The stencil-op rewrite and the
DEPTH_STENCIL2path are covered by the unit tests only. This title did not need either of them.@omonkeyz on GitHub · 2026-11-22 22:02 UTC · original
Applied in
f8e28c9+811c96f(merged in47ee74d) with your authorship kept, thanks. The graphics lead reviewed v3 and approved it against all five conditions. I added a small steward follow-up,1a45c7d:d3d12_xs lib tests pass (573/0). It ships in r29 or r30.
Pull request closed