#ifndef PSX_RENDER_PASS_H #define PSX_RENDER_PASS_H /* Host-timed render passes: runtime side of psx_mod_render_pass_plan() and * psx_mod_render_pass() (mod_plugins.h). See docs/RENDER_PASSES.md. */ #include #include "psx_cycle_freeze.h" /* g_psx_render_pass_active, the time freeze */ #include "gpu_gl_renderer.h" #ifdef __cplusplus extern "C" { #endif /* Stores a pass may not make (memory.c render_pass_store): they would escape * the restore, so they are dropped and counted per device class. */ enum { RENDER_PASS_DROP_SPU = 0, RENDER_PASS_DROP_CD, RENDER_PASS_DROP_TIMER, RENDER_PASS_DROP_DMA, /* DMA channels other than GPU (2) and OTC (6) */ RENDER_PASS_DROP_GPU, /* GP1 commands other than DMA mode / info */ RENDER_PASS_DROP_OTHER, /* SIO, MDEC, memory control, mod arenas, ... */ RENDER_PASS_DROP_CLASSES }; extern uint64_t g_render_pass_dropped_writes[RENDER_PASS_DROP_CLASSES]; /* memory.c calls this before a pass reads MMIO. Reads of devices outside the * checkpoint can consume FIFOs/ACKs even with their clock frozen; reject the * entire pass before the access instead of fabricating a device result. */ int render_pass_mmio_read_allowed(uint32_t phys, uint32_t width); typedef struct RenderPassFailure { const char *reason; /* static name, NULL until the first refusal */ uint64_t attempt, plan, guest_cycle; uint32_t status, alpha_q16, struct_size; uint16_t x, y, w, h; GLRenderPassBeginDiag gl; } RenderPassFailure; typedef struct RenderPassStats { uint64_t plans; /* psx_mod_render_pass_plan calls that planned >= 1 */ uint64_t planned; /* phases planned (after shedding) */ uint64_t wanted; /* phases wanted before shedding */ uint64_t refused; /* plan calls that returned 0 while enabled */ uint64_t pass_attempts; /* all psx_mod_render_pass calls */ uint64_t argument_refused, status_refused, begin_refused, checkpoint_refused; RenderPassFailure last_failure; /* latched across successes; session reset clears */ uint64_t passes; /* passes run to completion and presented */ uint64_t local_views; /* psx_mod_render_local_view images committed */ uint64_t local_attempts; /* psx_mod_render_local_view calls */ uint64_t aborted; /* passes rolled back by a fault */ uint64_t discarded; /* passes whose plugin declined the image */ uint64_t watchdog; /* of which: guest-cycle watchdog overruns */ uint64_t vram_leaks; /* GPU writes outside the declared rect (dropped) */ uint64_t device_reads; /* aborted before reading an uncheckpointed device */ uint32_t last_device_read, last_device_read_width; uint64_t nesting_repairs; /* aborts whose skipped exits the restore undid */ char last_abort_detail[192]; /* skipped host exits; latched until session reset */ uint64_t verify_checks; /* PSX_RENDER_PASS_VERIFY comparisons */ uint64_t verify_mismatch; /* ... that found a difference */ uint64_t spans; /* psx_mod_run_guest_span calls that reached stop */ uint64_t span_failures; /* ... that left the span or overran */ uint64_t dropped[RENDER_PASS_DROP_CLASSES]; double last_pass_ms; /* host time of the last pass (sandbox + draw) */ double avg_pass_ms; /* smoothed */ double avg_begin_ms; /* smoothed: VRAM backup + checkpoint */ double avg_guest_ms; /* smoothed: the plugin's guest draw code */ double avg_end_ms; /* smoothed: GPU flush, capture, VRAM restore */ double avg_restore_ms; /* smoothed: machine state restore */ uint64_t guest_cycles_last; /* guest cycles the last pass executed */ int disabled; /* sticky: passes disabled after repeated faults */ int watchdog_flag; /* internal: the current pass overran */ } RenderPassStats; void render_pass_get_stats(RenderPassStats *out); /* Whether optional state-preservation verification is enabled. Zero executed * checks still means no coverage even when this is enabled. Not a pixel test. */ int render_pass_verification_enabled(void); /* Clears counters and the sticky fault latch (new mod session). */ void render_pass_reset_session(void); typedef struct RenderStereoStats { uint64_t attempts, pairs, refused, failed, shed; uint64_t last_pair_id, last_guest_cycle, eye_cycle[2]; uint64_t eye_hash[2]; /* measured entry state when VERIFY is enabled */ int32_t eye_view[2][3]; /* sampled from the actual projection ambient */ double last_pair_ms, avg_pair_ms; int last_eye; const char *last_failure; uint64_t last_failed_attempt, retained_pair_id; int last_failed_eye; const char *last_failed_reason; /* latched across later successes */ /* Shedding/recovery policy (stereo_shed_policy.c). A shed streak is bounded * by time and count; these report how the last one ended and how stale the * retained pair got. */ uint64_t shed_streak, shed_streak_max; /* consecutive sheds now / worst seen */ uint32_t shed_streak_ms; /* wall clock of the current streak */ uint64_t stale_frames; /* frames that published no new pair */ uint64_t budget_resets; /* estimates reset on scene/mode change */ double budget_ms; /* pair budget actually in use */ uint32_t budget_source; /* 0 vblank (fallback), 1 headset, 2 env */ uint64_t last_pair_age_ms; /* age of the retained pair, this frame */ int shedding; /* policy is currently suppressing */ /* Pair-scoped baseline: how often a machine snapshot was captured, and how * often a later eye of the same pair reused it instead of re-capturing. */ uint64_t checkpoint_saves; /* snapshots captured */ uint64_t checkpoint_reuses; /* eyes that reused the pair baseline */ uint64_t checkpoint_ram_bytes; /* RAM bytes copied by those captures */ } RenderStereoStats; void render_stereo_get_stats(RenderStereoStats *out); int render_pass_netplay_enabled(void); #ifdef __cplusplus } #endif #endif