Files
psxrecomp/runtime/include/gpu_vk_renderer.h
T
Matthew Stanley 0ac63b655c vulkan: 3rd renderer backend (WIP) — emitter, GPU-direct present, full-frame readback
Vulkan backend alongside software + OpenGL: geometry/textured-prim
pipelines, GPU-authoritative VRAM image, deferred-submit + drain-at-present
perf model, GPU-direct present (vk_renderer_present_vram), and a
full-VRAM-pack readback path (ensure_cpu rect_adds the whole VRAM rect
before pack_flush so screenshots/guest VRAM reads reflect live content,
not just the incremental pack-dirty rect — readback-only, no per-frame cost).

Runtime plumbing: --debug-port / --renderer / --window-title CLI overrides
(multi-instance fleet), latency_ring, SPIR-V shaders + embed_spirv.py,
config_loader renderer selection, debug_server screenshot wiring.

All on feat/vulkan-renderer; snapshot in backup/vulkan-wip-20260617.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 14:56:12 -07:00

58 lines
2.3 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 force_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). force_4_3 pillarboxes at native 4:3. */
void vk_renderer_present_cpu(const uint32_t *pixels, int src_w, int src_h,
int linear, int force_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);
/* Set the present mode: 1=FIFO (vsync), 0=IMMEDIATE (lowest latency, may tear),
* -1=MAILBOX (low-latency, tear-free). Applied on the next swapchain (re)build;
* unsupported modes fall back to FIFO (always available). */
void vk_renderer_set_present_mode(int mode);
#ifdef __cplusplus
}
#endif
#endif /* PSX_GPU_VK_RENDERER_H */