Imagination_BXM-4-64

Compute (DM4), Fragment/3D (DM3), and 3D-TQ Transfer (DM3) Kicks

This document specifies the exact hardware register sequences on the SpacemiT K3 (36.56.104.183) for the three workload types executed on Data Masters DM4 (CDM) and DM3 (FRAG 3D and 3D-TQ).


1. Compute / CDM (DM4) ([P][D])

DM4 is the most direct path on the GPU (it does not use the PM, HWRTData, or Freelist) and is the best initial milestone (M3) for validating clean-room firmware.

1.1. CDM Kick Sequence (CCB_CMD_TYPE_CDM)

With MemCtx activated in the BIF (bank 1..7 bound to DM4):

Step Register (Broadcast) Width Value / Source
1 BCAST[0xF330] (MULTICORE_COMPUTE_CTRL_COMMON) 32b Multicore execution setup (core mask = 1 on K3 MC1)
2 BCAST[0x0480] / BCAST[0x0484] 64b cmd.regs.cdm_ctrl_stream_base
3 BCAST[0x1858] 32b cmd.regs.tpu_tag_cdm_ctrl (K3-specific: TPU_DM_GLOBAL_REGISTERS is present!)
4 BCAST[0x17A8] / BCAST[0x17AC] 64b cmd.regs.tpu_border_colour_table
5 BCAST[0x0498] / BCAST[0x049C] 64b cmd.regs.cdm_context_state_base_addr (CSW state buffer)
6 (CSW Resume only) BCAST[0x04D8/0x04DC/0x04E0] 32b/64b Loads saved PDS/CDM resume state and writes BCAST[0x0490] = 1 → Mandatory poll CR[0x0490] bit 0 == 0
7 BCAST[0x04A8] / BCAST[0x04AC] 64b Programs ping-pong PDS state (buffer A or B)
8 BCAST[0x04B0], BCAST[0x04B8/0x04BC], BCAST[0x04C0] 32b/64b CDM context PDS task parameters
9 BCAST[0x0478] 32b 1 (CDM_START trigger)
10 CR[0x0B00] (MTS_SCHEDULE) 32b 0 (releases BG for other DMs if overlapping)

1.1.1 Compute with Zero Workgroups and execute_count ([D])

The CDM kick has no special path for “zero workgroups”: it always programs the CDM and triggers CDM_START. What exists is control over how many cores execute the wave:

if (flags & ROGUE_COMPUTE_FLAG_SINGLE_CORE) == 0 and num_cores != 1:
    BCAST[0xF330] = (execute_count << 8) | ((1 << num_cores) - 1)
else:
    BCAST[0xF330] = 1

1.2. CDM Completion (HW1 — EVENT_STATUS & 0x04)

  1. Clears event: BCAST[0x0138] = 0x04.
  2. If a CSW store was active:
    • Mandatory poll: ROGUE_CR_CDM_CONTEXT_STORE_STATUS (CR[0x04A0]) bit 0 == 1.
    • Checks CR[0x04A0] bit 1: if == 1, CDM was preempted (saves stored-core bitmask in the context, flushes compute cache, and does not retire the cCCB command).
  3. If normal completion:
    • Clears CSW flags in the context.
    • Executes the DM4 completion flush (full sequence in data-masters.md §4.1): BCAST[0x4000] = 1; CR[core*0x80000+0x0688] = 4 + poll; BCAST[0x0668] = 9 + poll b0; BCAST[0x1608] = 0x10001 + poll b0; BCAST[0x1488] = 1; BCAST[0x1744] = 0x280; BCAST[0x1740] = 0 (MCU_FENCE); BCAST[0x1720] = 0x13 (GP) / 0x33 + poll 0x1728 b0; barrier 0xBFC01800 = 1 + ehb + sync; and finally BCAST[0x3818] = 8 (DM_COMPUTE) + poll of ROGUE_CR_SLC_STATUS0 (0x3820) bit 2 == 0.
    • Retires the cCCB command (executes UPDATEs and advances Roff). Order matters: the SLC flush happens before the UPDATE/retirement — the host never sees the fence before the data is in DRAM.
  4. Deactivates MemCtx in the BIF, reschedules the DM4 queue, and updates statistics if needed.

