From: adam.b Date: Fri, 25 May 2018 13:45:50 +0000 (+0100) Subject: [Vulkan] Support for clear color in Swapchain X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c79fa0d57c7830dbf20214cb34c7467cfbd6b4e7;p=platform%2Fcore%2Fuifw%2Fdali-core.git [Vulkan] Support for clear color in Swapchain Change-Id: I69c0f44539183a915b7a6309b5bc5ede3ced69a7 --- diff --git a/dali/graphics/vulkan/vulkan-pipeline-cache.h b/dali/graphics/vulkan/vulkan-pipeline-cache.h index a8bba0b..17617ea 100644 --- a/dali/graphics/vulkan/vulkan-pipeline-cache.h +++ b/dali/graphics/vulkan/vulkan-pipeline-cache.h @@ -20,7 +20,7 @@ // INTERNAL INCLUDES #include - +#include namespace Dali { namespace Graphics @@ -34,10 +34,13 @@ struct PipelineDescription ShaderRef vertexShader; ShaderRef fragmentShader; + API::RenderCommand::RenderState::BlendState blendState; + bool operator==(const PipelineDescription& description) const { return (vertexShader == description.vertexShader) && - (fragmentShader == description.fragmentShader); + (fragmentShader == description.fragmentShader) && + (std::memcmp( &blendState, &description.blendState, sizeof(blendState) )); } std::vector descriptorSetLayouts; diff --git a/dali/graphics/vulkan/vulkan-swapchain.cpp b/dali/graphics/vulkan/vulkan-swapchain.cpp index a7c858c..35dcc06 100644 --- a/dali/graphics/vulkan/vulkan-swapchain.cpp +++ b/dali/graphics/vulkan/vulkan-swapchain.cpp @@ -255,7 +255,6 @@ struct Swapchain::Impl mQueue.Submit( cmdBuffer, FenceRef{} ); mQueue.WaitIdle(); } -#pragma GCC diagnostic pop bool SetImageFormat() { @@ -439,14 +438,13 @@ struct Swapchain::Impl } swapBuffer.firstUse = false; - // Begins primary render pass - BeginPrimaryRenderPass( swapBuffer ); - return swapBuffer.framebuffer; } -#pragma GCC diagnostic pop - void BeginPrimaryRenderPass( SwapchainBuffer& currentBuffer ) + + void BeginPrimaryRenderPass() { + auto& currentBuffer = mSwapchainBuffer[mCurrentBufferIndex]; + vk::RenderPassBeginInfo rpInfo{}; rpInfo.setRenderPass( currentBuffer.framebuffer->GetVkRenderPass() ) .setFramebuffer( currentBuffer.framebuffer->GetVkFramebuffer() ) @@ -457,6 +455,28 @@ struct Swapchain::Impl currentBuffer.masterCmdBuffer->BeginRenderPass( rpInfo, vk::SubpassContents::eSecondaryCommandBuffers ); } + void BeginPrimaryRenderPass( std::vector> colors ) + { + auto& currentBuffer = mSwapchainBuffer[mCurrentBufferIndex]; + + vk::RenderPassBeginInfo rpInfo{}; + + auto newColors = currentBuffer.framebuffer->GetDefaultClearValues(); + newColors[0].color.setFloat32( { colors[0][0], + colors[0][1], + colors[0][2], + colors[0][3] + } ); + + rpInfo.setRenderArea( vk::Rect2D( {0, 0}, mSurface->GetSize() ) ) + .setRenderPass( currentBuffer.framebuffer->GetVkRenderPass() ) + .setFramebuffer( currentBuffer.framebuffer->GetVkFramebuffer() ) + .setPClearValues( newColors.data() ) + .setClearValueCount( U32( currentBuffer.framebuffer->GetDefaultClearValues().size() ) ); + + currentBuffer.masterCmdBuffer->BeginRenderPass( rpInfo, vk::SubpassContents::eSecondaryCommandBuffers ); + } + void EndPrimaryRenderPass( SwapchainBuffer& currentBuffer ) { currentBuffer.masterCmdBuffer->EndRenderPass(); @@ -468,8 +488,6 @@ struct Swapchain::Impl * The master command buffer must be in the recording state * @param swapBuffer */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wframe-larger-than=" void UpdateLayoutPresentToColorAttachment( SwapchainBuffer& swapBuffer ) { auto& cmdBuf = swapBuffer.masterCmdBuffer; @@ -501,7 +519,6 @@ struct Swapchain::Impl std::vector{}, barriers ); } -#pragma GCC diagnostic pop CommandBufferRef GetPrimaryCommandBuffer() const { @@ -639,6 +656,17 @@ CommandBufferRef Swapchain::GetPrimaryCommandBuffer() const return mImpl->GetPrimaryCommandBuffer(); } +void Swapchain::BeginPrimaryRenderPass() +{ + mImpl->BeginPrimaryRenderPass( ); +} + +void Swapchain::BeginPrimaryRenderPass( std::vector> colors ) +{ + mImpl->BeginPrimaryRenderPass( colors ); +} + + } // namespace Vulkan } // namespace Graphics } // namespace Dali diff --git a/dali/graphics/vulkan/vulkan-swapchain.h b/dali/graphics/vulkan/vulkan-swapchain.h index 23141f9..9081f85 100644 --- a/dali/graphics/vulkan/vulkan-swapchain.h +++ b/dali/graphics/vulkan/vulkan-swapchain.h @@ -71,6 +71,17 @@ public: CommandBufferRef GetPrimaryCommandBuffer() const; /** + * Begins primary render pass, must be called after acquiring new image + */ + void BeginPrimaryRenderPass(); + + /** + * Begins primary render pass, must be called after acquiring new image + * @param beginInfo custom initialisation structure + */ + void BeginPrimaryRenderPass( std::vector> colors ); + + /** * Presents using default present queue, asynchronously */ void Present();