From 8df41428706de46d021a47fdc96a448fdb7548e2 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Fri, 2 Feb 2018 11:31:33 -0500 Subject: [PATCH] Vulkan: Implement SetBlendColor --- src/backend/vulkan/CommandBufferVk.cpp | 31 ++++++++++++++++++-------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/backend/vulkan/CommandBufferVk.cpp b/src/backend/vulkan/CommandBufferVk.cpp index 449ed2d30a..f91a752a04 100644 --- a/src/backend/vulkan/CommandBufferVk.cpp +++ b/src/backend/vulkan/CommandBufferVk.cpp @@ -161,14 +161,6 @@ namespace backend { namespace vulkan { device->fn.CmdSetLineWidth(commands, 1.0f); device->fn.CmdSetDepthBounds(commands, 0.0f, 1.0f); - float blendConstants[4] = { - 1.0f, - 1.0f, - 1.0f, - 1.0f, - }; - device->fn.CmdSetBlendConstants(commands, blendConstants); - device->fn.CmdSetStencilCompareMask(commands, VK_STENCIL_FRONT_AND_BACK, 0); device->fn.CmdSetStencilWriteMask(commands, VK_STENCIL_FRONT_AND_BACK, 0); device->fn.CmdSetStencilReference(commands, VK_STENCIL_FRONT_AND_BACK, 0); @@ -193,7 +185,17 @@ namespace backend { namespace vulkan { case Command::BeginRenderSubpass: { mCommands.NextCommand(); - // Do nothing because the single subpass is started in vkBeginRenderPass + // Do nothing related to subpasses because the single subpass is started in + // vkBeginRenderPass + + // Set up the default state + float blendConstants[4] = { + 0.0f, + 0.0f, + 0.0f, + 0.0f, + }; + device->fn.CmdSetBlendConstants(commands, blendConstants); } break; case Command::DrawArrays: { @@ -221,6 +223,17 @@ namespace backend { namespace vulkan { // Do nothing because the single subpass is ended in vkEndRenderPass } break; + case Command::SetBlendColor: { + SetBlendColorCmd* cmd = mCommands.NextCommand(); + float blendConstants[4] = { + cmd->r, + cmd->g, + cmd->b, + cmd->a, + }; + device->fn.CmdSetBlendConstants(commands, blendConstants); + } break; + case Command::SetIndexBuffer: { SetIndexBufferCmd* cmd = mCommands.NextCommand(); VkBuffer indexBuffer = ToBackend(cmd->buffer)->GetHandle();