2. Fragment / 3D Rendering (DM3) ([P][O][D])

DM3 executes full rendering (CCB_CMD_TYPE_FRAG) or SPM Partial Render (CCB_CMD_TYPE_FRAG_PR), using PM HW Context 1 and the 6 ISP pipes of the BXM-4-64.

2.1. 3D Kick Sequence

With MemCtx activated in the BIF (DM3) and HWRTData + Freelist loaded in the PM (HW context 1):

Step Register (Broadcast / Unicast) Width Value / Source
1 BCAST[0xF310] (MULTICORE_FRAGMENT_CTRL_COMMON) 32b Multicore fragment setup (1 core on K3)
2 BCAST[0x4070..0x4090] 32b usc_pixel_output_ctrl and usc_clear_register0..7
3 BCAST[0x40A0] 32b view_idx (multiview)
4 BCAST[0x3E40] 32b hwrtdata_common.screen_pixel_max (frag_screen)
5 BCAST[0x0F20] / BCAST[0x0F24] 64b hwrtdata.rgn_header_dev_addr + aligned_rgn_stride * current_rt
6 BCAST[0x0F18] 32b hwrtdata_common.isp_mtile_size
7 BCAST[0x0FA8] / BCAST[0x0FAC] 64b multi_sample_ctl (normal or flipped per flag)
8 BCAST[0x0FB0..0x0FBC] 64b isp_scissor_base and isp_dbias_base
9 BCAST[0x0F80] 32b cmd.regs.isp_bgobjdepth
10 BCAST[0x0F30] 32b cmd.regs.isp_aa
11 CR[core*0x80000+0x0FC0] / [+0x0FC4] 64b cmd.regs.isp_oclqry_base per core (if GET_VIS_RESULTS flag is set), advancing by cmd.regs.isp_oclqry_stride for each core
12 BCAST[0x0F28] 32b hwrtdata.rgn_header_size
13 BCAST[0x0620], BCAST[0x0628] 32b event_pixel_pds_code / event_pixel_pds_data / event_pixel_pds_info (0x0618)
14 BCAST[0x1510..0x154C] and BCAST[0x1550..0x158C] 64b × 8 Up to 8 PBE MRTs: pbe_word[i][0] at 0x1510 + i*8, pbe_word[i][1] at 0x1550 + i*8 (adjusted by RTA slice offset when current_rt > 0)
15 BCAST[0x1790] / BCAST[0x1794] 64b cmd.regs.tpu_border_colour_table
16 BCAST[0x0FD8] 32b min(((cmd.regs.isp_ctl >> 12) & 0xF) + 1, 6) (6 physical ISP pipes on K3!)
17 BCAST[0x06A0..0x06BC] 64b/32b pds_bgnd0_base, pds_bgnd1_base, pds_bgnd3_sizeinfo, pds_bgnd_reg_sizeinfo
18 BCAST[0x06D0] 32b Pixel Merge: 0x7F if DISABLE_PIXELMERGE, otherwise 0x1F \| pr_flag
19 BCAST[0x0F38] (ROGUE_CR_ISP_CTL) 32b cmd.regs.isp_ctl (typical value observed on K3 board: 0x8003500F)
20 BCAST[0x0F48..0x0F6C] 64b/32b ZLS: isp_zlsctl, zload_base, zstore_base, stencil_load_base, stencil_store_base (with RTA stride and on-demand buffers in PR)
21 BCAST[0x0F88] 32b cmd.regs.isp_bgobjvals
22 BCAST[0x0338] (PM_PARTIAL_RENDER_ENABLE) 32b 1 if Partial Render (SPM), 0 otherwise
23 CR[0x0388], CR[0x03D8], CR[0x03E0], CR[0x01C0] 32b 3D PM state: memfree flag (0x0388), current_rt index (0x03D8), last RT flag (0x03E0), PR flag (0x01C0)
24 (CSW Resume only) CR[0x0298], CR[0x01C8], CR[0x1020], BCAST[0x0F08] 32b Restores saved values (0x0360/0x0370/0x1008) into 0x0298/0x01C8/0x1020 and writes BCAST[0x0F08] \|= 0x10; on normal kick, writes 0 to 0x0298 and 0x01C8
25 BCAST[0x0F00] 32b 1 (ISP_START_RENDER trigger)
26 CR[0x0B00] (MTS_SCHEDULE) 32b 0 (allows BG to schedule other DMs)

