Compare commits

..

31 commits

Author SHA1 Message Date
Wunk
ac0cd66ca3
Merge c1e1b2b93a into 379649dbce 2026-06-05 15:50:07 +00:00
Wunkolo
c1e1b2b93a renderer_gl: Add layer/level specifier to MSAA resolves 2026-06-05 08:49:58 -07:00
Wunkolo
5e9b2aa33a renderer_gl: Fix MakeHandle string-view hazard
`glObjectLabel` expects a null-terminated string, but an `std::string_view` is not necessarily null-terminated
2026-06-05 08:49:58 -07:00
Wunkolo
f01b8fcdcd renderer_gl: Implement TextureRuntime::ClearTexture MSAA clears
When ArbClearTexture is not available, ensure the fallback implementation also clears the MSAA texture as well.
2026-06-05 08:49:58 -07:00
Wunkolo
3b3a5e5130 renderer_gl: Resolve framebuffer after each draw
Brute force approach while trying to determine a better heuristic. Framebuffer changes are not enough to determine the end of a "render pass". An 'msaa dirty flag' is likely the better way here.
2026-06-05 08:49:58 -07:00
Wunkolo
15be844ed8 renderer_gl: Implement multisample Convert{DS24S8ToRGBA8,RGBA4ToRGB5A1} 2026-06-05 08:49:58 -07:00
Wunkolo
9fd44f99d6 renderer_gl: Fix surface ScaleUp implementation
Should assign the new `res_scale` and `sample_count`
2026-06-05 08:49:58 -07:00
Wunkolo
2743ebd0c9 renderer_gl: Initial MSAA implementation
Basically copied over some of the paradigms over from Vulkan. Covers most rendering uses-cases except for conversions such as `ConvertDS24S8ToRGBA8` and `ConvertRGBA4ToRGB5A1`
2026-06-05 08:49:58 -07:00
Wunkolo
29954c1392 config: Refactor sample_count to antialiasing setting
Intended to allow for other anti-aliasing methods to be introduced
2026-06-05 08:49:58 -07:00
Wunkolo
0cb1680a20 renderer_vulkan: Fix Multisample ConvertDS24S8ToRGBA8
Migrate `ResolveTexture` to `BlitHelper`.
If the conversion was multi-sample, do a final resolve at the end of the conversion to ensure the non-multisample textures are updated as well.

Fixes Pokemon!
2026-06-05 08:49:58 -07:00
Wunkolo
a0a0cd648e renderer_vulkan: Fix MSAA image debug name 2026-06-05 08:49:58 -07:00
Wunkolo
0f8ffa6e66 renderer_vulkan: Fix multisample framebuffer creation
MSAA renderpasses require the "current" image as the main resolve target, and the MSAA image as the second attachment.
2026-06-05 08:49:58 -07:00
Wunkolo
5960b60d88 renderer_vulkan: Fix multisample ClearTextureWithRenderpass
Ensure that the multisample framebuffer is used rather than the usual one when using a render pass to clear the textures.

That way, a MSAA-render AND resolve is used to clear the textures at the same time.
2026-06-05 08:49:58 -07:00
Wunkolo
492304e215 renderer_vulkan: Fix ConvertDS24S8ToRGBA8 image targets
Ensure that the Multi-Sample texture is used for the destination color image as well. Should the dest image be MSAA too? Or should all the values be resolved into a minimum depth and some combination of stencil-values here?
2026-06-05 08:49:58 -07:00
Wunkolo
7b908bb4bc renderer_vulkan: Fix Surface::ScaleUp scale/sample increase
This should be checking the _new_ value to possibly cull upscaled texture creation rather than the current value of the surface. Fixes broken up render passes when drawing UI in some games.
2026-06-05 08:49:58 -07:00
Wunkolo
70b393e56d renderer_vulkan: Fix MSAA framebuffer target resolve surface
Use the specified type rather than defaulting to the surface's current one(implicit `ImageView` argument).
2026-06-05 08:49:58 -07:00
Wunkolo
0810828345 renderer_vulkan: Fix narrowing byte conversion
Fixes a compilation error on Unix platforms.
2026-06-05 08:49:58 -07:00
Wunkolo
a0655d5674 renderer_vulkan: Add TextureRuntime::ResolveTexture
Rather than use a big lambda, just rip this out into a proper function for other blit functions to utilize.
2026-06-05 08:49:58 -07:00
Wunkolo
8e839016d4 renderer_vulkan: Fix cleanup and debug-naming for d24s8_to_rgba8_ms_comp 2026-06-05 08:49:58 -07:00
Wunkolo
fd3a0a99a0 renderer_vulkan: Fix initialization of image handles
Try to optimally create the new image handles when a change in res scale or sample-count has actually occured. MSAA images need to be updated too in the case that the resolution scale has changed
2026-06-05 08:49:58 -07:00
Wunkolo
02eb015d36 renderer_vulkan: Derive framebuffer sample-count from attachments
Derive the framebuffer sample-count from the input color and depth operands. Similar to how `res_scale` is determined.
2026-06-05 08:49:58 -07:00
Wunkolo
177edd228e renderer_vulkan: Fix dangling surface reference during msaa resolve
These individual parameters need to be copied as the reference to the surface-object only lasts within the scope of this function.
2026-06-05 08:49:58 -07:00
Wunkolo
9d6527b3ae renderer_vulkan: Fix Framebuffer::sample_count move-operator
`sample_count` needs to be move/copied over.

