mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 02:11:36 -04:00
c9eaeb04d3
gl_renderer_set_dynamic_resolution(1) keeps the hr surface and the native-wide surfaces allocated at the scale context init gave them (the ceiling) and lets the internal scale step to any integer level from 1 to it while the game runs. A lower level renders into the surfaces' lower-left VRAM*S corner; every viewport, scissor, pack, copy and capture already takes the scale at use, so only allocation and the present's normalised UVs read the allocated size. Off (the default) nothing is allocated differently and no step can run. A step runs after a present, never inside a render pass: - it takes the top-left sample of every native block of the old surface (the sample the pack reads) into a 1x image and reseeds the new corner from it, so the guest-visible VRAM is unchanged byte for byte; - it rescales the displayed rect and the draw area from their old pixels, so neither the frame on screen nor the one being drawn shows 1x blocks; - it rescales the native-wide margins in place, in row bands ordered so no source row is overwritten before it is read; - it marks the mask stencil stale (rebuilt at once while mask checking is on) and drops the render-pass backup and images. Reallocating per step instead measured 30-106 ms at 7x-10x on an Apple M4, mostly the first touch of the new surface. Steps are not offered in the windowed high-resolution mode or with dual raster. gl_scale_invariance_test gains "steps" runs: rendering after a step into a ceiling-sized surface equals the fixed-scale run at that level; a chain of steps (9x down to 1x and back, 5x) leaves the native VRAM unchanged at every step, the two rects and the wide margins exact nearest rescales of their old pixels, everything else the old top-left samples, and mask checking right after a step correct; the window mode refuses steps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>