From 9ac95d011364e3d70bb6f111bf30ef610e6afe59 Mon Sep 17 00:00:00 2001 From: David Steele Date: Thu, 12 Sep 2024 19:22:12 +0100 Subject: [PATCH] Adding render pass to secondary command buffer Need to retrieve the actual render pass from the current framebuffer, so the begin info needs the render target. Change-Id: I17c65e6b010177091fa0bc2233b0e44455df2569 --- .../graphics/vulkan-impl/vulkan-command-buffer.cpp | 11 +++++++- .../graphics/vulkan-impl/vulkan-pipeline-impl.cpp | 10 ++++--- .../graphics/vulkan-impl/vulkan-render-target.cpp | 33 ++++++++++++++++++++-- .../graphics/vulkan-impl/vulkan-render-target.h | 7 +++++ 4 files changed, 53 insertions(+), 8 deletions(-) diff --git a/dali/internal/graphics/vulkan-impl/vulkan-command-buffer.cpp b/dali/internal/graphics/vulkan-impl/vulkan-command-buffer.cpp index 6e8989e..43a1dc4 100644 --- a/dali/internal/graphics/vulkan-impl/vulkan-command-buffer.cpp +++ b/dali/internal/graphics/vulkan-impl/vulkan-command-buffer.cpp @@ -68,7 +68,16 @@ void CommandBuffer::Begin(const Graphics::CommandBufferBeginInfo& info) { if(mCommandBufferImpl) { - mCommandBufferImpl->Begin(static_cast(info.usage), nullptr); + vk::CommandBufferInheritanceInfo inheritanceInfo{}; + if(info.renderPass) + { + auto renderTarget = ConstGraphicsCast(info.renderTarget); + inheritanceInfo.renderPass = renderTarget->GetRenderPass(info.renderPass)->GetVkHandle(); + inheritanceInfo.subpass = 0; + inheritanceInfo.queryFlags = static_cast(0); + inheritanceInfo.pipelineStatistics = static_cast(0); + } + mCommandBufferImpl->Begin(static_cast(info.usage), &inheritanceInfo); } } diff --git a/dali/internal/graphics/vulkan-impl/vulkan-pipeline-impl.cpp b/dali/internal/graphics/vulkan-impl/vulkan-pipeline-impl.cpp index 8bb63ca..cbc2d37 100644 --- a/dali/internal/graphics/vulkan-impl/vulkan-pipeline-impl.cpp +++ b/dali/internal/graphics/vulkan-impl/vulkan-pipeline-impl.cpp @@ -261,10 +261,12 @@ void PipelineImpl::InitializePipeline() dynInfo.setDynamicStates(mDynamicStates); gfxPipelineInfo.setPDynamicState(&dynInfo); - auto& allocator = mController.GetGraphicsDevice().GetAllocator(); - auto rtImpl = static_cast(mCreateInfo.renderTarget); - auto framebuffer = rtImpl->GetFramebuffer(); - auto surface = rtImpl->GetSurface(); + auto& allocator = mController.GetGraphicsDevice().GetAllocator(); + + auto rtImpl = static_cast(mCreateInfo.renderTarget); + + auto framebuffer = rtImpl->GetFramebuffer(); + auto surface = rtImpl->GetSurface(); FramebufferImpl* fbImpl = nullptr; if(surface) diff --git a/dali/internal/graphics/vulkan-impl/vulkan-render-target.cpp b/dali/internal/graphics/vulkan-impl/vulkan-render-target.cpp index 822c44d..0ea7a73 100644 --- a/dali/internal/graphics/vulkan-impl/vulkan-render-target.cpp +++ b/dali/internal/graphics/vulkan-impl/vulkan-render-target.cpp @@ -16,12 +16,16 @@ */ // CLASS HEADER -#include "vulkan-render-target.h" +#include // INTERNAL INCLUDES #include -#include "vulkan-framebuffer.h" -#include "vulkan-graphics-controller.h" +#include +#include +#include +#include +#include +#include namespace Dali::Graphics::Vulkan { @@ -63,4 +67,27 @@ Integration::RenderSurfaceInterface* RenderTarget::GetSurface() const return mCreateInfo.surface; } +Vulkan::RenderPassImpl* RenderTarget::GetRenderPass(const Graphics::RenderPass* gfxRenderPass) const +{ + auto renderPass = const_cast(static_cast(gfxRenderPass)); + + auto framebuffer = GetFramebuffer(); + auto surface = GetSurface(); + + FramebufferImpl* fbImpl = nullptr; + if(surface) + { + auto& gfxDevice = mController.GetGraphicsDevice(); + auto surfaceId = static_cast(surface)->GetSurfaceId(); + auto swapchain = gfxDevice.GetSwapchainForSurfaceId(surfaceId); + fbImpl = swapchain->GetCurrentFramebuffer(); + } + else if(framebuffer) + { + fbImpl = framebuffer->GetImpl(); + } + + return fbImpl->GetRenderPass(renderPass); +} + } // namespace Dali::Graphics::Vulkan diff --git a/dali/internal/graphics/vulkan-impl/vulkan-render-target.h b/dali/internal/graphics/vulkan-impl/vulkan-render-target.h index 72392b7..3002a3a 100644 --- a/dali/internal/graphics/vulkan-impl/vulkan-render-target.h +++ b/dali/internal/graphics/vulkan-impl/vulkan-render-target.h @@ -28,6 +28,7 @@ namespace Dali::Graphics::Vulkan { class Framebuffer; class Surface; +class RenderPassImpl; using RenderTargetResource = Resource; @@ -69,6 +70,12 @@ public: */ [[nodiscard]] Integration::RenderSurfaceInterface* GetSurface() const; + /** + * Find a matching render pass for this render target + * @param[in] renderPass A render pass to search for + * @return a matching render pass implementation from the current framebuffer + */ + [[nodiscard]] Vulkan::RenderPassImpl* GetRenderPass(const Graphics::RenderPass* renderPass) const; // Get Swapchain? private: -- 2.7.4