2.1.1. Per-Slice Patching (current_rt) ([O])

When the HWRTData belongs to a Render Target Array, each 3D kick processes one slice; the index is rta_ctl.current_render_target (a 32-bit field published by TA in CR[0x0D20]). The equations below use field names from the mainline 1.1 ABI — the exact offsets of each struct are in command-structs.md and data-structures.md; numeric offsets inside the DDK 24.2 command differ and must not be copied.

a) PBE — BCAST[0x1510..0x158C]. There are 8 MRTs × 16 B (2 qwords each), arranged in two interleaved banks of 8 64-bit entries:

Bank Destination Source
A BCAST[0x1510 + 8*i] (64 b) pbe_word[i][0] from the command
B BCAST[0x1550 + 8*i] (64 b) pbe_word[i][1]

with i = 0..7. All 16 registers are written unpatched in this step.

Slice patch — condition: rta_ctl.max_rts < 2 and the two low bits of the high word of the first pbe_word[0][1] equal 2. That is: only in the single-RT case with the PBE in this mode — not in the multi-RT case.

v = current_rt << 14
for off in {0x1550, 0x1558, 0x1560, 0x1568, 0x1570, 0x1578, 0x1580, 0x1588}:
    BCAST[off] = (CR[off] & 0xF0003FFF) | v

Field [29:14] (16 bits, unit 16 KiB) receives the slice index; bits [31:30] and [13:0] are preserved. The 0x1510 range is not patched.

b) Region header — BCAST[0x0F20] (64 b):

stride = ((hwrtdata_common.rgn_header_size * 6) + 0xFFF) & 0xFFFFF000
BCAST[0x0F20] = hwrtdata.rgn_header_dev_addr + stride * current_rt

The factor 6 is literal (it is (x<<3) - (x<<1)). The field is the number of region headers (simple parameter format 2).

c) Z / Stencil bases — BCAST[0x0F48..0x0F6C] (64 b each):

Register Value
0x0F48 isp_zload_base — unpatched
0x0F50 and 0x0F58 isp_zstore_base + current_rt * zls_stride (same value in both)
0x0F60 and 0x0F68 isp_stencil_load_base + current_rt * sls_stride (same value in both)

zls_stride and sls_stride are command fields (see command-structs.md); isp_stencil_store_base tracks the corresponding pair.

d) Slice indicators:

2.1.2. Occlusion Queries (ROGUE_FRAG_FLAGS_GET_VIS_RESULTS) ([D])

There is no extra bit in ISP_CTL and no specific flush. When the flag is set, the firmware simply programs the per-core base pair:

for core in 0 .. num_cores-1:
    CR[core*0x80000 + 0x0FC0] = isp_oclqry_base.lo + core * isp_oclqry_stride
    CR[core*0x80000 + 0x0FC4] = isp_oclqry_base.hi  (+ carry)

(num_cores comes from CR[0xF308]; isp_oclqry_stride is a command field.) The results are read back by the host from the buffer pointed to by isp_oclqry_base; the firmware does not read them.

