Skip to content

Commit

Permalink
[Vk] move common pixelFormat, sampleDescription, depthDefaults setup …
Browse files Browse the repository at this point in the history
…code into VulkanWindowSwapChainBased::createSwapchain()
  • Loading branch information
eugenegff committed Feb 11, 2025
1 parent b538072 commit 778153b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 93 deletions.
28 changes: 28 additions & 0 deletions RenderSystems/Vulkan/src/OgreVulkanWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,34 @@ namespace Ogre
{
mSuboptimal = false;

// Update pixelFormat, sample description, depth buffer defaults
mTexture->setPixelFormat( chooseSurfaceFormat( mHwGamma ) );
if( mDepthBuffer )
{
mDepthBuffer->setPixelFormat( DepthBuffer::DefaultDepthBufferFormat );
if( PixelFormatGpuUtils::isStencil( mDepthBuffer->getPixelFormat() ) )
mStencilBuffer = mDepthBuffer;
}

mSampleDescription = mDevice->mRenderSystem->validateSampleDescription(
mRequestedSampleDescription, mTexture->getPixelFormat(),
TextureFlags::NotTexture | TextureFlags::RenderWindowSpecific );
mTexture->_setSampleDescription( mRequestedSampleDescription, mSampleDescription );
if( mDepthBuffer )
mDepthBuffer->_setSampleDescription( mRequestedSampleDescription, mSampleDescription );

if( mDepthBuffer )
{
mTexture->_setDepthBufferDefaults( mDepthBuffer->isTilerMemoryless()
? DepthBuffer::POOL_MEMORYLESS
: DepthBuffer::NO_POOL_EXPLICIT_RTV,
false, mDepthBuffer->getPixelFormat() );
}
else
{
mTexture->_setDepthBufferDefaults( DepthBuffer::POOL_NO_DEPTH, false, PFG_NULL );
}

VkSurfaceCapabilitiesKHR surfaceCaps;
VkResult result = vkGetPhysicalDeviceSurfaceCapabilitiesKHR( mDevice->mPhysicalDevice,
mSurfaceKHR, &surfaceCaps );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,6 @@ namespace Ogre
if( !mNativeWindow )
return;

mClosed = false;
mFocused = true;
// WindowEventUtilities::_addRenderWindow( this );

createSurface();

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

Expand All @@ -376,37 +370,7 @@ namespace Ogre

setFinalResolution( mRequestedWidth, mRequestedHeight );

// mTexture is in OnStorage only once ever: at startup. Set these parameters once
if( mTexture->getResidencyStatus() == GpuResidency::OnStorage )
{
mTexture->setPixelFormat( chooseSurfaceFormat( mHwGamma ) );
if( mDepthBuffer )
{
mDepthBuffer->setPixelFormat( DepthBuffer::DefaultDepthBufferFormat );
if( PixelFormatGpuUtils::isStencil( mDepthBuffer->getPixelFormat() ) )
mStencilBuffer = mDepthBuffer;
}

mSampleDescription = mDevice->mRenderSystem->validateSampleDescription(
mRequestedSampleDescription, mTexture->getPixelFormat(),
TextureFlags::NotTexture | TextureFlags::RenderWindowSpecific );
mTexture->_setSampleDescription( mRequestedSampleDescription, mSampleDescription );
if( mDepthBuffer )
mDepthBuffer->_setSampleDescription( mRequestedSampleDescription, mSampleDescription );

if( mDepthBuffer )
{
mTexture->_setDepthBufferDefaults( mDepthBuffer->isTilerMemoryless()
? DepthBuffer::POOL_MEMORYLESS
: DepthBuffer::NO_POOL_EXPLICIT_RTV,
false, mDepthBuffer->getPixelFormat() );
}
else
{
mTexture->_setDepthBufferDefaults( DepthBuffer::POOL_NO_DEPTH, false, PFG_NULL );
}
}

createSurface();
createSwapchain();
}
//-------------------------------------------------------------------------
Expand Down
26 changes: 0 additions & 26 deletions RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,32 +205,6 @@ namespace Ogre
mStencilBuffer = 0;

setFinalResolution( mRequestedWidth, mRequestedHeight );
mTexture->setPixelFormat( chooseSurfaceFormat( mHwGamma ) );
if( mDepthBuffer )
{
mDepthBuffer->setPixelFormat( DepthBuffer::DefaultDepthBufferFormat );
if( PixelFormatGpuUtils::isStencil( mDepthBuffer->getPixelFormat() ) )
mStencilBuffer = mDepthBuffer;
}

mSampleDescription = mDevice->mRenderSystem->validateSampleDescription(
mRequestedSampleDescription, mTexture->getPixelFormat(),
TextureFlags::NotTexture | TextureFlags::RenderWindowSpecific );
mTexture->_setSampleDescription( mRequestedSampleDescription, mSampleDescription );
if( mDepthBuffer )
mDepthBuffer->_setSampleDescription( mRequestedSampleDescription, mSampleDescription );

if( mDepthBuffer )
{
mTexture->_setDepthBufferDefaults( mDepthBuffer->isTilerMemoryless()
? DepthBuffer::POOL_MEMORYLESS
: DepthBuffer::NO_POOL_EXPLICIT_RTV,
false, mDepthBuffer->getPixelFormat() );
}
else
{
mTexture->_setDepthBufferDefaults( DepthBuffer::POOL_NO_DEPTH, false, PFG_NULL );
}

createSwapchain();
}
Expand Down
30 changes: 0 additions & 30 deletions RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,36 +532,6 @@ namespace Ogre

setFinalResolution( mRequestedWidth, mRequestedHeight );

// if( mColourDepth == 16u )
// mTexture->setPixelFormat( PFG_B5G5R5A1_UNORM );
// else
mTexture->setPixelFormat( chooseSurfaceFormat( mHwGamma ) );
if( mDepthBuffer )
{
mDepthBuffer->setPixelFormat( DepthBuffer::DefaultDepthBufferFormat );
if( PixelFormatGpuUtils::isStencil( mDepthBuffer->getPixelFormat() ) )
mStencilBuffer = mDepthBuffer;
}

mSampleDescription = mDevice->mRenderSystem->validateSampleDescription(
mRequestedSampleDescription, mTexture->getPixelFormat(),
TextureFlags::NotTexture | TextureFlags::RenderWindowSpecific );
mTexture->_setSampleDescription( mRequestedSampleDescription, mSampleDescription );
if( mDepthBuffer )
mDepthBuffer->_setSampleDescription( mRequestedSampleDescription, mSampleDescription );

if( mDepthBuffer )
{
mTexture->_setDepthBufferDefaults( mDepthBuffer->isTilerMemoryless()
? DepthBuffer::POOL_MEMORYLESS
: DepthBuffer::NO_POOL_EXPLICIT_RTV,
false, mDepthBuffer->getPixelFormat() );
}
else
{
mTexture->_setDepthBufferDefaults( DepthBuffer::POOL_NO_DEPTH, false, PFG_NULL );
}

createSwapchain();

setHidden( mHidden );
Expand Down

0 comments on commit 778153b

Please sign in to comment.