D3D12: AdvancePredicationX advance step size (info wanted) #10

Open
opened 2026-11-26 06:06:59 +00:00 by github-bot · 2 comments
Owner

@⁠omonkeyz on GitHub · 2026-11-21 16:53 UTC · original

D3D12 CommandList slot 86, AdvancePredicationX (crates/compat/d3d12_xs/src/cl_fw.rs)

The console emits firmware record 0x4000d100 (IT1_ADVANCE_PREDICATION_X, one unused dword). It pairs with SetPredicationBufferX, record 0xd0 {buffer_addr_lo, buffer_addr_hi, offset}. The firmware moves the predicate address forward on each advance, but by how much is unknown. The CP firmware isn't in any game dump, and the debug UMDs only validate BufferLocation % 8.

The emulator currently uses predicate = buffer + offset and advance = +8 bytes. That is inferred, not confirmed.

If you have the console d3d12_x.h documentation for AdvancePredicationX, a title that calls it, or the CP firmware handling of 0xd1, please share the step size, plus whether offset is the start position or the stride.

**@⁠omonkeyz** on GitHub · 2026-11-21 16:53 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/10) **D3D12 CommandList slot 86, AdvancePredicationX** (`crates/compat/d3d12_xs/src/cl_fw.rs`) The console emits firmware record 0x4000d100 (`IT1_ADVANCE_PREDICATION_X`, one unused dword). It pairs with SetPredicationBufferX, record 0xd0 `{buffer_addr_lo, buffer_addr_hi, offset}`. The firmware moves the predicate address forward on each advance, but **by how much is unknown**. The CP firmware isn't in any game dump, and the debug UMDs only validate `BufferLocation % 8`. The emulator currently uses predicate = buffer + offset and advance = +8 bytes. That is inferred, not confirmed. If you have the console `d3d12_x.h` documentation for AdvancePredicationX, a title that calls it, or the CP firmware handling of 0xd1, please share the step size, plus whether `offset` is the start position or the stride.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:06:59 +00:00
Author
Owner

@⁠QuentinDanblon on GitHub · 2026-11-21 18:12 UTC · original

No proof of the step size, but here are public data points that narrow it down:

  • AMD PAL (MIT), PM4_PFP_SET_PREDICATION in src/core/hw/gfxip/gfx9/chip/gfx9_plus_merged_f32_pfp_pm4_packets.h and CmdUtil::BuildSetPredication in gfx9CmdUtil.cpp:
    • pred_op (ord2 bits 18:16): 0 clear, 1 ZPASS, 2 PRIMCOUNT, 3 DX12 (Boolean64), 4 Vulkan (Boolean32).
    • Address alignment: 8 bytes for Boolean64, 4 for Boolean32, 16 for ZPASS/PRIMCOUNT.
    • The continue bit (ord2 bit 31) is only legal for ZPASS/PRIMCOUNT. It accumulates several query results into one predicate (radeonsi si_query.c emit_set_predicate sets it on every packet after the first, walking results_base += result_size).
  • What follows from that [inference]: if record 0xd0 points at a DX12-style bool64 buffer, which the 8-byte BufferLocation % 8 check suggests, the firmware cannot use the hardware continue path. The next predicate is then the next aligned bool64, which is +8 and matches the current assumption. The alternatives would be +4 (bool32) or one ZPASS slot (16 B × number of RBs, plus 16 in radeonsi's layout) if the console predicates directly on occlusion query memory.
  • A way to tell them apart from a title: look at the shader or copy that fills the predication buffer. dwordx2 stores at index*8 mean 8; dword stores at index*4 mean 4. Or check whether the offset values passed to SetPredicationBufferX are multiples of 16×RB.

Links: https://github.com/GPUOpen-Drivers/pal (gfx9 PM4 headers), https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/gallium/drivers/radeonsi/si_query.c

**@⁠QuentinDanblon** on GitHub · 2026-11-21 18:12 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/10#issuecomment-7067082291) No proof of the step size, but here are public data points that narrow it down: - AMD PAL (MIT), `PM4_PFP_SET_PREDICATION` in `src/core/hw/gfxip/gfx9/chip/gfx9_plus_merged_f32_pfp_pm4_packets.h` and `CmdUtil::BuildSetPredication` in `gfx9CmdUtil.cpp`: - `pred_op` (ord2 bits 18:16): 0 clear, 1 ZPASS, 2 PRIMCOUNT, 3 DX12 (Boolean64), 4 Vulkan (Boolean32). - Address alignment: 8 bytes for Boolean64, 4 for Boolean32, 16 for ZPASS/PRIMCOUNT. - The `continue` bit (ord2 bit 31) is only legal for ZPASS/PRIMCOUNT. It accumulates several query results into one predicate (radeonsi `si_query.c` `emit_set_predicate` sets it on every packet after the first, walking `results_base += result_size`). - What follows from that **[inference]**: if record 0xd0 points at a DX12-style bool64 buffer, which the 8-byte `BufferLocation % 8` check suggests, the firmware cannot use the hardware continue path. The next predicate is then the next aligned bool64, which is +8 and matches the current assumption. The alternatives would be +4 (bool32) or one ZPASS slot (16 B × number of RBs, plus 16 in radeonsi's layout) if the console predicates directly on occlusion query memory. - A way to tell them apart from a title: look at the shader or copy that fills the predication buffer. dwordx2 stores at `index*8` mean 8; dword stores at `index*4` mean 4. Or check whether the `offset` values passed to SetPredicationBufferX are multiples of 16×RB. Links: https://github.com/GPUOpen-Drivers/pal (gfx9 PM4 headers), https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/gallium/drivers/radeonsi/si_query.c
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 13:12 UTC · original

Thanks, this narrows it down. +8 (bool64) stays the assumption; the next check is the stride of the stores that fill the predication buffer in a title capture.

**@⁠omonkeyz** on GitHub · 2026-11-23 13:12 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/10#issuecomment-7102205665) Thanks, this narrows it down. +8 (bool64) stays the assumption; the next check is the stride of the stores that fill the predication buffer in a title capture.
This discussion has been locked. Commenting is limited to contributors.
No description provided.