Skip to content

Commit

Permalink
[Vk] fixed Android runtime errors
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenegff committed Dec 5, 2024
1 parent 18a4c37 commit 924004d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ namespace Ogre
//-------------------------------------------------------------------------
void VulkanAndroidWindow::setNativeWindow( ANativeWindow *nativeWindow )
{
destroy();

This comment has been minimized.

Copy link
@AllianceDarkSylinc

AllianceDarkSylinc Dec 5, 2024

Is this safe?

The original called VulkanAndroidWindow::destroy() because it would end up calling mDevice->stall() when the app goes into the background.

Otherwise there were crashes when the app went back to the foreground.

This comment has been minimized.

Copy link
@AllianceDarkSylinc

AllianceDarkSylinc Dec 5, 2024

Furthermore setNativeWindow(nullptr) can be called while the swapchain is still in use; therefore we must stall or else we'll be deleting a swapchain that is still in use by the GPU.

This comment has been minimized.

Copy link
@eugenegff

eugenegff Dec 5, 2024

Author Member

Interesting question. VulkanWindow often call destroySwapchain+createSwapchain without any stalls, for example in VulkanWindowSwapChainBased::setVSync() and VulkanWindowSwapChainBased::setWantsToDownload(). But all VulkanXxxWindow::windowMovedOrResized() do mDevice->stall(); before it.

I will add mDevice->stall(); here. Old destroy() call is not appropriate as it destructs textures via destroySwapchain( finalDestruction = true );

This comment has been minimized.

Copy link
@eugenegff

eugenegff Dec 5, 2024

Author Member

Maybe mDevice->stall(); even should be moved into destroySwapchain()

This comment has been minimized.

Copy link
@eugenegff

eugenegff Dec 5, 2024

Author Member

Swappy calls are often between stall() and destroySwapchain(), making it hard

destroySwapchain();
destroySurface();

// Depth & Stencil buffer are normal textures; thus they need to be reeinitialized normally
if( mDepthBuffer && mDepthBuffer->getResidencyStatus() != GpuResidency::OnStorage )
Expand Down

0 comments on commit 924004d

Please sign in to comment.