From 2ca153212893651edd0cc2633e773bbf4a8f0a77 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Mon, 11 Nov 2024 12:54:42 +0100 Subject: [PATCH] Move D3D11DeviceResource[Manager] => OgreMain/DeviceDependedResource[Manager], in preparation to handle device lost event in Vulkan --- .../include/OgreDeviceDependedResource.h | 40 ++++++------- .../src/OgreDeviceDependedResource.cpp | 58 +++++++++---------- .../Direct3D11/include/OgreD3D11HLSLProgram.h | 8 +-- .../include/OgreD3D11HardwareBuffer.h | 8 +-- .../include/OgreD3D11RenderPassDescriptor.h | 8 +-- .../include/OgreD3D11RenderSystem.h | 5 +- .../Direct3D11/include/OgreD3D11TextureGpu.h | 8 +-- .../Direct3D11/include/OgreD3D11Window.h | 8 +-- .../Vao/OgreD3D11BufferInterfaceBase.h | 8 +-- .../include/Vao/OgreD3D11DynamicBuffer.h | 8 +-- .../Vao/OgreD3D11ReadOnlyBufferPacked.h | 8 +-- .../include/Vao/OgreD3D11StagingBuffer.h | 9 +-- .../include/Vao/OgreD3D11TexBufferPacked.h | 8 +-- .../include/Vao/OgreD3D11UavBufferPacked.h | 8 +-- .../Direct3D11/src/OgreD3D11HLSLProgram.cpp | 4 +- .../src/OgreD3D11HardwareBuffer.cpp | 4 +- .../src/OgreD3D11RenderPassDescriptor.cpp | 4 +- .../Direct3D11/src/OgreD3D11RenderSystem.cpp | 4 +- .../Direct3D11/src/OgreD3D11TextureGpu.cpp | 4 +- .../Direct3D11/src/OgreD3D11Window.cpp | 4 +- .../src/Vao/OgreD3D11BufferInterfaceBase.cpp | 4 +- .../src/Vao/OgreD3D11DynamicBuffer.cpp | 4 +- .../src/Vao/OgreD3D11ReadOnlyBufferPacked.cpp | 4 +- .../src/Vao/OgreD3D11StagingBuffer.cpp | 4 +- .../src/Vao/OgreD3D11TexBufferPacked.cpp | 4 +- .../src/Vao/OgreD3D11UavBufferPacked.cpp | 4 +- 26 files changed, 121 insertions(+), 119 deletions(-) rename RenderSystems/Direct3D11/include/OgreD3D11DeviceResource.h => OgreMain/include/OgreDeviceDependedResource.h (63%) rename RenderSystems/Direct3D11/src/OgreD3D11DeviceResource.cpp => OgreMain/src/OgreDeviceDependedResource.cpp (57%) diff --git a/RenderSystems/Direct3D11/include/OgreD3D11DeviceResource.h b/OgreMain/include/OgreDeviceDependedResource.h similarity index 63% rename from RenderSystems/Direct3D11/include/OgreD3D11DeviceResource.h rename to OgreMain/include/OgreDeviceDependedResource.h index c111d49884a..4915b24f22d 100644 --- a/RenderSystems/Direct3D11/include/OgreD3D11DeviceResource.h +++ b/OgreMain/include/OgreDeviceDependedResource.h @@ -25,55 +25,55 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------- */ -#ifndef __D3D11Resource_H__ -#define __D3D11Resource_H__ +#ifndef __DeviceDependedResource_H__ +#define __DeviceDependedResource_H__ -#include "OgreD3D11Prerequisites.h" +#include "OgrePrerequisites.h" #include "ogrestd/vector.h" namespace Ogre { - /** Represents a Direct3D rendering resource. + /** Represents a GPU device depended resource. Provide unified interface to handle various device states. This class is intended to be used as protected base. */ - class D3D11DeviceResource + class _OgreExport DeviceDependedResource { public: - // Called immediately after the Direct3D device has entered a removed state. + // Called immediately after the device has entered a lost state. // This is the place to release device depended resources. - virtual void notifyDeviceLost( D3D11Device *device ) = 0; + virtual void notifyDeviceLost() = 0; - // Called immediately after the Direct3D device has been reset. + // Called immediately after the device has been reset. // This is the place to create device depended resources. - virtual void notifyDeviceRestored( D3D11Device *device, unsigned pass ) = 0; + virtual void notifyDeviceRestored( unsigned pass ) = 0; protected: - D3D11DeviceResource(); - ~D3D11DeviceResource(); // protected and non-virtual + DeviceDependedResource(); + ~DeviceDependedResource(); // protected and non-virtual }; /** Singleton that is used to propagate device state changed notifications. This class is intended to be used as protected base. */ - class D3D11DeviceResourceManager + class _OgreExport DeviceDependedResourceManager { public: - void notifyResourceCreated( D3D11DeviceResource *deviceResource ); - void notifyResourceDestroyed( D3D11DeviceResource *deviceResource ); + void notifyResourceCreated( DeviceDependedResource *deviceResource ); + void notifyResourceDestroyed( DeviceDependedResource *deviceResource ); - void notifyDeviceLost( D3D11Device *device ); - void notifyDeviceRestored( D3D11Device *device ); + void notifyDeviceLost(); + void notifyDeviceRestored(); - static D3D11DeviceResourceManager *get(); + static DeviceDependedResourceManager *get(); protected: - D3D11DeviceResourceManager(); - ~D3D11DeviceResourceManager(); // protected and non-virtual + DeviceDependedResourceManager(); + ~DeviceDependedResourceManager(); // protected and non-virtual private: - vector::type mResources, mResourcesCopy; + vector::type mResources, mResourcesCopy; }; } // namespace Ogre diff --git a/RenderSystems/Direct3D11/src/OgreD3D11DeviceResource.cpp b/OgreMain/src/OgreDeviceDependedResource.cpp similarity index 57% rename from RenderSystems/Direct3D11/src/OgreD3D11DeviceResource.cpp rename to OgreMain/src/OgreDeviceDependedResource.cpp index 730d3c72190..7cb0bed1d9e 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11DeviceResource.cpp +++ b/OgreMain/src/OgreDeviceDependedResource.cpp @@ -25,90 +25,90 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------- */ -#include "OgreD3D11DeviceResource.h" +#include "OgreStableHeaders.h" -#include "ogrestd/vector.h" +#include "OgreDeviceDependedResource.h" namespace Ogre { - D3D11DeviceResource::D3D11DeviceResource() + DeviceDependedResource::DeviceDependedResource() { - D3D11DeviceResourceManager::get()->notifyResourceCreated( this ); + DeviceDependedResourceManager::get()->notifyResourceCreated( this ); } - D3D11DeviceResource::~D3D11DeviceResource() + DeviceDependedResource::~DeviceDependedResource() { - D3D11DeviceResourceManager::get()->notifyResourceDestroyed( this ); + DeviceDependedResourceManager::get()->notifyResourceDestroyed( this ); } // ------------------------------------------------------------------------ - static D3D11DeviceResourceManager *gs_D3D11DeviceResourceManager = NULL; + static DeviceDependedResourceManager *gs_DeviceDependedResourceManager = NULL; - D3D11DeviceResourceManager *D3D11DeviceResourceManager::get() + DeviceDependedResourceManager *DeviceDependedResourceManager::get() { - return gs_D3D11DeviceResourceManager; + return gs_DeviceDependedResourceManager; } - D3D11DeviceResourceManager::D3D11DeviceResourceManager() + DeviceDependedResourceManager::DeviceDependedResourceManager() { - assert( gs_D3D11DeviceResourceManager == NULL ); - gs_D3D11DeviceResourceManager = this; + assert( gs_DeviceDependedResourceManager == NULL ); + gs_DeviceDependedResourceManager = this; } - D3D11DeviceResourceManager::~D3D11DeviceResourceManager() + DeviceDependedResourceManager::~DeviceDependedResourceManager() { assert( mResources.empty() ); - assert( gs_D3D11DeviceResourceManager == this ); - gs_D3D11DeviceResourceManager = NULL; + assert( gs_DeviceDependedResourceManager == this ); + gs_DeviceDependedResourceManager = NULL; } - void D3D11DeviceResourceManager::notifyResourceCreated( D3D11DeviceResource *deviceResource ) + void DeviceDependedResourceManager::notifyResourceCreated( DeviceDependedResource *deviceResource ) { assert( std::find( mResources.begin(), mResources.end(), deviceResource ) == mResources.end() ); mResources.push_back( deviceResource ); } - void D3D11DeviceResourceManager::notifyResourceDestroyed( D3D11DeviceResource *deviceResource ) + void DeviceDependedResourceManager::notifyResourceDestroyed( DeviceDependedResource *deviceResource ) { - vector::type::iterator it = + vector::type::iterator it = std::find( mResources.begin(), mResources.end(), deviceResource ); assert( it != mResources.end() ); mResources.erase( it ); - vector::type::iterator itCopy = + vector::type::iterator itCopy = std::find( mResourcesCopy.begin(), mResourcesCopy.end(), deviceResource ); if( itCopy != mResourcesCopy.end() ) *itCopy = NULL; } - void D3D11DeviceResourceManager::notifyDeviceLost( D3D11Device *device ) + void DeviceDependedResourceManager::notifyDeviceLost() { assert( mResourcesCopy.empty() ); // reentrancy is not expected nor supported mResourcesCopy = mResources; - vector::type::iterator it = mResourcesCopy.begin(); - vector::type::iterator en = mResourcesCopy.end(); + vector::type::iterator it = mResourcesCopy.begin(); + vector::type::iterator en = mResourcesCopy.end(); while( it != en ) { - if( D3D11DeviceResource *deviceResource = *it ) - deviceResource->notifyDeviceLost( device ); + if( DeviceDependedResource *deviceResource = *it ) + deviceResource->notifyDeviceLost(); ++it; } mResourcesCopy.clear(); } - void D3D11DeviceResourceManager::notifyDeviceRestored( D3D11Device *device ) + void DeviceDependedResourceManager::notifyDeviceRestored() { assert( mResourcesCopy.empty() ); // reentrancy is not expected nor supported mResourcesCopy = mResources; for( unsigned pass = 0; pass < 2; ++pass ) { - vector::type::iterator it = mResourcesCopy.begin(); - vector::type::iterator en = mResourcesCopy.end(); + vector::type::iterator it = mResourcesCopy.begin(); + vector::type::iterator en = mResourcesCopy.end(); while( it != en ) { - if( D3D11DeviceResource *deviceResource = *it ) - deviceResource->notifyDeviceRestored( device, pass ); + if( DeviceDependedResource *deviceResource = *it ) + deviceResource->notifyDeviceRestored( pass ); ++it; } } diff --git a/RenderSystems/Direct3D11/include/OgreD3D11HLSLProgram.h b/RenderSystems/Direct3D11/include/OgreD3D11HLSLProgram.h index 6c3c3094807..01fd3e300dd 100644 --- a/RenderSystems/Direct3D11/include/OgreD3D11HLSLProgram.h +++ b/RenderSystems/Direct3D11/include/OgreD3D11HLSLProgram.h @@ -30,7 +30,7 @@ THE SOFTWARE. #include "OgreD3D11Prerequisites.h" -#include "OgreD3D11DeviceResource.h" +#include "OgreDeviceDependedResource.h" #include "OgreHighLevelGpuProgram.h" #include "OgreString.h" #include "Vao/OgreVertexBufferPacked.h" @@ -48,7 +48,7 @@ namespace Ogre can produce programs for OpenGL too. */ class _OgreD3D11Export D3D11HLSLProgram final : public HighLevelGpuProgram, - protected D3D11DeviceResource + protected DeviceDependedResource { public: /// Command object for setting entry point @@ -94,8 +94,8 @@ namespace Ogre static CmdColumnMajorMatrices msCmdColumnMajorMatrices; static CmdEnableBackwardsCompatibility msCmdEnableBackwardsCompatibility; - void notifyDeviceLost( D3D11Device *device ) override; - void notifyDeviceRestored( D3D11Device *device, unsigned pass ) override; + void notifyDeviceLost() override; + void notifyDeviceRestored( unsigned pass ) override; /** Internal method for creating an appropriate low-level program from this high-level program, must be implemented by subclasses. */ diff --git a/RenderSystems/Direct3D11/include/OgreD3D11HardwareBuffer.h b/RenderSystems/Direct3D11/include/OgreD3D11HardwareBuffer.h index 85a9afc1488..debd0d4b0f3 100644 --- a/RenderSystems/Direct3D11/include/OgreD3D11HardwareBuffer.h +++ b/RenderSystems/Direct3D11/include/OgreD3D11HardwareBuffer.h @@ -30,7 +30,7 @@ THE SOFTWARE. #include "OgreD3D11Prerequisites.h" -#include "OgreD3D11DeviceResource.h" +#include "OgreDeviceDependedResource.h" #include "OgreHardwareBuffer.h" namespace Ogre @@ -41,7 +41,7 @@ namespace Ogre aspects. */ class _OgreD3D11Export D3D11HardwareBuffer final : public HardwareBuffer, - protected D3D11DeviceResource + protected DeviceDependedResource { public: enum BufferType @@ -65,8 +65,8 @@ namespace Ogre /** See HardwareBuffer. */ void unlockImpl() override; - void notifyDeviceLost( D3D11Device *device ) override; - void notifyDeviceRestored( D3D11Device *device, unsigned pass ) override; + void notifyDeviceLost() override; + void notifyDeviceRestored( unsigned pass ) override; public: D3D11HardwareBuffer( BufferType btype, size_t sizeBytes, HardwareBuffer::Usage usage, diff --git a/RenderSystems/Direct3D11/include/OgreD3D11RenderPassDescriptor.h b/RenderSystems/Direct3D11/include/OgreD3D11RenderPassDescriptor.h index 36df1305935..77e6e5b4ff9 100644 --- a/RenderSystems/Direct3D11/include/OgreD3D11RenderPassDescriptor.h +++ b/RenderSystems/Direct3D11/include/OgreD3D11RenderPassDescriptor.h @@ -32,7 +32,7 @@ THE SOFTWARE. #include "OgreD3D11Prerequisites.h" #include "OgreCommon.h" -#include "OgreD3D11DeviceResource.h" +#include "OgreDeviceDependedResource.h" #include "OgreRenderPassDescriptor.h" #include "OgreRenderSystem.h" @@ -61,7 +61,7 @@ namespace Ogre */ class _OgreD3D11Export D3D11RenderPassDescriptor final : public RenderPassDescriptor, public RenderSystem::Listener, - protected D3D11DeviceResource + protected DeviceDependedResource { protected: ComPtr mColourRtv[OGRE_MAX_MULTIPLE_RENDER_TARGETS]; @@ -74,8 +74,8 @@ namespace Ogre D3D11Device &mDevice; D3D11RenderSystem *mRenderSystem; - void notifyDeviceLost( D3D11Device *device ) override; - void notifyDeviceRestored( D3D11Device *device, unsigned pass ) override; + void notifyDeviceLost() override; + void notifyDeviceRestored( unsigned pass ) override; void checkRenderWindowStatus(); void calculateSharedKey(); diff --git a/RenderSystems/Direct3D11/include/OgreD3D11RenderSystem.h b/RenderSystems/Direct3D11/include/OgreD3D11RenderSystem.h index 38efc81ccc8..002b9605e55 100644 --- a/RenderSystems/Direct3D11/include/OgreD3D11RenderSystem.h +++ b/RenderSystems/Direct3D11/include/OgreD3D11RenderSystem.h @@ -33,7 +33,7 @@ THE SOFTWARE. #include "OgreRenderSystem.h" #include "OgreD3D11Device.h" -#include "OgreD3D11DeviceResource.h" +#include "OgreDeviceDependedResource.h" #include "OgreD3D11Driver.h" #include "OgreD3D11PixelFormatToShaderType.h" #include "OgreD3D11RenderPassDescriptor.h" @@ -51,7 +51,8 @@ namespace Ogre /** Implementation of DirectX11 as a rendering system. */ - class _OgreD3D11Export D3D11RenderSystem : public RenderSystem, protected D3D11DeviceResourceManager + class _OgreD3D11Export D3D11RenderSystem : public RenderSystem, + protected DeviceDependedResourceManager { private: Ogre::String mDriverName; // it`s hint rather than hard requirement, could be ignored if empty diff --git a/RenderSystems/Direct3D11/include/OgreD3D11TextureGpu.h b/RenderSystems/Direct3D11/include/OgreD3D11TextureGpu.h index 342c7abd2ba..800ba1bd4c9 100644 --- a/RenderSystems/Direct3D11/include/OgreD3D11TextureGpu.h +++ b/RenderSystems/Direct3D11/include/OgreD3D11TextureGpu.h @@ -31,7 +31,7 @@ THE SOFTWARE. #include "OgreD3D11Prerequisites.h" -#include "OgreD3D11DeviceResource.h" +#include "OgreDeviceDependedResource.h" #include "OgreDescriptorSetTexture.h" #include "OgreDescriptorSetUav.h" #include "OgreTextureGpu.h" @@ -40,7 +40,7 @@ THE SOFTWARE. namespace Ogre { - class _OgreD3D11Export D3D11TextureGpu : public TextureGpu, protected D3D11DeviceResource + class _OgreD3D11Export D3D11TextureGpu : public TextureGpu, protected DeviceDependedResource { protected: /// The general case is that the whole D3D11 texture will be accessed through the SRV. @@ -81,8 +81,8 @@ namespace Ogre void createInternalResourcesImpl() override; void destroyInternalResourcesImpl() override; - void notifyDeviceLost( D3D11Device *device ) override; - void notifyDeviceRestored( D3D11Device *device, unsigned pass ) override; + void notifyDeviceLost() override; + void notifyDeviceRestored( unsigned pass ) override; public: D3D11TextureGpu( GpuPageOutStrategy::GpuPageOutStrategy pageOutStrategy, VaoManager *vaoManager, diff --git a/RenderSystems/Direct3D11/include/OgreD3D11Window.h b/RenderSystems/Direct3D11/include/OgreD3D11Window.h index ca9555c829a..bb9cb27deb6 100644 --- a/RenderSystems/Direct3D11/include/OgreD3D11Window.h +++ b/RenderSystems/Direct3D11/include/OgreD3D11Window.h @@ -32,12 +32,12 @@ THE SOFTWARE. #include "OgreD3D11Prerequisites.h" #include "OgreCommon.h" -#include "OgreD3D11DeviceResource.h" +#include "OgreDeviceDependedResource.h" #include "OgreWindow.h" namespace Ogre { - class _OgreD3D11Export D3D11Window : public Window, protected D3D11DeviceResource + class _OgreD3D11Export D3D11Window : public Window, protected DeviceDependedResource { protected: D3D11Device &mDevice; @@ -113,8 +113,8 @@ namespace Ogre void resizeSwapChainBuffers( uint32 width, uint32 height ); void notifyResolutionChanged(); - void notifyDeviceLost( D3D11Device *device ) override; - void notifyDeviceRestored( D3D11Device *device, unsigned pass ) override; + void notifyDeviceLost() override; + void notifyDeviceRestored( unsigned pass ) override; public: D3D11WindowSwapChainBased( const String &title, uint32 width, uint32 height, bool fullscreenMode, diff --git a/RenderSystems/Direct3D11/include/Vao/OgreD3D11BufferInterfaceBase.h b/RenderSystems/Direct3D11/include/Vao/OgreD3D11BufferInterfaceBase.h index c21ce1962b5..5a846ba402f 100644 --- a/RenderSystems/Direct3D11/include/Vao/OgreD3D11BufferInterfaceBase.h +++ b/RenderSystems/Direct3D11/include/Vao/OgreD3D11BufferInterfaceBase.h @@ -31,7 +31,7 @@ THE SOFTWARE. #include "OgreD3D11Prerequisites.h" -#include "OgreD3D11DeviceResource.h" +#include "OgreDeviceDependedResource.h" #include "Vao/OgreBufferInterface.h" namespace Ogre @@ -40,7 +40,7 @@ namespace Ogre Hence most equivalent functionality is encapsulated here. */ class _OgreD3D11Export D3D11BufferInterfaceBase : public BufferInterface, - protected D3D11DeviceResource + protected DeviceDependedResource { protected: size_t mVboPoolIdx; @@ -51,8 +51,8 @@ namespace Ogre size_t alignment, ID3D11Buffer *dstBuffer, ID3D11Buffer *srcBuffer, ID3D11DeviceContextN *context ); - void notifyDeviceLost( D3D11Device *device ) override; - void notifyDeviceRestored( D3D11Device *device, unsigned pass ) override; + void notifyDeviceLost() override; + void notifyDeviceRestored( unsigned pass ) override; public: D3D11BufferInterfaceBase( size_t vboPoolIdx, ID3D11Buffer *d3dBuffer ); diff --git a/RenderSystems/Direct3D11/include/Vao/OgreD3D11DynamicBuffer.h b/RenderSystems/Direct3D11/include/Vao/OgreD3D11DynamicBuffer.h index 33716a3b902..b71190008e4 100644 --- a/RenderSystems/Direct3D11/include/Vao/OgreD3D11DynamicBuffer.h +++ b/RenderSystems/Direct3D11/include/Vao/OgreD3D11DynamicBuffer.h @@ -31,7 +31,7 @@ THE SOFTWARE. #include "OgreD3D11Prerequisites.h" -#include "OgreD3D11DeviceResource.h" +#include "OgreDeviceDependedResource.h" #include "Vao/OgreBufferPacked.h" #include "ogrestd/vector.h" @@ -52,7 +52,7 @@ namespace Ogre Caller is responsible for proper synchronization. No check is performed to see if two map calls overlap. */ - class _OgreD3D11Export D3D11DynamicBuffer final : protected D3D11DeviceResource + class _OgreD3D11Export D3D11DynamicBuffer final : protected DeviceDependedResource { protected: struct MappedRange @@ -76,8 +76,8 @@ namespace Ogre size_t addMappedRange( size_t start, size_t count ); - void notifyDeviceLost( D3D11Device *device ) override; - void notifyDeviceRestored( D3D11Device *device, unsigned pass ) override; + void notifyDeviceLost() override; + void notifyDeviceRestored( unsigned pass ) override; public: D3D11DynamicBuffer( ID3D11Buffer *vboName, size_t vboSize, D3D11Device &device ); diff --git a/RenderSystems/Direct3D11/include/Vao/OgreD3D11ReadOnlyBufferPacked.h b/RenderSystems/Direct3D11/include/Vao/OgreD3D11ReadOnlyBufferPacked.h index 4ac98731ea8..5987c6ed9d1 100644 --- a/RenderSystems/Direct3D11/include/Vao/OgreD3D11ReadOnlyBufferPacked.h +++ b/RenderSystems/Direct3D11/include/Vao/OgreD3D11ReadOnlyBufferPacked.h @@ -33,7 +33,7 @@ THE SOFTWARE. #include "Vao/OgreReadOnlyBufferPacked.h" -#include "OgreD3D11DeviceResource.h" +#include "OgreDeviceDependedResource.h" #include "OgreDescriptorSetTexture.h" namespace Ogre @@ -41,7 +41,7 @@ namespace Ogre class D3D11BufferInterface; class _OgreD3D11Export D3D11ReadOnlyBufferPacked final : public ReadOnlyBufferPacked, - protected D3D11DeviceResource + protected DeviceDependedResource { DXGI_FORMAT mInternalFormat; D3D11Device &mDevice; @@ -61,8 +61,8 @@ namespace Ogre ID3D11ShaderResourceView *createResourceView( int cacheIdx, uint32 offset, uint32 sizeBytes ); ID3D11ShaderResourceView *bindBufferCommon( size_t offset, size_t sizeBytes ); - void notifyDeviceLost( D3D11Device *device ) override; - void notifyDeviceRestored( D3D11Device *device, unsigned pass ) override; + void notifyDeviceLost() override; + void notifyDeviceRestored( unsigned pass ) override; public: D3D11ReadOnlyBufferPacked( size_t internalBufStartBytes, size_t numElements, diff --git a/RenderSystems/Direct3D11/include/Vao/OgreD3D11StagingBuffer.h b/RenderSystems/Direct3D11/include/Vao/OgreD3D11StagingBuffer.h index 5246d972e7f..b9166bd0293 100644 --- a/RenderSystems/Direct3D11/include/Vao/OgreD3D11StagingBuffer.h +++ b/RenderSystems/Direct3D11/include/Vao/OgreD3D11StagingBuffer.h @@ -31,7 +31,7 @@ THE SOFTWARE. #include "OgreD3D11Prerequisites.h" -#include "OgreD3D11DeviceResource.h" +#include "OgreDeviceDependedResource.h" #include "Vao/OgreStagingBuffer.h" @@ -47,7 +47,8 @@ namespace Ogre In other words, a staging buffer is an intermediate buffer to transfer data between CPU & GPU */ - class _OgreD3D11Export D3D11StagingBuffer final : public StagingBuffer, protected D3D11DeviceResource + class _OgreD3D11Export D3D11StagingBuffer final : public StagingBuffer, + protected DeviceDependedResource { protected: /// mVboName is not deleted by us (the VaoManager does) as we may have @@ -81,8 +82,8 @@ namespace Ogre const void *_mapForReadImpl( size_t offset, size_t sizeBytes ) override; - void notifyDeviceLost( D3D11Device *device ) override; - void notifyDeviceRestored( D3D11Device *device, unsigned pass ) override; + void notifyDeviceLost() override; + void notifyDeviceRestored( unsigned pass ) override; public: D3D11StagingBuffer( size_t sizeBytes, VaoManager *vaoManager, bool uploadOnly, diff --git a/RenderSystems/Direct3D11/include/Vao/OgreD3D11TexBufferPacked.h b/RenderSystems/Direct3D11/include/Vao/OgreD3D11TexBufferPacked.h index 92683d0a52d..4e6e3b4c41a 100644 --- a/RenderSystems/Direct3D11/include/Vao/OgreD3D11TexBufferPacked.h +++ b/RenderSystems/Direct3D11/include/Vao/OgreD3D11TexBufferPacked.h @@ -31,7 +31,7 @@ THE SOFTWARE. #include "OgreD3D11Prerequisites.h" -#include "OgreD3D11DeviceResource.h" +#include "OgreDeviceDependedResource.h" #include "OgreDescriptorSetTexture.h" #include "Vao/OgreTexBufferPacked.h" @@ -40,7 +40,7 @@ namespace Ogre class D3D11BufferInterface; class _OgreD3D11Export D3D11TexBufferPacked final : public TexBufferPacked, - protected D3D11DeviceResource + protected DeviceDependedResource { DXGI_FORMAT mInternalFormat; D3D11Device &mDevice; @@ -60,8 +60,8 @@ namespace Ogre ID3D11ShaderResourceView *createResourceView( int cacheIdx, uint32 offset, uint32 sizeBytes ); ID3D11ShaderResourceView *bindBufferCommon( size_t offset, size_t sizeBytes ); - void notifyDeviceLost( D3D11Device *device ) override; - void notifyDeviceRestored( D3D11Device *device, unsigned pass ) override; + void notifyDeviceLost() override; + void notifyDeviceRestored( unsigned pass ) override; public: D3D11TexBufferPacked( size_t internalBufStartBytes, size_t numElements, uint32 bytesPerElement, diff --git a/RenderSystems/Direct3D11/include/Vao/OgreD3D11UavBufferPacked.h b/RenderSystems/Direct3D11/include/Vao/OgreD3D11UavBufferPacked.h index a64e5943f66..204115edcfd 100644 --- a/RenderSystems/Direct3D11/include/Vao/OgreD3D11UavBufferPacked.h +++ b/RenderSystems/Direct3D11/include/Vao/OgreD3D11UavBufferPacked.h @@ -31,7 +31,7 @@ THE SOFTWARE. #include "OgreD3D11Prerequisites.h" -#include "OgreD3D11DeviceResource.h" +#include "OgreDeviceDependedResource.h" #include "OgreDescriptorSetUav.h" #include "Vao/OgreUavBufferPacked.h" @@ -40,7 +40,7 @@ namespace Ogre class D3D11BufferInterface; class _OgreD3D11Export D3D11UavBufferPacked final : public UavBufferPacked, - protected D3D11DeviceResource + protected DeviceDependedResource { protected: D3D11Device &mDevice; @@ -60,8 +60,8 @@ namespace Ogre ID3D11UnorderedAccessView *createResourceView( int cacheIdx, uint32 offset, uint32 sizeBytes ); - void notifyDeviceLost( D3D11Device *device ) override; - void notifyDeviceRestored( D3D11Device *device, unsigned pass ) override; + void notifyDeviceLost() override; + void notifyDeviceRestored( unsigned pass ) override; public: D3D11UavBufferPacked( size_t internalBufStartBytes, size_t numElements, uint32 bytesPerElement, diff --git a/RenderSystems/Direct3D11/src/OgreD3D11HLSLProgram.cpp b/RenderSystems/Direct3D11/src/OgreD3D11HLSLProgram.cpp index 828cad4df75..73a88ca7341 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11HLSLProgram.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11HLSLProgram.cpp @@ -58,13 +58,13 @@ namespace Ogre D3D11HLSLProgram::CmdEnableBackwardsCompatibility D3D11HLSLProgram::msCmdEnableBackwardsCompatibility; //----------------------------------------------------------------------- - void D3D11HLSLProgram::notifyDeviceLost( D3D11Device *device ) + void D3D11HLSLProgram::notifyDeviceLost() { if( mHighLevelLoaded ) unloadHighLevelImpl(); } //----------------------------------------------------------------------- - void D3D11HLSLProgram::notifyDeviceRestored( D3D11Device *device, unsigned pass ) + void D3D11HLSLProgram::notifyDeviceRestored( unsigned pass ) { if( pass == 0 && mHighLevelLoaded ) loadHighLevelImpl(); diff --git a/RenderSystems/Direct3D11/src/OgreD3D11HardwareBuffer.cpp b/RenderSystems/Direct3D11/src/OgreD3D11HardwareBuffer.cpp index 972c5aff8c0..d381029ef5d 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11HardwareBuffer.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11HardwareBuffer.cpp @@ -113,9 +113,9 @@ namespace Ogre SAFE_DELETE( mShadowBuffer ); } //----------------------------------------------------------------------------------- - void D3D11HardwareBuffer::notifyDeviceLost( D3D11Device *device ) { mlpD3DBuffer.Reset(); } + void D3D11HardwareBuffer::notifyDeviceLost() { mlpD3DBuffer.Reset(); } //----------------------------------------------------------------------------------- - void D3D11HardwareBuffer::notifyDeviceRestored( D3D11Device *device, unsigned pass ) {} + void D3D11HardwareBuffer::notifyDeviceRestored( unsigned pass ) {} //--------------------------------------------------------------------- void *D3D11HardwareBuffer::lockImpl( size_t offset, size_t length, LockOptions options ) { diff --git a/RenderSystems/Direct3D11/src/OgreD3D11RenderPassDescriptor.cpp b/RenderSystems/Direct3D11/src/OgreD3D11RenderPassDescriptor.cpp index 88c876a74de..1817246339a 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11RenderPassDescriptor.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11RenderPassDescriptor.cpp @@ -62,14 +62,14 @@ namespace Ogre mRenderSystem->removeListener( this ); } //----------------------------------------------------------------------------------- - void D3D11RenderPassDescriptor::notifyDeviceLost( D3D11Device *device ) + void D3D11RenderPassDescriptor::notifyDeviceLost() { for( size_t i = 0; i < mNumColourEntries; ++i ) mColourRtv[i].Reset(); mDepthStencilRtv.Reset(); } //----------------------------------------------------------------------------------- - void D3D11RenderPassDescriptor::notifyDeviceRestored( D3D11Device *device, unsigned pass ) + void D3D11RenderPassDescriptor::notifyDeviceRestored( unsigned pass ) { if( pass == 1 ) entriesModified( RenderPassDescriptor::All ); diff --git a/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp b/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp index 26805ad7d36..34026b0a83a 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp @@ -1727,7 +1727,7 @@ namespace Ogre static_cast( mTextureGpuManager )->_destroyD3DResources(); static_cast( mVaoManager )->_destroyD3DResources(); - notifyDeviceLost( &mDevice ); + notifyDeviceLost(); // Release all automatic temporary buffers and free unused // temporary buffers, so we doesn't need to recreate them, @@ -1741,7 +1741,7 @@ namespace Ogre static_cast( mTextureGpuManager )->_createD3DResources(); // recreate device depended resources - notifyDeviceRestored( &mDevice ); + notifyDeviceRestored(); Root::getSingleton().getHlmsManager()->_changeRenderSystem( this ); diff --git a/RenderSystems/Direct3D11/src/OgreD3D11TextureGpu.cpp b/RenderSystems/Direct3D11/src/OgreD3D11TextureGpu.cpp index 58bde0b08b0..5c6e77aae73 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11TextureGpu.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11TextureGpu.cpp @@ -52,7 +52,7 @@ namespace Ogre //----------------------------------------------------------------------------------- D3D11TextureGpu::~D3D11TextureGpu() { destroyInternalResourcesImpl(); } //----------------------------------------------------------------------------------- - void D3D11TextureGpu::notifyDeviceLost( D3D11Device *device ) + void D3D11TextureGpu::notifyDeviceLost() { mPendingResidencyChanges = 0; // we already cleared D3D11TextureGpuManager::mScheduledTasks mTexturePool = 0; // texture pool is already destroyed @@ -67,7 +67,7 @@ namespace Ogre mDefaultDisplaySrv.Reset(); } //--------------------------------------------------------------------- - void D3D11TextureGpu::notifyDeviceRestored( D3D11Device *device, unsigned pass ) + void D3D11TextureGpu::notifyDeviceRestored( unsigned pass ) { if( pass == 0 ) { diff --git a/RenderSystems/Direct3D11/src/OgreD3D11Window.cpp b/RenderSystems/Direct3D11/src/OgreD3D11Window.cpp index e3576aa0739..34d37f1b97f 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11Window.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11Window.cpp @@ -124,13 +124,13 @@ namespace Ogre //----------------------------------------------------------------------------------- D3D11WindowSwapChainBased::~D3D11WindowSwapChainBased() {} //----------------------------------------------------------------------------------- - void D3D11WindowSwapChainBased::notifyDeviceLost( D3D11Device *device ) + void D3D11WindowSwapChainBased::notifyDeviceLost() { _destroySizeDependedD3DResources(); _destroySwapChain(); } //----------------------------------------------------------------------------------- - void D3D11WindowSwapChainBased::notifyDeviceRestored( D3D11Device *device, unsigned pass ) + void D3D11WindowSwapChainBased::notifyDeviceRestored( unsigned pass ) { if( pass == 0 ) { diff --git a/RenderSystems/Direct3D11/src/Vao/OgreD3D11BufferInterfaceBase.cpp b/RenderSystems/Direct3D11/src/Vao/OgreD3D11BufferInterfaceBase.cpp index 8adc1135398..8fdd1e3393a 100644 --- a/RenderSystems/Direct3D11/src/Vao/OgreD3D11BufferInterfaceBase.cpp +++ b/RenderSystems/Direct3D11/src/Vao/OgreD3D11BufferInterfaceBase.cpp @@ -43,13 +43,13 @@ namespace Ogre //----------------------------------------------------------------------------------- D3D11BufferInterfaceBase::~D3D11BufferInterfaceBase() {} //----------------------------------------------------------------------------------- - void D3D11BufferInterfaceBase::notifyDeviceLost( D3D11Device *device ) + void D3D11BufferInterfaceBase::notifyDeviceLost() { mVboPoolIdx = 0xFFFFFFFF; mVboName.Reset(); } //----------------------------------------------------------------------------------- - void D3D11BufferInterfaceBase::notifyDeviceRestored( D3D11Device *device, unsigned pass ) {} + void D3D11BufferInterfaceBase::notifyDeviceRestored( unsigned pass ) {} //----------------------------------------------------------------------------------- void D3D11BufferInterfaceBase::splicedCopy( size_t dstOffsetBytes, size_t srcOffsetBytes, size_t sizeBytes, size_t alignment, diff --git a/RenderSystems/Direct3D11/src/Vao/OgreD3D11DynamicBuffer.cpp b/RenderSystems/Direct3D11/src/Vao/OgreD3D11DynamicBuffer.cpp index 2344fe36122..d48909083da 100644 --- a/RenderSystems/Direct3D11/src/Vao/OgreD3D11DynamicBuffer.cpp +++ b/RenderSystems/Direct3D11/src/Vao/OgreD3D11DynamicBuffer.cpp @@ -45,9 +45,9 @@ namespace Ogre //----------------------------------------------------------------------------------- D3D11DynamicBuffer::~D3D11DynamicBuffer() {} //----------------------------------------------------------------------------------- - void D3D11DynamicBuffer::notifyDeviceLost( D3D11Device *device ) { mVboName.Reset(); } + void D3D11DynamicBuffer::notifyDeviceLost() { mVboName.Reset(); } //----------------------------------------------------------------------------------- - void D3D11DynamicBuffer::notifyDeviceRestored( D3D11Device *device, unsigned pass ) {} + void D3D11DynamicBuffer::notifyDeviceRestored( unsigned pass ) {} //----------------------------------------------------------------------------------- size_t D3D11DynamicBuffer::addMappedRange( size_t start, size_t count ) { diff --git a/RenderSystems/Direct3D11/src/Vao/OgreD3D11ReadOnlyBufferPacked.cpp b/RenderSystems/Direct3D11/src/Vao/OgreD3D11ReadOnlyBufferPacked.cpp index 6d4d66ec901..9fbeeb3a043 100644 --- a/RenderSystems/Direct3D11/src/Vao/OgreD3D11ReadOnlyBufferPacked.cpp +++ b/RenderSystems/Direct3D11/src/Vao/OgreD3D11ReadOnlyBufferPacked.cpp @@ -56,7 +56,7 @@ namespace Ogre //----------------------------------------------------------------------------------- D3D11ReadOnlyBufferPacked::~D3D11ReadOnlyBufferPacked() {} //----------------------------------------------------------------------------------- - void D3D11ReadOnlyBufferPacked::notifyDeviceLost( D3D11Device *device ) + void D3D11ReadOnlyBufferPacked::notifyDeviceLost() { for( unsigned cacheIdx = 0; cacheIdx < 16; ++cacheIdx ) { @@ -66,7 +66,7 @@ namespace Ogre } } //----------------------------------------------------------------------------------- - void D3D11ReadOnlyBufferPacked::notifyDeviceRestored( D3D11Device *device, unsigned pass ) {} + void D3D11ReadOnlyBufferPacked::notifyDeviceRestored( unsigned pass ) {} //----------------------------------------------------------------------------------- bool D3D11ReadOnlyBufferPacked::isD3D11Structured() const { diff --git a/RenderSystems/Direct3D11/src/Vao/OgreD3D11StagingBuffer.cpp b/RenderSystems/Direct3D11/src/Vao/OgreD3D11StagingBuffer.cpp index 560033d6bcd..67b569f7427 100644 --- a/RenderSystems/Direct3D11/src/Vao/OgreD3D11StagingBuffer.cpp +++ b/RenderSystems/Direct3D11/src/Vao/OgreD3D11StagingBuffer.cpp @@ -48,9 +48,9 @@ namespace Ogre //----------------------------------------------------------------------------------- D3D11StagingBuffer::~D3D11StagingBuffer() {} //----------------------------------------------------------------------------------- - void D3D11StagingBuffer::notifyDeviceLost( D3D11Device *device ) { mVboName.Reset(); } + void D3D11StagingBuffer::notifyDeviceLost() { mVboName.Reset(); } //----------------------------------------------------------------------------------- - void D3D11StagingBuffer::notifyDeviceRestored( D3D11Device *device, unsigned pass ) {} + void D3D11StagingBuffer::notifyDeviceRestored( unsigned pass ) {} //----------------------------------------------------------------------------------- void *D3D11StagingBuffer::mapImpl( size_t sizeBytes ) { diff --git a/RenderSystems/Direct3D11/src/Vao/OgreD3D11TexBufferPacked.cpp b/RenderSystems/Direct3D11/src/Vao/OgreD3D11TexBufferPacked.cpp index 08464f316cc..e5ed86e40f1 100644 --- a/RenderSystems/Direct3D11/src/Vao/OgreD3D11TexBufferPacked.cpp +++ b/RenderSystems/Direct3D11/src/Vao/OgreD3D11TexBufferPacked.cpp @@ -57,7 +57,7 @@ namespace Ogre //----------------------------------------------------------------------------------- D3D11TexBufferPacked::~D3D11TexBufferPacked() {} //----------------------------------------------------------------------------------- - void D3D11TexBufferPacked::notifyDeviceLost( D3D11Device *device ) + void D3D11TexBufferPacked::notifyDeviceLost() { for( unsigned cacheIdx = 0; cacheIdx < 16; ++cacheIdx ) { @@ -67,7 +67,7 @@ namespace Ogre } } //----------------------------------------------------------------------------------- - void D3D11TexBufferPacked::notifyDeviceRestored( D3D11Device *device, unsigned pass ) {} + void D3D11TexBufferPacked::notifyDeviceRestored( unsigned pass ) {} //----------------------------------------------------------------------------------- bool D3D11TexBufferPacked::isD3D11Structured() const { diff --git a/RenderSystems/Direct3D11/src/Vao/OgreD3D11UavBufferPacked.cpp b/RenderSystems/Direct3D11/src/Vao/OgreD3D11UavBufferPacked.cpp index a36a8cf8fbb..32a428eb345 100644 --- a/RenderSystems/Direct3D11/src/Vao/OgreD3D11UavBufferPacked.cpp +++ b/RenderSystems/Direct3D11/src/Vao/OgreD3D11UavBufferPacked.cpp @@ -53,7 +53,7 @@ namespace Ogre //----------------------------------------------------------------------------------- D3D11UavBufferPacked::~D3D11UavBufferPacked() {} //----------------------------------------------------------------------------------- - void D3D11UavBufferPacked::notifyDeviceLost( D3D11Device *device ) + void D3D11UavBufferPacked::notifyDeviceLost() { for( unsigned cacheIdx = 0; cacheIdx < 16; ++cacheIdx ) { @@ -63,7 +63,7 @@ namespace Ogre } } //----------------------------------------------------------------------------------- - void D3D11UavBufferPacked::notifyDeviceRestored( D3D11Device *device, unsigned pass ) {} + void D3D11UavBufferPacked::notifyDeviceRestored( unsigned pass ) {} //----------------------------------------------------------------------------------- TexBufferPacked *D3D11UavBufferPacked::getAsTexBufferImpl( PixelFormatGpu pixelFormat ) {