mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-27 10:38:46 -04:00
Live video apply: one texture-filter enum for settings, handoff and menu
Review (#601/#603): the live path and the launcher handoff both collapsed the texture filter to a boolean (value ? 1 : 0), so neither could carry xBR (#586) and they could drift from settings.toml. PSX_TEXTURE_FILTER_* is now the one enum (equal to [video] texture_filtering / gr_set_texture_filter), and psx_texture_filter_from_ui is the one translation used by the launcher handoff (seed, UserSettings, live globals) and the in-game apply. Unit- tested in host_overlay_test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -65,7 +65,7 @@ int psx_host_ui_capture_active(void);
|
||||
* thread only. */
|
||||
typedef struct PsxHostVideoSettings {
|
||||
int fullscreen; /* 0 windowed, 1 borderless, 2 exclusive */
|
||||
int texture_filter; /* 0 nearest, 1 bilinear */
|
||||
int texture_filter; /* PSX_TEXTURE_FILTER_* (the [video] enum) */
|
||||
int fmv_filter; /* VIDEO_FMV_FILTER_* (config value) */
|
||||
int scanlines; /* 0/1 */
|
||||
int scanline_strength_pct; /* 0..100 */
|
||||
@@ -79,6 +79,18 @@ typedef struct PsxHostVideoSettings {
|
||||
int present_thread; /* restart */
|
||||
} PsxHostVideoSettings;
|
||||
|
||||
/* Texture filter: ONE enum for settings.toml, the launcher handoff and the
|
||||
* in-game menu, so they cannot drift apart (#586 added xBR; a boolean UI
|
||||
* cannot represent it). Values match [video] texture_filtering and
|
||||
* gr_set_texture_filter(). STABLE_WORLD is set by mods, not by settings. */
|
||||
#define PSX_TEXTURE_FILTER_NEAREST 0
|
||||
#define PSX_TEXTURE_FILTER_BILINEAR 1
|
||||
#define PSX_TEXTURE_FILTER_STABLE_WORLD 2
|
||||
#define PSX_TEXTURE_FILTER_XBR 3
|
||||
/* A launcher / menu value to the enum: in-range values pass through, and
|
||||
* anything else is nearest (the native default). Older launchers send 0/1. */
|
||||
int psx_texture_filter_from_ui(int value);
|
||||
|
||||
#define PSX_VIDEO_RESTART_RENDERER (1u << 0)
|
||||
#define PSX_VIDEO_RESTART_RESOLUTION (1u << 1)
|
||||
#define PSX_VIDEO_RESTART_THREADS (1u << 2)
|
||||
|
||||
@@ -147,3 +147,8 @@ unsigned psx_host_video_restart_bits(const PsxHostVideoSettings *boot,
|
||||
m |= PSX_VIDEO_RESTART_THREADS;
|
||||
return m;
|
||||
}
|
||||
|
||||
int psx_texture_filter_from_ui(int value) {
|
||||
return (value >= PSX_TEXTURE_FILTER_NEAREST && value <= PSX_TEXTURE_FILTER_XBR)
|
||||
? value : PSX_TEXTURE_FILTER_NEAREST;
|
||||
}
|
||||
|
||||
@@ -9753,7 +9753,7 @@ extern "C" unsigned psx_video_apply_live(const PsxHostVideoSettings *next) {
|
||||
if (m & PSX_VIDEO_LIVE_FULLSCREEN)
|
||||
(void)psx_window_fullscreen_set(sdl_window, &s_window_fullscreen, next->fullscreen);
|
||||
if (m & PSX_VIDEO_LIVE_TEXTURE_FILTER) {
|
||||
g_video_texfilter = next->texture_filter ? 1 : 0;
|
||||
g_video_texfilter = psx_texture_filter_from_ui(next->texture_filter);
|
||||
if (g_mod_texfilter < 0) gr_set_texture_filter(g_video_texfilter);
|
||||
}
|
||||
if (m & PSX_VIDEO_LIVE_FMV_FILTER) {
|
||||
|
||||
@@ -146,10 +146,20 @@ static void test_video(void) {
|
||||
CHECK(psx_host_video_live_changes(NULL, &b) == 0 && psx_host_video_restart_bits(&a, NULL) == 0);
|
||||
}
|
||||
|
||||
/* One texture-filter enum for settings, handoff and menu (xBR included). */
|
||||
static void test_texture_filter(void) {
|
||||
CHECK(psx_texture_filter_from_ui(0) == PSX_TEXTURE_FILTER_NEAREST);
|
||||
CHECK(psx_texture_filter_from_ui(1) == PSX_TEXTURE_FILTER_BILINEAR);
|
||||
CHECK(psx_texture_filter_from_ui(3) == PSX_TEXTURE_FILTER_XBR);
|
||||
CHECK(psx_texture_filter_from_ui(9) == PSX_TEXTURE_FILTER_NEAREST);
|
||||
CHECK(psx_texture_filter_from_ui(-1) == PSX_TEXTURE_FILTER_NEAREST);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
test_draw_lifetime();
|
||||
test_draw_reentrant();
|
||||
test_video();
|
||||
test_texture_filter();
|
||||
test_sink();
|
||||
test_draw();
|
||||
test_pause();
|
||||
|
||||
Reference in New Issue
Block a user