Permalink
Browse files

Start separating depth and stencil renderpass actions, only internall…

…y in the Vulkan code so far.
  • Loading branch information...
hrydgard committed Dec 30, 2017
1 parent 1e64919 commit a0f718ace1ebab045c0d94b6124d6227a0124470
@@ -141,8 +141,8 @@ void VulkanQueueRunner::InitBackbufferRenderPass() {
assert(res == VK_SUCCESS);
}
VkRenderPass VulkanQueueRunner::GetRenderPass(VKRRenderPassAction colorAction, VKRRenderPassAction depthAction) {
RPKey key{ colorAction, depthAction };
VkRenderPass VulkanQueueRunner::GetRenderPass(VKRRenderPassAction colorLoadAction, VKRRenderPassAction depthLoadAction, VKRRenderPassAction stencilLoadAction) {
RPKey key{ colorLoadAction, depthLoadAction, stencilLoadAction };
auto pass = renderPasses_.Get(key);
if (pass) {
return pass;
@@ -153,7 +153,7 @@ VkRenderPass VulkanQueueRunner::GetRenderPass(VKRRenderPassAction colorAction, V
VkAttachmentDescription attachments[2] = {};
attachments[0].format = VK_FORMAT_R8G8B8A8_UNORM;
attachments[0].samples = VK_SAMPLE_COUNT_1_BIT;
switch (colorAction) {
switch (colorLoadAction) {
case VKRRenderPassAction::CLEAR:
attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
break;
@@ -174,17 +174,25 @@ VkRenderPass VulkanQueueRunner::GetRenderPass(VKRRenderPassAction colorAction, V
attachments[1].format = vulkan_->GetDeviceInfo().preferredDepthStencilFormat;
attachments[1].samples = VK_SAMPLE_COUNT_1_BIT;
switch (depthAction) {
switch (depthLoadAction) {
case VKRRenderPassAction::CLEAR:
attachments[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
attachments[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
break;
case VKRRenderPassAction::KEEP:
attachments[1].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
attachments[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
break;
case VKRRenderPassAction::DONT_CARE:
attachments[1].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
break;
}
switch (stencilLoadAction) {
case VKRRenderPassAction::CLEAR:
attachments[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
break;
case VKRRenderPassAction::KEEP:
attachments[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
break;
case VKRRenderPassAction::DONT_CARE:
attachments[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
break;
}
@@ -604,7 +612,7 @@ void VulkanQueueRunner::PerformBindFramebufferAsRenderTarget(const VKRStep &step
fb->depth.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
}
renderPass = GetRenderPass(step.render.color, step.render.depthStencil);
renderPass = GetRenderPass(step.render.color, step.render.depthStencil, step.render.depthStencil);
if (step.render.color == VKRRenderPassAction::CLEAR) {
Uint8x4ToFloat4(clearVal[0].color.float32, step.render.clearColor);
numClearVals = 1;
@@ -159,7 +159,7 @@ class VulkanQueueRunner {
VkRenderPass GetBackbufferRenderPass() const {
return backbufferRenderPass_;
}
VkRenderPass GetRenderPass(VKRRenderPassAction color, VKRRenderPassAction depth);
VkRenderPass GetRenderPass(VKRRenderPassAction colorLoadAction, VKRRenderPassAction depthLoadAction, VKRRenderPassAction stencilLoadAction);
inline int RPIndex(VKRRenderPassAction color, VKRRenderPassAction depth) {
return (int)depth * 3 + (int)color;
@@ -198,7 +198,8 @@ class VulkanQueueRunner {
struct RPKey {
VKRRenderPassAction colorAction;
VKRRenderPassAction depthStencilAction;
VKRRenderPassAction depthAction;
VKRRenderPassAction stencilAction;
};
// Renderpasses, all combinations of preserving or clearing or dont-care-ing fb contents.
@@ -194,15 +194,15 @@ class VulkanRenderManager {
VkCommandBuffer GetInitCmd();
VkRenderPass GetRenderPass(VKRRenderPassAction color, VKRRenderPassAction depthStencil) {
return queueRunner_.GetRenderPass(color, depthStencil);
VkRenderPass GetRenderPass(VKRRenderPassAction colorLoadAction, VKRRenderPassAction depthLoadAction, VKRRenderPassAction stencilLoadAction) {
return queueRunner_.GetRenderPass(colorLoadAction, depthLoadAction, stencilLoadAction);
}
VkRenderPass GetBackbufferRenderPass() {
return queueRunner_.GetBackbufferRenderPass();
}
VkRenderPass GetCompatibleRenderPass() {
if (curRenderStep_ && curRenderStep_->render.framebuffer != nullptr) {
return queueRunner_.GetRenderPass(VKRRenderPassAction::CLEAR, VKRRenderPassAction::CLEAR);
return queueRunner_.GetRenderPass(VKRRenderPassAction::CLEAR, VKRRenderPassAction::CLEAR, VKRRenderPassAction::CLEAR);
} else {
return queueRunner_.GetBackbufferRenderPass();
}
@@ -462,7 +462,7 @@ class VKContext : public DrawContext {
switch (obj) {
case NativeObject::FRAMEBUFFER_RENDERPASS:
// Return a representative renderpass.
return (uintptr_t)renderManager_.GetRenderPass(VKRRenderPassAction::CLEAR, VKRRenderPassAction::CLEAR);
return (uintptr_t)renderManager_.GetRenderPass(VKRRenderPassAction::CLEAR, VKRRenderPassAction::CLEAR, VKRRenderPassAction::CLEAR);
case NativeObject::BACKBUFFER_RENDERPASS:
return (uintptr_t)renderManager_.GetBackbufferRenderPass();
case NativeObject::COMPATIBLE_RENDERPASS:
@@ -1295,7 +1295,7 @@ class VKFramebuffer : public Framebuffer {
Framebuffer *VKContext::CreateFramebuffer(const FramebufferDesc &desc) {
VkCommandBuffer cmd = renderManager_.GetInitCmd();
VKRFramebuffer *vkrfb = new VKRFramebuffer(vulkan_, cmd, renderManager_.GetRenderPass(VKRRenderPassAction::CLEAR, VKRRenderPassAction::CLEAR), desc.width, desc.height);
VKRFramebuffer *vkrfb = new VKRFramebuffer(vulkan_, cmd, renderManager_.GetRenderPass(VKRRenderPassAction::CLEAR, VKRRenderPassAction::CLEAR, VKRRenderPassAction::CLEAR), desc.width, desc.height);
return new VKFramebuffer(vkrfb);
}

0 comments on commit a0f718a

Please sign in to comment.