Skip to content

sdl3: Add OpenGL and Vulkan contexts - #19353

Merged
LibretroAdmin merged 15 commits into
libretro:masterfrom
RobLoach:sdl3-hardware-contexts
Aug 11, 2026
Merged

sdl3: Add OpenGL and Vulkan contexts#19353
LibretroAdmin merged 15 commits into
libretro:masterfrom
RobLoach:sdl3-hardware-contexts

Conversation

@RobLoach

@RobLoach RobLoach commented Aug 5, 2026

Copy link
Copy Markdown
Member

Adds the SDL3 OpenGL and Vulkan contexts so that the SDL3 video driver can load hardware-rendered cores. Also fixes up a few things within the video driver itself:

  • Can remember window positions
  • Consolidates shared code across the driver and contexts into sdl3_common
  • Fixes a rendering bug when applying the scissor rect
  • Addresses windowed fullscreen vs normal fullscreen

Test

  1. Compile, and run RetroArch
  2. Set the video driver to "sdl3"
  3. Load up all three of the libretro-video samples
  4. Watch the logs, when loading
  5. Expect to see that it shows the SDL3 context driver in the logs

@cscd98

cscd98 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Does this include GLES?

@RobLoach

RobLoach commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

Yes, sdl3_ctx_bind_api() checks against GFX_CTX_OPENGL_API and GFX_CTX_OPENGL_ES_API:

https://github.com/libretro/RetroArch/pull/19353/changes#diff-9e0fc37ea8bbba2c7ffe7d973dee9eb1e15591dff1ce84343bc3f599bc4191c0R152

Can force the opengles renderer with...

./configure --enable-sdl3 --enable-opengles --disable-opengl && make
SDL_RENDER_DRIVER=opengles2 ./retroarch

Comment thread gfx/common/sdl3_common.c Outdated
Comment thread gfx/drivers/vulkan.c Outdated
Comment thread gfx/drivers_context/sdl3_gl_ctx.c Outdated
Comment thread gfx/drivers_context/sdl3_vk_ctx.c Outdated
Comment thread gfx/video_driver.c Outdated
@XerTheSquirrel

Copy link
Copy Markdown
Member

I do not see anything glaring at least with my knowledge of SDL3.

@XerTheSquirrel

Copy link
Copy Markdown
Member

Okay so with testing on Wayland:

stephanie@arborvitaetree:~/Projects/RetroArch$ SDL_VIDEODRIVER=wayland SDL_VIDEO_DRIVER=wayland SDL_RENDER_DRIVER=vulkan ./retroarch
[INFO] RetroArch 1.22.2 (Git a8c5b1815e)
[INFO] === Build =======================================
[INFO] CPU Model Name: 13th Gen Intel(R) Core(TM) i7-1370P
[INFO] Capabilities: MMX MMXEXT SSE SSE2 SSE3 SSSE3 SSE4 SSE42 AES AVX AVX2 
[INFO] Version: 1.22.2
[INFO] Git: a8c5b1815e
[INFO] Built: Aug 10 2026
[INFO] =================================================
[INFO] [Input] Found input driver: "sdl3".
[INFO] [Environ] SET_PIXEL_FORMAT: RGB565.
[INFO] [Core] Version of libretro API: 1, Compiled against API: 1
[INFO] [Core] Geometry: 320x240, Aspect: 1.333, FPS: 60.00, Sample rate: 48000.00 Hz.
[INFO] [Video] Set video size to: 640x480.
[INFO] [SDL3] Available renderers (change with $SDL_RENDER_DRIVER):
[INFO] [SDL3]   opengl
[INFO] [SDL3]   opengles2
[INFO] [SDL3]   vulkan
[INFO] [SDL3]   gpu
[INFO] [SDL3]   software
[INFO] [SDL3] Creating window @ 640x480.
[INFO] [SDL3] Renderer: vulkan.
[INFO] [Video] Graphics driver did not initialize an input driver. Attempting to pick a suitable driver.
[WARN] [SDL3] Failed to load gamepad mappings from "/home/stephanie/.config/retroarch/autoconfig/sdl3/gamecontrollerdb.cfg".
[INFO] [Input] Found joypad driver: "sdl3".
[INFO] [Video] Found display server: "wayland".
[INFO] [Audio] Set audio input rate to: 48000.00 Hz.
[INFO] [PipeWire] Found Sink Node: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI3__sink.
[INFO] [PipeWire] Found Sink Node: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI2__sink.
[INFO] [PipeWire] Found Sink Node: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI1__sink.
[INFO] [PipeWire] Found Sink Node: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Speaker__sink.
[INFO] [Audio] Started synchronous audio driver.
[INFO] [Audio] sinc resampler: integer s16 path available.
[INFO] [Microphone] [PipeWire] Found Source Node: alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Mic2__source.
[INFO] [Microphone] [PipeWire] Found Source Node: alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Mic1__source.
[INFO] [Microphone] Initialized microphone driver.
[INFO] [Display] Found display driver: "sdl3".
[INFO] [Playlist] Loading favorites file: "/home/stephanie/.config/retroarch/playlists/builtin/content_favorites.lpl".
[INFO] [Playlist] Loading history file: "/home/stephanie/.config/retroarch/playlists/builtin/content_history.lpl".
[INFO] [Playlist] Loading history file: "/home/stephanie/.config/retroarch/playlists/builtin/content_image_history.lpl".
[INFO] [Playlist] Loading history file: "/home/stephanie/.config/retroarch/playlists/builtin/content_music_history.lpl".
[INFO] RetroArch 1.22.2 (Git a8c5b1815e)
[INFO] === Build =======================================
[INFO] CPU Model Name: 13th Gen Intel(R) Core(TM) i7-1370P
[INFO] Capabilities: MMX MMXEXT SSE SSE2 SSE3 SSSE3 SSE4 SSE42 AES AVX AVX2 
[INFO] Version: 1.22.2
[INFO] Git: a8c5b1815e
[INFO] Built: Aug 10 2026
[INFO] =================================================
[INFO] [Input] Found input driver: "sdl3".
[INFO] [Core] Loading dynamic libretro core from: "/home/stephanie/.config/retroarch/cores/craft_libretro.so".
[INFO] [Override] Redirecting save file to "/home/stephanie/.config/retroarch/saves/Craft/Craft.srm".
[INFO] [Override] Redirecting save state to "/home/stephanie/.config/retroarch/states/Craft/Craft.state".
[INFO] [Environ] SET_INPUT_DESCRIPTORS.
[INFO] [Environ] SET_VARIABLES.
[INFO] [Environ] SET_SUPPORT_NO_GAME: yes.
[INFO] [Environ] GET_LOG_INTERFACE.
[INFO] [Environ] SET_PIXEL_FORMAT: XRGB8888.
[INFO] [Environ] SET_HW_RENDER, context type: gl.
[INFO] [HW] Requesting OpenGL context.
[INFO] [Environ] SET_KEYBOARD_CALLBACK.
[INFO] [Environ] GET_RUMBLE_INTERFACE.
[libretro INFO] Rumble environment supported.
[libretro INFO] Got size: 640 x 480.
[INFO] [SRAM] Skipping SRAM load.
[INFO] [Core] Version of libretro API: 1, Compiled against API: 1
[INFO] [Core] Geometry: 640x480, Aspect: 1.778, FPS: 60.00, Sample rate: 48000.00 Hz.
[INFO] [Video] Set video size to: 640x360.
[INFO] [Video] Using HW render, OpenGL driver forced.
[INFO] [Video] "glcore" saved as cached driver.
[INFO] [SDL3 GL] SDL 3.2.10 gfx context driver initialized.
[INFO] [GLCore] Found GL context: "gl_sdl3".
[INFO] [GLCore] Detecting screen resolution: 1280x800.
[INFO] [GLCore] Initializing HW render (1024x1024).
[INFO] [GLCore] Max texture size: 16384 px, renderbuffer size: 16384 px.
[INFO] [GLCore] Source is SDR (32-bit), output SDR.
[INFO] [GLCore] Vendor: Intel, Renderer: Mesa Intel(R) Iris(R) Xe Graphics (RPL-P).
[INFO] [GLCore] Version: 4.6 (Compatibility Profile) Mesa 25.0.7-2+deb13u1.
[INFO] [GLCore] Using resolution 960x540.
[INFO] [GLCore] Using Slang shader backend.
[INFO] [GLCore] Loading stock shader.
[INFO] [GLCore] Building pass #0 (N/A)
[INFO] [GLCore] Not using frame history.
[INFO] [GLCore] Not using framebuffer feedback.
[INFO] [Video] Graphics driver did not initialize an input driver. Attempting to pick a suitable driver.
[WARN] [SDL3] Failed to load gamepad mappings from "/home/stephanie/.config/retroarch/autoconfig/sdl3/gamecontrollerdb.cfg".
[INFO] [Input] Found joypad driver: "sdl3".
[INFO] [Video] Found display server: "wayland".
context_reset.
[INFO] [Audio] Set audio input rate to: 48000.00 Hz.
[INFO] [PipeWire] Found Sink Node: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI3__sink.
[INFO] [PipeWire] Found Sink Node: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI2__sink.
[INFO] [PipeWire] Found Sink Node: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI1__sink.
[INFO] [PipeWire] Found Sink Node: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Speaker__sink.
[INFO] [Audio] Started synchronous audio driver.
[INFO] [Audio] sinc resampler: integer s16 path available.
[INFO] [Microphone] [PipeWire] Found Source Node: alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Mic2__source.
[INFO] [Microphone] [PipeWire] Found Source Node: alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Mic1__source.
[INFO] [Microphone] Initialized microphone driver.
[INFO] [Display] Found display driver: "glcore".
[INFO] [Playlist] Loading favorites file: "/home/stephanie/.config/retroarch/playlists/builtin/content_favorites.lpl".
[INFO] [Playlist] Loading history file: "/home/stephanie/.config/retroarch/playlists/builtin/content_history.lpl".
[INFO] [Playlist] Loading history file: "/home/stephanie/.config/retroarch/playlists/builtin/content_image_history.lpl".
[INFO] [Playlist] Loading history file: "/home/stephanie/.config/retroarch/playlists/builtin/content_music_history.lpl".
[INFO] [Environ] GET_SYSTEM_DIRECTORY: "/home/stephanie/.config/retroarch/system".
[libretro INFO] Down: no, Code: 276, Char: 0, Mod: 0.
[libretro INFO] Down: no, Code: 275, Char: 0, Mod: 0.
[libretro INFO] Down: no, Code: 273, Char: 0, Mod: 0.
[libretro INFO] Down: no, Code: 273, Char: 0, Mod: 0.
[libretro INFO] Down: yes, Code: 308, Char: 0, Mod: 4.
[libretro INFO] Down: no, Code: 308, Char: 0, Mod: 0.

