mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 02:11:36 -04:00
eee07fe910
The OpenGL backend capped supersampling at 4, the software mirror's limit, although its hr surface lives on the GPU. Raise the compile-time ceiling to 32 (gpu_render.h) and decide the real scale at context init: - Query GL_MAX_TEXTURE_SIZE, GL_MAX_RENDERBUFFER_SIZE and GL_MAX_VIEWPORT_DIMS and clamp S so the 1024*S x 512*S surface fits them and a 2 GiB memory budget (PSX_GL_VRAM_BUDGET_MB overrides it). Apple's GL on Metal reports 16384, so 16x is the most a full-VRAM surface can be. The clamp is logged with the limit that applied. - If the surface still fails to allocate, retry one scale lower inside GL. Only a 1x failure drops the backend to software, as before. - Draw lines above 1x as quads one native pixel thick covering both endpoints. glLineWidth(S) is capped at 1 on core profiles, so every line was one hr pixel thick (1/9 of native at 9x). - Present a supersampled source with an area resolve when it is more than 1.25x the output (1200 lines into a 1080 window, 480i menus), and inset the UV rect by half a texel instead of half a native pixel, which cropped and zoomed the image by (S-1)/2 texels per edge. - Size the copy scratch to the largest copy (copies stage at its origin) and rebuild the mask stencil in tiles, only over the primitive bbox union, so a large S does not cost another full-size surface. - Refuse a native-wide surface wider than the driver limit (uncapped Fit at a high scale) with one log line; the frame presents 4:3. - main.cpp: the offline and dual-raster clamps no longer cap GL at the software 4x. The CPU present path presents GL frames at 1x (its readout is native) and its staging buffer stays sized for at most 4x. - [video] supersampling accepts 1..32 in game.toml and settings.toml; the runtime clamps per backend. Every change is gated on S > 1: at 1x the renderer is byte-identical (same native VRAM and presented framebuffer digests as the previous source on a fixed GP0 scene). Tests: gl_scale_limits_test (clamp arithmetic), gl_internal_scale_guards (source guards + runner parsing), and gl_scale_invariance_test, a hidden real-GL run at 1,2,3,5,9x that requires identical guest-visible VRAM at every scale, one-native-pixel lines at internal resolution, and a 32x request that stays on GL at the driver's clamp (16x on Apple). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>