if(!framebuffer)
throw invalid_operation("VulkanCommands::begin_render_pass");
+ viewport = pipeline_state->get_viewport();
+
const VulkanFunctions &vk = device.get_functions();
if(!current_buffer)
if(dynamic_cast<const SwapChainTexture *>(framebuffer->get_attachment(i)))
to_present = true;
if(!to_present)
- framebuffer->prepare_image_layouts(clear);
- VkRenderPass render_pass = device.get_pipeline_cache().get_render_pass(framebuffer->get_format(), clear, !clear_values, to_present);
+ framebuffer->prepare_image_layouts(clear && !viewport);
+ VkRenderPass render_pass = device.get_pipeline_cache().get_render_pass(framebuffer->get_format(), clear, (!clear_values && !viewport), to_present);
framebuffer->refresh();
begin_info.renderPass = handle_cast<::VkRenderPass>(render_pass);
begin_info.framebuffer = handle_cast<::VkFramebuffer>(framebuffer->handle);
- viewport = pipeline_state->get_viewport();
if(viewport)
{
begin_info.renderArea.offset.x = viewport->left;
void VulkanFramebuffer::prepare_image_layouts(bool discard) const
{
for(const Framebuffer::Attachment &a: static_cast<const Framebuffer *>(this)->attachments)
- a.tex->change_layout(a.level, get_vulkan_attachment_layout(get_components(a.tex->get_format())), discard);
+ a.tex->change_layout(a.level, get_vulkan_attachment_layout(get_components(a.tex->get_format())), (discard && a.layer<0));
}
void VulkanFramebuffer::set_debug_name(const string &name)
attachments[i].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachments[i].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
attachments[i].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
- attachments[i].initialLayout = (clear ? VK_IMAGE_LAYOUT_UNDEFINED : external_layout);
+ attachments[i].initialLayout = ((clear && discard) ? VK_IMAGE_LAYOUT_UNDEFINED : external_layout);
attachments[i].finalLayout = external_layout;
if(subpass_layout==VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)