mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-28 02:56:36 -04:00
39dead88bb
Mirrors gpu_sw_renderer.c's native-wide model on the GL backend. Canonical VRAM (the hr FBO) stays 100% faithful; native-wide lives in SEPARATE per-base_x wide FBOs, each framebuffer-targeting primitive mirrored at local x = vram_x - base_x + OFFSET. Present reads the displayed buffer's wide FBO via the CPU present path (Option B: lowest-risk reuse). 4:3 / non-opted games never call wide_configure, so the wide path never runs and the canonical pass is identical. - GEO_VS/TEX_VS: add u_xoff (x translation) + u_xhalf (x clip half-extent); x term is now (a_pos.x+u_shift+u_xoff)/u_xhalf-1.0. Defaults 0/512 set once at init, restored after every wide pass, so canonical reduces to (x+shift)/512-1. - Wide FBO management (WIDE_MAX_SURF=4): lazy RGBA8 color tex + FBO per base_x; glb_wide_configure/set_target/disable_target/clear mirror the SW functions. - Double-draw: each draw func emits its canonical pass first (unchanged), then if g_wide_cur re-issues the SAME glDrawArrays into the wide FBO via shared wide_target_begin/end helpers (geometry / shaded+textured: both STP passes with identical blend + u_semipass). Flat-rect full-screen-overlay extend replicated (covers [0, native_w) -> fills the full wide width) via a dedicated full-width wide pass with the generic per-tri mirror suppressed. - glb_render_wide_display: glFinish then glReadPixels(GL_BGRA, GL_UNSIGNED_BYTE) yields ARGB8888 byte-identical to sw_render_wide_display / upload_present_tex; rows flipped (GL bottom-left origin) and alpha forced 0xFF to match SW. - Vtable: wire the 5 .wide_* ptrs so gr_wide_supported() returns nonzero for GL. - main.cpp present: guard the VRAM-FBO early-return with !wide_present so a wide GL frame falls through to the existing CPU readout block; all other paths same. Builds clean. Visual validation pending (human). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>