2.2. 3D Completion (HW1 — EVENT_STATUS & 0x08)

  1. Checks mode = CR[0x0F08] & 3: if mode == 0, it is a normal 3D / PR render; if mode != 0, it is a 3D-TQ (see section 3.2).
  2. If a CSW store was active:
    • Checks ROGUE_CR_ISP_STATUS (CR[0x1038]) bit 0 == 0 (render did not run to completion).
    • If preempted: saves CR[0x1008] into context_state, performs mandatory poll of CR[0x03F8] mask 0xC2 == 0xC2, saves CR[0x0360] and CR[0x0370] into context_state, clears BCAST[0x0138] = 0x4108 (or 0x08), flushes 3D cache, and does not retire the cCCB command.
  3. If normal completion (not preempted):
    • ZLS Store sync: if (CR[0x0F48] & 4) != 0 (Z/S store enabled), polls EVENT_STATUS (CR[0x0130]) bit 14 (0x4000) == 0x4000 and clears with BCAST[0x0138] = 0x4008 (otherwise clears 0x08).
    • PM 3D MemFree sync: if CR[0x0388] & 1 == 1 (PM page freeing enabled), polls CR[0x0130] bit 8 (0x100) == 0x100 and clears BCAST[0x0138] = 0x100.
    • RTA (Render Target Array) loop: if hwrtdata.active_render_targets > 0 and current_rt < active_render_targets - 1:
      • Increments current_rt, loads the next valid target from valid_render_targets, and immediately re-triggers the 3D kick for the next slice without retiring the cCCB command!
    • End of all slices:
      • If it was a Partial Render (SPM): flushes 3D cache, sets HWRTDATA_PARTIAL_RENDERED (BIT(3) in hwrtdata.hwrt_data_flags), and signals PR completion to the SPM controller (which will schedule TA resumption — see partial-render-spm.md).
      • If it was a normal 3D render: clears HWRTDATA_HAS_LAST_GEOM (BIT(2) in hwrtdata.hwrt_data_flags), executes the DM3 completion flush (data-masters.md §4.1: BCAST[0x0688] = 2 per core, 0x0668 = 3, 0x1608 = 0x38001, extra block 0x1470/0x1478/0x1480, 0x1744 = 0x180, 0x1720 = 0xb/0x2b, wrapper barrier, and BCAST[0x3818] = 6 = DM_TA\|DM_PIXEL + poll 0x3820 b2), retires the cCCB command (executing UPDATEs), notifies the SPM controller of 3D page release (in case a TA is waiting for memory), and reschedules DM2/DM3.

3. Transfer via 3D Pipeline — 3D-TQ (DM3) ([P][O][D])

On the SpacemiT K3 (no TLA/TDM), texture copies and readbacks use CCB_CMD_TYPE_TQ_3D, which drives the same ISP/PBE hardware in a simplified mode without HWRTData/PM.

3.1. 3D-TQ Kick Sequence

Step Register (Broadcast) Value / Source
1 BCAST[0xF310] Multicore fragment setup
2 BCAST[0x0F88] cmd.regs.isp_bgobjvals
3 BCAST[0x06A0..0x06BC] pds_bgnd0/1/3/reg_sizeinfo
4 (If (cmd.regs.isp_render & 3) == 2 — fast mode) BCAST[0x0F20/0x0F24], 0x0F28, 0x0FCC, 0x0FC8 Fast transfer region address/size
5 BCAST[0x4070..0x4090] usc_pixel_output_ctrl and clear regs
6 BCAST[0x3E40], 0x0F18, 0x0F10 frag_screen, isp_mtile_size, ISP control
7 BCAST[0x0FD8] min(((cmd.regs.isp_ctl >> 12) & 0xF) + 1, 6) (max 6 pipes on K3)
8 BCAST[0x0F30], 0x0628, 0x0618, 0x0620 isp_aa and event_pixel_pds_*
9 BCAST[0x1510..0x1524] and BCAST[0x1550..0x1564] Up to 3 PBE MRTs (word0 and word1)
10 BCAST[0x0388] = 0, BCAST[0x0F48/0x0F4C] = 0 Disables PM memfree and ZLS
11 BCAST[0x0F38] cmd.regs.isp_ctl
12 (CSW Resume only) CR[0x1020] + isp_render \|= 0x10 Restores saved state
13 BCAST[0x0F00] = 1 followed by BCAST[0x0F08] = cmd.regs.isp_render Mandatory dual trigger (ISP_START_RENDER + ISP_RENDER mode)

