summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-07-25 05:59:29 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-08-02 19:21:37 +0000
commit955768292c4316f6e12c7cceff330a203a756337 (patch)
tree5e061c93383ec9de08991fe02d42f184508b9b39 /Graphics/GraphicsEngine
parentAdded framebuffer object implementation stubs (diff)
downloadDiligentCore-955768292c4316f6e12c7cceff330a203a756337.tar.gz
DiligentCore-955768292c4316f6e12c7cceff330a203a756337.zip
Implemente framebuffer in Vulkan
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/FramebufferBase.hpp44
-rw-r--r--Graphics/GraphicsEngine/interface/Framebuffer.h14
-rw-r--r--Graphics/GraphicsEngine/interface/GraphicsTypes.h7
3 files changed, 55 insertions, 10 deletions
diff --git a/Graphics/GraphicsEngine/include/FramebufferBase.hpp b/Graphics/GraphicsEngine/include/FramebufferBase.hpp
index ad33e9c0..6bf77918 100644
--- a/Graphics/GraphicsEngine/include/FramebufferBase.hpp
+++ b/Graphics/GraphicsEngine/include/FramebufferBase.hpp
@@ -33,6 +33,8 @@
#include "Framebuffer.h"
#include "DeviceObjectBase.hpp"
#include "RenderDeviceBase.hpp"
+#include "TextureView.h"
+#include "GraphicsAccessories.hpp"
namespace Diligent
{
@@ -63,15 +65,57 @@ public:
bool bIsDeviceInternal = false) :
TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal}
{
+ if (Desc.pRenderPass == nullptr)
+ {
+ LOG_ERROR_AND_THROW("Render pass must not be null");
+ }
+
+ if (this->m_Desc.AttachmentCount > 0)
+ {
+ m_ppAttachments =
+ ALLOCATE(GetRawAllocator(), "Memory for framebuffer attachment array", ITextureView*, this->m_Desc.AttachmentCount);
+ this->m_Desc.ppAttachments = m_ppAttachments;
+ for (Uint32 i = 0; i < this->m_Desc.AttachmentCount; ++i)
+ {
+ m_ppAttachments[i] = Desc.ppAttachments[i];
+ m_ppAttachments[i]->AddRef();
+
+ if ((this->m_Desc.Width == 0 || this->m_Desc.Height == 0 || this->m_Desc.NumArraySlices == 0) && m_ppAttachments[i] != nullptr)
+ {
+ const auto& ViewDesc = m_ppAttachments[i]->GetDesc();
+ const auto& TexDesc = m_ppAttachments[i]->GetTexture()->GetDesc();
+
+ auto MipLevelProps = GetMipLevelProperties(TexDesc, ViewDesc.MostDetailedMip);
+ if (this->m_Desc.Width == 0)
+ this->m_Desc.Width = MipLevelProps.LogicalWidth;
+ if (this->m_Desc.Height == 0)
+ this->m_Desc.Height = MipLevelProps.LogicalHeight;
+ if (this->m_Desc.NumArraySlices == 0)
+ this->m_Desc.NumArraySlices = ViewDesc.NumArraySlices;
+ }
+ }
+ }
+ Desc.pRenderPass->AddRef();
}
~FramebufferBase()
{
+ if (this->m_Desc.AttachmentCount > 0)
+ {
+ VERIFY_EXPR(m_ppAttachments != nullptr);
+ for (Uint32 i = 0; i < this->m_Desc.AttachmentCount; ++i)
+ {
+ m_ppAttachments[i]->Release();
+ }
+ GetRawAllocator().Free(m_ppAttachments);
+ }
+ this->m_Desc.pRenderPass->Release();
}
IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_Framebuffer, TDeviceObjectBase)
private:
+ ITextureView** m_ppAttachments = nullptr;
};
} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/Framebuffer.h b/Graphics/GraphicsEngine/interface/Framebuffer.h
index c8bed172..9b00ea70 100644
--- a/Graphics/GraphicsEngine/interface/Framebuffer.h
+++ b/Graphics/GraphicsEngine/interface/Framebuffer.h
@@ -46,22 +46,22 @@ static const struct INTERFACE_ID IID_Framebuffer =
struct FramebufferDesc DILIGENT_DERIVE(DeviceObjectAttribs)
/// Render pass that the framebuffer will be compatible with.
- IRenderPass* pRenderPass DEFAULT_INITIALIZER(nullptr);
+ IRenderPass* pRenderPass DEFAULT_INITIALIZER(nullptr);
/// The number of attachments.
- Uint32 AttachmentCount DEFAULT_INITIALIZER(0);
+ Uint32 AttachmentCount DEFAULT_INITIALIZER(0);
/// Pointer to the array of attachments.
- const ITextureView* pAttachments DEFAULT_INITIALIZER(nullptr);
+ ITextureView* const* ppAttachments DEFAULT_INITIALIZER(nullptr);
/// Width of the framebuffer.
- Uint32 Width DEFAULT_INITIALIZER(0);
+ Uint32 Width DEFAULT_INITIALIZER(0);
/// Height of the framebuffer.
- Uint32 Height DEFAULT_INITIALIZER(0);
+ Uint32 Height DEFAULT_INITIALIZER(0);
- /// The number of layers in the framebuffer.
- Uint32 Layers DEFAULT_INITIALIZER(0);
+ /// The number of array slices in the framebuffer.
+ Uint32 NumArraySlices DEFAULT_INITIALIZER(0);
};
typedef struct FramebufferDesc FramebufferDesc;
diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
index 0d0631b7..a6612158 100644
--- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h
+++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
@@ -84,7 +84,8 @@ DILIGENT_TYPED_ENUM(BIND_FLAGS, Uint32)
BIND_RENDER_TARGET = 0x20L,///< A texture can be bound as a render target
BIND_DEPTH_STENCIL = 0x40L,///< A texture can be bound as a depth-stencil target
BIND_UNORDERED_ACCESS = 0x80L,///< A buffer or a texture can be bound as an unordered access view
- BIND_INDIRECT_DRAW_ARGS = 0x100L///< A buffer can be bound as the source buffer for indirect draw commands
+ BIND_INDIRECT_DRAW_ARGS = 0x100L,///< A buffer can be bound as the source buffer for indirect draw commands
+ BIND_INPUT_ATTACHMENT = 0x200L ///< A texture can be used as render pass input attachment
};
DEFINE_FLAG_ENUM_OPERATORS(BIND_FLAGS)
@@ -1372,8 +1373,8 @@ typedef struct EngineCreateInfo EngineCreateInfo;
/// Attributes of the OpenGL-based engine implementation
struct EngineGLCreateInfo DILIGENT_DERIVE(EngineCreateInfo)
- /// Native window wrapper
- NativeWindow Window;
+ /// Native window wrapper
+ NativeWindow Window;
/// Create debug OpenGL context and enable debug output.