Skip to content

Commit

Permalink
vulkan: fix partial rendering with !load_target
Browse files Browse the repository at this point in the history
We always need to pick LOAD_OP_LOAD for partial renders, even if we
don't care about blending, because this is required to preserve
framebuffer contents outside the scissor area.

We could in theory get around this in some cases, when we know we're
rendering to partial crops that perfectly align with the render area
granularity, but we'd need to know this ahead of time, which we
explicitly can't (by the fact that it's fixed in advantage).

Bite the bullet and always load the framebuffer contents. In theory it
might be faster to just use a partial/misaligned render area instead,
but I have no clue how to benchmark that as my hardware does not make a
distinction whatsoever.

Closes #111
  • Loading branch information
haasn committed Nov 19, 2021
1 parent 86f7a56 commit d4f2fb1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/vulkan/gpu_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,13 @@ no_descriptors: ;
};
}

VkAttachmentLoadOp loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
VkAttachmentLoadOp loadOp;
if (pass->params.load_target) {
if (pass->params.blend_params)
loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
pass_vk->initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
} else {
pass_vk->initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
}

VkRenderPassCreateInfo rinfo = {
Expand Down Expand Up @@ -991,7 +991,7 @@ void vk_pass_run(pl_gpu gpu, const struct pl_pass_run_params *params)
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
.renderPass = pass_vk->renderPass,
.framebuffer = tex_vk->framebuffer,
.renderArea = (VkRect2D){{0, 0}, {tex->params.w, tex->params.h}},
.renderArea.extent = {tex->params.w, tex->params.h},
};

vk->CmdBeginRenderPass(cmd->buf, &binfo, VK_SUBPASS_CONTENTS_INLINE);
Expand Down

0 comments on commit d4f2fb1

Please sign in to comment.