Skip to content

Commit

Permalink
KRRenderPass now keeps RenderPassInfo after initialization.
Browse files Browse the repository at this point in the history
KRRenderPass now accepts clear color at initialization, no longer requiring to pass it on every instantiation.
  • Loading branch information
kearwood committed Jan 21, 2024
1 parent b37acc1 commit d92a039
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions kraken/KRRenderPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ using namespace hydra;
KRRenderPass::KRRenderPass(KRContext& context)
: KRContextObject(context)
, m_renderPass(VK_NULL_HANDLE)
, m_info{}
{

}
Expand All @@ -52,6 +53,7 @@ void KRRenderPass::create(KRDevice& device, VkFormat swapChainImageFormat, VkFor
if (m_renderPass) {
return;
}
m_info = info;

VkAttachmentDescription colorAttachment{};
colorAttachment.format = swapChainImageFormat;
Expand Down Expand Up @@ -124,13 +126,13 @@ void KRRenderPass::destroy(KRDevice& device)
}
}

void KRRenderPass::begin(VkCommandBuffer& commandBuffer, KRSurface& surface, const Vector4& clearColor)
void KRRenderPass::begin(VkCommandBuffer& commandBuffer, KRSurface& surface)
{
std::array<VkClearValue, 2> clearValues{};
clearValues[0].color.float32[0] = clearColor[0];
clearValues[0].color.float32[1] = clearColor[1];
clearValues[0].color.float32[2] = clearColor[2];
clearValues[0].color.float32[3] = clearColor[3];
clearValues[0].color.float32[0] = m_info.clearColorValue[0];
clearValues[0].color.float32[1] = m_info.clearColorValue[1];
clearValues[0].color.float32[2] = m_info.clearColorValue[2];
clearValues[0].color.float32[3] = m_info.clearColorValue[3];
clearValues[1].depthStencil = { 1.0f, 0 };

VkRenderPassBeginInfo renderPassInfo{};
Expand Down
3 changes: 2 additions & 1 deletion kraken/KRSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ KrResult KRSurface::createSwapChain()
info.clearDepth = true;
info.keepDepth = false;
info.finalPass = false;
info.clearColorValue = Vector4::Zero();
m_forwardOpaquePass->create(*device, selectedSurfaceFormat.format, depthImageFormat, info);

info.clearColor = true;
Expand Down Expand Up @@ -332,6 +333,6 @@ void KRSurface::endFrame()

void KRSurface::renderBlackFrame(VkCommandBuffer &commandBuffer)
{
m_blackFramePass->begin(commandBuffer, *this, Vector4::Create(0.0f, 0.0f, 0.0f, 1.0f));
m_blackFramePass->begin(commandBuffer, *this);
m_blackFramePass->end(commandBuffer);
}

0 comments on commit d92a039

Please sign in to comment.