Phase 9 cleanup: rip out SDL 1.2 video knobs no SDL 3 path uses

After the SDL 3 renderer migration, the engine has exactly one back
buffer (a CPU-side ARGB8888 SDL_Surface) and one presentation path
(upload to streaming SDL_Texture, RenderPresent). All the SDL 1.2
hardware-surface / page-flipping / depth / driver knobs were dead.

Removed from gfxengine_t:
- _doublebuf, doublebuffer() setter+getter
- _pages, pages() setter
- _shadow, shadow() setter+getter
- _depth + the depth argument processing in mode()
- _driver, driver() setter, gfx_drivers_t enum, GFX_DRIVER_SDL2D
- xflags + the extraflags parameter to open()
- broken_rgba8 (the OpenGL RGBA→RGBA4 workaround field)
- MAX_PAGES + backpage/frontpage + the per-page dirtyrects[]/
  dirtytable[]/dirtywtable[] arrays. Collapsed to 1-D dirtytable.
- __invalidate(int page, ...) → __invalidate(rect, window).
- The per-page invalidate() switch on _pages.
- vsync() now hot-applies via SDL_SetRenderVSync (no hide/show cycle).
- mode() keeps the int-bits arg for API compat but ignores it.

Removed from prefs_t:
- videodriver, depth, doublebuf, shadow, pages, broken_rgba8.
  Their config-file keys are now read as obsolete fields (silently
  consumed, never re-written) so existing config files load cleanly
  without breaking on unknown keys.

Removed from the options menu:
- Display Depth, Display Buffering Mode, Software Shadow Buffer,
  Display Buffer Pages, Broken RGBA8.

Removed from the escape-hammering safe-video-mode reset path the
fields that no longer exist (doublebuf, pages, shadow, depth,
videodriver).

dashboard.cpp: dropped the doublebuffer()-guarded second pass of the
loading-animation nibble draw; SDL 3's single back buffer doesn't
need it.