3.2. 3D-TQ Completion (HW1 — EVENT_STATUS & 0x08 with CR[0x0F08] & 3 != 0)

  1. Clears event: BCAST[0x0138] = 0x08.
  2. If preempted via CSW, flushes 3D cache and preserves the command in the cCCB.
  3. Normal case: executes the same DM3 completion flush used by 3D (data-masters.md §4.1, including BCAST[0x3818] = 6), retires the cCCB command, updates UFOs, releases MemCtx in the BIF, and reschedules DM3.

4. Context Switch (CSW) per DM ([O])

Each DM has two halves: store (the firmware programs the dump destination and triggers it; the hardware writes the state) and resume (the next kick reprograms the source and resumes).

The preemption request arrives through a per-DM dispatcher: 2 and 6 → VDM/TA, 3 → ISP/3D, 4 → CDM; the other DMs do not have CSW.

  VDM / TA (2, 6) ISP / 3D (3) CDM (4)
store trigger CR[0x0468] = 1 (unicast) BCAST[0x1000] = 1 CR[0x0488] = 1 (per core or broadcast)
completion CR[0x0430] & 1 CR[0x03F8] & 0xC2 == 0xC2 CR[0x0490] returns to 0
timeout 0x4F ticks of CR[0x0160]; on expiration → pulse CR[0x0100] = 0x804000 (GPP+TESS reset) and restore 0x0418/0x0420 BCAST[0x0138] = 0x4118 + DM3 completion flush (data-masters.md §4.1) DM watchdog
store addresses 0x0428, 0x0CC0, 0x0438..0x0460 from the context’s ctxswitch_regs 0x04A8/0x04B0/0x04B8/0x04C0 (A/B)
resume 0x0408 (stream), 0x0418/0x0420 (call stack) 0x1020 (per core), 0x0298, 0x01C8, 0x0F08 \|= 0x10 0x04D8/0x04DC, 0x04E0 + 0x0490 = 1

4.1 VDM / TA

4.2 ISP / 3D

4.3 CDM (ping-pong A/B)

The CDM context maintains two sets of buffers and alternates on each kick (toggle ^= 1):

# resume (always from the buffer opposite to the next store)
if (toggle & 1) == 0: resume_pds0 = cdmreg_cdm_resume_pds0      (A)
else:                 resume_pds0 = cdmreg_cdm_resume_pds0_b    (B)
for each active core:
    CR[core*0x80000 + 0x04D8] = resume_pds0.lo
    CR[core*0x80000 + 0x04DC] = resume_pds0.hi
    CR[core*0x80000 + 0x04E0] = command_resume_field
    CR[core*0x80000 + 0x0490] = 1            # trigger
    poll(CR[core*0x80000 + 0x0490] == 0)

# next context
toggle ^= 1
if (toggle & 1) == 0: BCAST[0x04A8] = cdmreg_cdm_context_pds0    (A)
else:                 BCAST[0x04A8] = cdmreg_cdm_context_pds0_b  (B)
BCAST[0x04B0] = cdmreg_cdm_context_pds1
BCAST[0x04B8] = cdmreg_cdm_terminate_pds      (64 b)
BCAST[0x04C0] = cdmreg_cdm_terminate_pds1

Result: resume from A ⇒ next store in B, and vice versa. The CDM ctxswitch struct is 56 B (context_pds0, context_pds1, terminate_pds, terminate_pds1, resume_pds0, context_pds0_b, resume_pds0_b).