mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-28 10:59:16 -04:00
2641f7c59b
Framework fixes surfaced while bringing up a title that stresses overlays, HD texture replacement and PGXP at a doubled CRTC rate. All are general; the title's own configuration stays in its game repository. CORRECTNESS * Overlay DLL shim was deleted by the preprocessor. compile_overlays.py injected overlay_dispatch_preamble.c.inc after the syntactically LAST #include. A conditional i-cache include moved that anchor inside an #else, and DLL builds define PSX_OVERLAY_DLL_BUILD, so the callback definitions preprocessed away and every overlay DLL failed to link. Any title using overlays would silently fall back to per-instruction interpretation. The shim is now anchored to the unconditional #include "psx_runtime.h" and raises if that anchor is absent. * Overlay capture kept stale PC bitmaps when executed code later became data, so one variant's PC set could be compiled against another variant's bytes. overlay_watch_note_write now retires the whole page's execution/dispatch epoch when any executed word is overwritten; static demand is keyed by (load_addr, size, bytes) and resolved only against matching range identities. * VRAM-to-VRAM copies only invalidated the destination and never registered it as a replacement candidate, so textures arriving by copy could not be dumped or replaced at all. gr_copy_rect now calls tex_pack_on_copy with the same (texture,palette) key semantics as CPU uploads. * PGXP shared-edge seams: a per-primitive all-or-nothing gate cannot stop two adjacent primitives disagreeing about a shared endpoint, so the edge is submitted at two sub-pixel positions. Adds a frame-stamped canonical endpoint cache keyed by final integer screen position: the first use fixes the coordinates and every later occurrence reuses them. * PGXP provenance: PGXPValue carries per-component X/Y/Z projection ids, so a value assembled from different projections can no longer arm correction. Destructive AND/XOR/NOR/SLT, link and COP0 writes now invalidate shadows, and the SXYP shadow FIFO shifts with guest SXY. * Precise NCLIP no longer replaces guest MAC0. It is telemetry only, so face visibility stays bit-exact with the integer GTE. * Removed two counters that were reported as correctness evidence but were never incremented anywhere. PERFORMANCE * PSX_ENABLE_LTO plus a noinline guard on the shared cycle wrappers. Unguarded ThinLTO clones hot interlock bodies and REGRESSES the hot path; guarded, it becomes a win. Adds runtime/tests/bench_psx_runtime_hotpath.c, which verifies variant equivalence by digest so codegen changes are measurable. * Cycle accounting: emitters select specialized arity-0/1/2/3 helpers at generation time instead of a generic dependency-mask loop; main-RAM loads combine base/wait/completion into one exact charge. Exactness is covered by pipeline-state, load-state, deadline-crossing and cross-device causality tests. * HD texture invalidation replaced a linear scan of up to 8192 upload records per VRAM write with a tile-refcount index; out-of-domain writes early-out. * Translation/text-substitution dispatch is gated behind a monotonic mutation epoch instead of running a callback on every dispatch. * card_data_writes_check no longer runs on every RAM write. CAPABILITY * fixed_outer_aspect: the outer presentation aspect becomes a function of user configuration only. Scene classification selects content transforms, never the outer viewport, so menus/FMV stay centred undistorted inside a wide canvas. VERIFICATION AND LIMITS docs/UPSTREAM_2026-08-20.md audits each change against the diff, marks unsupported claims UNKNOWN, and lists a suggested PR split and review focus. Unit and structural tests accompany each item, but this body of work has NOT been validated end-to-end against a fixed reproducible workload -- reviewers should treat the timing-exactness and PGXP changes as the highest-risk areas. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
64 lines
2.6 KiB
C
64 lines
2.6 KiB
C
#ifndef PSX_GPU_VK_RENDERER_H
|
|
#define PSX_GPU_VK_RENDERER_H
|
|
|
|
/* gpu_vk_renderer.c — hardware Vulkan renderer backend.
|
|
*
|
|
* Selected via [video] renderer = "vulkan". Like the GL backend it is
|
|
* GPU-authoritative: VRAM lives as a Vulkan image and present blits straight
|
|
* from it to the swapchain (no per-frame readback). Vulkan is loaded ENTIRELY
|
|
* at runtime through SDL_Vulkan_LoadLibrary + vkGetInstanceProcAddr, so the exe
|
|
* has no link-time vulkan-1 dependency and gracefully falls back to software on
|
|
* a machine without a Vulkan ICD.
|
|
*
|
|
* The backend supplies its vtable through vk_backend_get() (NULL until a context
|
|
* is created and the pipeline is ready). */
|
|
|
|
struct SDL_Window;
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Create the Vulkan instance/device/swapchain on a window made with
|
|
* SDL_WINDOW_VULKAN. Returns 1 on success, 0 to fall back to software. */
|
|
int vk_renderer_init_context(struct SDL_Window *win);
|
|
|
|
/* Tear down all Vulkan objects (idempotent). */
|
|
void vk_renderer_shutdown(void);
|
|
|
|
/* Present the displayed VRAM region straight from the GPU VRAM image to the
|
|
* swapchain (15-bit frames; deterministic, no readback). Returns 1 on success,
|
|
* 0 if the Vulkan path is inactive (caller keeps the CPU present path). */
|
|
int vk_renderer_present_vram(int disp_x, int disp_y, int w, int h,
|
|
int linear, int content_4_3);
|
|
|
|
/* GPU-direct native-wide present (mirrors gl_renderer_present_wide_fbo). */
|
|
int vk_renderer_present_wide(int disp_x, int disp_y, int disp_h, int linear);
|
|
|
|
/* Present an ARGB8888 image as a letterboxed quad (24-bit FMV frames and the
|
|
* display-disabled clear). content_4_3 selects the centered safe area. */
|
|
void vk_renderer_present_cpu(const uint32_t *pixels, int src_w, int src_h,
|
|
int linear, int content_4_3);
|
|
void vk_renderer_present_blank(void);
|
|
|
|
/* Sync the GPU VRAM image down into the CPU VRAM mirror (screenshots, debug
|
|
* server, 24-bit present). No-op when the Vulkan path is inactive. */
|
|
void vk_renderer_sync_cpu(void);
|
|
|
|
/* After savestate restore: push CPU VRAM into the Vulkan image (see GL twin). */
|
|
void vk_renderer_restage_vram_after_savestate(void);
|
|
|
|
/* Set the present policy: 1=tear-free, 0=IMMEDIATE (lowest latency, may tear),
|
|
* -1=MAILBOX. Tear-free prefers MAILBOX because the frontend already paces
|
|
* frames; unsupported modes fall back to FIFO (always available). */
|
|
void vk_renderer_set_present_mode(int mode);
|
|
|
|
void vk_renderer_set_display_aspect(int num, int den);
|
|
void vk_renderer_set_fixed_outer_aspect(int enabled);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* PSX_GPU_VK_RENDERER_H */
|