Also reorder the accessor order to match the declaration of variables.
2026-06-05 08:49:58 -07:00
Wunkolo
fa97aaade4 renderer_vulkan: Fix multisample texture init barrier
Should address the MultiSampled image directly since the multisampled image is just a transient image and not the leading state of the image.
2026-06-05 08:49:58 -07:00
Wunkolo
88ded6e8c2 renderer_vulkan: Implement multisample texture runtime
This seems to be enough for simple programs to render with MSAA enabled!
2026-06-05 08:49:58 -07:00
Wunkolo
ff7b039c5c renderer_vulkan: Implement multisample pipeline/renderpass support
Allows multi-sample render passes and graphics pipelines to be created, using sample-rate shading rather than coverage-based MSAA.
2026-06-05 08:49:58 -07:00
Wunkolo
fdf022753c rasterizer_cache: Initial support for multi-sample surfaces 2026-06-05 08:49:58 -07:00
Wunkolo
f682a89bdc vk_instance: Add detection of MSAA features
Full multi-sample support is when renderpass-2 and depth-stencil-resolve extensions are available and when sample-rate-shading and msaa-storage-images are supported.
2026-06-05 08:49:58 -07:00
Wunkolo
fcadfd8e19 vk_blit_helper: Add d24s8_to_rgba8_ms_comp
Helper host-shader for blitting multi-sampled DS24S8 textures to multi-sampled RGBA8
2026-06-05 08:49:58 -07:00
Wunkolo
faf61b898a config: Add sample_count renderer option
Option is only enabled when the renderer is set to Vulkan, for now.
2026-06-05 08:49:58 -07:00
crueter
379649dbce
cmake: Fix MoltenVK fetch order/library conflicts (#2183)
* [cmake] Fix MoltenVK fetch order/library conflicts

Rather than dealing with `find_library` shenanigans, just set the
library path directly (when using bundled MoltenVK). System MoltenVK
solely uses `find_library`.

Avoids cache nonsense that can cause system/bundled versions to get
mixed up, and overall makes the system/bundled mvk handling a lot more
consistent

```
cmake -S . -B build -DUSE_SYSTEM_MOLTENVK=ON
-- Using MoltenVK at /opt/homebrew/lib/libMoltenVK.dylib.
cmake -S . -B build -DUSE_SYSTEM_MOLTENVK=OFF
-- Using MoltenVK at /Users/crueter/code/azahar/build/externals/MoltenVK/MoltenVK/dynamic/dylib/macOS/libMoltenVK.dylib.
cmake -S . -B build -DUSE_SYSTEM_MOLTENVK=ON
-- Using MoltenVK at /opt/homebrew/lib/libMoltenVK.dylib.
```

Signed-off-by: crueter <crueter@eden-emu.dev>

* remove old comment

Signed-off-by: crueter <crueter@eden-emu.dev>

* Cleanup

---------

Signed-off-by: crueter <crueter@eden-emu.dev>
Co-authored-by: OpenSauce04 <opensauce04@gmail.com>
2026-06-05 16:36:48 +01:00
2 changed files with 12 additions and 15 deletions

View file

@ -411,13 +411,21 @@ if (APPLE)
endif()
find_library(AVFOUNDATION_LIBRARY AVFoundation REQUIRED)
find_library(IOSURFACE_LIBRARY IOSurface REQUIRED)
set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${AVFOUNDATION_LIBRARY} ${IOSURFACE_LIBRARY} ${MOLTENVK_LIBRARY})
set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${AVFOUNDATION_LIBRARY} ${IOSURFACE_LIBRARY})
if (ENABLE_VULKAN AND NOT ENABLE_LIBRETRO)
if (NOT USE_SYSTEM_MOLTENVK)
download_moltenvk()
endif()
if (USE_SYSTEM_MOLTENVK)
find_library(MOLTENVK_LIBRARY MoltenVK REQUIRED)
else()
download_moltenvk()
if (IOS)
set(MOLTENVK_RELATIVE_LIBPATH "static/MoltenVK.xcframework/ios-arm64/libMoltenVK.a")
else()
set(MOLTENVK_RELATIVE_LIBPATH "dynamic/dylib/macOS/libMoltenVK.dylib")
endif()
set(MOLTENVK_LIBRARY "${CMAKE_BINARY_DIR}/externals/MoltenVK/MoltenVK/${MOLTENVK_RELATIVE_LIBPATH}")
endif()
message(STATUS "Using MoltenVK at ${MOLTENVK_LIBRARY}.")
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} ${MOLTENVK_LIBRARY})
endif()

View file

@ -171,15 +171,8 @@ function(download_qt target)
endfunction()
function(download_moltenvk)
if (IOS)
set(MOLTENVK_PLATFORM "static/MoltenVK.xcframework/ios-arm64")
else()
set(MOLTENVK_PLATFORM "dynamic/dylib/macOS")
endif()
set(MOLTENVK_DIR "${CMAKE_BINARY_DIR}/externals/MoltenVK")
set(MOLTENVK_TAR "${CMAKE_BINARY_DIR}/externals/MoltenVK.tar")
if (NOT EXISTS ${MOLTENVK_DIR})
if (NOT EXISTS "${CMAKE_BINARY_DIR}/externals/MoltenVK")
if (NOT EXISTS ${MOLTENVK_TAR})
file(DOWNLOAD https://github.com/KhronosGroup/MoltenVK/releases/download/v1.2.9/MoltenVK-all.tar
${MOLTENVK_TAR} SHOW_PROGRESS)
@ -188,10 +181,6 @@ function(download_moltenvk)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${MOLTENVK_TAR}"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals")
endif()
# Add the MoltenVK library path to the prefix so find_library can locate it.
list(APPEND CMAKE_PREFIX_PATH "${MOLTENVK_DIR}/MoltenVK/${MOLTENVK_PLATFORM}")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE)
endfunction()
function(get_external_prefix lib_name prefix_var)