Skip to content

Add Libretro Slang Shader / Filters Support (Frontend UI) - #2687

Draft
Pedro-HDSR wants to merge 13 commits into
melonDS-emu:masterfrom
Pedro-HDSR:pr-slang-shaders
Draft

Add Libretro Slang Shader / Filters Support (Frontend UI)#2687
Pedro-HDSR wants to merge 13 commits into
melonDS-emu:masterfrom
Pedro-HDSR:pr-slang-shaders

Conversation

@Pedro-HDSR

Copy link
Copy Markdown

melonDS — Shader/Filter UI Extension

This PR adds a runtime shader filter system to melonDS, allowing users to apply visual filters (scalers, CRT effects, anti-aliasing, handheld LCD grids, etc.) directly from the View → Filters window without needing to edit config files manually.

Key Implementations:

  • 35 curated shader presets from the libretro slang-shaders collection, including xBRZ, HQx, Scale2x, Super-xBR, SMAA, FXAA, CRT EasyMode/Geom/Hyllian/Lottes, GameBoy DMG, LCD Grid, NTSC composite, and more
  • Filter stacking — combine multiple shaders (e.g. xBRZ upscale + CRT scanlines)
  • Adjustable parameters — sliders for every shader parameter with extended ranges for experimentation
  • Persistent settings — your filter selection and parameter tweaks are saved across sessions
  • No External Dependencies Required for End-Users: Shaders are compiled at runtime via glslang and spirv-cross.

The slang-shaders submodule remains pristine — zero modifications to any shader source. All integration is in the C++ frontend layer.

Architectural Notes & CI/CD Changes:

  • I kept modifications to the original core code to an absolute minimum. The major architectural addition is the inclusion of the glslang and spirv-cross libraries. These are the official Khronos compilers and the standard, high-performance method for reading and translating Slang shaders natively.
  • CI/CD and Packaging: To ensure the res/slang-shaders directory is properly distributed to end-users out-of-the-box, I updated the GitHub Actions workflows. The pipeline now packages the executable alongside the res/ folder (bundled into a .zip for Windows/BSD, and natively injected into the .AppImage / .app directories for Linux/macOS).

Modified files (focused on GLSLANG/SPIRV-CROSS integration and packaging):

vcpkg.json
.github/workflows/build-bsd.yml
.github/workflows/build-macos.yml
.github/workflows/build-ubuntu.yml
.github/workflows/build-windows.yml
CMakeLists.txt
src/frontend/qt_sdl/CMakeLists.txt
src/frontend/qt_sdl/Config.cpp
src/frontend/qt_sdl/Screen.cpp
src/frontend/qt_sdl/Screen.h
src/frontend/qt_sdl/Window.cpp
src/frontend/qt_sdl/Window.h

Added files (Core shader implementation and UI):

.gitmodules
res/slang-shaders/
src/frontend/qt_sdl/FrontendShader.h
src/frontend/qt_sdl/ShaderConfigDialog.cpp
src/frontend/qt_sdl/ShaderConfigDialog.h
src/frontend/qt_sdl/ShaderManager.cpp
src/frontend/qt_sdl/ShaderManager.h
src/frontend/qt_sdl/ShaderParser.cpp
src/frontend/qt_sdl/ShaderParser.h
src/frontend/qt_sdl/SlangPreset.cpp
src/frontend/qt_sdl/SlangPreset.h

Showcase:

shader-menu-1 shader-menu-2 nearest-default adaptative-sharpen crt-hyllian nds-color sabr xbrz-6x zfast-lcd

Comment thread CMakeLists.txt
if (BUILD_QT_SDL)
add_subdirectory(src/frontend/qt_sdl)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res DESTINATION bin)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a gross violation of https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
Anything related to this "./res" directory should be redone and put into appropriate places.

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.

2 participants