mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-28 10:59:16 -04:00
GL native-wide (16:9) compositor: port SW wide path to OpenGL backend
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>
This commit is contained in:
@@ -1335,7 +1335,12 @@ static void sdl_vblank_present(void) {
|
||||
* the PSX_GL_FORCE_CPU_PRESENT diagnostic sync the FBO down and use
|
||||
* the CPU readout below. */
|
||||
#ifndef PSX_SDL_NO_RENDER
|
||||
if (g_gl_active && g_gl_fbo_present && !di.depth24) {
|
||||
/* Native-wide GL present: the wide compositor lives in separate per-base
|
||||
* FBOs that the deterministic VRAM-FBO present can't read, so a wide
|
||||
* frame falls through to the CPU readout path below (gr_render_wide_
|
||||
* display -> sdl_pixel_buf -> gl_renderer_present). 4:3 / FMV / non-wide
|
||||
* frames keep the fast VRAM-FBO present (early return) unchanged. */
|
||||
if (g_gl_active && g_gl_fbo_present && !di.depth24 && !wide_present) {
|
||||
gl_renderer_present_vram((int)di.display_x, (int)di.display_y,
|
||||
(int)present_w, (int)h, g_video_aa ? 1 : 0,
|
||||
fmv_frame ? 1 : 0);
|
||||
|
||||
Reference in New Issue
Block a user