Fix initialising of gl_manager and checking gl_manager and context_vulkan preventing crash issues.

This commit is contained in:
Bastiaan Olij 2021-12-14 12:49:29 +11:00
parent b0e93711b3
commit d08b28aeb0
7 changed files with 73 additions and 78 deletions

View file

@ -54,8 +54,8 @@ class DisplayServerIPhone : public DisplayServer {
_THREAD_SAFE_CLASS_
#if defined(VULKAN_ENABLED)
VulkanContextIPhone *context_vulkan;
RenderingDeviceVulkan *rendering_device_vulkan;
VulkanContextIPhone *context_vulkan = nullptr;
RenderingDeviceVulkan *rendering_device_vulkan = nullptr;
#endif
DisplayServer::ScreenOrientation screen_orientation;

View file

@ -54,6 +54,8 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Windo
#if defined(GLES3_ENABLED)
// FIXME: Add support for both OpenGL and Vulkan when OpenGL is implemented
// again,
// Note that we should be checking "opengl3" as the driver, might never enable this seeing OpenGL is deprecated on iOS
// We are hardcoding the rendering_driver to "vulkan" down below
if (rendering_driver == "opengl_es") {
bool gl_initialization_error = false;
@ -131,18 +133,16 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Windo
DisplayServerIPhone::~DisplayServerIPhone() {
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
if (rendering_device_vulkan) {
rendering_device_vulkan->finalize();
memdelete(rendering_device_vulkan);
rendering_device_vulkan = nullptr;
}
if (rendering_device_vulkan) {
rendering_device_vulkan->finalize();
memdelete(rendering_device_vulkan);
rendering_device_vulkan = nullptr;
}
if (context_vulkan) {
context_vulkan->window_destroy(MAIN_WINDOW_ID);
memdelete(context_vulkan);
context_vulkan = nullptr;
}
if (context_vulkan) {
context_vulkan->window_destroy(MAIN_WINDOW_ID);
memdelete(context_vulkan);
context_vulkan = nullptr;
}
#endif
}
@ -565,10 +565,8 @@ void DisplayServerIPhone::resize_window(CGSize viewSize) {
Size2i size = Size2i(viewSize.width, viewSize.height) * screen_get_max_scale();
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
if (context_vulkan) {
context_vulkan->window_resize(MAIN_WINDOW_ID, size.x, size.y);
}
if (context_vulkan) {
context_vulkan->window_resize(MAIN_WINDOW_ID, size.x, size.y);
}
#endif