From 16dd04efc73e4093a991a517f786ebaf03f3f6d1 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 24 Jul 2020 21:18:48 -0700 Subject: Added framebuffer object implementation stubs --- Graphics/GraphicsEngine/CMakeLists.txt | 1 + .../GraphicsEngine/include/FramebufferBase.hpp | 77 ++++++++++++++++++++++ .../GraphicsEngine/include/RenderDeviceBase.hpp | 29 ++++---- Graphics/GraphicsEngine/include/RenderPassBase.hpp | 2 +- Graphics/GraphicsEngine/interface/RenderDevice.h | 14 ++++ 5 files changed, 110 insertions(+), 13 deletions(-) create mode 100644 Graphics/GraphicsEngine/include/FramebufferBase.hpp (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/CMakeLists.txt b/Graphics/GraphicsEngine/CMakeLists.txt index 7a8a4715..daafe96e 100644 --- a/Graphics/GraphicsEngine/CMakeLists.txt +++ b/Graphics/GraphicsEngine/CMakeLists.txt @@ -13,6 +13,7 @@ set(INCLUDE include/EngineFactoryBase.hpp include/EngineMemory.h include/FenceBase.hpp + include/FramebufferBase.hpp include/pch.h include/PipelineStateBase.hpp include/QueryBase.hpp diff --git a/Graphics/GraphicsEngine/include/FramebufferBase.hpp b/Graphics/GraphicsEngine/include/FramebufferBase.hpp new file mode 100644 index 00000000..ad33e9c0 --- /dev/null +++ b/Graphics/GraphicsEngine/include/FramebufferBase.hpp @@ -0,0 +1,77 @@ +/* + * Copyright 2019-2020 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 +/// Implementation of the Diligent::FramebufferBase template class + +#include "Framebuffer.h" +#include "DeviceObjectBase.hpp" +#include "RenderDeviceBase.hpp" + +namespace Diligent +{ + +void ValidateFramebufferDesc(const FramebufferDesc& Desc); + +/// Template class implementing base functionality for the framebuffer object. + +/// \tparam BaseInterface - base interface that this class will inheret +/// (e.g. Diligent::IFramebufferVk). +/// \tparam RenderDeviceImplType - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) +template +class FramebufferBase : public DeviceObjectBase +{ +public: + using TDeviceObjectBase = DeviceObjectBase; + + /// \param pRefCounters - reference counters object that controls the lifetime of this framebuffer pass. + /// \param pDevice - pointer to the device. + /// \param Desc - Framebuffer description. + /// \param bIsDeviceInternal - flag indicating if the Framebuffer is an internal device object and + /// must not keep a strong reference to the device. + FramebufferBase(IReferenceCounters* pRefCounters, + RenderDeviceImplType* pDevice, + const FramebufferDesc& Desc, + bool bIsDeviceInternal = false) : + TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal} + { + } + + ~FramebufferBase() + { + } + + IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_Framebuffer, TDeviceObjectBase) + +private: +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp b/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp index 854e5ec9..a0ffeda6 100644 --- a/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp +++ b/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp @@ -223,6 +223,9 @@ public: /// Size of the render pass object (RenderPassD3D12Impl, RenderPassVkImpl, etc.), in bytes const size_t RenderPassObjSize; + + /// Size of the framebuffer object (FramebufferD3D12Impl, FramebufferVkImpl, etc.), in bytes + const size_t FramebufferObjSize; }; /// \param pRefCounters - reference counters object that controls the lifetime of this render device @@ -246,18 +249,19 @@ public: m_TexFmtInfoInitFlags (TEX_FORMAT_NUM_FORMATS, false, STD_ALLOCATOR_RAW_MEM(bool, RawMemAllocator, "Allocator for vector")), m_wpDeferredContexts (NumDeferredContexts, RefCntWeakPtr(), STD_ALLOCATOR_RAW_MEM(RefCntWeakPtr, RawMemAllocator, "Allocator for vector< RefCntWeakPtr >")), m_RawMemAllocator {RawMemAllocator}, - m_TexObjAllocator {RawMemAllocator, ObjectSizes.TextureObjSize, 64 }, - m_TexViewObjAllocator {RawMemAllocator, ObjectSizes.TexViewObjSize, 64 }, - m_BufObjAllocator {RawMemAllocator, ObjectSizes.BufferObjSize, 128 }, - m_BuffViewObjAllocator {RawMemAllocator, ObjectSizes.BuffViewObjSize, 128 }, - m_ShaderObjAllocator {RawMemAllocator, ObjectSizes.ShaderObjSize, 32 }, - m_SamplerObjAllocator {RawMemAllocator, ObjectSizes.SamplerObjSize, 32 }, - m_PSOAllocator {RawMemAllocator, ObjectSizes.PSOSize, 128 }, - m_SRBAllocator {RawMemAllocator, ObjectSizes.SRBSize, 1024}, - m_ResMappingAllocator {RawMemAllocator, sizeof(ResourceMappingImpl), 16 }, - m_FenceAllocator {RawMemAllocator, ObjectSizes.FenceSize, 16 }, - m_QueryAllocator {RawMemAllocator, ObjectSizes.QuerySize, 16 }, - m_RenderPassAllocator {RawMemAllocator, ObjectSizes.RenderPassObjSize, 16 } + m_TexObjAllocator {RawMemAllocator, ObjectSizes.TextureObjSize, 64 }, + m_TexViewObjAllocator {RawMemAllocator, ObjectSizes.TexViewObjSize, 64 }, + m_BufObjAllocator {RawMemAllocator, ObjectSizes.BufferObjSize, 128 }, + m_BuffViewObjAllocator {RawMemAllocator, ObjectSizes.BuffViewObjSize, 128 }, + m_ShaderObjAllocator {RawMemAllocator, ObjectSizes.ShaderObjSize, 32 }, + m_SamplerObjAllocator {RawMemAllocator, ObjectSizes.SamplerObjSize, 32 }, + m_PSOAllocator {RawMemAllocator, ObjectSizes.PSOSize, 128 }, + m_SRBAllocator {RawMemAllocator, ObjectSizes.SRBSize, 1024}, + m_ResMappingAllocator {RawMemAllocator, sizeof(ResourceMappingImpl), 16 }, + m_FenceAllocator {RawMemAllocator, ObjectSizes.FenceSize, 16 }, + m_QueryAllocator {RawMemAllocator, ObjectSizes.QuerySize, 16 }, + m_RenderPassAllocator {RawMemAllocator, ObjectSizes.RenderPassObjSize, 16 }, + m_FramebufferAllocator {RawMemAllocator, ObjectSizes.FramebufferObjSize, 16 } // clang-format on { // Initialize texture format info @@ -431,6 +435,7 @@ protected: FixedBlockMemoryAllocator m_FenceAllocator; ///< Allocator for fence objects FixedBlockMemoryAllocator m_QueryAllocator; ///< Allocator for query objects FixedBlockMemoryAllocator m_RenderPassAllocator; ///< Allocator for render pass objects + FixedBlockMemoryAllocator m_FramebufferAllocator; ///< Allocator for framebuffer objects }; diff --git a/Graphics/GraphicsEngine/include/RenderPassBase.hpp b/Graphics/GraphicsEngine/include/RenderPassBase.hpp index a8d73dc2..8099abb2 100644 --- a/Graphics/GraphicsEngine/include/RenderPassBase.hpp +++ b/Graphics/GraphicsEngine/include/RenderPassBase.hpp @@ -42,7 +42,7 @@ void ValidateRenderPassDesc(const RenderPassDesc& Desc); /// Template class implementing base functionality for the render pass object. /// \tparam BaseInterface - base interface that this class will inheret -/// (Diligent::IRenderPassVk). +/// (e.g. Diligent::IRenderPassVk). /// \tparam RenderDeviceImplType - type of the render device implementation /// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, /// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) diff --git a/Graphics/GraphicsEngine/interface/RenderDevice.h b/Graphics/GraphicsEngine/interface/RenderDevice.h index 24c641bc..ddbc75b2 100644 --- a/Graphics/GraphicsEngine/interface/RenderDevice.h +++ b/Graphics/GraphicsEngine/interface/RenderDevice.h @@ -47,6 +47,7 @@ #include "Fence.h" #include "Query.h" #include "RenderPass.h" +#include "Framebuffer.h" #include "DepthStencilState.h" #include "RasterizerState.h" @@ -201,6 +202,19 @@ DILIGENT_BEGIN_INTERFACE(IRenderDevice, IObject) IRenderPass** ppRenderPass) PURE; + + /// Creates a framebuffer object + + /// \param [in] Desc - Framebuffer description, see Diligent::FramebufferDesc for details. + /// \param [out] ppFramebuffer - Address of the memory location where the pointer to the + /// framebuffer interface will be stored. + /// The function calls AddRef(), so that the new object will contain + /// one reference. + VIRTUAL void METHOD(CreateFramebuffer)(THIS_ + const FramebufferDesc REF Desc, + IFramebuffer** ppFramebuffer) PURE; + + /// Gets the device capabilities, see Diligent::DeviceCaps for details VIRTUAL const DeviceCaps REF METHOD(GetDeviceCaps)(THIS) CONST PURE; -- cgit v1.2.3