Vulkan works with:

[INFO] RetroArch 1.22.2 (Git a8c5b1815e)
[INFO] === Build =======================================
[INFO] CPU Model Name: 13th Gen Intel(R) Core(TM) i7-1370P
[INFO] Capabilities: MMX MMXEXT SSE SSE2 SSE3 SSSE3 SSE4 SSE42 AES AVX AVX2 
[INFO] Version: 1.22.2
[INFO] Git: a8c5b1815e
[INFO] Built: Aug 10 2026
[INFO] =================================================
[INFO] [Input] Found input driver: "sdl3".
[INFO] [Environ] SET_SUBSYSTEM_INFO.
[INFO] [Core] Loading dynamic libretro core from: "/home/stephanie/.config/retroarch/cores/mupen64plus_next_libretro.so".
[INFO] [Override] Redirecting save file to "/home/stephanie/.config/retroarch/saves/Mupen64Plus-Next/Wetrix (U) (M6) [!].srm".
[INFO] [Override] Redirecting save state to "/home/stephanie/.config/retroarch/states/Mupen64Plus-Next/Wetrix (U) (M6) [!].state".
[INFO] [Environ] GET_CORE_OPTIONS_VERSION.
[INFO] [Environ] SET_CORE_OPTIONS_V2.
[INFO] [Environ] SET_CONTROLLER_INFO.
[INFO] [Environ] GET_SYSTEM_DIRECTORY: "/home/stephanie/.config/retroarch/system".
[INFO] [Environ] GET_SYSTEM_DIRECTORY: "/home/stephanie/.config/retroarch/system".
[INFO] [Environ] GET_LOG_INTERFACE.
[INFO] [Environ] GET_PERF_INTERFACE.
[INFO] [Environ] SET_PIXEL_FORMAT: XRGB8888.
[INFO] [Environ] GET_RUMBLE_INTERFACE.
[libretro INFO] mupen64plus: Using full mem base
[INFO] [Environ] GET_SYSTEM_DIRECTORY: "/home/stephanie/.config/retroarch/system".
[INFO] [Content] Loading content file: "/home/stephanie/Collection/old64drive/roms/w/Wetrix (U) (M6) [!].z64".
[libretro INFO] Selected HLE RSP with Angrylion, falling back to Parallel RSP!
[INFO] [Environ] SET_HW_RENDER, context type: vulkan.
[INFO] [HW] Requesting Vulkan context.
[INFO] [Environ] SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE.
[libretro DEBUG] mupen64plus: [EmuThread] M64CMD_ROM_OPEN
[libretro INFO] mupen64plus: Goodname: Wetrix (U) (M6) [!]
[libretro INFO] mupen64plus: Name: Wetrix              
[libretro INFO] mupen64plus: MD5: 6E81D3056E409208E4AF2D39A2FF0F03
[libretro INFO] mupen64plus: CRC: CEA8B54F 7F21D503
[libretro INFO] mupen64plus: Imagetype: .z64 (native)
[libretro INFO] mupen64plus: Rom size: 8388608 bytes (or 8 Mb or 64 Megabits)
[libretro INFO] mupen64plus: ClockRate = F
[libretro INFO] mupen64plus: Version: 1444
[libretro INFO] mupen64plus: Manufacturer: Nintendo
[libretro INFO] mupen64plus: Cartridge_ID: 5457
[libretro INFO] mupen64plus: Country: USA
[libretro INFO] mupen64plus: PC = 80000400
[libretro INFO] mupen64plus: Save type: 5
[libretro DEBUG] mupen64plus: [EmuThread] M64CMD_ROM_GET_HEADER
[INFO] [Core] Version of libretro API: 1, Compiled against API: 1
[INFO] [Core] Geometry: 640x480, Aspect: 1.333, FPS: 60.00, Sample rate: 44100.00 Hz.
[INFO] [Video] Set video size to: 640x480.
[INFO] [Video] Using HW render, vulkan driver forced.
[INFO] [Video] "vulkan" saved as cached driver.
[INFO] [Vulkan] Vulkan dynamic library loaded.
[INFO] [SDL3 Vulkan] SDL 3.2.10 gfx context driver initialized.
[INFO] [Vulkan] Got HW context negotiation interface 2.
[INFO] [Vulkan] Found GPU #0: "Intel(R) Iris(R) Xe Graphics (RPL-P)".
[INFO] [Vulkan] Found GPU #1: "llvmpipe (LLVM 19.1.7, 256 bits)".
[INFO] [Vulkan] Using GPU #0: "Intel(R) Iris(R) Xe Graphics (RPL-P)".
[INFO]: Layer count: 9
[INFO]: Found layer: VK_LAYER_VALVE_steam_overlay_32.
[INFO]: Found layer: VK_LAYER_VALVE_steam_overlay_64.
[INFO]: Found layer: VK_LAYER_VALVE_steam_fossilize_32.
[INFO]: Found layer: VK_LAYER_VALVE_steam_fossilize_64.
[INFO]: Found layer: VK_LAYER_MANGOHUD_overlay_x86_64.
[INFO]: Found layer: VK_LAYER_FROG_gamescope_wsi_x86_64.
[INFO]: Found layer: VK_LAYER_MESA_device_select.
[INFO]: Found layer: VK_LAYER_INTEL_nullhw.
[INFO]: Found layer: VK_LAYER_MESA_overlay.
[INFO]: Enabling instance extension: VK_EXT_debug_utils.
[INFO]: Using Vulkan GPU: Intel(R) Iris(R) Xe Graphics (RPL-P)
[INFO]: Enabling device extension: VK_KHR_swapchain.
[INFO]: Enabling device extension: VK_KHR_sampler_mirror_clamp_to_edge.
[INFO]: Enabling device extension: VK_KHR_external_semaphore_fd.
[INFO]: Enabling device extension: VK_KHR_external_memory_fd.
[INFO]: Enabling device extension: VK_KHR_draw_indirect_count.
[INFO]: Enabling device extension: VK_EXT_calibrated_timestamps.
[INFO]: Enabling device extension: VK_EXT_conservative_rasterization.
[INFO]: Enabling device extension: VK_KHR_image_format_list.
[INFO]: Enabling device extension: VK_KHR_shader_float_controls.
[INFO]: Enabling device extension: VK_KHR_8bit_storage.
[INFO]: Enabling device extension: VK_KHR_16bit_storage.
[INFO]: Enabling device extension: VK_KHR_shader_float16_int8.
[INFO]: Enabling device extension: VK_EXT_subgroup_size_control.
[INFO]: Enabling device extension: VK_NV_compute_shader_derivatives.
[INFO]: Enabling device extension: VK_EXT_host_query_reset.
[INFO]: Enabling device extension: VK_EXT_shader_demote_to_helper_invocation.
[INFO]: Enabling device extension: VK_EXT_scalar_block_layout.
[INFO]: Enabling device extension: VK_KHR_uniform_buffer_standard_layout.
[INFO]: Enabling device extension: VK_KHR_timeline_semaphore.
[INFO]: Enabling device extension: VK_EXT_memory_budget.
[INFO]: Enabling device extension: VK_KHR_synchronization2.
[INFO]: Enabling device extension: VK_EXT_pipeline_creation_cache_control.
[INFO]: Enabling device extension: VK_KHR_format_feature_flags2.
[INFO]: Enabling device extension: VK_EXT_external_memory_host.
[INFO] [Vulkan] Using semaphores for WSI acquire.
[INFO] [Vulkan] Got 4 swapchain images.
[INFO] [Vulkan] Using resolution 960x720.
[INFO] [Vulkan] Source is SDR (32-bit), swapchain SDR.
[INFO] [Vulkan] Using BGRA8888 format.
[INFO] [Vulkan] Loading stock shader.
[INFO] [Video] Graphics driver did not initialize an input driver. Attempting to pick a suitable driver.
[WARN] [SDL3] Failed to load gamepad mappings from "/home/stephanie/.config/retroarch/autoconfig/sdl3/gamecontrollerdb.cfg".
[INFO] [Input] Found joypad driver: "sdl3".
[INFO] [Video] Found display server: "wayland".
plugin_start_gfx
[INFO] [Environ] SET_INPUT_DESCRIPTORS.
[INFO] [Audio] Set audio input rate to: 44100.00 Hz.
[INFO] [PipeWire] Found Sink Node: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI3__sink.
[INFO] [PipeWire] Found Sink Node: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI2__sink.
[INFO] [PipeWire] Found Sink Node: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI1__sink.
[INFO] [PipeWire] Found Sink Node: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Speaker__sink.
[INFO] [Audio] Started synchronous audio driver.
[INFO] [Audio] sinc resampler: integer s16 path available.
[INFO] [Microphone] [PipeWire] Found Source Node: alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Mic2__source.
[INFO] [Microphone] [PipeWire] Found Source Node: alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Mic1__source.
[INFO] [Microphone] Initialized microphone driver.
[INFO] [Display] Found display driver: "vulkan".
[INFO] [Environ] SET_SUBSYSTEM_INFO.
[INFO] [Playlist] Loading favorites file: "/home/stephanie/.config/retroarch/playlists/builtin/content_favorites.lpl".
[INFO] [Playlist] Loading history file: "/home/stephanie/.config/retroarch/playlists/builtin/content_history.lpl".
[INFO] [Playlist] Loading history file: "/home/stephanie/.config/retroarch/playlists/builtin/content_image_history.lpl".
[INFO] [Playlist] Loading history file: "/home/stephanie/.config/retroarch/playlists/builtin/content_music_history.lpl".
[INFO] [Playlist] Written to file: "/home/stephanie/.config/retroarch/playlists/builtin/content_history.lpl".
[libretro DEBUG] mupen64plus: [EmuThread] M64CMD_EXECUTE
[libretro INFO] mupen64plus: Game controller 0 (Standard controller) has a Memory pak plugged in
[libretro INFO] mupen64plus: Game controller 1 (Standard controller) has nothing plugged in
[libretro INFO] mupen64plus: Game controller 2 (Standard controller) has nothing plugged in
[libretro INFO] mupen64plus: Game controller 3 (Standard controller) has nothing plugged in
[libretro INFO] mupen64plus: Using CIC type X102
[INFO] [Environ] SET_MEMORY_MAPS.
[libretro INFO] Using 4 sync frames for parallel-RDP.
[libretro INFO] paraLLEl-RDP: Using RDRAM size of 8388608 bytes.
[INFO]: Enabling 8 and 16-bit integer arithmetic support for more efficient shaders!
[libretro INFO] mupen64plus: Initializing 4 RDRAM modules for a total of 8 MB
[libretro INFO] mupen64plus: Starting R4300 emulator: Dynamic Recompiler
[libretro INFO] mupen64plus: Init new dynarec
[INFO] [Audio] sinc resampler active path: float
image

There always is the line [INFO] [Video] Graphics driver did not initialize an input driver. Attempting to pick a suitable driver.. It should pick sdl3, I had to set this manually.

@XerTheSquirrel

Copy link
Copy Markdown
Member

The automatic input selection is working with SDL3 now.

@RobLoach

Copy link
Copy Markdown
Member Author

Thanks so much for testing. Wasn't quite able to test Wayland fully, so appreciate your jumping in.

@LibretroAdmin

Copy link
Copy Markdown
Contributor

Let me know if/when you want it merged. You can disregard the checks failed there, that is that mingw issue I talked about earlier that is already fixed in master (Github Msys2/mingw-w64 is pulling in newer packages for ffmpeg and at the time of this PR retroarch couldn't deal with newer ffmpeg yet)

@RobLoach

Copy link
Copy Markdown
Member Author

Good to go in my book. We can have follow up PRs if there's anything else.

@LibretroAdmin
LibretroAdmin merged commit 681aee4 into libretro:master Aug 11, 2026
89 of 97 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants