From 924004dd6b52b3886f5a716acef5b6abe78c3752 Mon Sep 17 00:00:00 2001
From: Eugene Golushkov <e.golushkov@nospam-gmail.com>
Date: Thu, 5 Dec 2024 15:07:56 +0100
Subject: [PATCH] [Vk] fixed Android runtime errors

---
 RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp            | 3 ++-
 .../Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp
index 210011c90d..f770fb96cf 100644
--- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp
+++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp
@@ -1170,11 +1170,12 @@ namespace Ogre
             mDevice->mVaoManager = vaoManager;
 
             mDevice->setPhysicalDevice( mInstance, mActiveDevice, externalDevice );
-            vaoManager->createVkResources();
 
             mRealCapabilities = createRenderSystemCapabilities();
             mCurrentCapabilities = mRealCapabilities;
 
+            vaoManager->createVkResources();
+
             initialiseFromRenderSystemCapabilities( mCurrentCapabilities, 0 );
 
             mHardwareBufferManager = OGRE_NEW v1::VulkanHardwareBufferManager( mDevice, mVaoManager );
diff --git a/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp b/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp
index 2c0035bb54..f09a81b1dc 100644
--- a/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp
+++ b/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp
@@ -336,7 +336,8 @@ namespace Ogre
     //-------------------------------------------------------------------------
     void VulkanAndroidWindow::setNativeWindow( ANativeWindow *nativeWindow )
     {
-        destroy();
+        destroySwapchain();
+        destroySurface();
 
         // Depth & Stencil buffer are normal textures; thus they need to be reeinitialized normally
         if( mDepthBuffer && mDepthBuffer->getResidencyStatus() != GpuResidency::OnStorage )