D3D12: SYSTEM_TIMESTAMP frequency for Write64BitValueBottomOfPipeX (info wanted) #14

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

@⁠omonkeyz on GitHub · 2026-11-21 17:19 UTC · original

D3D12 CommandList slot 70, Write64BitValueBottomOfPipeX, SYSTEM_TIMESTAMP flag (crates/compat/d3d12_xs/src/bop64.rs)

Flag bit 1 makes the console write EVENT_WRITE_EOP with data_sel 4 (the system counter), not data_sel 3 (the GPU timestamp). Neither the counter's frequency nor its epoch appears in any console binary we have (xgs12, xgs12_10, the debug drivers, xgskmd10.sys, pixrt), and no title we have uses the flag.

The emulator currently converts to the QPC time base. The competing reading is the GPU core-clock counter: PS4 Gnm names data_sel 4 GpuCoreClockCounter, which would be a fixed 1825 MHz on Series X and 1563 MHz on Series S.

If you know the frequency and epoch of the Scarlett system counter, or have a title that uses this flag, please share it here.

**@⁠omonkeyz** on GitHub · 2026-11-21 17:19 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/14) **D3D12 CommandList slot 70, Write64BitValueBottomOfPipeX, SYSTEM_TIMESTAMP flag** (`crates/compat/d3d12_xs/src/bop64.rs`) Flag bit 1 makes the console write EVENT_WRITE_EOP with data_sel 4 (the system counter), not data_sel 3 (the GPU timestamp). Neither the counter's frequency nor its epoch appears in any console binary we have (xgs12, xgs12_10, the debug drivers, xgskmd10.sys, pixrt), and no title we have uses the flag. The emulator currently converts to the QPC time base. The competing reading is the GPU core-clock counter: PS4 Gnm names data_sel 4 GpuCoreClockCounter, which would be a fixed 1825 MHz on Series X and 1563 MHz on Series S. If you know the frequency and epoch of the Scarlett system counter, or have a title that uses this flag, please share it here.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:07:11 +00:00
Author
Owner

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

Public sources don't settle the epoch. They do point to the core-clock reading over QPC.

Encoding (high confidence)

  • AMD PAL (MIT), gfx9_plus_merged_f32_me_pm4_packets.h ME_RELEASE_MEM_data_sel_enum: 3 = send_gpu_clock_counter, 4 = send_system_clock_counter, 6 = send_emulated_sclk_counter (GFX11). The MEC and PFP headers have the same 3/4 values.
  • Linux nvd.h (gfx10) L375-381, also soc15d.h and cikd.h: "3 - send 64bit GPU counter value / 4 - send 64bit sys counter value".
  • No open-source AMD driver emits 4. PAL (gfx9UniversalCmdBuffer.cpp L4378, gfx9ComputeCmdBuffer.cpp L434) and RADV (radv_query.c) write timestamps with 3. They convert it with the kernel's gpu_counter_freq. On gfx10, including the Van Gogh APU, that is SMUIO GOLDEN_TSC: "The SMUIO TSC clock frequency is 100MHz" (gfx_v10_0.c L7715-7786). GOLDEN_TSC is not the CPU TSC; PAL and RADV calibrate against the CPU clock separately.

What 4 counts (medium confidence, inference)

  • AMD calls SCLK "the system (graphics) clock" (amd_shared.h L187/190). PAL's GFX11 enum puts send_emulated_sclk_counter next to it.
  • Sony Gnm (behavioural reference only: GPCS4 GnmConstant.h L1137-1163, GPL) names 3 the "system's 100Mhz global clock" and 4 the "timestamp from the GPU's Core clock". shadPS4 (GPL) implements 4 as host time scaled to the GPU core clock.
  • Older KFD headers name 4 send_cp_perfcounter_hi_lo, which would be a count in the SCLK domain.
  • So "SYSTEM" in the flag name probably means AMD's system clock (SCLK), not system time. The 100 MHz reference/QPC-like counter is the one behind data_sel 3.

Suggested reading

  • Frequency: Series X 1,825,000,000 Hz (Xbox Wire), Series S 1,565,000,000 Hz (xbox.com; the issue says 1563). Assume the default fixed power state; with Dynamic Power States enabled an SCLK counter would tick at a variable rate.
  • Conversion: origin + muldiv_u128(qpc_now - qpc_origin, F_sclk, qpc_freq), kept monotonic.
  • Epoch: the same emulated origin as data_sel 3. Both counters run freely from power-up, so titles can only rely on differences between values.

