Updated call sites to no longer pass clear color to KRRenderPass::Begin(), as KRRenderPass now retains the clear color after initialization.
KRRenderPass now has configurable stencil clear, load, and store operations.
This commit is contained in:
@@ -197,7 +197,7 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS
|
|||||||
|
|
||||||
// Start render pass
|
// Start render pass
|
||||||
KRRenderPass& deferredGBufferPass = compositeSurface.getDeferredGBufferPass();
|
KRRenderPass& deferredGBufferPass = compositeSurface.getDeferredGBufferPass();
|
||||||
deferredGBufferPass.begin(commandBuffer, compositeSurface, Vector4::Zero());
|
deferredGBufferPass.begin(commandBuffer, compositeSurface);
|
||||||
|
|
||||||
// Render the geometry
|
// Render the geometry
|
||||||
scene.render(commandBuffer, compositeSurface, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_DEFERRED_GBUFFER, false);
|
scene.render(commandBuffer, compositeSurface, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_DEFERRED_GBUFFER, false);
|
||||||
@@ -234,7 +234,7 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS
|
|||||||
|
|
||||||
// Start render pass
|
// Start render pass
|
||||||
KRRenderPass& deferredOpaquePass = compositeSurface.getDeferredOpaquePass();
|
KRRenderPass& deferredOpaquePass = compositeSurface.getDeferredOpaquePass();
|
||||||
deferredOpaquePass.begin(commandBuffer, compositeSurface, Vector4::Create(0.0f, 0.0f, 0.0f, 1.0f));
|
deferredOpaquePass.begin(commandBuffer, compositeSurface);
|
||||||
|
|
||||||
// Set source to buffers from pass 2
|
// Set source to buffers from pass 2
|
||||||
m_pContext->getTextureManager()->selectTexture(0 /*GL_TEXTURE_2D*/, 6, lightAccumulationTexture);
|
m_pContext->getTextureManager()->selectTexture(0 /*GL_TEXTURE_2D*/, 6, lightAccumulationTexture);
|
||||||
@@ -253,7 +253,7 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS
|
|||||||
|
|
||||||
// Start render pass
|
// Start render pass
|
||||||
KRRenderPass& forwardOpaquePass = compositeSurface.getForwardOpaquePass();
|
KRRenderPass& forwardOpaquePass = compositeSurface.getForwardOpaquePass();
|
||||||
forwardOpaquePass.begin(commandBuffer, compositeSurface, Vector4::Create(0.0f, 0.0f, 0.0f, 1.0f));
|
forwardOpaquePass.begin(commandBuffer, compositeSurface);
|
||||||
|
|
||||||
// Render the geometry
|
// Render the geometry
|
||||||
scene.render(commandBuffer, compositeSurface, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_FORWARD_OPAQUE, false);
|
scene.render(commandBuffer, compositeSurface, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_FORWARD_OPAQUE, false);
|
||||||
@@ -414,7 +414,7 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS
|
|||||||
GL_PUSH_GROUP_MARKER("Post Processing");
|
GL_PUSH_GROUP_MARKER("Post Processing");
|
||||||
|
|
||||||
KRRenderPass& postCompositePass = compositeSurface.getPostCompositePass();
|
KRRenderPass& postCompositePass = compositeSurface.getPostCompositePass();
|
||||||
postCompositePass.begin(commandBuffer, compositeSurface, Vector4::Create(0.0f, 0.0f, 0.0f, 1.0f));
|
postCompositePass.begin(commandBuffer, compositeSurface);
|
||||||
|
|
||||||
renderPost(commandBuffer, compositeSurface);
|
renderPost(commandBuffer, compositeSurface);
|
||||||
|
|
||||||
@@ -774,7 +774,7 @@ void KRCamera::renderDebug(VkCommandBuffer& commandBuffer, KRSurface& surface)
|
|||||||
m_debug_text_vbo_data.load(commandBuffer);
|
m_debug_text_vbo_data.load(commandBuffer);
|
||||||
|
|
||||||
KRRenderPass& debugPass = surface.getDebugPass();
|
KRRenderPass& debugPass = surface.getDebugPass();
|
||||||
debugPass.begin(commandBuffer, surface, Vector4::Create(0.0f, 0.0f, 0.0f, 1.0f));
|
debugPass.begin(commandBuffer, surface);
|
||||||
|
|
||||||
KRTexture* fontTexture = m_pContext->getTextureManager()->getTexture("font");
|
KRTexture* fontTexture = m_pContext->getTextureManager()->getTexture("font");
|
||||||
fontTexture->resetPoolExpiry(0.0f, KRTexture::TEXTURE_USAGE_UI);
|
fontTexture->resetPoolExpiry(0.0f, KRTexture::TEXTURE_USAGE_UI);
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ void KRRenderPass::create(KRDevice& device, VkFormat swapChainImageFormat, VkFor
|
|||||||
depthAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
|
depthAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
depthAttachment.loadOp = info.clearDepth ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD;
|
depthAttachment.loadOp = info.clearDepth ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||||
depthAttachment.storeOp = info.keepDepth ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
depthAttachment.storeOp = info.keepDepth ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||||
depthAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
depthAttachment.stencilLoadOp = info.clearStencil ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||||
depthAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
depthAttachment.stencilStoreOp = info.keepStencil ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||||
depthAttachment.initialLayout = info.clearDepth ? VK_IMAGE_LAYOUT_UNDEFINED : VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
depthAttachment.initialLayout = info.clearDepth ? VK_IMAGE_LAYOUT_UNDEFINED : VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||||
depthAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
depthAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||||
|
|
||||||
@@ -133,7 +133,8 @@ void KRRenderPass::begin(VkCommandBuffer& commandBuffer, KRSurface& surface)
|
|||||||
clearValues[0].color.float32[1] = m_info.clearColorValue[1];
|
clearValues[0].color.float32[1] = m_info.clearColorValue[1];
|
||||||
clearValues[0].color.float32[2] = m_info.clearColorValue[2];
|
clearValues[0].color.float32[2] = m_info.clearColorValue[2];
|
||||||
clearValues[0].color.float32[3] = m_info.clearColorValue[3];
|
clearValues[0].color.float32[3] = m_info.clearColorValue[3];
|
||||||
clearValues[1].depthStencil = { 1.0f, 0 };
|
clearValues[1].depthStencil.depth = m_info.clearDepthValue;
|
||||||
|
clearValues[1].depthStencil.stencil = m_info.clearStencilValue;
|
||||||
|
|
||||||
VkRenderPassBeginInfo renderPassInfo{};
|
VkRenderPassBeginInfo renderPassInfo{};
|
||||||
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
||||||
|
|||||||
@@ -48,15 +48,21 @@ public:
|
|||||||
bool keepColor;
|
bool keepColor;
|
||||||
bool clearDepth;
|
bool clearDepth;
|
||||||
bool keepDepth;
|
bool keepDepth;
|
||||||
|
bool clearStencil;
|
||||||
|
bool keepStencil;
|
||||||
bool finalPass;
|
bool finalPass;
|
||||||
|
hydra::Vector4 clearColorValue;
|
||||||
|
float clearDepthValue;
|
||||||
|
uint32_t clearStencilValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
void create(KRDevice& device, VkFormat swapChainImageFormat, VkFormat depthImageFormat, const RenderPassInfo& info);
|
void create(KRDevice& device, VkFormat swapChainImageFormat, VkFormat depthImageFormat, const RenderPassInfo& info);
|
||||||
void destroy(KRDevice& device);
|
void destroy(KRDevice& device);
|
||||||
|
|
||||||
void begin(VkCommandBuffer& commandBuffer, KRSurface& surface, const hydra::Vector4& clearColor);
|
void begin(VkCommandBuffer& commandBuffer, KRSurface& surface);
|
||||||
void end(VkCommandBuffer& commandBuffer);
|
void end(VkCommandBuffer& commandBuffer);
|
||||||
|
|
||||||
// private:
|
// private:
|
||||||
VkRenderPass m_renderPass;
|
VkRenderPass m_renderPass;
|
||||||
|
RenderPassInfo m_info;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -201,10 +201,16 @@ KrResult KRSurface::createSwapChain()
|
|||||||
KRRenderPass::RenderPassInfo info{};
|
KRRenderPass::RenderPassInfo info{};
|
||||||
info.clearColor = true;
|
info.clearColor = true;
|
||||||
info.keepColor = true;
|
info.keepColor = true;
|
||||||
info.clearDepth = true;
|
|
||||||
info.keepDepth = false;
|
|
||||||
info.finalPass = false;
|
|
||||||
info.clearColorValue = Vector4::Zero();
|
info.clearColorValue = Vector4::Zero();
|
||||||
|
|
||||||
|
info.clearDepth = true;
|
||||||
|
info.keepDepth = true;
|
||||||
|
info.clearDepthValue = 1.0f;
|
||||||
|
|
||||||
|
info.clearStencil = true;
|
||||||
|
info.keepStencil = true;
|
||||||
|
info.clearStencilValue = 0;
|
||||||
|
info.finalPass = false;
|
||||||
m_forwardOpaquePass->create(*device, selectedSurfaceFormat.format, depthImageFormat, info);
|
m_forwardOpaquePass->create(*device, selectedSurfaceFormat.format, depthImageFormat, info);
|
||||||
|
|
||||||
info.clearColor = true;
|
info.clearColor = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user