#2624·Provenance

[Spike] libretro RETRO_ENVIRONMENT_SET_HW_RENDER bridge for OpenGL/Vulkan cores

Author: github-actions[bot]Created Mar 7, 2026Updated Mar 27, 2026
Labelsaudio

Overview

Several native libretro cores request hardware-accelerated rendering via RETRO_ENVIRONMENT_SET_HW_RENDER — the standard libretro mechanism for cores that need OpenGL, OpenGL ES, or Vulkan contexts. The current PVLibRetroCoreBridge does not handle this environment callback in a way that provides a working render context, which means these cores load and run but produce no video output.

Affected Cores

  • Flycast (Dreamcast) — builds, audio plays, no video (#2369)
  • BeetlePSX (PSX with hardware upscaling) — builds with Vulkan/GL, no video (#2368)
  • Play! (PS2) — listed in PR #2373 as "compiling broke"
  • Potentially others: FreeIntv, any future hardware-accelerated libretro core

How retro_hw_render_callback works

When a libretro core wants hardware rendering, it calls:

c
retro_hw_render_callback hw_render = {
    .context_type = RETRO_HW_CONTEXT_OPENGLES3, // or OPENGL, VULKAN
    .context_reset = my_context_reset,
    .get_current_framebuffer = my_get_framebuffer,
    .get_proc_address = my_get_proc_address,
    .depth = true,
    .stencil = false,
    .bottom_left_origin = true,
};
environ_cb(RETRO_ENVIRONMENT_SET_HW_RENDER, &hw_render);

The host (Provenance) must then:

  1. Create an OpenGL ES or Vulkan context
  2. Call hw_render.context_reset() once the context is ready
  3. Make the context current before each retro_run()
  4. Implement get_current_framebuffer to return an FBO that Provenance then blits to the Metal layer
  5. Implement get_proc_address to return OpenGL function pointers

What needs to be built

For OpenGL ES path:

  • Create an EAGLContext (or CAEAGLLayer backed context) in the bridge
  • Wire get_proc_address to dlsym(RTLD_DEFAULT, symbol)
  • Create an FBO for the core to render into
  • After retro_run(), blit the FBO contents to the Metal texture used by PVMetalViewController

For Vulkan path:

  • Provide MoltenVK context via VkInstance/VkDevice
  • Wire to CAMetalLayer (the surface_handle that DuckStation also needs)
  • Use VK_MVK_moltenvk extension for iOS integration

Reference implementations

  • DuckStation's PVDuckStationCoreBridge.mm already has partial Vulkan/MoltenVK setup — worth studying
  • RetroArch's iOS video drivers show how to connect GL/Vulkan to UIKit views
  • OpenEmu's OEGameHelperLayer for the GL path

Current state of RetroArch-wrapped cores

a20b7c788 enabled 3D GLES cores in the RetroArch wrapper. This means Flycast and BeetlePSX already work via the RetroArch path. The native libretro bridge is a separate (harder) effort but would allow:

  • Running without the full RetroArch binary overhead
  • Better integration with Provenance's native UI
  • Use in "Provenance Lite" builds

Success criteria

  1. Flycast renders video in native libretro mode
  2. BeetlePSX renders video in native libretro mode
  3. Both work on physical device (not just simulator)

Related

  • #2369 Flycast
  • #2368 BeetlePSX
  • #2373 Original PR
  • #2482 Core Updates epic

Source: Provenance-Emu/Provenance