Skip to content

Commit

Permalink
[Vk] Avoid swapchain recreation in windowMovedOrResized() when window…
Browse files Browse the repository at this point in the history
… is moved but not resized. Swapchains suboptimal due to the mismatching colorspace or orientation are still rebuilt.
  • Loading branch information
eugenegff committed Oct 8, 2024
1 parent a3fcd63 commit 7255629
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ namespace Ogre
if( mClosed || !mNativeWindow )
return;

const uint32 newWidth = static_cast<uint32>( ANativeWindow_getWidth( mNativeWindow ) );
const uint32 newHeight = static_cast<uint32>( ANativeWindow_getHeight( mNativeWindow ) );
if( newWidth == getWidth() && newHeight == getHeight() && !mRebuildingSwapchain )
return;

mDevice->stall();

#ifdef OGRE_VULKAN_USE_SWAPPY
Expand Down Expand Up @@ -285,9 +290,6 @@ namespace Ogre
mStencilBuffer->_transitionTo( GpuResidency::OnStorage, (uint8 *)0 );
}

const uint32 newWidth = static_cast<uint32>( ANativeWindow_getWidth( mNativeWindow ) );
const uint32 newHeight = static_cast<uint32>( ANativeWindow_getHeight( mNativeWindow ) );

setFinalResolution( newWidth, newHeight );

createSwapchain();
Expand Down
12 changes: 9 additions & 3 deletions RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,14 @@ namespace Ogre
mTop = geom->y;
}

auto newWidth = geom->width;
auto newHeight = geom->height;

free( geom );

if( newWidth == getWidth() && newHeight == getHeight() && !mRebuildingSwapchain )
return;

mDevice->stall();

destroySwapchain();
Expand All @@ -527,11 +535,9 @@ namespace Ogre
if( mStencilBuffer && mStencilBuffer != mDepthBuffer )
mStencilBuffer->_transitionTo( GpuResidency::OnStorage, (uint8 *)0 );

setFinalResolution( geom->width, geom->height );
setFinalResolution( newWidth, newHeight );

createSwapchain();

free( geom );
}
//-------------------------------------------------------------------------
void VulkanXcbWindow::_setVisible( bool visible ) { mVisible = visible; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,9 @@ namespace Ogre

updateWindowRect();

if( mRequestedWidth == getWidth() && mRequestedHeight == getHeight() && !mRebuildingSwapchain )
return;

mDevice->stall();

destroySwapchain();
Expand Down

0 comments on commit 7255629

Please sign in to comment.