Build clean, binary still runs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ville Lindholm
2026-05-28 22:12:40 +03:00
co-authored by Claude
parent acb3925bb4
commit 8d57d63da2
8 changed files with 76 additions and 229 deletions
+31 -116
View File
@@ -54,15 +54,10 @@ gfxengine_t::gfxengine_t()
sf1 = df = dsf = acf = NULL;
gfx = NULL;
csengine = NULL;
_driver = GFX_DRIVER_SDL2D;
_shadow = 1;
_doublebuf = 1;
_pages = -1;
_vsync = 1;
_fullscreen = 0;
_centered = 0;
use_interpolation = 1;
_depth = 0;
_title = "GfxEngine v0.4";
_icontitle = "GfxEngine";
_cursor = 1;
@@ -71,11 +66,9 @@ gfxengine_t::gfxengine_t()
_autoinvalidate = 1;
_scalemode = GFX_SCALE_NEAREST;
_clamping = 0;
xflags = 0;
_dither = 0;
_dither_type = 0;
broken_rgba8 = 0;
alpha_threshold = 0;
_brightness = 1.0;
@@ -94,10 +87,7 @@ gfxengine_t::gfxengine_t()
for(int i = 0; i < CS_LAYERS ; ++i)
xratio[i] = yratio[i] = 0.0;
dirtyrects[0] = 0;
dirtyrects[1] = 0;
frontpage = 0;
backpage = 1;
dirtyrects = 0;
screenshot_count = 0;
}
@@ -160,75 +150,23 @@ void gfxengine_t::scale(float x, float y)
void gfxengine_t::mode(int bits, int fullscreen)
{
// SDL 3 uses the renderer's pixel format directly; the legacy depth
// argument is accepted for API compatibility but ignored.
(void)bits;
int was_showing = is_showing;
hide();
int olddepth = _depth;
_depth = bits;
if(_depth != olddepth)
reload();
_fullscreen = fullscreen;
if(was_showing)
show();
}
void gfxengine_t::driver(gfx_drivers_t drv)
{
int was_showing = is_showing;
hide();
_driver = drv;
if(was_showing)
show();
}
void gfxengine_t::doublebuffer(int use)
{
if(_doublebuf == use)
return;
int was_showing = is_showing;
hide();
_doublebuf = use;
if(was_showing)
show();
}
void gfxengine_t::pages(int np)
{
_pages = np;
}
void gfxengine_t::vsync(int use)
{
if(_vsync == use)
return;
int was_showing = is_showing;
hide();
_vsync = use;
if(was_showing)
show();
}
void gfxengine_t::shadow(int use)
{
if(_shadow == use)
return;
int was_showing = is_showing;
hide();
_shadow = use;
if(was_showing)
show();
if(sdl_renderer)
SDL_SetRenderVSync(sdl_renderer, use ? 1 : 0);
}
void gfxengine_t::autoinvalidate(int use)
@@ -435,9 +373,9 @@ void gfxengine_t::clampcolor(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
void gfxengine_t::dither(int type, int _broken_rgba8)
{
(void)_broken_rgba8; // legacy OpenGL workaround; no-op in SDL 3
_dither = type >= 0;
_dither_type = type;
broken_rgba8 = _broken_rgba8;
if(!df)
return;
@@ -678,10 +616,8 @@ void gfxengine_t::on_frame(cs_engine_t *e)
}
int gfxengine_t::open(int objects, int extraflags)
int gfxengine_t::open(int objects)
{
xflags = extraflags;
if(is_open)
return show();
@@ -917,42 +853,23 @@ void gfxengine_t::hide(void)
void gfxengine_t::invalidate(SDL_Rect *rect, window_t *window)
{
switch(_pages)
{
case -1:
if(_doublebuf)
__invalidate(1, rect, window);
__invalidate(0, rect, window);
break;
case 0:
__invalidate(0, NULL, NULL);
break;
case 3:
__invalidate(2, rect, window);
// Fallthrough!
case 2:
__invalidate(1, rect, window);
// Fallthrough!
case 1:
__invalidate(0, rect, window);
break;
}
__invalidate(rect, window);
}
void gfxengine_t::__invalidate(int page, SDL_Rect *rect, window_t *window)
void gfxengine_t::__invalidate(SDL_Rect *rect, window_t *window)
{
if(!screen_surface)
return;
if(!rect || (_pages == 0))
if(!rect)
{
dirtyrects[page] = 1;
dirtytable[page][0].x = 0;
dirtytable[page][0].y = 0;
dirtytable[page][0].w = screen_surface->w;
dirtytable[page][0].h = screen_surface->h;
dirtywtable[page][0] = NULL;
dirtyrects = 1;
dirtytable[0].x = 0;
dirtytable[0].y = 0;
dirtytable[0].w = screen_surface->w;
dirtytable[0].h = screen_surface->h;
dirtywtable[0] = NULL;
return;
}
@@ -989,19 +906,18 @@ void gfxengine_t::__invalidate(int page, SDL_Rect *rect, window_t *window)
if(!dr.w || !dr.h)
return;
for(int i = 0; i < dirtyrects[page]; ++i)
if(memcmp(&dirtytable[page][i], &dr, sizeof(dr)) == 0)
for(int i = 0; i < dirtyrects; ++i)
if(memcmp(&dirtytable[i], &dr, sizeof(dr)) == 0)
return;
if(dirtyrects[page] < MAX_DIRTYRECTS - 1)
if(dirtyrects < MAX_DIRTYRECTS - 1)
{
dirtytable[page][dirtyrects[page]] = dr;
dirtywtable[page][dirtyrects[page]] = window;
++dirtyrects[page];
dirtytable[dirtyrects] = dr;
dirtywtable[dirtyrects] = window;
++dirtyrects;
}
else
log_printf(ELOG, "gfxengine: Page %d out of dirtyrects!\n",
page);
log_printf(ELOG, "gfxengine: Out of dirtyrects!\n");
}
@@ -1268,20 +1184,19 @@ void gfxengine_t::flip()
// buffer per frame. Keep the dirtyrect iteration only to drive the
// phys_refresh() callbacks that window widgets rely on; the upload
// is a single full-surface copy regardless.
frontpage = backpage = 0;
for(int i = 0; i < dirtyrects[backpage]; ++i)
for(int i = 0; i < dirtyrects; ++i)
{
if(dirtywtable[backpage][i])
if(dirtywtable[i])
{
if(!dirtywtable[backpage][i]->visible())
if(!dirtywtable[i]->visible())
continue;
SDL_Rect dr = dirtytable[backpage][i];
dirtywtable[backpage][i]->phys_refresh(&dr);
SDL_Rect dr = dirtytable[i];
dirtywtable[i]->phys_refresh(&dr);
}
else
refresh_rect(&dirtytable[backpage][i]);
refresh_rect(&dirtytable[i]);
}
dirtyrects[backpage] = 0;
dirtyrects = 0;
SDL_UpdateTexture(fb_texture, NULL, softbuf->pixels, softbuf->pitch);
SDL_RenderClear(sdl_renderer);
+5 -37
View File
@@ -24,7 +24,6 @@
#define GFX_BANKS 256
#define MAX_DIRTYRECTS 1024
#define MAX_PAGES 3
#include <stdio.h>
#include <stdlib.h>
@@ -33,11 +32,6 @@
#include "sprite.h"
#include "cs.h"
enum gfx_drivers_t
{
GFX_DRIVER_SDL2D = 0
};
enum gfx_scalemodes_t
{
GFX_SCALE_NEAREST = 0,
@@ -69,25 +63,11 @@ class gfxengine_t
void size(int w, int h);
void centered(int c);
void scale(float x, float y);
void driver(gfx_drivers_t drv);
void mode(int bits, int fullscreen);
// 1: Use double buffering if possible
void doublebuffer(int use);
// -1: Use default for shadow() and doublebuffer() settings
// 0: None; assume flipping gives you a garbage buffer
// 1: Assume flipping leaves the back buffer intact
// 2: Assume two buffers that are swapped when flipping
// 3: Assume three buffers cycled when flipping
void pages(int np);
// 1: Enable vsync, if available
void vsync(int use);
// 1: Use a software shadow back buffer, if possible
void shadow(int use);
void autoinvalidate(int use);
void interpolation(int inter);
@@ -102,12 +82,10 @@ class gfxengine_t
void wrap(int x, int y);
/* Info */
int doublebuffer() { return _doublebuf; }
int shadow() { return _shadow; }
int autoinvalidate() { return _autoinvalidate; }
/* Engine open/close */
int open(int objects = 1024, int extraflags = 0);
int open(int objects = 1024);
void close();
/* Data management (use while engine is open) */
@@ -206,7 +184,6 @@ class gfxengine_t
float yscale() { return ys * (1.f/256.f); }
protected:
gfx_drivers_t _driver;
gfx_scalemodes_t _scalemode;
int _clamping;
SDL_Window *sdl_window;
@@ -214,11 +191,9 @@ class gfxengine_t
SDL_Texture *fb_texture;
SDL_Surface *screen_surface; // alias for softbuf in SDL 3
SDL_Surface *softbuf;
int backpage;
int frontpage;
int dirtyrects[MAX_PAGES];
SDL_Rect dirtytable[MAX_PAGES][MAX_DIRTYRECTS];
window_t *dirtywtable[MAX_PAGES][MAX_DIRTYRECTS];
int dirtyrects;
SDL_Rect dirtytable[MAX_DIRTYRECTS];
window_t *dirtywtable[MAX_DIRTYRECTS];
window_t *fullwin;
window_t *window;
window_t *windows; // Linked list
@@ -236,23 +211,17 @@ class gfxengine_t
s_container_t *gfx;
SoFont *fonts[GFX_BANKS]; // Kludge.
cs_engine_t *csengine;
int xflags;
int _doublebuf;
int _pages;
int _vsync;
int _shadow;
int _fullscreen;
int _centered;
int _autoinvalidate;
int use_interpolation;
int _width, _height;
int _depth;
const char *_title;
const char *_icontitle;
int _cursor;
int _dither;
int _dither_type;
int broken_rgba8; //Klugde for OpenGL (if RGBA8 ==> RGBA4)
int alpha_threshold; //For noalpha()
float _brightness;
float _contrast;
@@ -267,8 +236,7 @@ class gfxengine_t
int screenshot_count;
void __invalidate(int page, SDL_Rect *rect = NULL,
window_t *window = NULL);
void __invalidate(SDL_Rect *rect = NULL, window_t *window = NULL);
void refresh_rect(SDL_Rect *r);
static void on_frame(cs_engine_t *e);