From 4f5a4499cf0eee3761788eb6a422cd25e02ace40 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 4 Mar 2021 12:46:21 -0800 Subject: Refactored passing template arguments to base classes --- Graphics/GraphicsEngineOpenGL/CMakeLists.txt | 1 + .../GraphicsEngineOpenGL/include/BufferGLImpl.hpp | 6 +- .../include/BufferViewGLImpl.hpp | 4 +- .../include/DeviceContextGLImpl.hpp | 17 +-- .../include/EngineGLImplTraits.hpp | 115 +++++++++++++++++++++ .../GraphicsEngineOpenGL/include/FenceGLImpl.hpp | 6 +- .../include/FramebufferGLImpl.hpp | 6 +- .../include/PipelineResourceSignatureGLImpl.hpp | 4 +- .../include/PipelineStateGLImpl.hpp | 6 +- .../GraphicsEngineOpenGL/include/QueryGLImpl.hpp | 6 +- .../include/RenderDeviceGLImpl.hpp | 48 +-------- .../include/RenderPassGLImpl.hpp | 4 +- .../GraphicsEngineOpenGL/include/SamplerGLImpl.hpp | 6 +- .../GraphicsEngineOpenGL/include/ShaderGLImpl.hpp | 6 +- .../include/ShaderResourceBindingGLImpl.hpp | 4 +- .../GraphicsEngineOpenGL/include/TextureBaseGL.hpp | 6 +- .../include/TextureViewGLImpl.hpp | 4 +- .../GraphicsEngineOpenGL/src/ShaderVariableGL.cpp | 1 + 18 files changed, 149 insertions(+), 101 deletions(-) create mode 100644 Graphics/GraphicsEngineOpenGL/include/EngineGLImplTraits.hpp (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt index 6890b22d..d2853156 100644 --- a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt +++ b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt @@ -7,6 +7,7 @@ set(INCLUDE include/BufferGLImpl.hpp include/BufferViewGLImpl.hpp include/DeviceContextGLImpl.hpp + include/EngineGLImplTraits.hpp include/FBOCache.hpp include/FenceGLImpl.hpp include/FramebufferGLImpl.hpp diff --git a/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.hpp index ba10834e..9fd8be2f 100644 --- a/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.hpp @@ -39,13 +39,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Buffer object implementation in OpenGL backend. -class BufferGLImpl final : public BufferBase, public AsyncWritableResource +class BufferGLImpl final : public BufferBase, public AsyncWritableResource { public: - using TBufferBase = BufferBase; + using TBufferBase = BufferBase; BufferGLImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, diff --git a/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.hpp index 73d654a9..a61e7e6d 100644 --- a/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.hpp @@ -37,10 +37,10 @@ namespace Diligent { /// Buffer view implementation in OpenGL backend. -class BufferViewGLImpl final : public BufferViewBase +class BufferViewGLImpl final : public BufferViewBase { public: - using TBuffViewBase = BufferViewBase; + using TBuffViewBase = BufferViewBase; BufferViewGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.hpp index dc27008f..9926204f 100644 --- a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.hpp @@ -47,24 +47,11 @@ namespace Diligent { -struct DeviceContextGLImplTraits -{ - using BufferType = BufferGLImpl; - using TextureType = TextureBaseGL; - using PipelineStateType = PipelineStateGLImpl; - using DeviceType = RenderDeviceGLImpl; - using QueryType = QueryGLImpl; - using FramebufferType = FramebufferGLImpl; - using RenderPassType = RenderPassGLImpl; - using BottomLevelASType = BottomLevelASBase; - using TopLevelASType = TopLevelASBase; -}; - /// Device context implementation in OpenGL backend. -class DeviceContextGLImpl final : public DeviceContextBase +class DeviceContextGLImpl final : public DeviceContextBase { public: - using TDeviceContextBase = DeviceContextBase; + using TDeviceContextBase = DeviceContextBase; DeviceContextGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDeviceGL, bool bIsDeferred); diff --git a/Graphics/GraphicsEngineOpenGL/include/EngineGLImplTraits.hpp b/Graphics/GraphicsEngineOpenGL/include/EngineGLImplTraits.hpp new file mode 100644 index 00000000..077c11ce --- /dev/null +++ b/Graphics/GraphicsEngineOpenGL/include/EngineGLImplTraits.hpp @@ -0,0 +1,115 @@ +/* + * Copyright 2019-2021 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +/// \file +/// Declaration of Diligent::EngineGLImplTraits struct + +#include "RenderDeviceGL.h" +#include "PipelineStateGL.h" +#include "ShaderResourceBindingGL.h" +#include "BufferGL.h" +#include "BufferViewGL.h" +#include "TextureGL.h" +#include "TextureViewGL.h" +#include "ShaderGL.h" +#include "SamplerGL.h" +#include "FenceGL.h" +#include "QueryGL.h" +#include "RenderPass.h" +#include "Framebuffer.h" +#include "PipelineResourceSignature.h" +#include "DeviceContextGL.h" +#include "BaseInterfacesGL.h" + +namespace Diligent +{ + +class RenderDeviceGLImpl; +class DeviceContextGLImpl; +class PipelineStateGLImpl; +class ShaderResourceBindingGLImpl; +class BufferGLImpl; +class BufferViewGLImpl; +class TextureBaseGL; +class TextureViewGLImpl; +class ShaderGLImpl; +class SamplerGLImpl; +class FenceGLImpl; +class QueryGLImpl; +class RenderPassGLImpl; +class FramebufferGLImpl; +class BottomLevelASGLImpl; +class TopLevelASGLImpl; +class ShaderBindingTableGLImpl; +class PipelineResourceSignatureGLImpl; + +class FixedBlockMemoryAllocator; + +struct EngineGLImplTraits +{ + using RenderDeviceInterface = IGLDeviceBaseInterface; + using DeviceContextInterface = IDeviceContextGL; + using PipelineStateInterface = IPipelineStateGL; + using ShaderResourceBindingInterface = IShaderResourceBindingGL; + using BufferInterface = IBufferGL; + using BufferViewInterface = IBufferViewGL; + using TextureInterface = ITextureGL; + using TextureViewInterface = ITextureViewGL; + using ShaderInterface = IShaderGL; + using SamplerInterface = ISamplerGL; + using FenceInterface = IFenceGL; + using QueryInterface = IQueryGL; + using RenderPassInterface = IRenderPass; + using FramebufferInterface = IFramebuffer; + using PipelineResourceSignatureInterface = IPipelineResourceSignature; + + using RenderDeviceImplType = RenderDeviceGLImpl; + using DeviceContextImplType = DeviceContextGLImpl; + using PipelineStateImplType = PipelineStateGLImpl; + using ShaderResourceBindingImplType = ShaderResourceBindingGLImpl; + using BufferImplType = BufferGLImpl; + using BufferViewImplType = BufferViewGLImpl; + using TextureImplType = TextureBaseGL; + using TextureViewImplType = TextureViewGLImpl; + using ShaderImplType = ShaderGLImpl; + using SamplerImplType = SamplerGLImpl; + using FenceImplType = FenceGLImpl; + using QueryImplType = QueryGLImpl; + using RenderPassImplType = RenderPassGLImpl; + using FramebufferImplType = FramebufferGLImpl; + using BottomLevelASImplType = BottomLevelASGLImpl; + using TopLevelASImplType = TopLevelASGLImpl; + using ShaderBindingTableImplType = ShaderBindingTableGLImpl; + using PipelineResourceSignatureImplType = PipelineResourceSignatureGLImpl; + + using BuffViewObjAllocatorType = FixedBlockMemoryAllocator; + using TexViewObjAllocatorType = FixedBlockMemoryAllocator; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.hpp index ba99aa71..108a676d 100644 --- a/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.hpp @@ -40,13 +40,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Fence object implementation in OpenGL backend. -class FenceGLImpl final : public FenceBase +class FenceGLImpl final : public FenceBase { public: - using TFenceBase = FenceBase; + using TFenceBase = FenceBase; FenceGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/include/FramebufferGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/FramebufferGLImpl.hpp index f7e604e2..67ddc685 100644 --- a/Graphics/GraphicsEngineOpenGL/include/FramebufferGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/FramebufferGLImpl.hpp @@ -40,13 +40,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Framebuffer implementation in OpenGL backend. -class FramebufferGLImpl final : public FramebufferBase +class FramebufferGLImpl final : public FramebufferBase { public: - using TFramebufferBase = FramebufferBase; + using TFramebufferBase = FramebufferBase; FramebufferGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp index 5c5d7c53..1966c12d 100644 --- a/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp @@ -57,10 +57,10 @@ const char* GetBindingRangeName(BINDING_RANGE Range); /// Implementation of the Diligent::PipelineResourceSignatureGLImpl class -class PipelineResourceSignatureGLImpl final : public PipelineResourceSignatureBase +class PipelineResourceSignatureGLImpl final : public PipelineResourceSignatureBase { public: - using TPipelineResourceSignatureBase = PipelineResourceSignatureBase; + using TPipelineResourceSignatureBase = PipelineResourceSignatureBase; PipelineResourceSignatureGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.hpp index 476a742b..2ba8fd21 100644 --- a/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.hpp @@ -41,13 +41,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Pipeline state object implementation in OpenGL backend. -class PipelineStateGLImpl final : public PipelineStateBase +class PipelineStateGLImpl final : public PipelineStateBase { public: - using TPipelineStateBase = PipelineStateBase; + using TPipelineStateBase = PipelineStateBase; PipelineStateGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDeviceGL, diff --git a/Graphics/GraphicsEngineOpenGL/include/QueryGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/QueryGLImpl.hpp index 8b69862b..b5a95fad 100644 --- a/Graphics/GraphicsEngineOpenGL/include/QueryGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/QueryGLImpl.hpp @@ -39,13 +39,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Query object implementation in OpenGL backend. -class QueryGLImpl final : public QueryBase +class QueryGLImpl final : public QueryBase { public: - using TQueryBase = QueryBase; + using TQueryBase = QueryBase; QueryGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp index 5342ed3e..a0821579 100644 --- a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp @@ -28,6 +28,8 @@ #pragma once #include + +#include "EngineGLImplTraits.hpp" #include "RenderDeviceBase.hpp" #include "GLContext.hpp" #include "VAOCache.hpp" @@ -38,54 +40,12 @@ namespace Diligent { - -class RenderDeviceGLImpl; -class PipelineStateGLImpl; -class ShaderResourceBindingGLImpl; -class BufferGLImpl; -class BufferViewGLImpl; -class TextureBaseGL; -class TextureViewGLImpl; -class ShaderGLImpl; -class SamplerGLImpl; -class FenceGLImpl; -class QueryGLImpl; -class RenderPassGLImpl; -class FramebufferGLImpl; -class BottomLevelASGLImpl; -class TopLevelASGLImpl; -class ShaderBindingTableGLImpl; -class PipelineResourceSignatureGLImpl; - -struct RenderDeviceGLImplTraits -{ - using BaseInterface = IGLDeviceBaseInterface; - - using RenderDeviceImplType = RenderDeviceGLImpl; - using PipelineStateImplType = PipelineStateGLImpl; - using ShaderResourceBindingImplType = ShaderResourceBindingGLImpl; - using BufferImplType = BufferGLImpl; - using BufferViewImplType = BufferViewGLImpl; - using TextureImplType = TextureBaseGL; - using TextureViewImplType = TextureViewGLImpl; - using ShaderImplType = ShaderGLImpl; - using SamplerImplType = SamplerGLImpl; - using FenceImplType = FenceGLImpl; - using QueryImplType = QueryGLImpl; - using RenderPassImplType = RenderPassGLImpl; - using FramebufferImplType = FramebufferGLImpl; - using BottomLevelASImplType = BottomLevelASGLImpl; - using TopLevelASImplType = TopLevelASGLImpl; - using ShaderBindingTableImplType = ShaderBindingTableGLImpl; - using PipelineResourceSignatureImplType = PipelineResourceSignatureGLImpl; -}; - /// Render device implementation in OpenGL backend. // RenderDeviceGLESImpl is inherited from RenderDeviceGLImpl -class RenderDeviceGLImpl : public RenderDeviceBase +class RenderDeviceGLImpl : public RenderDeviceBase { public: - using TRenderDeviceBase = RenderDeviceBase; + using TRenderDeviceBase = RenderDeviceBase; RenderDeviceGLImpl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, diff --git a/Graphics/GraphicsEngineOpenGL/include/RenderPassGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/RenderPassGLImpl.hpp index 0dc5f98d..f307ae15 100644 --- a/Graphics/GraphicsEngineOpenGL/include/RenderPassGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/RenderPassGLImpl.hpp @@ -40,10 +40,10 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Render pass implementation in Direct3D11 backend. -class RenderPassGLImpl final : public RenderPassBase +class RenderPassGLImpl final : public RenderPassBase { public: - using TRenderPassBase = RenderPassBase; + using TRenderPassBase = RenderPassBase; RenderPassGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/include/SamplerGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/SamplerGLImpl.hpp index 81705735..3dcc95e7 100644 --- a/Graphics/GraphicsEngineOpenGL/include/SamplerGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/SamplerGLImpl.hpp @@ -37,13 +37,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Sampler implementation in OpenGL backend. -class SamplerGLImpl final : public SamplerBase +class SamplerGLImpl final : public SamplerBase { public: - using TSamplerBase = SamplerBase; + using TSamplerBase = SamplerBase; SamplerGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDeviceGL, const SamplerDesc& SamplerDesc, bool bIsDeviceInternal = false); ~SamplerGLImpl(); diff --git a/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.hpp index b958d59d..31c4686b 100644 --- a/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.hpp @@ -38,8 +38,6 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - inline GLenum GetGLShaderType(SHADER_TYPE ShaderType) { switch (ShaderType) @@ -73,10 +71,10 @@ inline GLenum ShaderTypeToGLShaderBit(SHADER_TYPE ShaderType) } /// Shader object implementation in OpenGL backend. -class ShaderGLImpl final : public ShaderBase +class ShaderGLImpl final : public ShaderBase { public: - using TShaderBase = ShaderBase; + using TShaderBase = ShaderBase; ShaderGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDeviceGL, diff --git a/Graphics/GraphicsEngineOpenGL/include/ShaderResourceBindingGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/ShaderResourceBindingGLImpl.hpp index 08efc5fe..5c585383 100644 --- a/Graphics/GraphicsEngineOpenGL/include/ShaderResourceBindingGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/ShaderResourceBindingGLImpl.hpp @@ -42,10 +42,10 @@ namespace Diligent { /// Shader resource binding object implementation in OpenGL backend. -class ShaderResourceBindingGLImpl final : public ShaderResourceBindingBase +class ShaderResourceBindingGLImpl final : public ShaderResourceBindingBase { public: - using TBase = ShaderResourceBindingBase; + using TBase = ShaderResourceBindingBase; ShaderResourceBindingGLImpl(IReferenceCounters* pRefCounters, PipelineResourceSignatureGLImpl* pPRS); diff --git a/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.hpp b/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.hpp index 6b507c67..2d4101ea 100644 --- a/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.hpp @@ -39,13 +39,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Base implementation of a texture object in OpenGL backend. -class TextureBaseGL : public TextureBase, public AsyncWritableResource +class TextureBaseGL : public TextureBase, public AsyncWritableResource { public: - using TTextureBase = TextureBase; + using TTextureBase = TextureBase; using ViewImplType = TextureViewGLImpl; TextureBaseGL(IReferenceCounters* pRefCounters, diff --git a/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.hpp index 47e110a5..ae50f76c 100644 --- a/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.hpp @@ -40,10 +40,10 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Texture view implementation in OpenGL backend. -class TextureViewGLImpl final : public TextureViewBase +class TextureViewGLImpl final : public TextureViewBase { public: - using TTextureViewBase = TextureViewBase; + using TTextureViewBase = TextureViewBase; TextureViewGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderVariableGL.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderVariableGL.cpp index aa36a7aa..be2312de 100644 --- a/Graphics/GraphicsEngineOpenGL/src/ShaderVariableGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/ShaderVariableGL.cpp @@ -223,6 +223,7 @@ void ShaderVariableManagerGL::DestroyVariables(IMemoryAllocator& Allocator) ssbo.~StorageBufferBindInfo(); }); + Allocator.Free(m_ResourceBuffer); m_ResourceBuffer = nullptr; } -- cgit v1.2.3