]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/commands_backend.cpp
Implement textures and samplers for Vulkan
[libs/gl.git] / source / backends / vulkan / commands_backend.cpp
index a5f2ceb5ad9dcd38789c14801cf0ca759a83b2ce..54282c36b675235e9b642c099bf8b588adb40d0c 100644 (file)
@@ -71,17 +71,20 @@ void VulkanCommands::begin_render_pass(bool clear, const ClearValue *clear_value
 
        Synchronizer &sync = device.get_synchronizer();
        sync.reset();
-       sync.barrier(current_buffer);
 
        bool to_present = false;
        unsigned n_attachments = framebuffer->get_format().size();
        for(unsigned i=0; i<n_attachments; ++i)
                if(dynamic_cast<const SwapChainTexture *>(framebuffer->get_attachment(i)))
                        to_present = true;
+       if(!to_present)
+               framebuffer->synchronize(clear);
        VkRenderPass render_pass = device.get_pipeline_cache().get_render_pass(framebuffer->get_format(), clear, !clear_values, to_present);
 
        framebuffer->refresh();
 
+       sync.barrier(current_buffer);
+
        VkRenderPassBeginInfo begin_info = { };
        begin_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
        begin_info.renderPass = handle_cast<::VkRenderPass>(render_pass);
@@ -195,8 +198,6 @@ void VulkanCommands::use_pipeline(const PipelineState *ps)
                        end_render_pass();
 
        pipeline_state = ps;
-       if(pipeline_state)
-               pipeline_state->refresh();
 }
 
 void VulkanCommands::clear(const ClearValue *values)
@@ -222,6 +223,7 @@ void VulkanCommands::draw_instanced(const Batch &batch, unsigned count)
        if(!framebuffer)
                 begin_render_pass(false, 0);
 
+       pipeline_state->refresh();
        pipeline_state->apply(current_buffer);
        unsigned first_index = batch.get_offset()/batch.get_index_size();
        vk.CmdDrawIndexed(current_buffer, batch.size(), count, first_index, 0, 0);