From 10e03cd7571e905c17092e234a74eed217f1c83d Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Mon, 16 Nov 2026 23:45:08 -0500 Subject: vgsp: eng89s - admit the real CALL(0) 0x3800 draw; GZ_EGL harness The real 570.144 direct-GL draw window (12068 B @ push 0x402f9d8) carries no 0x3910/0x3914 write. Its draw is an op=4 IMMD to method 0x3800 (imm=0xd48=3400) plus CALL slots 44/57/58 (0x3960/0x39c8/0x39d0), and the window has no colour-target bind of its own, so RT-gated admission sent it down the compute-QMD lane. Recognize and admit the real marker: the walker, chunk check and window marker accept 0x3800/0x3960/0x39c8/0x39d0 (0x3910/ 0x3914 kept); the call-0 admission predicate scans the admitted window (a pre-window run header can swallow the window head); the draw chunk is forced first (draw_slice=1, order 0) and the window replayed verbatim. The booter's DRAW_IAB window predicate accepts the op=4 CALL(0) and the secondaries, the census names slot 0 (MME-CALL-ARGS slot=0 data=), and the final emitted window gets MME-EXEC-CALL slot=0 (the physical GR front-end executes the CALL; the kernel has no CALL interpreter, the 0x114 prelude uploads precede the window in the same launch). Guest harness: add tools/guest-diag/gz_es.c and an on-demand build in push_gl_tools.sh; GZ_EGL=1 switches gzdoom_pbuf_run.sh/mission-gz.sh to SDL offscreen + real NVIDIA EGL/GLES (default unchanged); push_gl_tools.sh creates the NVIDIA EGL vendor ICD only when missing. Receipts: c1025 GL-FLUSH admitted=1, DRAW-WRITE m=0x3800 op=4 data=0xd48, 3D mark admitted (CALL(0) 0x3800 draw marker), 3D stream chunked, 3D chunk launch draw=1, MME-CALL-ARGS slot=0 data=0xd48, MME-EXEC-CALL slot=0 op=4 imm=0xd48. Exact 0x402f9d8 post-fix replay still unverified (run wedged on an earlier draw window); stores/px remain open. --- kernel/gsp_phys_booter.c | 84 ++++++++++++++++++++++++++++++++++- kernel/gsp_sema_service.c | 110 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 186 insertions(+), 8 deletions(-) (limited to 'kernel') diff --git a/kernel/gsp_phys_booter.c b/kernel/gsp_phys_booter.c index 2be4a60..5f1b99f 100644 --- a/kernel/gsp_phys_booter.c +++ b/kernel/gsp_phys_booter.c @@ -19164,7 +19164,19 @@ MODULE_PARM_DESC(sema_gl_mme_release_chain, * carry 1+cnt words; only op 1/3 walk past the header method), so a * CALL_MME_DATA(34) port write (0x3914) or another slot's call never * selects the record. + * + * eng89s: the real 570.144 direct-GL draw is CALL_MME_MACRO(0) - an IMMD + * (op 4) write to 0x3800 whose immediate is the macro program length + * (c1022: hdr 0x8d480e00 imm=0xd48=3400) - with 0x3960/0x39c8/0x39d0 + * (slots 44/57/58) as secondaries. Accept it as a DRAW_IAB-bearing + * window so the saved-window release prefers the real draw chunk. */ +static bool gsp_phys_gr_mme_draw_method(u32 m) +{ + return m == 0x3800u || m == 0x3910u || m == 0x3914u || + m == 0x3960u || m == 0x39c8u || m == 0x39d0u; +} + static bool gsp_phys_gr_mme_window_has_draw_ia(const u32 *win, u32 n) { u32 r = 0; @@ -19185,14 +19197,19 @@ static bool gsp_phys_gr_mme_window_has_draw_ia(const u32 *win, u32 n) * k=(0x3910-0x804)/4 with the macro data/address in the * following word. Only count it when that data word exists * (k + 1 < span), so a bare method mention is not a CALL. + * eng89s: an op=4 CALL(0) carries its argument as the header + * immediate, so it needs no following data word. */ for (k = 0; k < span; k++) { u32 m = ((h & 0xfffu) << 2) + 4u * k; if (k && op != 1u && op != 3u) break; - if (m == 0x3800u + 34u * 8u && - k + 1u < span && r + k + 1u < n) + if (!gsp_phys_gr_mme_draw_method(m)) + continue; + if (m == 0x3800u && op == 4u && cnt) + return true; + if (k + 1u < span && r + k + 1u < n) return true; } r += span; @@ -19503,6 +19520,28 @@ static void gsp_phys_gr_mme_call_census(const struct gsp_phys_gr_submit *req, (have_gold ? gent : 0u), win_n, held); } + /* + * eng89s: the real draw's CALL_MME_MACRO(0) target. + * An IMMD carries its argument in the header immediate; + * an interior INC/ONEINC run carries it in the following + * data word. + */ + if (j == 0u) { + u32 data = 0; + + if (op == 4u) + data = (h >> 16) & 0x1fffu; + else if (k + 1u < span) + data = req->stream[r + k + 1u]; + pr_info("vgsp-gr: MME-CALL-ARGS slot=0 data=0x%x at=%u\n", + data, r + k); + pr_info("vgsp-gr: MME-CALL-TARGET slot=0 method=0x%x client=0x%x golden=0x%x used=0x%x win=%u held=%u\n", + m, have_cli ? sa_ent[0] : 0u, + have_gold ? gent : 0u, + have_cli ? sa_ent[0] : + (have_gold ? gent : 0u), + win_n, held); + } } r += span; } @@ -26013,6 +26052,47 @@ if (gsp_phys_gr_slot_kept(j, sa_mask, wn, w); } } + /* + * eng89s: op=4 CALL_MME_MACRO(0) execution receipt. There is + * no kernel-side CALL interpreter: the FINAL emitted window is + * walked by the physical GR front-end, and CALL(0) resolves to + * the START-ADDRESS RAM entry the prelude pack uploaded. A + * call that survived the hold/elision passes above is in the + * emitted bytes, so name its resolved target; a held call has + * no receipt (MME-CALL-HOLD names the hold instead). + */ + if ((u32)(p - pb) > win_emit_off) { + static u32 mme_exec_log; + u32 ew = win_emit_off, en = (u32)(p - pb); + + while (ew < en && mme_exec_log < 32u) { + u32 h = pb[ew]; + u32 op = (h >> 29) & 7u; + u32 cnt = (h >> 16) & 0x1fffu; + u32 span = 1u; + u32 m0 = (h & 0xfffu) << 2; + + if ((op <= 3u || op == 5u) && cnt && + ew + 1u + cnt <= en) + span = 1u + cnt; + if (m0 == 0x3800u && + (op == 4u || op == 0u || op == 1u || + op == 3u || op == 5u)) { + u32 sa_ent[64] = { 0 }; + u64 sa_mask = gsp_sema_mme_sa_get( + sa_ent, 64); + u32 addr = (sa_mask & 1ull) ? + sa_ent[0] : 0u; + + mme_exec_log++; + pr_info("vgsp-gr: MME-EXEC-CALL slot=0 addr=0x%x h=0x%x push=0x%llx rel=%u op=%u imm=0x%x\n", + addr, req->h_object, + req->push_va, req->stream_rel, + op, op == 4u ? cnt : 0u); + } + ew += span; + } + } /* * eng39: neutralize the client's own notify/report-semaphore * targets in the FINAL emitted window (after the CALL/pair diff --git a/kernel/gsp_sema_service.c b/kernel/gsp_sema_service.c index ad99397..7eb67ae 100644 --- a/kernel/gsp_sema_service.c +++ b/kernel/gsp_sema_service.c @@ -11953,6 +11953,20 @@ static bool svc_gl_mismatch_new_push(u64 push_va) return true; } +/* + * eng89s: the real direct-GL draw markers. The 570.144 client encodes the + * draw as CALL_MME_MACRO(0): an IMMD (op 4) write to method 0x3800 whose + * immediate is the macro program length (c1022: hdr 0x8d480e00, m=0x3800, + * imm=0xd48=3400), followed by CALL slots 44/57/58 as ONE_INC runs to + * 0x3960 / 0x39c8 / 0x39d0. The older DRAW_IAB slots 34 (0x3910 macro / + * 0x3914 data) stay accepted for the lanes that use them. + */ +static bool svc_gl_draw_method(u32 m) +{ + return m == 0x3800u || m == 0x3910u || m == 0x3914u || + m == 0x3960u || m == 0x39c8u || m == 0x39d0u; +} + static u32 svc_gl_draw_walk(const u32 *win, u32 n, u32 base_word, u32 *at, u32 *span_out, u32 *runs_out, bool log_it, struct svc_channel *ch, u64 push_va) @@ -11988,7 +12002,7 @@ static u32 svc_gl_draw_walk(const u32 *win, u32 n, u32 base_word, if (k && !incr) break; m = m0 + 4u * k; - if (m != 0x3910u && m != 0x3914u) + if (!svc_gl_draw_method(m)) continue; if (!found) { *at = r; @@ -12001,6 +12015,23 @@ static u32 svc_gl_draw_walk(const u32 *win, u32 n, u32 base_word, ch->h_object, push_va, base_word + r, m, op, cnt, span); } + /* + * eng89s: the CALL(0) marker is an IMMD: its argument is + * the header's immediate, not a following data word. + */ + if (m == 0x3800u) { + if (log_it && svc_gl_draw_write_log < 16u) { + u32 data = op == 4u ? cnt : + (k + 1u < span ? + win[r + k + 1u] : 0u); + + svc_gl_draw_write_log++; + pr_info("sema-gl: DRAW-WRITE h=0x%x push=0x%llx m=0x3800 op=%u data=0x%x at=%u run=%u\n", + ch->h_object, push_va, op, data, + r + k, r); + } + continue; + } /* eng89r: the write word and its data word, bounded * 16 per push. `at`/`run` are window words. */ if (log_it && svc_gl_draw_write_log < 16u && @@ -12364,12 +12395,13 @@ static bool svc_gl_chunk_has_draw_ia(const u32 *win, u32 n) if ((op <= 3u || op == 5u) && cnt && r + 1u + cnt <= n) span = 1u + cnt; - /* eng89r: interior methods again (see svc_gl_draw_walk). */ + /* eng89r: interior methods again (see svc_gl_draw_walk). + * eng89s: the real draw is CALL(0) (0x3800, op 4 IMMD) with + * 0x3960/0x39c8/0x39d0 as the slot 44/57/58 secondaries. */ for (k = 0; k < span; k++) { if (k && !incr) break; - if (m0 + 4u * k == 0x3910u || - m0 + 4u * k == 0x3914u) + if (svc_gl_draw_method(m0 + 4u * k)) return true; } r += span; @@ -12744,6 +12776,11 @@ static bool svc_gl_win_has_draw_legacy(const u8 *buf, u32 len) * r + (0x3910 - 0x804)/4). Walk every method the run reaches * (m0 + 4*k, k= at_off || at_off > len) + return false; + r = start_off / 4u; + end = at_off / 4u; + n = len / 4u; + while (r < end && r < n) { + u32 h = win[r]; + u32 op = (h >> 29) & 7u; + u32 cnt = (h >> 16) & 0x1fffu; + u32 span = 1u; + u32 m0 = (h & 0xfffu) << 2; + + if ((op <= 3u || op == 5u) && cnt && r + 1u + cnt <= end) + span = 1u + cnt; + if (op == 4u && m0 == 0x3800u && cnt >= 0x100u) + return true; + r += span; + } + return false; +} + static void svc_gl_rt_note(const u8 *buf, u32 len, u64 h, u64 push) { u32 A[4] = { 0 }, B[4] = { 0 }, W[4] = { 0 }, H[4] = { 0 }; @@ -12892,6 +12969,27 @@ static bool svc_gl_window_drawwin_ok(const u8 *buf, u32 len, u32 start_off, } return true; } + /* + * eng89s: the real draw window carries the CALL(0) marker but no + * colour-target bind of its own (c1022: RT-SCAN found no 0x800..0x80c + * write and no bind was persisted on the channel), so every clause + * above misses and the window fell to the compute-QMD lane. The + * op=4 CALL(0) with a plausible macro-program length is the primary + * draw marker of this lane; admit on it. The caller still enforces + * the raw/geometry gates before streaming. + */ + if (svc_gl_win_has_draw_call0(buf, len, start_off, at_off)) { + static u32 call0_adm_log; + + if (call0_adm_log < 16u) { + call0_adm_log++; + pr_info("sema-gl: 3D mark admitted (CALL(0) 0x3800 draw marker) start=0x%x at=0x%x win=%u words\n", + start_off, at_off, + at_off > start_off ? + (at_off - start_off) / 4u : 0u); + } + return true; + } /* * eng89: the draw window usually carries no bind of its own (the * target was bound by an earlier state push). Admit on the -- cgit v1.2.3