]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/commands_backend.cpp
Move PipelineState refresh to just before draw call
[libs/gl.git] / source / backends / vulkan / commands_backend.cpp
index 1752e9dad68cf37422ab4dfdc07c0d23f708cfc1..84bc104a3e372fd1f19832d8a9a52562ec7411c4 100644 (file)
@@ -69,10 +69,14 @@ void VulkanCommands::begin_render_pass(bool clear, const ClearValue *clear_value
 
        device.get_transfer_queue().dispatch_transfers(current_buffer);
 
+       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->VulkanFramebuffer::get_attachment(i)))
+               if(dynamic_cast<const SwapChainTexture *>(framebuffer->get_attachment(i)))
                        to_present = true;
        VkRenderPass render_pass = device.get_pipeline_cache().get_render_pass(framebuffer->get_format(), clear, !clear_values, to_present);
 
@@ -191,8 +195,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)
@@ -218,6 +220,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);