summaryrefslogtreecommitdiffstats
path: root/kernel/gsp_phys_booter.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/gsp_phys_booter.c')
-rw-r--r--kernel/gsp_phys_booter.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/kernel/gsp_phys_booter.c b/kernel/gsp_phys_booter.c
index deb4e0a..607e947 100644
--- a/kernel/gsp_phys_booter.c
+++ b/kernel/gsp_phys_booter.c
@@ -19936,6 +19936,25 @@ module_param_named(sema_gl_raster_prelude, gsp_phys_rmcall_gr_raster_pre,
MODULE_PARM_DESC(sema_gl_raster_prelude,
"Emit CT_WRITE(0..7)=0x1111 + depth/stencil/scissor disable ahead of replayed 3D windows (default 0; A/B)");
+/*
+ * eng67 DRAW-STATE finding (c797): the release launch has RT0/RT1 bound
+ * (alias 0xa000000, 1920x1080, fmt 0xe6), vertex stream 0 bound at
+ * 0x1e305dc and the DRAW_IAB emitted its 8x3-vertex draws (0xd74=0x15),
+ * but the viewport SCALE/OFFSET methods 0xa00..0xa14 are all zero on the
+ * replay context (they are client channel state the per-frame window never
+ * carries), so every vertex maps to (0,0) and no fragment reaches the RT.
+ * Emit a full-color-target viewport before the window, sized from the
+ * tracked RT0 width/height (fallback 1920x1080):
+ * 0xa00 SCALE_X = +W/2.0 0xa04 SCALE_Y = -H/2.0
+ * 0xa08 SCALE_Z = 0.5 0xa0c OFFSET_X = W/2.0
+ * 0xa10 OFFSET_Y = H/2.0 0xa14 OFFSET_Z = 0.5
+ * Beef-family launches only (the direct-GL replay lane). Default 0 = off.
+ */
+static u32 gsp_phys_rmcall_gr_viewport;
+module_param_named(sema_gl_viewport, gsp_phys_rmcall_gr_viewport, uint, 0644);
+MODULE_PARM_DESC(sema_gl_viewport,
+ "Emit a full-RT viewport (0xa00..0xa14, W/H from the RT0 shadow, fallback 1920x1080) before replayed beef 3D windows; 0=off, 1=on (default 0; A/B)");
+
bool gsp_phys_rmcall_gr_raster_pre_value(void)
{
return READ_ONCE(gsp_phys_rmcall_gr_raster_pre);
@@ -32701,6 +32720,67 @@ gr_page_unmapped:
in[nfin++] = 0u;
}
/*
+ * eng67: full-RT viewport for the replay context (see
+ * the sema_gl_viewport comment). The RT0 W/H come from
+ * the C597 method shadow (the client's last color
+ * target bind); a zero/implausible pair falls back to
+ * 1920x1080. Method writes are constant IMMD runs.
+ */
+ if (READ_ONCE(gsp_phys_rmcall_gr_viewport) &&
+ (req->h_object & 0xfffff000u) == 0xbeef0000u) {
+ void __iomem *vbar0 = gsp_phys_gpu_bar0();
+ u32 rtw = vbar0 ? gsp_phys_mme_shadow_read(
+ vbar0, 0xc597u, 0x0808u) : 0u;
+ u32 rth = vbar0 ? gsp_phys_mme_shadow_read(
+ vbar0, 0xc597u, 0x080cu) : 0u;
+ u32 fx, fy, fy_off, fz = 0x3f000000u; /* 0.5f */
+
+ if (rtw < 16u || rtw > 16384u)
+ rtw = 1920u;
+ if (rth < 16u || rth > 16384u)
+ rth = 1080u;
+ /*
+ * IEEE-754 bits without FP: V = W/2 (rounded),
+ * then e = floor(log2 V), mantissa = V<<(23-e).
+ */
+ {
+ u32 vx = (rtw + 1u) >> 1;
+ u32 vy = (rth + 1u) >> 1;
+ int ex = 31 - __builtin_clz(vx);
+ int ey = 31 - __builtin_clz(vy);
+
+ fx = (((u32)(ex + 127)) << 23) |
+ ((vx << (23 - ex)) & 0x7fffffu);
+ fy = 0x80000000u |
+ (((u32)(ey + 127)) << 23) |
+ ((vy << (23 - ey)) & 0x7fffffu);
+ fy_off = (((u32)(ey + 127)) << 23) |
+ ((vy << (23 - ey)) &
+ 0x7fffffu);
+ }
+ in[nfin++] = 0x20000000u | (1u << 16) |
+ (0x0a00u >> 2);
+ in[nfin++] = fx;
+ in[nfin++] = 0x20000000u | (1u << 16) |
+ (0x0a04u >> 2);
+ in[nfin++] = fy;
+ in[nfin++] = 0x20000000u | (1u << 16) |
+ (0x0a08u >> 2);
+ in[nfin++] = fz;
+ in[nfin++] = 0x20000000u | (1u << 16) |
+ (0x0a0cu >> 2);
+ in[nfin++] = fx;
+ in[nfin++] = 0x20000000u | (1u << 16) |
+ (0x0a10u >> 2);
+ in[nfin++] = fy_off; /* OFFSET_Y = +H/2 */
+ in[nfin++] = 0x20000000u | (1u << 16) |
+ (0x0a14u >> 2);
+ in[nfin++] = fz;
+ pr_info_ratelimited("vgsp-gr: VIEWPORT emitted %ux%u scale_bits=%08x,%08x offset_bits=%08x,%08x h=0x%x push=0x%llx\n",
+ rtw, rth, fx, fy, fx, fy_off,
+ req->h_object, req->push_va);
+ }
+ /*
* SESSION 155 CONT 22: neutral blend/alpha/cull/
* point/ZCULL state (see sema_gl_raster_extra).
*/