Live resolution: truthful restart contract per backend

Keep the requested internal resolution / supersample (shown and saved)
apart from what the backend last applied. When the live change is
unavailable (no GL, windowed high-resolution mode, CPU-authoritative dual
rendering, no context) or refused, the session scale is left as applied and
PSX_VIDEO_RESTART_RESOLUTION stays set, in both psx_video_apply_live and
the menu's restart bits (psx_host_video_restart_bits_backend, unit-tested
for the capable and refused cases). video_set rejects invalid presets and
factors without applying or saving, and reports applied values, capability
and pending restart. TCP command index regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shokunin
2026-10-22 14:20:55 -07:00
parent 359019c052
commit b1ce3be00a
8 changed files with 139 additions and 20 deletions
+28 -7
View File
@@ -10632,21 +10632,42 @@ static void handle_dynres_check(int id, const char *json)
/* {"cmd":"video_set","internal_resolution":N,"supersample":M} - change the
* Internal resolution preset (lines, 1 native, -1 match display) and/or the
* supersample (thousandths) through the in-game menu's live path. Returns the
* restart bits the change still needs (0 = fully live). */
* supersample (thousandths, 1000..4000) through the in-game menu's live path.
* Invalid values are rejected without applying or saving anything. Returns
* the restart bits the change still needs (0 = applied live), the requested
* values, and the values the backend actually applied. */
static void handle_video_set(int id, const char *json)
{
extern void psx_video_current(PsxHostVideoSettings *v);
extern unsigned psx_video_apply_live(const PsxHostVideoSettings *next);
extern void psx_video_resolution_applied(int *ir, int *ss_milli, int *live_capable,
int *restart_pending);
const int k_absent = -1000000;
const int ir = json_get_int(json, "internal_resolution", k_absent);
const int ss = json_get_int(json, "supersample", k_absent);
if (ir == k_absent && ss == k_absent) {
send_err(id, "video_set needs internal_resolution and/or supersample");
return;
}
if (ir != k_absent && !(ir == 1 || ir == -1 || (ir >= 2 && ir <= 8640))) {
send_err(id, "invalid internal_resolution (1 native, -1 match display, 2..8640 lines)");
return;
}
if (ss != k_absent && (ss < 1000 || ss > 4000)) {
send_err(id, "invalid supersample (1000..4000 thousandths)");
return;
}
PsxHostVideoSettings v;
psx_video_current(&v);
const int ir = json_get_int(json, "internal_resolution", 0);
const int ss = json_get_int(json, "supersample", 0);
if (ir) v.internal_resolution = ir;
if (ss) v.supersample_milli = ss;
if (ir != k_absent) v.internal_resolution = ir;
if (ss != k_absent) v.supersample_milli = ss;
const unsigned restart = psx_video_apply_live(&v);
int air = 0, ass = 0, cap = 0, pend = 0;
psx_video_resolution_applied(&air, &ass, &cap, &pend);
send_fmt("{\"id\":%d,\"ok\":true,\"restart\":%u,\"internal_resolution\":%d,"
"\"supersample\":%d}\n", id, restart, v.internal_resolution, v.supersample_milli);
"\"supersample\":%d,\"applied_internal_resolution\":%d,"
"\"applied_supersample\":%d,\"live_capable\":%d,\"restart_pending\":%d}\n",
id, restart, v.internal_resolution, v.supersample_milli, air, ass, cap, pend);
}
static void handle_video_info(int id, const char *json)