[macOS / iOS] Switch Vulkan init to VK_EXT_metal_surface extension.
This commit is contained in:
parent
dfe226b933
commit
f458943455
|
@ -80,7 +80,7 @@ DisplayServerIOS::DisplayServerIOS(const String &p_rendering_driver, WindowMode
|
||||||
if (!layer) {
|
if (!layer) {
|
||||||
ERR_FAIL_MSG("Failed to create iOS Vulkan rendering layer.");
|
ERR_FAIL_MSG("Failed to create iOS Vulkan rendering layer.");
|
||||||
}
|
}
|
||||||
wpd.vulkan.layer_ptr = &layer;
|
wpd.vulkan.layer_ptr = (CAMetalLayer *const *)&layer;
|
||||||
rendering_context = memnew(RenderingContextDriverVulkanIOS);
|
rendering_context = memnew(RenderingContextDriverVulkanIOS);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
#include "drivers/vulkan/rendering_context_driver_vulkan.h"
|
#include "drivers/vulkan/rendering_context_driver_vulkan.h"
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <QuartzCore/CAMetalLayer.h>
|
||||||
|
|
||||||
class RenderingContextDriverVulkanIOS : public RenderingContextDriverVulkan {
|
class RenderingContextDriverVulkanIOS : public RenderingContextDriverVulkan {
|
||||||
private:
|
private:
|
||||||
|
@ -46,7 +46,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct WindowPlatformData {
|
struct WindowPlatformData {
|
||||||
CALayer *const *layer_ptr;
|
CAMetalLayer *const *layer_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
RenderingContextDriverVulkanIOS();
|
RenderingContextDriverVulkanIOS();
|
||||||
|
|
|
@ -35,22 +35,22 @@
|
||||||
#ifdef USE_VOLK
|
#ifdef USE_VOLK
|
||||||
#include <volk.h>
|
#include <volk.h>
|
||||||
#else
|
#else
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan_metal.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *RenderingContextDriverVulkanIOS::_get_platform_surface_extension() const {
|
const char *RenderingContextDriverVulkanIOS::_get_platform_surface_extension() const {
|
||||||
return VK_MVK_IOS_SURFACE_EXTENSION_NAME;
|
return VK_EXT_METAL_SURFACE_EXTENSION_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderingContextDriver::SurfaceID RenderingContextDriverVulkanIOS::surface_create(const void *p_platform_data) {
|
RenderingContextDriver::SurfaceID RenderingContextDriverVulkanIOS::surface_create(const void *p_platform_data) {
|
||||||
const WindowPlatformData *wpd = (const WindowPlatformData *)(p_platform_data);
|
const WindowPlatformData *wpd = (const WindowPlatformData *)(p_platform_data);
|
||||||
|
|
||||||
VkIOSSurfaceCreateInfoMVK create_info = {};
|
VkMetalSurfaceCreateInfoEXT create_info = {};
|
||||||
create_info.sType = VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK;
|
create_info.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
|
||||||
create_info.pView = (__bridge const void *)(*wpd->layer_ptr);
|
create_info.pLayer = *wpd->layer_ptr;
|
||||||
|
|
||||||
VkSurfaceKHR vk_surface = VK_NULL_HANDLE;
|
VkSurfaceKHR vk_surface = VK_NULL_HANDLE;
|
||||||
VkResult err = vkCreateIOSSurfaceMVK(instance_get(), &create_info, nullptr, &vk_surface);
|
VkResult err = vkCreateMetalSurfaceEXT(instance_get(), &create_info, nullptr, &vk_surface);
|
||||||
ERR_FAIL_COND_V(err != VK_SUCCESS, SurfaceID());
|
ERR_FAIL_COND_V(err != VK_SUCCESS, SurfaceID());
|
||||||
|
|
||||||
Surface *surface = memnew(Surface);
|
Surface *surface = memnew(Surface);
|
||||||
|
|
|
@ -203,7 +203,7 @@ DisplayServerMacOS::WindowID DisplayServerMacOS::_create_window(WindowMode p_mod
|
||||||
} wpd;
|
} wpd;
|
||||||
#ifdef VULKAN_ENABLED
|
#ifdef VULKAN_ENABLED
|
||||||
if (rendering_driver == "vulkan") {
|
if (rendering_driver == "vulkan") {
|
||||||
wpd.vulkan.view_ptr = &wd.window_view;
|
wpd.vulkan.layer_ptr = (CAMetalLayer *const *)&layer;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Error err = rendering_context->window_create(window_id_counter, &wpd);
|
Error err = rendering_context->window_create(window_id_counter, &wpd);
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
#include "drivers/vulkan/rendering_context_driver_vulkan.h"
|
#include "drivers/vulkan/rendering_context_driver_vulkan.h"
|
||||||
|
|
||||||
#import <AppKit/AppKit.h>
|
#import <QuartzCore/CAMetalLayer.h>
|
||||||
|
|
||||||
class RenderingContextDriverVulkanMacOS : public RenderingContextDriverVulkan {
|
class RenderingContextDriverVulkanMacOS : public RenderingContextDriverVulkan {
|
||||||
private:
|
private:
|
||||||
|
@ -46,7 +46,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct WindowPlatformData {
|
struct WindowPlatformData {
|
||||||
const id *view_ptr;
|
CAMetalLayer *const *layer_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
RenderingContextDriverVulkanMacOS();
|
RenderingContextDriverVulkanMacOS();
|
||||||
|
|
|
@ -35,22 +35,22 @@
|
||||||
#ifdef USE_VOLK
|
#ifdef USE_VOLK
|
||||||
#include <volk.h>
|
#include <volk.h>
|
||||||
#else
|
#else
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan_metal.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *RenderingContextDriverVulkanMacOS::_get_platform_surface_extension() const {
|
const char *RenderingContextDriverVulkanMacOS::_get_platform_surface_extension() const {
|
||||||
return VK_MVK_MACOS_SURFACE_EXTENSION_NAME;
|
return VK_EXT_METAL_SURFACE_EXTENSION_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderingContextDriver::SurfaceID RenderingContextDriverVulkanMacOS::surface_create(const void *p_platform_data) {
|
RenderingContextDriver::SurfaceID RenderingContextDriverVulkanMacOS::surface_create(const void *p_platform_data) {
|
||||||
const WindowPlatformData *wpd = (const WindowPlatformData *)(p_platform_data);
|
const WindowPlatformData *wpd = (const WindowPlatformData *)(p_platform_data);
|
||||||
|
|
||||||
VkMacOSSurfaceCreateInfoMVK create_info = {};
|
VkMetalSurfaceCreateInfoEXT create_info = {};
|
||||||
create_info.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
|
create_info.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
|
||||||
create_info.pView = (__bridge const void *)(*wpd->view_ptr);
|
create_info.pLayer = *wpd->layer_ptr;
|
||||||
|
|
||||||
VkSurfaceKHR vk_surface = VK_NULL_HANDLE;
|
VkSurfaceKHR vk_surface = VK_NULL_HANDLE;
|
||||||
VkResult err = vkCreateMacOSSurfaceMVK(instance_get(), &create_info, nullptr, &vk_surface);
|
VkResult err = vkCreateMetalSurfaceEXT(instance_get(), &create_info, nullptr, &vk_surface);
|
||||||
ERR_FAIL_COND_V(err != VK_SUCCESS, SurfaceID());
|
ERR_FAIL_COND_V(err != VK_SUCCESS, SurfaceID());
|
||||||
|
|
||||||
Surface *surface = memnew(Surface);
|
Surface *surface = memnew(Surface);
|
||||||
|
|
Loading…
Reference in New Issue