mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-25 21:41:03 +00:00
- set default magnification filter for Metal layer to nearest
Magnification filter is applied to swapchain image when it's copied to a physical display surface This is needed for gfx-portability because MoltenVK uses nearest sampling by default
This commit is contained in:
parent
3c0ff178fd
commit
d9dcc26dc6
2 changed files with 18 additions and 3 deletions
|
@ -1482,8 +1482,14 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
|
|||
endif()
|
||||
|
||||
if( APPLE )
|
||||
set( LINK_FRAMEWORKS "-framework Cocoa -framework IOKit -framework OpenGL")
|
||||
|
||||
if( HAVE_VULKAN )
|
||||
set( LINK_FRAMEWORKS "${LINK_FRAMEWORKS} -framework QuartzCore" )
|
||||
endif()
|
||||
|
||||
set_target_properties(zdoom PROPERTIES
|
||||
LINK_FLAGS "-framework Cocoa -framework IOKit -framework OpenGL"
|
||||
LINK_FLAGS "${LINK_FRAMEWORKS}"
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/zdoom-info.plist" )
|
||||
|
||||
# Dymanic libraries like libvulkan.dylib or libMoltenVK.dylib will be loaded by dlopen()
|
||||
|
|
|
@ -925,6 +925,15 @@ bool I_GetVulkanPlatformExtensions(unsigned int *count, const char **names)
|
|||
|
||||
bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface)
|
||||
{
|
||||
NSView *const view = CocoaVideo::GetWindow().contentView;
|
||||
CALayer *const layer = view.layer;
|
||||
|
||||
// Set magnification filter for swapchain image when it's copied to a physical display surface
|
||||
// This is needed for gfx-portability because MoltenVK uses preferred nearest sampling by default
|
||||
const char *const magFilterEnv = getenv("MVK_CONFIG_SWAPCHAIN_MAG_FILTER_USE_NEAREST");
|
||||
const bool useNearestFilter = magFilterEnv == nullptr || strtol(magFilterEnv, nullptr, 0) != 0;
|
||||
layer.magnificationFilter = useNearestFilter ? kCAFilterNearest : kCAFilterLinear;
|
||||
|
||||
if (vkCreateMetalSurfaceEXT)
|
||||
{
|
||||
// Preferred surface creation path
|
||||
|
@ -932,7 +941,7 @@ bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface)
|
|||
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
|
||||
surfaceCreateInfo.pNext = nullptr;
|
||||
surfaceCreateInfo.flags = 0;
|
||||
surfaceCreateInfo.pLayer = static_cast<CAMetalLayer*>(CocoaVideo::GetWindow().contentView.layer);
|
||||
surfaceCreateInfo.pLayer = static_cast<CAMetalLayer*>(layer);
|
||||
|
||||
const VkResult result = vkCreateMetalSurfaceEXT(instance, &surfaceCreateInfo, nullptr, surface);
|
||||
return result == VK_SUCCESS;
|
||||
|
@ -943,7 +952,7 @@ bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface)
|
|||
windowCreateInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
|
||||
windowCreateInfo.pNext = nullptr;
|
||||
windowCreateInfo.flags = 0;
|
||||
windowCreateInfo.pView = [CocoaVideo::GetWindow() contentView];
|
||||
windowCreateInfo.pView = view;
|
||||
|
||||
const VkResult result = vkCreateMacOSSurfaceMVK(instance, &windowCreateInfo, nullptr, surface);
|
||||
return result == VK_SUCCESS;
|
||||
|
|
Loading…
Reference in a new issue