KRRenderPass now keeps RenderPassInfo after initialization.
KRRenderPass now accepts clear color at initialization, no longer requiring to pass it on every instantiation.
This commit is contained in:
@@ -38,6 +38,7 @@ using namespace hydra;
|
|||||||
KRRenderPass::KRRenderPass(KRContext& context)
|
KRRenderPass::KRRenderPass(KRContext& context)
|
||||||
: KRContextObject(context)
|
: KRContextObject(context)
|
||||||
, m_renderPass(VK_NULL_HANDLE)
|
, m_renderPass(VK_NULL_HANDLE)
|
||||||
|
, m_info{}
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -52,6 +53,7 @@ void KRRenderPass::create(KRDevice& device, VkFormat swapChainImageFormat, VkFor
|
|||||||
if (m_renderPass) {
|
if (m_renderPass) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
m_info = info;
|
||||||
|
|
||||||
VkAttachmentDescription colorAttachment{};
|
VkAttachmentDescription colorAttachment{};
|
||||||
colorAttachment.format = swapChainImageFormat;
|
colorAttachment.format = swapChainImageFormat;
|
||||||
@@ -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{};
|
std::array<VkClearValue, 2> clearValues{};
|
||||||
clearValues[0].color.float32[0] = clearColor[0];
|
clearValues[0].color.float32[0] = m_info.clearColorValue[0];
|
||||||
clearValues[0].color.float32[1] = clearColor[1];
|
clearValues[0].color.float32[1] = m_info.clearColorValue[1];
|
||||||
clearValues[0].color.float32[2] = clearColor[2];
|
clearValues[0].color.float32[2] = m_info.clearColorValue[2];
|
||||||
clearValues[0].color.float32[3] = clearColor[3];
|
clearValues[0].color.float32[3] = m_info.clearColorValue[3];
|
||||||
clearValues[1].depthStencil = { 1.0f, 0 };
|
clearValues[1].depthStencil = { 1.0f, 0 };
|
||||||
|
|
||||||
VkRenderPassBeginInfo renderPassInfo{};
|
VkRenderPassBeginInfo renderPassInfo{};
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ KrResult KRSurface::createSwapChain()
|
|||||||
info.clearDepth = true;
|
info.clearDepth = true;
|
||||||
info.keepDepth = false;
|
info.keepDepth = false;
|
||||||
info.finalPass = false;
|
info.finalPass = false;
|
||||||
|
info.clearColorValue = Vector4::Zero();
|
||||||
m_forwardOpaquePass->create(*device, selectedSurfaceFormat.format, depthImageFormat, info);
|
m_forwardOpaquePass->create(*device, selectedSurfaceFormat.format, depthImageFormat, info);
|
||||||
|
|
||||||
info.clearColor = true;
|
info.clearColor = true;
|
||||||
@@ -332,6 +333,6 @@ void KRSurface::endFrame()
|
|||||||
|
|
||||||
void KRSurface::renderBlackFrame(VkCommandBuffer &commandBuffer)
|
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);
|
m_blackFramePass->end(commandBuffer);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user