pgxp: framework-owned PGXP Precision mod, every game, default off

psx.enhancement.pgxp (game_id \"*\") in the builtin catalog: one Mods-page
toggle that arms sub-pixel vertex precision + perspective-correct
texturing with the user-validated defaults (tolerance clamp 0.5px), plus
a cpu-mode option. Default off = the faithful floor (G1.9). Fully
effective on PGXP-variant binaries; reduced-but-safe coverage elsewhere
(the always-emitted swc2 tier + interpreters, validate-on-read).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Matthew Stanley
2026-08-15 20:52:21 -07:00
parent ed9ec01abe
commit d31ce5ac6d
3 changed files with 77 additions and 0 deletions
@@ -0,0 +1,33 @@
format_version = 5
id = "psx.enhancement.pgxp"
version = "1.0.0"
name = "PGXP Precision (geometry + textures)"
author = "psxrecomp"
description = "Sub-pixel vertex precision and perspective-correct texturing (the PGXP technique): the runtime shadows the GTE's full-precision projections and follows them to the GPU, so 3D polygons stop wobbling between whole pixels and large floor/wall textures stop warping. Visual-only: the game's own math, culling and readback see exactly what real hardware produces."
resolver = "declarative"
save_compatibility = "shared"
# Sub-pixel precision is a property of the emulated GTE/GPU pair, not of any
# particular disc, so this ships with the framework and applies to every game.
[[target]]
game_id = "*"
[[feature]]
id = "pgxp"
name = "PGXP Precision"
description = "Disabled by default (the faithful floor). Corrections are validated per vertex against the exact packet words the game drew with and clamped to half a pixel, so 2D sprites and UI are never touched and a vertex the tracker cannot prove simply draws the faithful way. Most effective on a build compiled with the PGXP hook variant; on other builds coverage is reduced but never harmful. Needs supersampling >= 2 to be visible."
group = "Visual"
default_enabled = false
[[option]]
feature = "pgxp"
id = "cpu_mode"
label = "CPU-mode propagation"
description = "Also track precision through CPU arithmetic (register repacking math). Off matches the reference implementations' default; on can raise coverage in games that rebuild vertices with integer math. Always safe either way - validation rejects anything stale."
group = "Visual"
type = "boolean"
default = "false"
[[plugin]]
feature = "pgxp"
id = "psx.pgxp"
+1
View File
@@ -332,6 +332,7 @@ set(PSXRECOMP_RUNTIME_SOURCES
${PSXRECOMP_ROOT}/runtime/src/event_ring.c
${PSXRECOMP_ROOT}/runtime/src/game_options.c
${PSXRECOMP_ROOT}/runtime/src/mod_builtin_speed.c
${PSXRECOMP_ROOT}/runtime/src/mod_builtin_pgxp.c
${PSXRECOMP_ROOT}/runtime/src/mod_packages.cpp
${PSXRECOMP_ROOT}/runtime/src/mod_runtime.cpp
${PSXRECOMP_ROOT}/runtime/src/psx_keybinds.c
+43
View File
@@ -0,0 +1,43 @@
/*
* Framework-owned PGXP precision mod, available to every game.
*
* Sub-pixel vertex precision + perspective-correct texturing is a property of
* the emulated GTE/GPU pair, not of any particular disc, so it ships here and
* mods/builtin/packages/psx.enhancement.pgxp targets game_id "*". Default off
* (the faithful floor, ENHANCEMENTS.md G1.9); enabling arms the value-
* propagation engine (pgxp.cpp) with the user-validated defaults — tolerance
* clamp 0.5px, cpu-mode per the mod option.
*
* Coverage note: the engine reaches near-total dataflow coverage on a binary
* compiled with the PGXP hook variant (-DPSX_PGXP=1, PSX_PGXP_VARIANT); on a
* base-flavour binary only the always-emitted swc2 tier and the interpreters
* feed it, so the correction is weaker there but never harmful — every vertex
* is validated against the exact packet word before it is believed.
*/
#include "mod_plugins.h"
#include "pgxp.h"
#include <string.h>
#define PKG_PGXP "psx.enhancement.pgxp"
/* gte.cpp / gpu.c — the two correction toggles this mod arms. */
extern void gte_geometry_correction_set(int enabled);
extern void gpu_texture_correction_set(int enabled);
static int pgxp_option_flag(const char* feature, const char* id) {
char text[16] = "";
return psx_mod_option_value(PKG_PGXP, feature, id, text, sizeof text) &&
strcmp(text, "true") == 0;
}
static void builtin_pgxp_activate(void) {
gte_geometry_correction_set(1);
gpu_texture_correction_set(1); /* also arms the shadow engine */
pgxp_set_cpu_mode(pgxp_option_flag("pgxp", "cpu_mode"));
}
PSX_MOD_CONSTRUCTOR(psx_register_builtin_pgxp_plugin) {
(void)psx_mod_register_activation_plugin("psx.pgxp",
builtin_pgxp_activate);
}