CommandBuffer::CommandBuffer(const Graphics::CommandBufferCreateInfo& createInfo, VulkanGraphicsController& controller)
: CommandBufferResource(createInfo, controller),
- mDynamicStateMask(CommandBuffer::INITIAL_DYNAMIC_MASK_VALUE),
- mCommandBufferImpl(nullptr)
+ mDynamicStateMask(CommandBuffer::INITIAL_DYNAMIC_MASK_VALUE)
{
auto& device = controller.GetGraphicsDevice();
bool isPrimary = true;
{
isPrimary = false;
}
- auto commandPool = device.GetCommandPool(std::this_thread::get_id());
- mCommandBufferImpl = commandPool->NewCommandBuffer(isPrimary);
+ auto commandPool = device.GetCommandPool(std::this_thread::get_id());
+ for(uint32_t i = 0; i < device.GetBufferCount(); ++i)
+ {
+ mCommandBufferImpl.emplace_back(commandPool->NewCommandBuffer(isPrimary));
+ }
}
CommandBuffer::~CommandBuffer() = default;
{
// Don't delete the impl, it's pool allocated and should have been
// returned to the command pool for re-use.
- mCommandBufferImpl = nullptr;
+ mCommandBufferImpl.clear();
}
bool CommandBuffer::InitializeResource()
void CommandBuffer::Begin(const Graphics::CommandBufferBeginInfo& info)
{
- mDynamicStateMask = CommandBuffer::INITIAL_DYNAMIC_MASK_VALUE;
- mRenderTarget = ConstGraphicsCast<Vulkan::RenderTarget, Graphics::RenderTarget>(info.renderTarget);
+ mDynamicStateMask = CommandBuffer::INITIAL_DYNAMIC_MASK_VALUE;
+ mRenderTarget = ConstGraphicsCast<Vulkan::RenderTarget, Graphics::RenderTarget>(info.renderTarget);
+ uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
- if(mCommandBufferImpl)
+ if(mCommandBufferImpl[bufferIndex])
{
+ DALI_LOG_INFO(gLogCmdBufferFilter, Debug::Verbose, "CommandBuffer::Begin: ptr:%p bufferIndex=%d", this, bufferIndex);
vk::CommandBufferInheritanceInfo inheritanceInfo{};
if(info.renderPass)
{
inheritanceInfo.queryFlags = static_cast<vk::QueryControlFlags>(0);
inheritanceInfo.pipelineStatistics = static_cast<vk::QueryPipelineStatisticFlags>(0);
}
- mCommandBufferImpl->Begin(static_cast<vk::CommandBufferUsageFlags>(info.usage), &inheritanceInfo);
+ mCommandBufferImpl[bufferIndex]->Begin(static_cast<vk::CommandBufferUsageFlags>(info.usage), &inheritanceInfo);
// Default depth/stencil should be off:
SetDepthTestEnable(false);
void CommandBuffer::End()
{
- if(mCommandBufferImpl)
+ uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
{
- mCommandBufferImpl->End();
+ mCommandBufferImpl[bufferIndex]->End();
}
}
void CommandBuffer::Reset()
{
- if(mCommandBufferImpl)
+ uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ DALI_LOG_INFO(gLogCmdBufferFilter, Debug::Verbose, "CommandBuffer::Reset: ptr:%p bufferIndex=%d", this, bufferIndex);
+
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
{
- mCommandBufferImpl->Reset();
+ mCommandBufferImpl[bufferIndex]->Reset();
}
mDynamicStateMask = CommandBuffer::INITIAL_DYNAMIC_MASK_VALUE;
mRenderTarget = nullptr;
const std::vector<const Graphics::Buffer*>& gfxBuffers,
const std::vector<uint32_t>& offsets)
{
+ uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
std::vector<BufferImpl*> buffers;
buffers.reserve(gfxBuffers.size());
for(auto& gfxBuffer : gfxBuffers)
{
buffers.push_back(ConstGraphicsCast<Buffer, Graphics::Buffer>(gfxBuffer)->GetImpl());
}
- mCommandBufferImpl->BindVertexBuffers(firstBinding, buffers, offsets);
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
+ {
+ mCommandBufferImpl[bufferIndex]->BindVertexBuffers(firstBinding, buffers, offsets);
+ }
}
void CommandBuffer::BindIndexBuffer(const Graphics::Buffer& gfxBuffer,
uint32_t offset,
Format format)
{
- auto indexBuffer = ConstGraphicsCast<Buffer, Graphics::Buffer>(&gfxBuffer);
- DALI_ASSERT_DEBUG(indexBuffer && indexBuffer->GetImpl());
- mCommandBufferImpl->BindIndexBuffer(*indexBuffer->GetImpl(), offset, format);
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
+ {
+ auto indexBuffer = ConstGraphicsCast<Buffer, Graphics::Buffer>(&gfxBuffer);
+ DALI_ASSERT_DEBUG(indexBuffer && indexBuffer->GetImpl());
+
+ mCommandBufferImpl[bufferIndex]->BindIndexBuffer(*indexBuffer->GetImpl(), offset, format);
+ }
}
void CommandBuffer::BindUniformBuffers(const std::vector<UniformBufferBinding>& bindings)
{
- mCommandBufferImpl->BindUniformBuffers(bindings);
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
+ {
+ mCommandBufferImpl[bufferIndex]->BindUniformBuffers(bindings);
+ }
}
void CommandBuffer::BindPipeline(const Graphics::Pipeline& pipeline)
{
- mCommandBufferImpl->BindPipeline(&pipeline);
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
+ {
+ mCommandBufferImpl[bufferIndex]->BindPipeline(&pipeline);
+ }
}
void CommandBuffer::BindTextures(const std::vector<TextureBinding>& textureBindings)
{
- mCommandBufferImpl->BindTextures(textureBindings);
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
+ {
+ mCommandBufferImpl[bufferIndex]->BindTextures(textureBindings);
+ }
mController.CheckTextureDependencies(textureBindings, mRenderTarget);
}
void CommandBuffer::BindSamplers(const std::vector<SamplerBinding>& samplerBindings)
{
- mCommandBufferImpl->BindSamplers(samplerBindings);
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
+ {
+ mCommandBufferImpl[bufferIndex]->BindSamplers(samplerBindings);
+ }
}
void CommandBuffer::BindPushConstants(void* data,
Rect2D renderArea,
const std::vector<ClearValue>& clearValues)
{
- auto renderTarget = static_cast<Vulkan::RenderTarget*>(gfxRenderTarget);
- DALI_ASSERT_DEBUG(mRenderTarget == renderTarget && "RenderPass has different render target to cmd buffer Begin");
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
- auto renderPass = static_cast<Vulkan::RenderPass*>(gfxRenderPass);
- auto surface = renderTarget->GetSurface();
- auto& device = mController.GetGraphicsDevice();
- FramebufferImpl* framebuffer = nullptr;
- RenderPassHandle renderPassImpl;
- if(surface)
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
{
- auto window = static_cast<Internal::Adaptor::WindowRenderSurface*>(surface);
- auto surfaceId = window->GetSurfaceId();
- auto swapchain = device.GetSwapchainForSurfaceId(surfaceId);
-
- // If we have swapchain then we need to acquire image
- // This is a special case:
- // We assume that:
- // - only one BeginRenderPass() happens per surface so we can acquire image here
- // - swapchain shouldn't change but in case it does hence the condition below (?)
- if(mLastSwapchain != swapchain)
+ auto renderTarget = static_cast<Vulkan::RenderTarget*>(gfxRenderTarget);
+ DALI_ASSERT_DEBUG(mRenderTarget == renderTarget && "RenderPass has different render target to cmd buffer Begin");
+
+ auto renderPass = static_cast<Vulkan::RenderPass*>(gfxRenderPass);
+ auto surface = mRenderTarget->GetSurface();
+ auto& device = mController.GetGraphicsDevice();
+ FramebufferImpl* framebuffer = nullptr;
+ RenderPassHandle renderPassImpl;
+ if(surface)
{
- mLastSwapchain = swapchain;
+ auto window = static_cast<Internal::Adaptor::WindowRenderSurface*>(surface);
+ auto surfaceId = window->GetSurfaceId();
+ auto swapchain = device.GetSwapchainForSurfaceId(surfaceId);
+ framebuffer = swapchain->GetCurrentFramebuffer();
+ renderPassImpl = framebuffer->GetImplFromRenderPass(renderPass);
}
-
- if(mLastSwapchain)
+ else
{
- framebuffer = mLastSwapchain->AcquireNextFramebuffer(true);
+ auto framebufferHandle = mRenderTarget->GetFramebuffer();
+ framebuffer = framebufferHandle->GetImpl();
+ renderPassImpl = framebuffer->GetImplFromRenderPass(renderPass);
+ mController.AddTextureDependencies(renderTarget);
}
- // In case something went wrong we will try to replace swapchain once
- // before calling it a day.
- if(!framebuffer || !swapchain->IsValid())
- {
- // make sure device doesn't do any work before replacing swapchain
- device.DeviceWaitIdle();
-
- // replace swapchain (only once)
- swapchain = device.ReplaceSwapchainForSurface(swapchain->GetSurface(), std::move(swapchain));
+ std::vector<vk::ClearValue> vkClearValues;
- mLastSwapchain = swapchain;
-
- // get new valid framebuffer
- if(mLastSwapchain)
+ auto attachments = renderPass->GetCreateInfo().attachments;
+ if(attachments != nullptr &&
+ !attachments->empty()) // Can specify clear color even if load op is not clear.
+ {
+ for(auto clearValue : clearValues)
{
- framebuffer = swapchain->AcquireNextFramebuffer(true);
+ vk::ClearColorValue color;
+ color.float32[0] = clearValue.color.r;
+ color.float32[1] = clearValue.color.g;
+ color.float32[2] = clearValue.color.b;
+ color.float32[3] = clearValue.color.a;
+ vkClearValues.emplace_back(color);
}
- DALI_ASSERT_ALWAYS(framebuffer && "Replacing invalid swapchain unsuccessful! Goodbye!");
}
- renderPassImpl = framebuffer->GetImplFromRenderPass(renderPass);
- }
- else
- {
- auto coreFramebuffer = renderTarget->GetFramebuffer();
- framebuffer = coreFramebuffer->GetImpl();
- renderPassImpl = framebuffer->GetImplFromRenderPass(renderPass);
- mController.AddTextureDependencies(renderTarget);
- }
-
- std::vector<vk::ClearValue> vkClearValues;
-
- auto attachments = renderPass->GetCreateInfo().attachments;
- if(attachments != nullptr &&
- !attachments->empty()) // Can specify clear color even if load op is not clear.
- {
- for(auto clearValue : clearValues)
- {
- vk::ClearColorValue color;
- color.float32[0] = clearValue.color.r;
- color.float32[1] = clearValue.color.g;
- color.float32[2] = clearValue.color.b;
- color.float32[3] = clearValue.color.a;
- vkClearValues.emplace_back(color);
- }
+ mCommandBufferImpl[bufferIndex]->BeginRenderPass(vk::RenderPassBeginInfo{}
+ .setFramebuffer(framebuffer->GetVkHandle())
+ .setRenderPass(renderPassImpl->GetVkHandle())
+ .setRenderArea({{0, 0}, {renderArea.width, renderArea.height}})
+ .setPClearValues(vkClearValues.data())
+ .setClearValueCount(uint32_t(vkClearValues.size())),
+ vk::SubpassContents::eSecondaryCommandBuffers);
}
-
- mCommandBufferImpl->BeginRenderPass(vk::RenderPassBeginInfo{}
- .setFramebuffer(framebuffer->GetVkHandle())
- .setRenderPass(renderPassImpl->GetVkHandle())
- .setRenderArea({{0, 0}, {renderArea.width, renderArea.height}})
- .setPClearValues(vkClearValues.data())
- .setClearValueCount(uint32_t(vkClearValues.size())),
- vk::SubpassContents::eSecondaryCommandBuffers);
}
void CommandBuffer::EndRenderPass(Graphics::SyncObject* syncObject)
{
- mCommandBufferImpl->EndRenderPass();
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
+ {
+ mCommandBufferImpl[bufferIndex]->EndRenderPass();
+ }
}
void CommandBuffer::ReadPixels(uint8_t* buffer)
{
- mCommandBufferImpl->ReadPixels(buffer);
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
+ {
+ mCommandBufferImpl[bufferIndex]->ReadPixels(buffer);
+ }
}
void CommandBuffer::ExecuteCommandBuffers(std::vector<const Graphics::CommandBuffer*>&& gfxCommandBuffers)
{
- std::vector<vk::CommandBuffer> vkCommandBuffers;
- vkCommandBuffers.reserve(gfxCommandBuffers.size());
- for(auto& gfxCmdBuf : gfxCommandBuffers)
+ uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
{
- vkCommandBuffers.push_back(ConstGraphicsCast<CommandBuffer, Graphics::CommandBuffer>(gfxCmdBuf)->GetImpl()->GetVkHandle());
+ std::vector<vk::CommandBuffer> vkCommandBuffers;
+ vkCommandBuffers.reserve(gfxCommandBuffers.size());
+ for(auto& gfxCmdBuf : gfxCommandBuffers)
+ {
+ vkCommandBuffers.push_back(ConstGraphicsCast<CommandBuffer, Graphics::CommandBuffer>(gfxCmdBuf)->GetImpl()->GetVkHandle());
+ }
+ mCommandBufferImpl[bufferIndex]->ExecuteCommandBuffers(vkCommandBuffers);
}
- mCommandBufferImpl->ExecuteCommandBuffers(vkCommandBuffers);
}
void CommandBuffer::Draw(uint32_t vertexCount,
uint32_t firstVertex,
uint32_t firstInstance)
{
- mCommandBufferImpl->Draw(vertexCount, instanceCount, firstVertex, firstInstance);
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
+ {
+ mCommandBufferImpl[bufferIndex]->Draw(vertexCount, instanceCount, firstVertex, firstInstance);
+ }
}
void CommandBuffer::DrawIndexed(uint32_t indexCount,
int32_t vertexOffset,
uint32_t firstInstance)
{
- mCommandBufferImpl->DrawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
+ {
+ mCommandBufferImpl[bufferIndex]->DrawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
+ }
}
void CommandBuffer::DrawIndexedIndirect(Graphics::Buffer& gfxBuffer,
uint32_t drawCount,
uint32_t stride)
{
- auto buffer = ConstGraphicsCast<Buffer, Graphics::Buffer>(&gfxBuffer)->GetImpl();
-
- mCommandBufferImpl->DrawIndexedIndirect(*buffer, offset, drawCount, stride);
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
+ {
+ auto buffer = ConstGraphicsCast<Buffer, Graphics::Buffer>(&gfxBuffer)->GetImpl();
+ mCommandBufferImpl[bufferIndex]->DrawIndexedIndirect(*buffer, offset, drawCount, stride);
+ }
}
void CommandBuffer::DrawNative(const DrawNativeInfo* drawInfo)
void CommandBuffer::SetScissor(Rect2D value)
{
- // @todo Vulkan accepts array of scissors... add to API
-
- if(SetDynamicState(mDynamicState.scissor, value, DynamicStateMaskBits::SCISSOR))
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
{
- mCommandBufferImpl->SetScissor(value);
+ // @todo Vulkan accepts array of scissors... add to API
+
+ if(SetDynamicState(mDynamicState.scissor, value, DynamicStateMaskBits::SCISSOR))
+ {
+ mCommandBufferImpl[bufferIndex]->SetScissor(value);
+ }
}
}
correctedValue.y = value.height;
}
- if(SetDynamicState(mDynamicState.viewport, correctedValue, DynamicStateMaskBits::VIEWPORT))
+ uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
{
- mCommandBufferImpl->SetViewport(correctedValue);
+ if(SetDynamicState(mDynamicState.viewport, correctedValue, DynamicStateMaskBits::VIEWPORT))
+ {
+ mCommandBufferImpl[bufferIndex]->SetViewport(correctedValue);
+ }
}
}
void CommandBuffer::SetStencilTestEnable(bool stencilEnable)
{
- if(SetDynamicState(mDynamicState.stencilTest, stencilEnable, DynamicStateMaskBits::STENCIL_TEST))
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
{
- mCommandBufferImpl->SetStencilTestEnable(stencilEnable);
+ if(SetDynamicState(mDynamicState.stencilTest, stencilEnable, DynamicStateMaskBits::STENCIL_TEST))
+ {
+ mCommandBufferImpl[bufferIndex]->SetStencilTestEnable(stencilEnable);
+ }
}
}
void CommandBuffer::SetStencilWriteMask(uint32_t writeMask)
{
- if(SetDynamicState(mDynamicState.stencilWriteMask, writeMask, DynamicStateMaskBits::STENCIL_WRITE_MASK))
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
{
- mCommandBufferImpl->SetStencilWriteMask(vk::StencilFaceFlagBits::eFrontAndBack, writeMask);
+ if(SetDynamicState(mDynamicState.stencilWriteMask, writeMask, DynamicStateMaskBits::STENCIL_WRITE_MASK))
+ {
+ mCommandBufferImpl[bufferIndex]->SetStencilWriteMask(vk::StencilFaceFlagBits::eFrontAndBack, writeMask);
+ }
}
}
Graphics::StencilOp passOp,
Graphics::StencilOp depthFailOp)
{
+ uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
if(SetDynamicState(mDynamicState.stencilCompareMask, compareMask, DynamicStateMaskBits::STENCIL_COMP_MASK))
{
- mCommandBufferImpl->SetStencilCompareMask(vk::StencilFaceFlagBits::eFrontAndBack, compareMask);
+ mCommandBufferImpl[bufferIndex]->SetStencilCompareMask(vk::StencilFaceFlagBits::eFrontAndBack, compareMask);
}
if(SetDynamicState(mDynamicState.stencilReference, reference, DynamicStateMaskBits::STENCIL_REF))
{
- mCommandBufferImpl->SetStencilReference(vk::StencilFaceFlagBits::eFrontAndBack, reference);
+ mCommandBufferImpl[bufferIndex]->SetStencilReference(vk::StencilFaceFlagBits::eFrontAndBack, reference);
}
if(SetDynamicState(mDynamicState.stencilFailOp, failOp, DynamicStateMaskBits::STENCIL_OP_FAIL) ||
SetDynamicState(mDynamicState.stencilDepthFailOp, depthFailOp, DynamicStateMaskBits::STENCIL_OP_DEPTH_FAIL) ||
SetDynamicState(mDynamicState.stencilCompareOp, compareOp, DynamicStateMaskBits::STENCIL_OP_COMP))
{
- mCommandBufferImpl->SetStencilOp(vk::StencilFaceFlagBits::eFrontAndBack,
- VkStencilOpType(failOp).op,
- VkStencilOpType(passOp).op,
- VkStencilOpType(depthFailOp).op,
- VkCompareOpType(compareOp).op);
+ mCommandBufferImpl[bufferIndex]->SetStencilOp(vk::StencilFaceFlagBits::eFrontAndBack,
+ VkStencilOpType(failOp).op,
+ VkStencilOpType(passOp).op,
+ VkStencilOpType(depthFailOp).op,
+ VkCompareOpType(compareOp).op);
}
}
void CommandBuffer::SetDepthCompareOp(Graphics::CompareOp compareOp)
{
- if(SetDynamicState(mDynamicState.depthCompareOp, compareOp, DynamicStateMaskBits::DEPTH_OP_COMP))
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
{
- mCommandBufferImpl->SetDepthCompareOp(VkCompareOpType(compareOp).op);
+ if(SetDynamicState(mDynamicState.depthCompareOp, compareOp, DynamicStateMaskBits::DEPTH_OP_COMP))
+ {
+ mCommandBufferImpl[bufferIndex]->SetDepthCompareOp(VkCompareOpType(compareOp).op);
+ }
}
}
void CommandBuffer::SetDepthTestEnable(bool depthTestEnable)
{
- if(SetDynamicState(mDynamicState.depthTest, depthTestEnable, DynamicStateMaskBits::DEPTH_TEST))
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
{
- mCommandBufferImpl->SetDepthTestEnable(depthTestEnable);
+ if(SetDynamicState(mDynamicState.depthTest, depthTestEnable, DynamicStateMaskBits::DEPTH_TEST))
+ {
+ mCommandBufferImpl[bufferIndex]->SetDepthTestEnable(depthTestEnable);
+ }
}
}
void CommandBuffer::SetDepthWriteEnable(bool depthWriteEnable)
{
- if(SetDynamicState(mDynamicState.depthWrite, depthWriteEnable, DynamicStateMaskBits::DEPTH_WRITE))
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
{
- mCommandBufferImpl->SetDepthWriteEnable(depthWriteEnable);
+ if(SetDynamicState(mDynamicState.depthWrite, depthWriteEnable, DynamicStateMaskBits::DEPTH_WRITE))
+ {
+ mCommandBufferImpl[bufferIndex]->SetDepthWriteEnable(depthWriteEnable);
+ }
}
}
return mRenderTarget;
}
+[[nodiscard]] Vulkan::CommandBufferImpl* CommandBuffer::GetImpl() const
+{
+ const uint32_t bufferIndex = mController.GetGraphicsDevice().GetCurrentBufferIndex();
+ if(bufferIndex < mCommandBufferImpl.size() && mCommandBufferImpl[bufferIndex])
+ {
+ return mCommandBufferImpl[bufferIndex];
+ }
+ return nullptr;
+}
+
} // namespace Dali::Graphics::Vulkan