diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index ca11ec480d2..f193f738370 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -2415,6 +2415,7 @@ static bool wined3d_adapter_vk_init_device_extensions(struct wined3d_adapter_vk {VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, VK_API_VERSION_1_1}, {VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_API_VERSION_1_1}, {VK_KHR_SWAPCHAIN_EXTENSION_NAME, ~0u, true}, + {VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME, VK_API_VERSION_1_2}, /* KHR_synchronization2 is required for KHR_video_queue. */ {VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME, ~0u}, {VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME, ~0u}, @@ -2556,12 +2557,32 @@ static BOOL wined3d_adapter_vk_init(struct wined3d_adapter_vk *adapter_vk, properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; properties2.pNext = &id_properties; + memset(&adapter_vk->driver_properties, 0, sizeof(adapter_vk->driver_properties)); + adapter_vk->driver_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES; + id_properties.pNext = &adapter_vk->driver_properties; + if (vk_info->vk_ops.vkGetPhysicalDeviceProperties2) VK_CALL(vkGetPhysicalDeviceProperties2(adapter_vk->physical_device, &properties2)); else VK_CALL(vkGetPhysicalDeviceProperties(adapter_vk->physical_device, &properties2.properties)); adapter_vk->device_limits = properties2.properties.limits; + /* CW HACK 18311: Use the Vulkan renderer on macOS for d3d10/11. */ + if (wined3d_settings.renderer == WINED3D_RENDERER_AUTO) + { + bool d3d10 = !(wined3d_creation_flags & WINED3D_PIXEL_CENTER_INTEGER); + bool moltenvk = adapter_vk->driver_properties.driverID == VK_DRIVER_ID_MOLTENVK; + + if (!moltenvk || !d3d10) + { + if (!moltenvk) + TRACE("Not running on MoltenVK, defaulting to the OpenGL backend.\n"); + if (!d3d10) + TRACE("Application using < d3d10 API, defaulting to the OpenGL backend.\n"); + goto fail_vulkan; + } + } + VK_CALL(vkGetPhysicalDeviceMemoryProperties(adapter_vk->physical_device, &adapter_vk->memory_properties)); if (id_properties.deviceLUIDValid) diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index c2e91b38bad..306be90543c 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -3477,13 +3477,25 @@ done: static struct wined3d_adapter *wined3d_adapter_create(unsigned int ordinal, DWORD wined3d_creation_flags) { + struct wined3d_adapter *adapter = NULL; + if (wined3d_creation_flags & WINED3D_NO3D) return wined3d_adapter_no3d_create(ordinal, wined3d_creation_flags); if (wined3d_settings.renderer == WINED3D_RENDERER_VULKAN) return wined3d_adapter_vk_create(ordinal, wined3d_creation_flags); - return wined3d_adapter_gl_create(ordinal, wined3d_creation_flags); + if (wined3d_settings.renderer == WINED3D_RENDERER_OPENGL) + return wined3d_adapter_gl_create(ordinal, wined3d_creation_flags); + + /* CW HACK 18311: Use the Vulkan renderer on macOS. */ + if ((adapter = wined3d_adapter_vk_create(ordinal, wined3d_creation_flags))) + ERR_(winediag)("Using the Vulkan renderer for d3d10/11 applications.\n"); + + if (!adapter) + adapter = wined3d_adapter_gl_create(ordinal, wined3d_creation_flags); + + return adapter; } static void STDMETHODCALLTYPE wined3d_null_wined3d_object_destroyed(void *parent) {} diff --git a/dlls/wined3d/wined3d_vk.h b/dlls/wined3d/wined3d_vk.h index 55f40d5a831..6b257f0da16 100644 --- a/dlls/wined3d/wined3d_vk.h +++ b/dlls/wined3d/wined3d_vk.h @@ -806,6 +806,7 @@ struct wined3d_adapter_vk VkPhysicalDeviceLimits device_limits; VkPhysicalDeviceMemoryProperties memory_properties; + VkPhysicalDeviceDriverProperties driver_properties; }; static inline struct wined3d_adapter_vk *wined3d_adapter_vk(struct wined3d_adapter *adapter)