diff --git a/OgreMain/include/OgreDepthBuffer.h b/OgreMain/include/OgreDepthBuffer.h index c28634ea238..085f18a3329 100644 --- a/OgreMain/include/OgreDepthBuffer.h +++ b/OgreMain/include/OgreDepthBuffer.h @@ -89,6 +89,11 @@ namespace Ogre POOL_NO_DEPTH = 0, POOL_MANUAL_USAGE OGRE_DEPRECATED_ENUM_VER( 3 ) = 0, POOL_DEFAULT = 1, + + /// The depth buffer doesn't does not have memory backing it. + /// It will be created with TextureFlags::TilerMemoryless. + POOL_MEMORYLESS = 65533, + /// Deprecated. /// /// Do NOT use this flag directly. It made sense in Ogre 2.1 diff --git a/OgreMain/include/OgreRenderPassDescriptor.h b/OgreMain/include/OgreRenderPassDescriptor.h index 85197166869..f48fada81ce 100644 --- a/OgreMain/include/OgreRenderPassDescriptor.h +++ b/OgreMain/include/OgreRenderPassDescriptor.h @@ -204,6 +204,10 @@ namespace Ogre protected: void checkRequiresTextureFlipping(); + void validateMemorylessTexture( const TextureGpu *texture, + const LoadAction::LoadAction loadAction, + const StoreAction::StoreAction storeAction, + const bool bIsDepthStencil ); virtual void colourEntriesModified(); public: diff --git a/OgreMain/include/OgreTextureGpu.h b/OgreMain/include/OgreTextureGpu.h index b64fd297e47..ddf4e35f0e4 100644 --- a/OgreMain/include/OgreTextureGpu.h +++ b/OgreMain/include/OgreTextureGpu.h @@ -169,15 +169,19 @@ namespace Ogre /// If this flag is present, either RenderToTexture or Uav must be present DiscardableContent = 1u << 14u, /// When this flag is present, we can save VRAM by using memoryless storage mode (Metal on - /// iOS and Apple Silicon macOS). Choose the memoryless mode if your texture is a memoryless - /// render target that’s temporarily populated and accessed by the GPU. Memoryless render - /// targets are render targets that exist only in tile memory and are not backed by system - /// memory. An example is a depth or stencil texture thatʼs used only within a render pass - /// and isnʼt needed before or after GPU execution. This flag requires RenderToTexture + /// iOS and Apple Silicon macOS) aka TRANSIENT memory (Vulkan). + /// + /// With this flag set, the texture will not be backed by memory, it will only ever live in + /// cache. Only TBDR GPUs support this. It will be ignored if unsupported. + /// + /// Many operations are unsupported with TilerMemoryless textures (e.g. copy operations) + /// because there is no memory behind them. + /// + /// An example is a depth or stencil texture thatʼs used only within a render pass + /// and isnʼt needed before or after GPU execution. + /// + /// This flag requires RenderToTexture. TilerMemoryless = 1u << 15u, - /// When this flag is present together with RenderToTexture it will use DepthBuffer with - /// TilerMemoryless option - TilerDepthMemoryless = 1u << 16u // clang-format on }; } @@ -660,10 +664,6 @@ namespace Ogre bool isPoolOwner() const; bool isDiscardableContent() const; bool isTilerMemoryless() const { return ( mTextureFlags & TextureFlags::TilerMemoryless ) != 0; } - bool isTilerDepthMemoryless() const - { - return ( mTextureFlags & TextureFlags::TilerDepthMemoryless ) != 0; - } /// OpenGL RenderWindows are a bit specific: /// * Their origins are upside down. Which means we need to flip Y. diff --git a/OgreMain/include/OgreWindow.h b/OgreMain/include/OgreWindow.h index 86e9d5c3904..d898db90472 100644 --- a/OgreMain/include/OgreWindow.h +++ b/OgreMain/include/OgreWindow.h @@ -81,6 +81,8 @@ namespace Ogre void setFinalResolution( uint32 widthPx, uint32 heightPx ); + static bool requestedMemoryless( const NameValuePairList *ogre_nullable miscParams ); + public: Window( const String &title, uint32 widthPt, uint32 heightPt, bool fullscreenMode ); virtual ~Window(); @@ -288,7 +290,8 @@ namespace Ogre void _setPrimary(); bool isPrimary() const; - virtual void _initialize( TextureGpuManager *textureGpuManager ) = 0; + virtual void _initialize( TextureGpuManager *textureGpuManager, + const NameValuePairList *ogre_nullable miscParams ) = 0; /// Overloaded version of getMetrics from RenderTarget, including extra details /// specific to windowing systems. Result is in pixels. diff --git a/OgreMain/src/OgreAsyncTextureTicket.cpp b/OgreMain/src/OgreAsyncTextureTicket.cpp index e3bd8c95293..2dde44e948b 100644 --- a/OgreMain/src/OgreAsyncTextureTicket.cpp +++ b/OgreMain/src/OgreAsyncTextureTicket.cpp @@ -87,6 +87,8 @@ namespace Ogre assert( ( !textureSrc->isMultisample() || !textureSrc->hasMsaaExplicitResolves() || textureSrc->isOpenGLRenderWindow() ) && "Cannot download from an explicitly resolved MSAA texture!" ); + OGRE_ASSERT_LOW( !textureSrc->isTilerMemoryless() && + "Cannot download from a memoryless texture!" ); } //----------------------------------------------------------------------------------- void AsyncTextureTicket::notifyTextureChanged( TextureGpu *texture, diff --git a/OgreMain/src/OgreRenderPassDescriptor.cpp b/OgreMain/src/OgreRenderPassDescriptor.cpp index 6e7b49cbc90..c8e36e78549 100644 --- a/OgreMain/src/OgreRenderPassDescriptor.cpp +++ b/OgreMain/src/OgreRenderPassDescriptor.cpp @@ -163,6 +163,47 @@ namespace Ogre mRequiresTextureFlipping = mColour[0].resolveTexture->requiresTextureFlipping(); } //----------------------------------------------------------------------------------- + void RenderPassDescriptor::validateMemorylessTexture( const TextureGpu *texture, + const LoadAction::LoadAction loadAction, + const StoreAction::StoreAction storeAction, + const bool bIsDepthStencil ) + { + if( !texture->isTilerMemoryless() ) + return; + + if( loadAction != LoadAction::Clear && loadAction != LoadAction::DontCare && + loadAction != LoadAction::ClearOnTilers ) + { + OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, + "Texture '" + texture->getNameStr() + + "' is TilerMemoryless. For load actions it can only use clear, " + "dont_care or clear_on_tilers.", + "RenderPassDescriptor::validateMemorylessTexture" ); + } + + if( !texture->isMultisample() || bIsDepthStencil ) + { + if( storeAction != StoreAction::DontCare ) + { + OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, + "Texture '" + texture->getNameStr() + + "' is TilerMemoryless. For store actions it can only use dont_care.", + "RenderPassDescriptor::validateMemorylessTexture" ); + } + } + else + { + if( storeAction != StoreAction::DontCare && storeAction != StoreAction::MultisampleResolve ) + { + OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, + "MSAA Texture '" + texture->getNameStr() + + "' is TilerMemoryless. For store actions it can only use dont_care " + "or resolve.", + "RenderPassDescriptor::validateMemorylessTexture" ); + } + } + } + //----------------------------------------------------------------------------------- void RenderPassDescriptor::colourEntriesModified() { mNumColourEntries = 0; @@ -176,6 +217,9 @@ namespace Ogre { const RenderPassColourTarget &colourEntry = mColour[mNumColourEntries]; + validateMemorylessTexture( colourEntry.texture, colourEntry.loadAction, + colourEntry.storeAction, false ); + if( colourEntry.texture->isRenderWindowSpecific() ) { RenderPassColourTarget &colourEntryRW = mColour[mNumColourEntries]; @@ -208,6 +252,14 @@ namespace Ogre "RenderPassDescriptor::colourEntriesModified" ); } + if( colourEntry.resolveTexture->isTilerMemoryless() ) + { + OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, + "Resolving to Texture '" + colourEntry.resolveTexture->getNameStr() + + "' which is memoryless!", + "RenderPassDescriptor::colourEntriesModified" ); + } + if( colourEntry.texture != colourEntry.resolveTexture && !colourEntry.texture->hasMsaaExplicitResolves() ) { @@ -305,6 +357,8 @@ namespace Ogre "RenderPassDescriptor::entriesModified" ); } } + + validateMemorylessTexture( mDepth.texture, mDepth.loadAction, mDepth.storeAction, true ); } if( mStencil.texture && mStencil.texture != mDepth.texture ) @@ -323,6 +377,9 @@ namespace Ogre "RenderPassDescriptor::entriesModified" ); } } + + validateMemorylessTexture( mStencil.texture, mStencil.loadAction, mStencil.storeAction, + true ); } checkRequiresTextureFlipping(); diff --git a/OgreMain/src/OgreRenderSystem.cpp b/OgreMain/src/OgreRenderSystem.cpp index 9c186e9e497..cd43a7c885d 100644 --- a/OgreMain/src/OgreRenderSystem.cpp +++ b/OgreMain/src/OgreRenderSystem.cpp @@ -675,7 +675,7 @@ namespace Ogre if( !preferDepthTexture ) textureFlags |= TextureFlags::NotTexture | TextureFlags::DiscardableContent; - if( colourTexture->isTilerMemoryless() || colourTexture->isTilerDepthMemoryless() ) + if( colourTexture->getDepthBufferPoolId() == DepthBuffer::POOL_MEMORYLESS ) textureFlags |= TextureFlags::TilerMemoryless; char tmpBuffer[64]; diff --git a/OgreMain/src/OgreStagingTexture.cpp b/OgreMain/src/OgreStagingTexture.cpp index bad83d27128..5f5926a53ea 100644 --- a/OgreMain/src/OgreStagingTexture.cpp +++ b/OgreMain/src/OgreStagingTexture.cpp @@ -135,6 +135,14 @@ namespace Ogre "Did you modify it? Did it get corrupted?" ); assert( ( !cpuSrcBox || srcBox.equalSize( *cpuSrcBox ) ) && "Src & cpuSrcBox must be equal" ); + if( dstTexture->isTilerMemoryless() ) + { + OGRE_EXCEPT( + Exception::ERR_INVALIDPARAMS, + "Cannot upload to texture '" + dstTexture->getNameStr() + "' because it's memoryless.", + "StagingTexture::upload" ); + } + if( dstTexture->isMultisample() ) { OGRE_EXCEPT( diff --git a/OgreMain/src/OgreTextureGpu.cpp b/OgreMain/src/OgreTextureGpu.cpp index 71e232ae2ad..aa2a5ed9ed8 100644 --- a/OgreMain/src/OgreTextureGpu.cpp +++ b/OgreMain/src/OgreTextureGpu.cpp @@ -30,6 +30,7 @@ THE SOFTWARE. #include "OgreTextureGpu.h" +#include "OgreDepthBuffer.h" #include "OgreException.h" #include "OgreLogManager.h" #include "OgreLwString.h" @@ -668,6 +669,8 @@ namespace Ogre assert( this != dst || !srcBox.overlaps( dstBox ) ); assert( srcMipLevel < this->getNumMipmaps() && dstMipLevel < dst->getNumMipmaps() ); OGRE_ASSERT_LOW( ( this->getOrientationMode() & 0x01 ) == ( dst->getOrientationMode() & 0x01 ) ); + OGRE_ASSERT_LOW( !this->isTilerMemoryless() ); + OGRE_ASSERT_LOW( !dst->isTilerMemoryless() ); } //----------------------------------------------------------------------------------- void TextureGpu::_setDepthBufferDefaults( uint16 depthBufferPoolId, bool preferDepthTexture, @@ -913,7 +916,7 @@ namespace Ogre this->getInternalHeight() == colourTarget->getInternalHeight() && this->getSampleDescription() == colourTarget->getSampleDescription() && this->isTilerMemoryless() == - ( colourTarget->isTilerMemoryless() || colourTarget->isTilerDepthMemoryless() ) && + ( colourTarget->getDepthBufferPoolId() == DepthBuffer::POOL_MEMORYLESS ) && this->isRenderWindowSpecific() == colourTarget->isRenderWindowSpecific() ) { return true; diff --git a/OgreMain/src/OgreWindow.cpp b/OgreMain/src/OgreWindow.cpp index 4b957085a41..ecb0c36f14c 100644 --- a/OgreMain/src/OgreWindow.cpp +++ b/OgreMain/src/OgreWindow.cpp @@ -31,6 +31,7 @@ THE SOFTWARE. #include "OgreWindow.h" #include "OgreException.h" +#include "OgreStringConverter.h" namespace Ogre { @@ -71,6 +72,20 @@ namespace Ogre if( mStencilBuffer ) mStencilBuffer->setResolution( widthPx, heightPx, 1u ); } + //------------------------------------------------------------------------- + bool Window::requestedMemoryless( const NameValuePairList *ogre_nullable miscParams ) + { + if( !miscParams ) + return false; + + NameValuePairList::const_iterator opt; + NameValuePairList::const_iterator end = miscParams->end(); + + opt = miscParams->find( "memoryless_depth_buffer" ); + if( opt != end ) + return StringConverter::parseBool( opt->second ); + return false; + } //----------------------------------------------------------------------------------- void Window::setTitle( const String &title ) { mTitle = title; } //----------------------------------------------------------------------------------- diff --git a/RenderSystems/Direct3D11/include/OgreD3D11Window.h b/RenderSystems/Direct3D11/include/OgreD3D11Window.h index ca9555c829a..0bf5dd1b147 100644 --- a/RenderSystems/Direct3D11/include/OgreD3D11Window.h +++ b/RenderSystems/Direct3D11/include/OgreD3D11Window.h @@ -123,7 +123,8 @@ namespace Ogre D3D11RenderSystem *renderSystem ); ~D3D11WindowSwapChainBased() override; - void _initialize( TextureGpuManager *textureGpuManager ) override; + void _initialize( TextureGpuManager *textureGpuManager, + const NameValuePairList *ogre_nullable miscParams ) override; void destroy() override; /// @copydoc Window::setFsaa diff --git a/RenderSystems/Direct3D11/include/Windowing/WIN32/OgreD3D11WindowHwnd.h b/RenderSystems/Direct3D11/include/Windowing/WIN32/OgreD3D11WindowHwnd.h index b32edfa9cfe..75f65c0355e 100644 --- a/RenderSystems/Direct3D11/include/Windowing/WIN32/OgreD3D11WindowHwnd.h +++ b/RenderSystems/Direct3D11/include/Windowing/WIN32/OgreD3D11WindowHwnd.h @@ -73,7 +73,8 @@ namespace Ogre D3D11Device &device, D3D11RenderSystem *renderSystem ); ~D3D11WindowHwnd() override; - void _initialize( TextureGpuManager *textureGpuManager ) override; + void _initialize( TextureGpuManager *textureGpuManager, + const NameValuePairList *ogre_nullable miscParams ) override; void destroy() override; void reposition( int32 left, int32 top ) override; diff --git a/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp b/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp index 26805ad7d36..3e09ca05ec3 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp @@ -1029,7 +1029,7 @@ namespace Ogre mSecondaryWindows.push_back( win ); } - win->_initialize( mTextureGpuManager ); + win->_initialize( mTextureGpuManager, miscParams ); return win; } diff --git a/RenderSystems/Direct3D11/src/OgreD3D11Window.cpp b/RenderSystems/Direct3D11/src/OgreD3D11Window.cpp index e3576aa0739..64d4ced0f9b 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11Window.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11Window.cpp @@ -171,7 +171,8 @@ namespace Ogre return mUseFlipMode ? 2 : mRenderSystem->getVaoManager()->getDynamicBufferMultiplier() - 1u; } //----------------------------------------------------------------------------------- - void D3D11WindowSwapChainBased::_initialize( TextureGpuManager *textureGpuManager ) + void D3D11WindowSwapChainBased::_initialize( TextureGpuManager *textureGpuManager, + const NameValuePairList * ) { _createSwapChain(); diff --git a/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowHwnd.cpp b/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowHwnd.cpp index bdc7289d993..647bb48781b 100644 --- a/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowHwnd.cpp +++ b/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowHwnd.cpp @@ -470,9 +470,10 @@ namespace Ogre setHidden( mHidden ); } //----------------------------------------------------------------------------------- - void D3D11WindowHwnd::_initialize( TextureGpuManager *textureGpuManager ) + void D3D11WindowHwnd::_initialize( TextureGpuManager *textureGpuManager, + const NameValuePairList *miscParams ) { - D3D11WindowSwapChainBased::_initialize( textureGpuManager ); + D3D11WindowSwapChainBased::_initialize( textureGpuManager, miscParams ); IDXGIFactory1 *dxgiFactory1 = mDevice.GetDXGIFactory(); dxgiFactory1->MakeWindowAssociation( mHwnd, diff --git a/RenderSystems/GL3Plus/include/windowing/GLX/OgreGLXWindow.h b/RenderSystems/GL3Plus/include/windowing/GLX/OgreGLXWindow.h index a2cdd7c6334..1e949964c39 100644 --- a/RenderSystems/GL3Plus/include/windowing/GLX/OgreGLXWindow.h +++ b/RenderSystems/GL3Plus/include/windowing/GLX/OgreGLXWindow.h @@ -36,6 +36,8 @@ THE SOFTWARE. namespace Ogre { + OGRE_ASSUME_NONNULL_BEGIN + class _OgrePrivate GLXWindow final : public Window { protected: @@ -60,7 +62,8 @@ namespace Ogre GLXGLSupport *glsupport ); ~GLXWindow() override; - void _initialize( TextureGpuManager *textureManager ) override; + void _initialize( TextureGpuManager *textureManager, + const NameValuePairList *ogre_nullable miscParams ) override; void setVSync( bool vSync, uint32 vSyncInterval ) override; void reposition( int32 left, int32 top ) override; @@ -108,6 +111,8 @@ namespace Ogre bool requiresTextureFlipping() const { return false; } }; + + OGRE_ASSUME_NONNULL_END } // namespace Ogre #endif diff --git a/RenderSystems/GL3Plus/include/windowing/win32/OgreWin32Window.h b/RenderSystems/GL3Plus/include/windowing/win32/OgreWin32Window.h index a773850c40a..32e3caac2bb 100644 --- a/RenderSystems/GL3Plus/include/windowing/win32/OgreWin32Window.h +++ b/RenderSystems/GL3Plus/include/windowing/win32/OgreWin32Window.h @@ -73,7 +73,8 @@ namespace Ogre Win32GLSupport &glsupport ); virtual ~Win32Window(); - virtual void _initialize( TextureGpuManager *textureGpuManager ); + virtual void _initialize( TextureGpuManager *textureGpuManager, + const NameValuePairList *ogre_nullable miscParams ); virtual void destroy(); virtual void reposition( int32 left, int32 top ); diff --git a/RenderSystems/GL3Plus/src/OgreGL3PlusRenderSystem.cpp b/RenderSystems/GL3Plus/src/OgreGL3PlusRenderSystem.cpp index d0bb3158dde..10f69da3eec 100644 --- a/RenderSystems/GL3Plus/src/OgreGL3PlusRenderSystem.cpp +++ b/RenderSystems/GL3Plus/src/OgreGL3PlusRenderSystem.cpp @@ -889,7 +889,7 @@ namespace Ogre mTextureGpuManager->_update( true ); } - win->_initialize( mTextureGpuManager ); + win->_initialize( mTextureGpuManager, miscParams ); return win; } diff --git a/RenderSystems/GL3Plus/src/windowing/GLX/OgreGLXWindow.cpp b/RenderSystems/GL3Plus/src/windowing/GLX/OgreGLXWindow.cpp index d574f370d90..ebf9ce92aeb 100644 --- a/RenderSystems/GL3Plus/src/windowing/GLX/OgreGLXWindow.cpp +++ b/RenderSystems/GL3Plus/src/windowing/GLX/OgreGLXWindow.cpp @@ -541,7 +541,7 @@ namespace Ogre mClosed = false; } //----------------------------------------------------------------------------------- - void GLXWindow::_initialize( TextureGpuManager *_textureManager ) + void GLXWindow::_initialize( TextureGpuManager *_textureManager, const NameValuePairList * ) { GL3PlusTextureGpuManager *textureManager = static_cast( _textureManager ); diff --git a/RenderSystems/GL3Plus/src/windowing/win32/OgreWin32Window.cpp b/RenderSystems/GL3Plus/src/windowing/win32/OgreWin32Window.cpp index 7f17e91e428..50b79adef02 100644 --- a/RenderSystems/GL3Plus/src/windowing/win32/OgreWin32Window.cpp +++ b/RenderSystems/GL3Plus/src/windowing/win32/OgreWin32Window.cpp @@ -642,7 +642,7 @@ namespace Ogre mFullscreenMode = mRequestedFullscreenMode; } //----------------------------------------------------------------------------------- - void Win32Window::_initialize( TextureGpuManager *textureGpuManager ) + void Win32Window::_initialize( TextureGpuManager *textureGpuManager, const NameValuePairList * ) { GL3PlusTextureGpuManager *textureManager = static_cast( textureGpuManager ); diff --git a/RenderSystems/Metal/include/OgreMetalTextureGpuManager.h b/RenderSystems/Metal/include/OgreMetalTextureGpuManager.h index 39e183ea00e..f14ba860c5a 100644 --- a/RenderSystems/Metal/include/OgreMetalTextureGpuManager.h +++ b/RenderSystems/Metal/include/OgreMetalTextureGpuManager.h @@ -75,7 +75,7 @@ namespace Ogre If caller doesn't delete it, it will leak. */ TextureGpu *createTextureGpuWindow( MetalWindow *window ); - TextureGpu *createWindowDepthBuffer(); + TextureGpu *createWindowDepthBuffer( const bool bMemoryLess ); id getBlankTextureMetalName( TextureTypes::TextureTypes textureType ) const; diff --git a/RenderSystems/Metal/include/OgreMetalWindow.h b/RenderSystems/Metal/include/OgreMetalWindow.h index d0a42e26fad..b31bd355c7c 100644 --- a/RenderSystems/Metal/include/OgreMetalWindow.h +++ b/RenderSystems/Metal/include/OgreMetalWindow.h @@ -78,7 +78,8 @@ namespace Ogre virtual void create( bool fullScreen, const NameValuePairList *miscParams ); void destroy() override; - void _initialize( TextureGpuManager *textureGpuManager ) override; + void _initialize( TextureGpuManager *textureGpuManager, + const NameValuePairList *miscParams ) override; void reposition( int32 left, int32 top ) override; void requestResolution( uint32 width, uint32 height ) override; diff --git a/RenderSystems/Metal/src/OgreMetalRenderSystem.mm b/RenderSystems/Metal/src/OgreMetalRenderSystem.mm index 65df397c37b..9f408420664 100644 --- a/RenderSystems/Metal/src/OgreMetalRenderSystem.mm +++ b/RenderSystems/Metal/src/OgreMetalRenderSystem.mm @@ -614,7 +614,7 @@ of this software and associated documentation files (the "Software"), to deal Window *win = OGRE_NEW MetalWindow( name, width, height, fullScreen, miscParams, &mDevice ); mWindows.insert( win ); - win->_initialize( mTextureGpuManager ); + win->_initialize( mTextureGpuManager, miscParams ); return win; } //------------------------------------------------------------------------- diff --git a/RenderSystems/Metal/src/OgreMetalTextureGpu.mm b/RenderSystems/Metal/src/OgreMetalTextureGpu.mm index 07a8b5acb83..ddd4839186d 100644 --- a/RenderSystems/Metal/src/OgreMetalTextureGpu.mm +++ b/RenderSystems/Metal/src/OgreMetalTextureGpu.mm @@ -32,6 +32,7 @@ of this software and associated documentation files (the "Software"), to deal #include "OgreMetalDevice.h" #include "OgreMetalMappings.h" #include "OgreMetalTextureGpuManager.h" +#include "OgreRenderSystem.h" #include "OgreStringConverter.h" #include "OgreTextureBox.h" #include "OgreTextureGpuListener.h" @@ -39,7 +40,6 @@ of this software and associated documentation files (the "Software"), to deal #include "Vao/OgreVaoManager.h" #import "Metal/MTLBlitCommandEncoder.h" -#include "OgreRoot.h" namespace Ogre { @@ -55,10 +55,7 @@ of this software and associated documentation files (the "Software"), to deal _setToDisplayDummyTexture(); } //----------------------------------------------------------------------------------- - MetalTextureGpu::~MetalTextureGpu() - { - destroyInternalResourcesImpl(); - } + MetalTextureGpu::~MetalTextureGpu() { destroyInternalResourcesImpl(); } //----------------------------------------------------------------------------------- void MetalTextureGpu::createInternalResourcesImpl() { @@ -83,27 +80,13 @@ of this software and associated documentation files (the "Software"), to deal if( mTextureType == TextureTypes::TypeCube || mTextureType == TextureTypes::TypeCubeArray ) desc.arrayLength /= 6u; - RenderSystem *rs = Root::getSingleton().getRenderSystem(); - const RenderSystemCapabilities *capabilities = rs->getCapabilities(); - bool isTiler = capabilities->hasCapability( RSC_IS_TILER ); - if( isTiler && isRenderWindowSpecific() && isRenderToTexture() ) - { - ConfigOptionMap &options = rs->getConfigOptions(); - Ogre::ConfigOptionMap::iterator opt = options.find( "WindowMemoryless" ); - if( opt != options.end() ) - isTiler = opt->second.currentValue == "Yes"; - } - if( isTiler ) + const RenderSystemCapabilities *capabilities = + mTextureManager->getRenderSystem()->getCapabilities(); + const bool isTiler = capabilities->hasCapability( RSC_IS_TILER ); + if( isTiler && isTilerMemoryless() ) { if( @available( iOS 10, macOS 11, * ) ) - { - if( ( isTilerMemoryless() && isRenderToTexture() ) || - ( isMultisample() && hasMsaaExplicitResolves() && !isTexture() && - isRenderToTexture() && isDiscardableContent() ) ) - { - desc.storageMode = MTLStorageModeMemoryless; - } - } + desc.storageMode = MTLStorageModeMemoryless; } if( isMultisample() && hasMsaaExplicitResolves() ) { @@ -140,14 +123,10 @@ of this software and associated documentation files (the "Software"), to deal { if( isTiler ) { + // mMsaaFramebufferName is always Memoryless because the user *NEVER* has access to it + // and we always auto-resolve in the same pass, thus MSAA contents are always transient. if( @available( iOS 10, macOS 11, * ) ) - { - if( ( ( isTilerMemoryless() || isTilerDepthMemoryless() ) && isRenderToTexture() ) || - ( !isTexture() && isRenderToTexture() && isDiscardableContent() ) ) - { - desc.storageMode = MTLStorageModeMemoryless; - } - } + desc.storageMode = MTLStorageModeMemoryless; } desc.textureType = MTLTextureType2DMultisample; desc.depth = 1u; @@ -486,15 +465,9 @@ of this software and associated documentation files (the "Software"), to deal mDesiredDepthBufferFormat = desiredDepthBufferFormat; } //----------------------------------------------------------------------------------- - uint16 MetalTextureGpuRenderTarget::getDepthBufferPoolId() const - { - return mDepthBufferPoolId; - } + uint16 MetalTextureGpuRenderTarget::getDepthBufferPoolId() const { return mDepthBufferPoolId; } //----------------------------------------------------------------------------------- - bool MetalTextureGpuRenderTarget::getPreferDepthTexture() const - { - return mPreferDepthTexture; - } + bool MetalTextureGpuRenderTarget::getPreferDepthTexture() const { return mPreferDepthTexture; } //----------------------------------------------------------------------------------- PixelFormatGpu MetalTextureGpuRenderTarget::getDesiredDepthBufferFormat() const { @@ -509,9 +482,6 @@ of this software and associated documentation files (the "Software"), to deal } //----------------------------------------------------------------------------------- #if OGRE_NO_VIEWPORT_ORIENTATIONMODE == 0 - OrientationMode MetalTextureGpuRenderTarget::getOrientationMode() const - { - return mOrientationMode; - } + OrientationMode MetalTextureGpuRenderTarget::getOrientationMode() const { return mOrientationMode; } #endif } // namespace Ogre diff --git a/RenderSystems/Metal/src/OgreMetalTextureGpuManager.mm b/RenderSystems/Metal/src/OgreMetalTextureGpuManager.mm index 3a4f09412f6..92d549c0b9e 100644 --- a/RenderSystems/Metal/src/OgreMetalTextureGpuManager.mm +++ b/RenderSystems/Metal/src/OgreMetalTextureGpuManager.mm @@ -156,13 +156,12 @@ of this software and associated documentation files (the "Software"), to deal const bool isTiler = capabilities->hasCapability( RSC_IS_TILER ); return OGRE_NEW MetalTextureGpuWindow( GpuPageOutStrategy::Discard, mVaoManager, "RenderWindow", TextureFlags::NotTexture | TextureFlags::RenderToTexture | - ( isTiler ? TextureFlags::TilerDepthMemoryless : 0 ) | TextureFlags::RenderWindowSpecific | TextureFlags::DiscardableContent, TextureTypes::Type2D, this, window ); } //----------------------------------------------------------------------------------- - TextureGpu *MetalTextureGpuManager::createWindowDepthBuffer() + TextureGpu *MetalTextureGpuManager::createWindowDepthBuffer( const bool bMemoryLess ) { const RenderSystemCapabilities *capabilities = Root::getSingleton().getRenderSystem()->getCapabilities(); @@ -170,8 +169,8 @@ of this software and associated documentation files (the "Software"), to deal return OGRE_NEW MetalTextureGpuRenderTarget( GpuPageOutStrategy::Discard, mVaoManager, "RenderWindow DepthBuffer", TextureFlags::NotTexture | TextureFlags::RenderToTexture | - ( isTiler ? TextureFlags::TilerMemoryless : 0 ) | TextureFlags::RenderWindowSpecific | - TextureFlags::DiscardableContent, + ( bMemoryLess ? TextureFlags::TilerMemoryless : 0 ) | + TextureFlags::RenderWindowSpecific | TextureFlags::DiscardableContent, TextureTypes::Type2D, this ); } //----------------------------------------------------------------------------------- diff --git a/RenderSystems/Metal/src/OgreMetalWindow.mm b/RenderSystems/Metal/src/OgreMetalWindow.mm index 33ab6ebff1a..4d926b9f6d3 100644 --- a/RenderSystems/Metal/src/OgreMetalWindow.mm +++ b/RenderSystems/Metal/src/OgreMetalWindow.mm @@ -496,14 +496,18 @@ static void SetupMetalWindowListeners( Ogre::MetalWindow *metalWindow, NSWindow mMetalView = 0; } //----------------------------------------------------------------------------------- - void MetalWindow::_initialize( TextureGpuManager *textureGpuManager ) + void MetalWindow::_initialize( TextureGpuManager *textureGpuManager, + const NameValuePairList *miscParams ) { MetalTextureGpuManager *textureManager = static_cast( textureGpuManager ); mTexture = textureManager->createTextureGpuWindow( this ); if( DepthBuffer::DefaultDepthBufferFormat != PFG_NULL ) - mDepthBuffer = textureManager->createWindowDepthBuffer(); + { + const bool bMemoryLess = requestedMemoryless( miscParams ); + mDepthBuffer = textureManager->createWindowDepthBuffer( bMemoryLess ); + } mTexture->setPixelFormat( mHwGamma ? PFG_BGRA8_UNORM_SRGB : PFG_BGRA8_UNORM ); if( mDepthBuffer ) @@ -516,8 +520,10 @@ static void SetupMetalWindowListeners( Ogre::MetalWindow *metalWindow, NSWindow if( mDepthBuffer ) { - mTexture->_setDepthBufferDefaults( DepthBuffer::NO_POOL_EXPLICIT_RTV, false, - mDepthBuffer->getPixelFormat() ); + mTexture->_setDepthBufferDefaults( mDepthBuffer->isTilerMemoryless() + ? DepthBuffer::POOL_MEMORYLESS + : DepthBuffer::NO_POOL_EXPLICIT_RTV, + false, mDepthBuffer->getPixelFormat() ); } else { diff --git a/RenderSystems/NULL/include/OgreNULLWindow.h b/RenderSystems/NULL/include/OgreNULLWindow.h index 75758229942..82a2f58a86d 100644 --- a/RenderSystems/NULL/include/OgreNULLWindow.h +++ b/RenderSystems/NULL/include/OgreNULLWindow.h @@ -34,6 +34,8 @@ THE SOFTWARE. namespace Ogre { + OGRE_ASSUME_NONNULL_BEGIN + class NULLWindow : public Window { bool mClosed; @@ -55,9 +57,12 @@ namespace Ogre bool isVisible() const override; void setHidden( bool hidden ) override; bool isHidden() const override; - void _initialize( TextureGpuManager *textureGpuManager ) override; + void _initialize( TextureGpuManager *textureGpuManager, + const NameValuePairList *ogre_nullable miscParams ) override; void swapBuffers() override; }; + + OGRE_ASSUME_NONNULL_END } // namespace Ogre #endif diff --git a/RenderSystems/NULL/src/OgreNULLRenderSystem.cpp b/RenderSystems/NULL/src/OgreNULLRenderSystem.cpp index 3b46c4a78ab..75f6b4dc341 100644 --- a/RenderSystems/NULL/src/OgreNULLRenderSystem.cpp +++ b/RenderSystems/NULL/src/OgreNULLRenderSystem.cpp @@ -147,7 +147,7 @@ namespace Ogre mInitialized = true; } - win->_initialize( mTextureGpuManager ); + win->_initialize( mTextureGpuManager, miscParams ); return win; } diff --git a/RenderSystems/NULL/src/OgreNULLWindow.cpp b/RenderSystems/NULL/src/OgreNULLWindow.cpp index 1791ccd8eb4..ae05f991f88 100644 --- a/RenderSystems/NULL/src/OgreNULLWindow.cpp +++ b/RenderSystems/NULL/src/OgreNULLWindow.cpp @@ -85,7 +85,7 @@ namespace Ogre //------------------------------------------------------------------------- bool NULLWindow::isHidden() const { return false; } //------------------------------------------------------------------------- - void NULLWindow::_initialize( TextureGpuManager *textureGpuManager ) + void NULLWindow::_initialize( TextureGpuManager *textureGpuManager, const NameValuePairList * ) { destroy(); diff --git a/RenderSystems/Vulkan/include/OgreVulkanTextureGpuManager.h b/RenderSystems/Vulkan/include/OgreVulkanTextureGpuManager.h index e3619108188..574d8af6e04 100644 --- a/RenderSystems/Vulkan/include/OgreVulkanTextureGpuManager.h +++ b/RenderSystems/Vulkan/include/OgreVulkanTextureGpuManager.h @@ -99,7 +99,7 @@ namespace Ogre TextureGpu *createTextureGpuWindow( VulkanWindowSwapChainBased *window ); TextureGpu *createTextureGpuNullWindow(); - TextureGpu *createWindowDepthBuffer(); + TextureGpu *createWindowDepthBuffer( const bool bMemoryLess ); VkImage getBlankTextureVulkanName( TextureTypes::TextureTypes textureType ) const; VkImageView getBlankTextureView( TextureTypes::TextureTypes textureType ) const; diff --git a/RenderSystems/Vulkan/include/OgreVulkanWindow.h b/RenderSystems/Vulkan/include/OgreVulkanWindow.h index fe2b80d88e4..00fb2bdb4a5 100644 --- a/RenderSystems/Vulkan/include/OgreVulkanWindow.h +++ b/RenderSystems/Vulkan/include/OgreVulkanWindow.h @@ -47,9 +47,6 @@ namespace Ogre VulkanWindow( const String &title, uint32 width, uint32 height, bool fullscreenMode ); void _setDevice( VulkanDevice *device ); - void _initialize( TextureGpuManager *textureGpuManager ) override; - virtual void _initialize( TextureGpuManager *textureGpuManager, - const NameValuePairList *ogre_nullable miscParams ) = 0; }; class VulkanWindowNull : public VulkanWindow diff --git a/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp b/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp index 3556f5fae9f..fa80138fafe 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp @@ -34,13 +34,12 @@ THE SOFTWARE. #include "OgrePixelFormatGpuUtils.h" #include "OgreException.h" +#include "OgreRenderSystem.h" #include "OgreTextureBox.h" #include "OgreVector2.h" #include "OgreVulkanMappings.h" #include "OgreVulkanTextureGpuManager.h" #include "OgreVulkanUtils.h" -#include "OgreRoot.h" -#include "OgreRenderSystem.h" #define TODO_add_resource_transitions @@ -64,7 +63,10 @@ namespace Ogre _setToDisplayDummyTexture(); } //----------------------------------------------------------------------------------- - VulkanTextureGpu::~VulkanTextureGpu() { destroyInternalResourcesImpl(); } + VulkanTextureGpu::~VulkanTextureGpu() + { + destroyInternalResourcesImpl(); + } //----------------------------------------------------------------------------------- PixelFormatGpu VulkanTextureGpu::getWorkaroundedPixelFormat( const PixelFormatGpu pixelFormat ) const { @@ -146,23 +148,15 @@ namespace Ogre if( isUav() ) imageInfo.usage |= VK_IMAGE_USAGE_STORAGE_BIT; - RenderSystem* rs = Root::getSingleton().getRenderSystem(); - const RenderSystemCapabilities *capabilities = rs->getCapabilities(); - bool isTiler = capabilities->hasCapability( RSC_IS_TILER ); - if(isTiler && isRenderWindowSpecific() && isRenderToTexture()) - { - ConfigOptionMap& options = rs->getConfigOptions(); - Ogre::ConfigOptionMap::iterator opt = options.find("WindowMemoryless"); - if(opt!=options.end()) - isTiler = opt->second.currentValue=="Yes"; - } - if(isTiler && !isUav() && !isPoolOwner() && isRenderToTexture()) + const RenderSystemCapabilities *capabilities = + mTextureManager->getRenderSystem()->getCapabilities(); + const bool isTiler = capabilities->hasCapability( RSC_IS_TILER ); + if( isTiler && isTilerMemoryless() ) { - if( isTilerMemoryless() || (isMultisample() && hasMsaaExplicitResolves() && !isTexture() && isDiscardableContent()) ) - { - imageInfo.usage |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; - imageInfo.usage &= (VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); - } + imageInfo.usage |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; + imageInfo.usage &= + ( VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT ); } String textureName = getNameStr(); @@ -1000,23 +994,17 @@ namespace Ogre ? VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT : VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; - RenderSystem* rs = Root::getSingleton().getRenderSystem(); - const RenderSystemCapabilities *capabilities = rs->getCapabilities(); - bool isTiler = capabilities->hasCapability( RSC_IS_TILER ); - if(isTiler && isRenderWindowSpecific() && isRenderToTexture()) - { - ConfigOptionMap& options = rs->getConfigOptions(); - Ogre::ConfigOptionMap::iterator opt = options.find("WindowMemoryless"); - if(opt!=options.end()) - isTiler = opt->second.currentValue=="Yes"; - } - if(isTiler && isRenderToTexture()) + const RenderSystemCapabilities *capabilities = + mTextureManager->getRenderSystem()->getCapabilities(); + const bool isTiler = capabilities->hasCapability( RSC_IS_TILER ); + if( isTiler ) { - if((isTilerMemoryless() || isTilerDepthMemoryless()) || (!isTexture() && isDiscardableContent()) ) - { - imageInfo.usage |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; - imageInfo.usage &= (VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); - } + // mMsaaFramebufferName is always Memoryless because the user *NEVER* has access to it + // and we always auto-resolve in the same pass, thus MSAA contents are always transient. + imageInfo.usage |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; + imageInfo.usage &= + ( VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT ); } String textureName = getNameStr() + "/MsaaImplicit"; diff --git a/RenderSystems/Vulkan/src/OgreVulkanTextureGpuManager.cpp b/RenderSystems/Vulkan/src/OgreVulkanTextureGpuManager.cpp index 58180a5b99d..61006825b89 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanTextureGpuManager.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanTextureGpuManager.cpp @@ -338,15 +338,17 @@ namespace Ogre TextureTypes::Type2D, this ); } //----------------------------------------------------------------------------------- - TextureGpu *VulkanTextureGpuManager::createWindowDepthBuffer() + TextureGpu *VulkanTextureGpuManager::createWindowDepthBuffer( const bool bMemoryLess ) { - return OGRE_NEW VulkanTextureGpuRenderTarget( GpuPageOutStrategy::Discard, mVaoManager, - "RenderWindow DepthBuffer", // - TextureFlags::NotTexture | // - TextureFlags::RenderToTexture | // - TextureFlags::RenderWindowSpecific | - TextureFlags::DiscardableContent, - TextureTypes::Type2D, this ); + return OGRE_NEW VulkanTextureGpuRenderTarget( + GpuPageOutStrategy::Discard, mVaoManager, + "RenderWindow DepthBuffer", // + TextureFlags::NotTexture | // + TextureFlags::RenderToTexture | // + TextureFlags::RenderWindowSpecific | // + TextureFlags::DiscardableContent | // + ( bMemoryLess ? TextureFlags::TilerMemoryless : 0 ), + TextureTypes::Type2D, this ); } //----------------------------------------------------------------------------------- TextureGpu *VulkanTextureGpuManager::createTextureImpl( diff --git a/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp b/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp index 3b1bceab498..e10dbbab5c4 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp @@ -63,13 +63,6 @@ namespace Ogre mDevice = device; } //------------------------------------------------------------------------- - void VulkanWindow::_initialize( TextureGpuManager *textureGpuManager ) - { - OGRE_EXCEPT( Exception::ERR_INVALID_CALL, - "Call _initialize( TextureGpuManager*, const NameValuePairList * ) instead", - "VulkanWindow::_initialize" ); - } - //------------------------------------------------------------------------- VulkanWindowNull::VulkanWindowNull( const String &title, uint32 width, uint32 height, bool fullscreenMode ) : VulkanWindow( title, width, height, fullscreenMode ) diff --git a/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidSupport.cpp b/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidSupport.cpp index 93b9960911c..624d5428c52 100644 --- a/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidSupport.cpp +++ b/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidSupport.cpp @@ -46,7 +46,6 @@ namespace Ogre ConfigOption optVSync; ConfigOption optVSyncInterval; ConfigOption optVSyncMethod; - ConfigOption optRTTMode; // Video mode possibilities optVideoMode.name = "Video Mode"; @@ -95,7 +94,6 @@ namespace Ogre mOptions[optVSync.name] = optVSync; mOptions[optVSyncInterval.name] = optVSyncInterval; mOptions[optVSyncMethod.name] = optVSyncMethod; - mOptions[optRTTMode.name] = optRTTMode; refreshConfig(); } diff --git a/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp b/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp index ca16434deca..cff0bacd65f 100644 --- a/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp +++ b/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp @@ -200,7 +200,10 @@ namespace Ogre static_cast( textureGpuManager ); mTexture = textureManager->createTextureGpuWindow( this ); if( DepthBuffer::DefaultDepthBufferFormat != PFG_NULL ) - mDepthBuffer = textureManager->createWindowDepthBuffer(); + { + const bool bMemoryLess = requestedMemoryless( miscParams ); + mDepthBuffer = textureManager->createWindowDepthBuffer( bMemoryLess ); + } mStencilBuffer = 0; setNativeWindow( nativeWindow ); @@ -429,8 +432,10 @@ namespace Ogre if( mDepthBuffer ) { - mTexture->_setDepthBufferDefaults( DepthBuffer::NO_POOL_EXPLICIT_RTV, false, - mDepthBuffer->getPixelFormat() ); + mTexture->_setDepthBufferDefaults( mDepthBuffer->isTilerMemoryless() + ? DepthBuffer::POOL_MEMORYLESS + : DepthBuffer::NO_POOL_EXPLICIT_RTV, + false, mDepthBuffer->getPixelFormat() ); } else { diff --git a/RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp b/RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp index 7400a37722f..9610d90052b 100644 --- a/RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp +++ b/RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp @@ -223,9 +223,13 @@ namespace Ogre VulkanTextureGpuManager *textureManager = static_cast( textureGpuManager ); + mTexture = textureManager->createTextureGpuWindow( this ); if( DepthBuffer::DefaultDepthBufferFormat != PFG_NULL ) - mDepthBuffer = textureManager->createWindowDepthBuffer(); + { + const bool bMemoryLess = requestedMemoryless( miscParams ); + mDepthBuffer = textureManager->createWindowDepthBuffer( bMemoryLess ); + } mStencilBuffer = 0; setFinalResolution( mRequestedWidth, mRequestedHeight ); @@ -246,8 +250,11 @@ namespace Ogre if( mDepthBuffer ) { - mTexture->_setDepthBufferDefaults( DepthBuffer::NO_POOL_EXPLICIT_RTV, false, - mDepthBuffer->getPixelFormat() ); + mTexture->_setDepthBufferDefaults( + mDepthBuffer->isTilerMemoryless() + ? DepthBuffer::POOL_MEMORYLESS + : DepthBuffer::NO_POOL_EXPLICIT_RTV, false, + mDepthBuffer->getPixelFormat() ); } else { diff --git a/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp b/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp index 351d0009d64..9df8c3629f5 100644 --- a/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp +++ b/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp @@ -535,9 +535,13 @@ namespace Ogre VulkanTextureGpuManager *textureManager = static_cast( textureGpuManager ); + mTexture = textureManager->createTextureGpuWindow( this ); if( DepthBuffer::DefaultDepthBufferFormat != PFG_NULL ) - mDepthBuffer = textureManager->createWindowDepthBuffer(); + { + const bool bMemoryLess = requestedMemoryless( miscParams ); + mDepthBuffer = textureManager->createWindowDepthBuffer( bMemoryLess ); + } setFinalResolution( mRequestedWidth, mRequestedHeight ); @@ -561,8 +565,11 @@ namespace Ogre if( mDepthBuffer ) { - mTexture->_setDepthBufferDefaults( DepthBuffer::NO_POOL_EXPLICIT_RTV, false, - mDepthBuffer->getPixelFormat() ); + mTexture->_setDepthBufferDefaults( + mDepthBuffer->isTilerMemoryless() + ? DepthBuffer::POOL_MEMORYLESS + : DepthBuffer::NO_POOL_EXPLICIT_RTV, false, + mDepthBuffer->getPixelFormat() ); } else { diff --git a/Samples/2.0/Common/src/GraphicsSystem.cpp b/Samples/2.0/Common/src/GraphicsSystem.cpp index 18a3ba5a837..3adaa12f85f 100644 --- a/Samples/2.0/Common/src/GraphicsSystem.cpp +++ b/Samples/2.0/Common/src/GraphicsSystem.cpp @@ -323,6 +323,7 @@ namespace Demo params.insert( std::make_pair( "FSAA", cfgOpts["FSAA"].currentValue ) ); params.insert( std::make_pair( "vsync", cfgOpts["VSync"].currentValue ) ); params.insert( std::make_pair( "reverse_depth", "Yes" ) ); + params.insert( std::make_pair( "memoryless_depth_buffer", "Yes" ) ); initMiscParamsListener( params );