Still unknown: whether Microsoft's CP firmware remaps 4 on Scarlett, the real epoch, gating behaviour, Scarlett's exact refclk (100 vs 99.81 MHz, as on gfx11 APUs), and the frequency the Xbox API reports. To check empirically, use an RDNA2 Linux box (Steam Deck is the closest APU): pin pp_dpm_sclk, then compare data_sel 4 and 3 deltas around a known delay.

**@⁠QuentinDanblon** on GitHub · 2026-11-21 18:29 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/14#issuecomment-7067292938) Public sources don't settle the epoch. They do point to the core-clock reading over QPC. **Encoding (high confidence)** - AMD PAL (MIT), `gfx9_plus_merged_f32_me_pm4_packets.h` `ME_RELEASE_MEM_data_sel_enum`: 3 = `send_gpu_clock_counter`, 4 = `send_system_clock_counter`, 6 = `send_emulated_sclk_counter` (GFX11). The MEC and PFP headers have the same 3/4 values. - Linux `nvd.h` (gfx10) L375-381, also `soc15d.h` and `cikd.h`: "3 - send 64bit GPU counter value / 4 - send 64bit sys counter value". - No open-source AMD driver emits 4. PAL (`gfx9UniversalCmdBuffer.cpp` L4378, `gfx9ComputeCmdBuffer.cpp` L434) and RADV (`radv_query.c`) write timestamps with 3. They convert it with the kernel's `gpu_counter_freq`. On gfx10, including the Van Gogh APU, that is SMUIO GOLDEN_TSC: "The SMUIO TSC clock frequency is 100MHz" (`gfx_v10_0.c` L7715-7786). GOLDEN_TSC is not the CPU TSC; PAL and RADV calibrate against the CPU clock separately. **What 4 counts (medium confidence, inference)** - AMD calls SCLK "the system (graphics) clock" (`amd_shared.h` L187/190). PAL's GFX11 enum puts `send_emulated_sclk_counter` next to it. - Sony Gnm (behavioural reference only: GPCS4 `GnmConstant.h` L1137-1163, GPL) names 3 the "system's 100Mhz global clock" and 4 the "timestamp from the GPU's Core clock". shadPS4 (GPL) implements 4 as host time scaled to the GPU core clock. - Older KFD headers name 4 `send_cp_perfcounter_hi_lo`, which would be a count in the SCLK domain. - So "SYSTEM" in the flag name probably means AMD's *system clock* (SCLK), not system time. The 100 MHz reference/QPC-like counter is the one behind data_sel 3. **Suggested reading** - Frequency: Series X 1,825,000,000 Hz (Xbox Wire), Series S **1,565,000,000 Hz** (xbox.com; the issue says 1563). Assume the default fixed power state; with Dynamic Power States enabled an SCLK counter would tick at a variable rate. - Conversion: `origin + muldiv_u128(qpc_now - qpc_origin, F_sclk, qpc_freq)`, kept monotonic. - Epoch: the same emulated origin as data_sel 3. Both counters run freely from power-up, so titles can only rely on differences between values. **Still unknown:** whether Microsoft's CP firmware remaps 4 on Scarlett, the real epoch, gating behaviour, Scarlett's exact refclk (100 vs 99.81 MHz, as on gfx11 APUs), and the frequency the Xbox API reports. To check empirically, use an RDNA2 Linux box (Steam Deck is the closest APU): pin `pp_dpm_sclk`, then compare data_sel 4 and 3 deltas around a known delay.
Author
Owner

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

Thanks, recorded. We'll keep data_sel 4 as an SCLK-domain counter at the fixed clock (1.825 GHz on Series X, 1.565 GHz on Series S) unless a title capture shows otherwise.

**@⁠omonkeyz** on GitHub · 2026-11-23 13:12 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/14#issuecomment-7102205148) Thanks, recorded. We'll keep data_sel 4 as an SCLK-domain counter at the fixed clock (1.825 GHz on Series X, 1.565 GHz on Series S) unless a title capture shows otherwise.
This discussion has been locked. Commenting is limited to contributors.
No description provided.