From 1133211961e878a9b39176c5fb1b9f72feb9ec71 Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 24 Dec 2019 18:56:05 -0800 Subject: Added IRenderDeviceGL::CreateDummyTexture method (API version 240047) --- .../GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h | 5 +++-- .../GraphicsEngineOpenGL/interface/RenderDeviceGL.h | 18 ++++++++++++++++++ .../GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp | 2 +- Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp | 4 ++-- 4 files changed, 24 insertions(+), 5 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h index 1f2bf173..5045ae75 100644 --- a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h @@ -92,6 +92,9 @@ public: /// Implementation of IRenderDeviceGL::CreateBufferFromGLHandle(). virtual void CreateBufferFromGLHandle(Uint32 GLHandle, const BufferDesc& BuffDesc, RESOURCE_STATE InitialState, IBuffer** ppBuffer) override final; + /// Implementation of IRenderDeviceGL::CreateDummyTexture(). + virtual void CreateDummyTexture(const TextureDesc& TexDesc, RESOURCE_STATE InitialState, ITexture** ppTexture) override final; + /// Implementation of IRenderDevice::ReleaseStaleResources() in OpenGL backend. virtual void ReleaseStaleResources(bool ForceRelease = false) override final {} @@ -107,8 +110,6 @@ public: void OnDestroyPSO(IPipelineState* pPSO); void OnDestroyBuffer(IBuffer* pBuffer); - void CreateDummyTexture(const TextureDesc& TexDesc, RESOURCE_STATE InitialState, class TextureBaseGL** ppTexture); - size_t GetCommandQueueCount() const { return 1; } Uint64 GetCommandQueueMask() const { return Uint64{1}; } diff --git a/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceGL.h b/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceGL.h index 85a815d0..7b560f87 100644 --- a/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceGL.h +++ b/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceGL.h @@ -75,6 +75,24 @@ public: const BufferDesc& BuffDesc, RESOURCE_STATE InitialState, IBuffer** ppBuffer) = 0; + + + /// Creates a dummy texture with null handle. + + /// The main usage of dummy textures is to serve as render target and depth buffer + /// proxies in a swap chain. When dummy color buffer is set as render target, the + /// engine binds default FBO provided by the swap chain. + /// + /// \param [in] TexDesc - Texture description. + /// \param [in] InitialState - Initial texture state. See Diligent::RESOURCE_STATE. + /// \param [out] ppTexture - Address of the memory location where the pointer to the + /// texture interface will be stored. + /// The function calls AddRef(), so that the new object will contain + /// one reference. + /// \note Only RESOURCE_DIM_TEX_2D dummy textures are supported. + virtual void CreateDummyTexture(const TextureDesc& TexDesc, + RESOURCE_STATE InitialState, + ITexture** ppTexture) = 0; }; } // namespace Diligent diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index f813cb58..02dacc62 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -291,7 +291,7 @@ void RenderDeviceGLImpl::CreateTextureFromGLHandle(Uint32 GLHandle, const Textur ); } -void RenderDeviceGLImpl::CreateDummyTexture(const TextureDesc& TexDesc, RESOURCE_STATE InitialState, TextureBaseGL** ppTexture) +void RenderDeviceGLImpl::CreateDummyTexture(const TextureDesc& TexDesc, RESOURCE_STATE InitialState, ITexture** ppTexture) { CreateDeviceObject( "texture", TexDesc, ppTexture, diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp index fc33ccf9..a5e0dd93 100644 --- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp @@ -82,7 +82,7 @@ void SwapChainGLImpl::CreateDummyBuffers(RenderDeviceGLImpl* pRenderDeviceGL) ColorBuffDesc.Height = m_SwapChainDesc.Height; ColorBuffDesc.Format = m_SwapChainDesc.ColorBufferFormat; ColorBuffDesc.BindFlags = BIND_RENDER_TARGET; - RefCntAutoPtr pDummyColorBuffer; + RefCntAutoPtr pDummyColorBuffer; pRenderDeviceGL->CreateDummyTexture(ColorBuffDesc, RESOURCE_STATE_RENDER_TARGET, &pDummyColorBuffer); m_pRenderTargetView = ValidatedCast(pDummyColorBuffer->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET)); @@ -90,7 +90,7 @@ void SwapChainGLImpl::CreateDummyBuffers(RenderDeviceGLImpl* pRenderDeviceGL) DepthBuffDesc.Name = "Main depth buffer stub"; DepthBuffDesc.Format = m_SwapChainDesc.DepthBufferFormat; DepthBuffDesc.BindFlags = BIND_DEPTH_STENCIL; - RefCntAutoPtr pDummyDepthBuffer; + RefCntAutoPtr pDummyDepthBuffer; pRenderDeviceGL->CreateDummyTexture(DepthBuffDesc, RESOURCE_STATE_DEPTH_WRITE, &pDummyDepthBuffer); m_pDepthStencilView = ValidatedCast(pDummyDepthBuffer->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL)); } -- cgit v1.2.3