mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 10:19:47 -04:00
e6ce5006b4
The repository root carried seven markdown files that were not onboarding
material, plus two that had been superseded by the code they described. This
sorts them: reader-facing docs to docs/, working notes to docs/internal/, and
the two superseded ones merged into the docs that replaced them.
Moved to docs/: WIDESCREEN.md, ENHANCEMENTS.md, TCP_COMMANDS.md
Moved to docs/internal/: PRINCIPLES.md, ISSUES.md, DEBUG.md, GTE_LM_FIX.md,
and from docs/: bios-hardening.md, overlay-status.md,
overlay-plan.md, overlay-recompilation-design.md,
overlay-discovery.md, TOMBA2_EXC_CONSULT_RESPONSE.md,
CASE_A_AOT_GAP.md, audit_inventory.md
Moved to docs/internal/upstream/: UPSTREAM_2026-08-20.md
The root keeps only what belongs there: README.md, CONTRIBUTING.md, LICENSE,
CLAUDE.md, THIRD_PARTY_ATTRIBUTION.md, RELEASE_NOTES.md, the dotfiles and
psxrecomp_cli.py.
MERGES
SPLITGEN_MIGRATION.md folded into docs/BUILDING.md as "Split generated C". Its
migration instructions were stale in a way that mattered: it told every game
repo to hand-edit its CMakeLists and add a file(GLOB ...) over
<serial>_full*.c, but runtime/runtime.cmake now does that itself. GEN_FULL_GLOB
is a multi-value argument of psxrecomp_add_game_runtime(); the loop at
runtime.cmake:1985 makes each pattern absolute against CMAKE_CURRENT_SOURCE_DIR,
expands it with file(GLOB), and concatenates the hits into
GAME_GENERATED_FULL_C. So a title names the pattern and gets however many shards
a regeneration produced. The rewritten section describes that, the two-step
fallback when the globs match nothing (GEN_FULL_FALLBACK, else <serial>_full.c
derived from the dispatch marker by substituting _dispatch.c), and the one
caveat the code actually has: that file(GLOB) is plain, not CONFIGURE_DEPENDS,
so a regeneration which changes the shard COUNT needs a re-configure to be seen.
psxrecomp-toml-readme.md folded into docs/GAME_PROJECT_SETUP.md as "EXE-only
autofill (psxrecomp-toml)", placed after "Disc autofill (probe_disc.py)" and
before "Project Studio" so the two autofill paths sit together. Its documented
flags were checked against the usage text in recompiler/src/main_toml.cpp:28-42
and against the argument parser at :150-165 -- all seven options match with no
drift, so the flag list is reproduced as-is. Added a pointer that probe_disc.py
is preferable when a cue exists, since that tool does the same EXE-header work
plus disc identity and netplay gates.
FUNCTIONAL FIXES
tools/gen_tcp_commands.py wrote to REPO/"TCP_COMMANDS.md". After the move that
path does not exist, so the generator would have created a new stray root file
and --check would have failed against it forever. Retargeted to
REPO/"docs"/"TCP_COMMANDS.md", along with the seven docstring and message
strings that name the path.
Running it surfaced two further problems, both fixed here:
* The doc was genuinely stale -- pre-existing drift, not introduced by this
commit (the moved file is byte-identical to origin/master, and no
debug-server command table is touched here). Four commands registered since
the last regeneration were missing from the index -- cdrom_timing_dump,
savestate_status, ws_ui_groups, xprobe_watch -- and scanline had gained a
backend. Regenerated: 307 -> 311 commands, and the change is confined to the
AUTOGEN block (the hand-written head and tail are byte-identical to master).
tools/gen_tcp_commands.py --check now exits 0.
* DOC.write_text() has no newline argument, so Python translated every newline
to os.linesep. On Windows that rewrote all 585 lines of the file to CRLF and
turned a four-line index update into a whole-file diff -- measured: 589 CRLF
/ 0 LF after a run, against 0 CRLF / 585 LF in the repo. Now written through
an explicit newline="" handle, verified to leave the file at 0 CRLF.
runtime/include/debug_server.h:9 and runtime/src/debug_server.c:8 cited "TCP.md
and DEBUG.md". TCP.md has never existed in this repo under that name; both now
name docs/TCP_COMMANDS.md and docs/internal/DEBUG.md.
LINK AND REFERENCE FIXES
Every inbound reference to a moved file was located by grepping each basename
across the whole tracked tree, not just the markdown. Markdown hrefs in
README.md, CONTRIBUTING.md, docs/ARCHITECTURE.md, docs/COMPILING_OVERLAYS.md,
docs/AOT_OVERLAY_PLAN.md, docs/RELOCATION_MANIFEST_FORMAT.md,
docs/config_schema.md, docs/OVERLAY_XREF.md, docs/TCP_COMMANDS.md and several
docs/internal/ files now point at the new locations; where two files became
siblings under docs/internal/ the path was shortened rather than lengthened
(bios-hardening.md's reference to overlay-discovery.md, for instance).
docs/COMPILING_OVERLAYS.md's "in this folder" phrasing was wrong once two of the
three files it listed moved, so it now names internal/ explicitly.
24 source-comment mentions of ENHANCEMENTS.md sections G1.x across 19 files
(recompiler, runtime, cmake) were retargeted to docs/ENHANCEMENTS.md with the
section numbers untouched. docs/SHADOW_ENHANCEMENTS.md is a DIFFERENT file and
was deliberately excluded.
20 rationale strings citing docs/CASE_A_AOT_GAP.md across the four
recompiler/seeds/*.json files were updated. Done as a byte-level substring
replacement rather than a JSON round-trip: two of those files are stored with
CRLF endings and two with LF, and re-serializing them reformatted 5,700 lines.
The byte-level version changes exactly 20 lines and each file still parses.
References that look similar but point elsewhere were deliberately left alone,
and are worth naming so a future pass does not "fix" them:
* "recomp-template PRINCIPLES.md" / "NES recomp template PRINCIPLES.md" in
CLAUDE.md:43, docs/SHADOW_ENHANCEMENTS.md:28,
docs/internal/HLE_SCHEDULER_CARVEOUT_PLAN.md:5,
runtime/src/debug_server.c:4934 and tools/parity_diff.py:8 are a different
repository's file. Only the five that mean this repo's PRINCIPLES.md were
updated.
* Every remaining bare ISSUES.md mention is a GAME repo's tracker
(MegaManX6Recomp 2/7/8/9, TombaRecomp 6), not this repo's.
* docs/disc-speed.md:4,54,56 and docs/internal/bios-hardening.md:5 name
overlay-discovery as a BRANCH, not a file, so no path applies.
INDEXES
README.md's "New here?" table gains rows for docs/WIDESCREEN.md,
docs/ENHANCEMENTS.md and docs/TCP_COMMANDS.md. docs/internal/README.md gains
sections indexing all fourteen documents that moved in, plus an "Upstream
contributor reviews" section describing upstream/ and the new sweep file, plus a
"Removed" bullet for CYCLE_TIMING_ARCH.md (deleted in the previous commit)
pointing at FAITHFUL_TIMING_PLAN.md, CYCLE_MODEL_BEETLE.md and
PRECISE_IRQ_SLICE.md -- following the SLJIT_PERSIST_CACHE.md precedent already
in that file.
docs/ENHANCEMENTS.md:7 claimed framework bugs live in "game repos' ISSUES.md
until a framework tracker exists". A framework tracker does exist; it now says
so and names the Beads epic.
VERIFICATION
A link checker was written to scan every tracked *.md for relative links,
resolving each against the tree being scanned. Baseline at origin/master: 129
files, 137 relative links, 3 broken. After both commits: 127 files, 159 relative
links, 3 broken -- the SAME three, all pre-existing and untouched here:
docs/DATA_SHARDS.md -> INSTANT_LOADS_PARKED.md (never existed)
docs/DATA_SHARDS.md -> INSTANT_LOADS_SPIKE2.md (never existed)
docs/NETPLAY.md -> ../lib/recomp-net/README.md (inside a submodule)
Zero new broken links. The checker's own coverage was checked against a raw grep
for markdown link openers: the 3-link difference is C++ lambdas inside code
blocks, correctly not treated as links.
Also verified: py_compile over all 113 tracked tools/*.py plus psxrecomp_cli.py;
all four seed JSONs still parse; the test-registration guard still reports 123
test files all registered; recompiler/tests/test_coverage_vault.py still passes;
and no file in this commit had its line endings flipped (checked mechanically
across all 50 modified files, after two files were caught and redone).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
295 lines
12 KiB
C++
295 lines
12 KiB
C++
/* test_pgxp.cpp — PGXP value-propagation engine unit tests (docs/ENHANCEMENTS.md
|
|
* G1.2/G1.3). White-box over runtime/src/pgxp.cpp with the gte.cpp fallback
|
|
* cache stubbed, exercising exactly the properties the engine's safety rests
|
|
* on: provenance roundtrips, validate-on-read, half-word semantics, the
|
|
* repack arithmetic, the suppression bracket, and the GPU-side safeguards. */
|
|
|
|
#include "pgxp.h"
|
|
#include "pgxp_hooks.h"
|
|
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
|
|
static int g_failures = 0;
|
|
#define CHECK(cond) \
|
|
do { \
|
|
if (!(cond)) { \
|
|
std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, \
|
|
#cond); \
|
|
g_failures++; \
|
|
} \
|
|
} while (0)
|
|
|
|
/* ---- gte.cpp fallback-cache stub ----------------------------------------- */
|
|
|
|
static uint32_t g_fb_packed = 0;
|
|
static int32_t g_fb_x16 = 0, g_fb_y16 = 0;
|
|
static int g_fb_valid = 0;
|
|
|
|
extern "C" int gte_geometry_correction_lookup(uint32_t packed,
|
|
int32_t *x16, int32_t *y16) {
|
|
if (!g_fb_valid || packed != g_fb_packed) return 0;
|
|
if (x16) *x16 = g_fb_x16;
|
|
if (y16) *y16 = g_fb_y16;
|
|
return 1;
|
|
}
|
|
|
|
/* ---- MIPS encodings ------------------------------------------------------ */
|
|
|
|
static uint32_t enc_i(uint32_t op, uint32_t rs, uint32_t rt, uint16_t imm) {
|
|
return (op << 26) | (rs << 21) | (rt << 16) | imm;
|
|
}
|
|
static uint32_t enc_r(uint32_t rs, uint32_t rt, uint32_t rd, uint32_t sh,
|
|
uint32_t funct) {
|
|
return (rs << 21) | (rt << 16) | (rd << 11) | (sh << 6) | funct;
|
|
}
|
|
static uint32_t enc_cop2(uint32_t sub, uint32_t rt, uint32_t rd) {
|
|
return (0x12u << 26) | (sub << 21) | (rt << 16) | (rd << 11);
|
|
}
|
|
|
|
#define LW(rs, rt) enc_i(0x23, rs, rt, 0)
|
|
#define SW(rs, rt) enc_i(0x2B, rs, rt, 0)
|
|
#define LH(rs, rt) enc_i(0x21, rs, rt, 0)
|
|
#define LHU(rs, rt) enc_i(0x25, rs, rt, 0)
|
|
#define SH(rs, rt) enc_i(0x29, rs, rt, 0)
|
|
#define SB(rs, rt) enc_i(0x28, rs, rt, 0)
|
|
#define LWC2(rt) enc_i(0x32, 1, rt, 0)
|
|
#define SWC2(rt) enc_i(0x3A, 1, rt, 0)
|
|
#define MFC2(rt, rd) enc_cop2(0x00, rt, rd)
|
|
#define MTC2(rt, rd) enc_cop2(0x04, rt, rd)
|
|
#define ADDIU(rs, rt, imm) enc_i(0x09, rs, rt, (uint16_t)(imm))
|
|
#define LUI(rt, imm) enc_i(0x0F, 0, rt, (uint16_t)(imm))
|
|
#define SLL(rt, rd, sh) enc_r(0, rt, rd, sh, 0x00)
|
|
#define SRA(rt, rd, sh) enc_r(0, rt, rd, sh, 0x03)
|
|
#define OR(rs, rt, rd) enc_r(rs, rt, rd, 0, 0x25)
|
|
#define ADDU(rs, rt, rd) enc_r(rs, rt, rd, 0, 0x21)
|
|
|
|
/* One projected vertex: x = 160.5, y = 80.25 -> packed integer word. */
|
|
static const uint32_t PACKED = (80u << 16) | 160u;
|
|
static const int32_t X16 = (160 << 16) | 0x8000; /* 160.5 */
|
|
static const int32_t Y16 = (80 << 16) | 0x4000; /* 80.25 */
|
|
static const uint16_t SZ3 = 100;
|
|
|
|
static const uint32_t ADDR_A = 0x80100000u; /* packet slot A (KSEG0) */
|
|
static const uint32_t ADDR_B = 0x00100040u; /* packet slot B (KUSEG) */
|
|
|
|
static void produce_at(uint32_t addr) {
|
|
pgxp_gte_push_sxy(X16, Y16, SZ3, PACKED);
|
|
psx_pgxp_cop2(nullptr, SWC2(14), PACKED, addr);
|
|
}
|
|
|
|
static int lookup(uint32_t addr, uint32_t word, int32_t ix, int32_t iy,
|
|
int32_t *x, int32_t *y, uint16_t *z) {
|
|
int32_t lx, ly; uint16_t lz;
|
|
int r = pgxp_get_precise_vertex(addr, word, ix, iy, &lx, &ly, &lz);
|
|
if (x) *x = lx;
|
|
if (y) *y = ly;
|
|
if (z) *z = lz;
|
|
return r;
|
|
}
|
|
|
|
int main(void) {
|
|
pgxp_set_enabled(1);
|
|
pgxp_set_tolerance(-1.0f);
|
|
pgxp_set_cpu_mode(0);
|
|
|
|
/* --- SWC2 produce -> GPU consume (the perspective-texturing spine) --- */
|
|
produce_at(ADDR_A);
|
|
{
|
|
int32_t x, y; uint16_t z;
|
|
CHECK(lookup(ADDR_A, PACKED, 160, 80, &x, &y, &z) == PGXP_SRC_DATAFLOW);
|
|
CHECK(x == X16 && y == Y16 && z == SZ3);
|
|
/* mirrors resolve to the same shadow word */
|
|
CHECK(lookup(0xA0100000u, PACKED, 160, 80, &x, &y, &z) ==
|
|
PGXP_SRC_DATAFLOW);
|
|
}
|
|
|
|
/* --- DMA/untracked overwrite: value validation rejects the shadow --- */
|
|
{
|
|
int32_t x, y; uint16_t z;
|
|
uint32_t other = (81u << 16) | 161u;
|
|
CHECK(lookup(ADDR_A, other, 161, 81, &x, &y, &z) == PGXP_SRC_NATIVE);
|
|
CHECK(x == (161 << 16) && y == (81 << 16) && z == 0);
|
|
}
|
|
|
|
/* --- LW/SW roundtrip: packet copied by the CPU keeps provenance --- */
|
|
produce_at(ADDR_A);
|
|
psx_pgxp_load(nullptr, LW(1, 8), ADDR_A, PACKED);
|
|
psx_pgxp_store(nullptr, SW(1, 8), ADDR_B, PACKED);
|
|
{
|
|
int32_t x, y; uint16_t z;
|
|
CHECK(lookup(ADDR_B, PACKED, 160, 80, &x, &y, &z) == PGXP_SRC_DATAFLOW);
|
|
CHECK(x == X16 && y == Y16 && z == SZ3);
|
|
}
|
|
|
|
/* --- stale GPR: register changed between load and store --- */
|
|
psx_pgxp_load(nullptr, LW(1, 8), ADDR_A, PACKED);
|
|
psx_pgxp_store(nullptr, SW(1, 8), ADDR_B, 0xDEADBEEFu); /* r8 mutated */
|
|
CHECK(lookup(ADDR_B, 0xDEADBEEFu, 0, 0, nullptr, nullptr, nullptr) ==
|
|
PGXP_SRC_NATIVE);
|
|
|
|
/* --- MOVE idiom (memory mode, no cpu_mode needed) --- */
|
|
produce_at(ADDR_A);
|
|
psx_pgxp_load(nullptr, LW(1, 8), ADDR_A, PACKED);
|
|
psx_pgxp_alu(nullptr, ADDU(8, 0, 10), PACKED, PACKED, 0);
|
|
psx_pgxp_store(nullptr, SW(1, 10), ADDR_B, PACKED);
|
|
CHECK(lookup(ADDR_B, PACKED, 160, 80, nullptr, nullptr, nullptr) ==
|
|
PGXP_SRC_DATAFLOW);
|
|
|
|
/* --- MFC2 -> SW (register transfer path) --- */
|
|
pgxp_gte_push_sxy(X16, Y16, SZ3, PACKED);
|
|
psx_pgxp_cop2(nullptr, MFC2(9, 14), PACKED, 0);
|
|
psx_pgxp_store(nullptr, SW(1, 9), ADDR_B, PACKED);
|
|
CHECK(lookup(ADDR_B, PACKED, 160, 80, nullptr, nullptr, nullptr) ==
|
|
PGXP_SRC_DATAFLOW);
|
|
|
|
/* --- LH/SH: halves travel independently, depth does not survive --- */
|
|
produce_at(ADDR_A);
|
|
psx_pgxp_load(nullptr, LHU(1, 8), ADDR_A + 2u, PACKED >> 16); /* Y */
|
|
psx_pgxp_store(nullptr, SH(1, 8), ADDR_B + 2u, PACKED >> 16);
|
|
psx_pgxp_load(nullptr, LHU(1, 8), ADDR_A, PACKED & 0xFFFFu); /* X */
|
|
psx_pgxp_store(nullptr, SH(1, 8), ADDR_B, PACKED & 0xFFFFu);
|
|
{
|
|
int32_t x, y; uint16_t z;
|
|
CHECK(lookup(ADDR_B, PACKED, 160, 80, &x, &y, &z) == PGXP_SRC_DATAFLOW);
|
|
CHECK(x == X16 && y == Y16);
|
|
CHECK(z == 0); /* SH killed the vertex depth */
|
|
}
|
|
|
|
/* --- SB destroys the touched half only --- */
|
|
produce_at(ADDR_B);
|
|
psx_pgxp_store(nullptr, SB(1, 8), ADDR_B, PACKED & 0xFFu); /* same byte */
|
|
{
|
|
int32_t x, y; uint16_t z;
|
|
/* low half invalidated -> not a full XY hit anymore */
|
|
CHECK(lookup(ADDR_B, PACKED, 160, 80, &x, &y, &z) != PGXP_SRC_DATAFLOW);
|
|
}
|
|
|
|
/* --- cpu-mode repack: lhu / sll 16 / or (the classic vertex build) --- */
|
|
pgxp_set_cpu_mode(1);
|
|
produce_at(ADDR_A);
|
|
psx_pgxp_load(nullptr, LHU(1, 8), ADDR_A + 2u, PACKED >> 16); /* Y */
|
|
psx_pgxp_alu(nullptr, SLL(8, 9, 16), (PACKED >> 16) << 16,
|
|
PACKED >> 16, 16);
|
|
psx_pgxp_load(nullptr, LHU(1, 10), ADDR_A, PACKED & 0xFFFFu); /* X */
|
|
psx_pgxp_alu(nullptr, OR(9, 10, 11), PACKED,
|
|
(PACKED >> 16) << 16, PACKED & 0xFFFFu);
|
|
psx_pgxp_store(nullptr, SW(1, 11), ADDR_B, PACKED);
|
|
{
|
|
int32_t x, y;
|
|
CHECK(lookup(ADDR_B, PACKED, 160, 80, &x, &y, nullptr) ==
|
|
PGXP_SRC_DATAFLOW);
|
|
CHECK(x == X16 && y == Y16);
|
|
}
|
|
|
|
/* --- cpu-mode addiu: fraction rides an integer offset (incl. -N) --- */
|
|
psx_pgxp_load(nullptr, LW(1, 8), ADDR_A, PACKED);
|
|
psx_pgxp_alu(nullptr, ADDIU(8, 12, 4), PACKED + 4u, PACKED, 4u);
|
|
psx_pgxp_store(nullptr, SW(1, 12), ADDR_B, PACKED + 4u);
|
|
{
|
|
int32_t x, y;
|
|
CHECK(lookup(ADDR_B, PACKED + 4u, 164, 80, &x, &y, nullptr) ==
|
|
PGXP_SRC_DATAFLOW);
|
|
CHECK(x == X16 + (4 << 16) && y == Y16);
|
|
}
|
|
psx_pgxp_load(nullptr, LW(1, 8), ADDR_A, PACKED);
|
|
psx_pgxp_alu(nullptr, ADDIU(8, 12, (uint16_t)-4), PACKED - 4u, PACKED,
|
|
(uint32_t)(int32_t)-4);
|
|
psx_pgxp_store(nullptr, SW(1, 12), ADDR_B, PACKED - 4u);
|
|
{
|
|
int32_t x;
|
|
CHECK(lookup(ADDR_B, PACKED - 4u, 156, 80, &x, nullptr, nullptr) ==
|
|
PGXP_SRC_DATAFLOW);
|
|
CHECK(x == X16 - (4 << 16));
|
|
}
|
|
pgxp_set_cpu_mode(0);
|
|
|
|
/* --- cpu-mode OFF: the same repack must degrade to native, cleanly --- */
|
|
produce_at(ADDR_A);
|
|
psx_pgxp_load(nullptr, LHU(1, 8), ADDR_A + 2u, PACKED >> 16);
|
|
psx_pgxp_alu(nullptr, SLL(8, 9, 16), (PACKED >> 16) << 16,
|
|
PACKED >> 16, 16);
|
|
psx_pgxp_store(nullptr, SW(1, 9), ADDR_B, (PACKED >> 16) << 16);
|
|
CHECK(lookup(ADDR_B, (PACKED >> 16) << 16, 0, 80, nullptr, nullptr,
|
|
nullptr) == PGXP_SRC_NATIVE);
|
|
|
|
/* --- truncation agreement: integer part must match the native parse --- */
|
|
produce_at(ADDR_A);
|
|
CHECK(lookup(ADDR_A, PACKED, 161, 80, nullptr, nullptr, nullptr) ==
|
|
PGXP_SRC_NATIVE);
|
|
|
|
/* --- tolerance clamp --- */
|
|
produce_at(ADDR_A);
|
|
pgxp_set_tolerance(0.25f); /* fraction is 0.5 -> reject */
|
|
CHECK(lookup(ADDR_A, PACKED, 160, 80, nullptr, nullptr, nullptr) ==
|
|
PGXP_SRC_NATIVE);
|
|
pgxp_set_tolerance(0.75f); /* 0.5 <= 0.75 -> accept */
|
|
CHECK(lookup(ADDR_A, PACKED, 160, 80, nullptr, nullptr, nullptr) ==
|
|
PGXP_SRC_DATAFLOW);
|
|
pgxp_set_tolerance(-1.0f);
|
|
|
|
/* --- fallback tier: no address -> position cache, never a depth --- */
|
|
g_fb_valid = 1; g_fb_packed = PACKED; g_fb_x16 = X16; g_fb_y16 = Y16;
|
|
{
|
|
int32_t x, y; uint16_t z;
|
|
CHECK(lookup(0xFFFFFFFFu, PACKED, 160, 80, &x, &y, &z) ==
|
|
PGXP_SRC_FALLBACK);
|
|
CHECK(x == X16 && y == Y16 && z == 0);
|
|
}
|
|
g_fb_valid = 0;
|
|
|
|
/* --- suppression bracket: nothing records inside it --- */
|
|
pgxp_invalidate_all();
|
|
pgxp_suppress_begin();
|
|
produce_at(ADDR_A);
|
|
pgxp_suppress_end();
|
|
CHECK(lookup(ADDR_A, PACKED, 160, 80, nullptr, nullptr, nullptr) ==
|
|
PGXP_SRC_NATIVE);
|
|
|
|
/* --- deferred invalidate inside the bracket --- */
|
|
produce_at(ADDR_A);
|
|
pgxp_suppress_begin();
|
|
pgxp_invalidate_all(); /* deferred */
|
|
pgxp_suppress_end(); /* applies here */
|
|
CHECK(lookup(ADDR_A, PACKED, 160, 80, nullptr, nullptr, nullptr) ==
|
|
PGXP_SRC_NATIVE);
|
|
|
|
/* --- invalidate-all + generation wrap --- */
|
|
produce_at(ADDR_A);
|
|
pgxp_invalidate_all();
|
|
CHECK(lookup(ADDR_A, PACKED, 160, 80, nullptr, nullptr, nullptr) ==
|
|
PGXP_SRC_NATIVE);
|
|
pgxp_test_set_generation(0xFFFFFFFFu);
|
|
pgxp_invalidate_all();
|
|
CHECK(pgxp_test_generation() == 1u);
|
|
|
|
/* --- test accessors mirror the SXY FIFO shadows --- */
|
|
pgxp_test_seed_gte_sxy(2, PACKED, X16, Y16, SZ3, 1);
|
|
{
|
|
uint32_t packed; int32_t x, y; uint16_t z; uint8_t valid;
|
|
pgxp_test_get_gte_sxy(2, &packed, &x, &y, &z, &valid);
|
|
CHECK(valid && packed == PACKED && x == X16 && y == Y16 && z == SZ3);
|
|
pgxp_test_seed_gte_sxy(2, 0, 0, 0, 0, 0);
|
|
pgxp_test_get_gte_sxy(2, &packed, &x, &y, &z, &valid);
|
|
CHECK(!valid);
|
|
}
|
|
|
|
/* --- stats sanity: dataflow hits were counted --- */
|
|
{
|
|
PGXPStats st;
|
|
pgxp_get_stats(&st);
|
|
CHECK(st.lookups > 0);
|
|
CHECK(st.dataflow_hit > 0);
|
|
CHECK(st.native > 0);
|
|
CHECK(st.fallback_hit > 0);
|
|
CHECK(st.value_mismatch > 0);
|
|
}
|
|
|
|
if (g_failures) {
|
|
std::fprintf(stderr, "test_pgxp: %d FAILURES\n", g_failures);
|
|
return 1;
|
|
}
|
|
std::printf("test_pgxp: all checks passed\n");
|
|
return 0;
|
|
}
|