X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fvulkan%2Fcommands_backend.cpp;h=bf8ee3f13d5652c21a14db09ff1e077e016740cc;hb=6d2e2a0bb28496a8c25b441009bdd2a1a1e72d81;hp=b7a342defb5ab741eb16f3b9c3bc06af6f8d7555;hpb=edc150206f9762facf37b419705ddb8cf21f4e4c;p=libs%2Fgl.git diff --git a/source/backends/vulkan/commands_backend.cpp b/source/backends/vulkan/commands_backend.cpp index b7a342de..bf8ee3f1 100644 --- a/source/backends/vulkan/commands_backend.cpp +++ b/source/backends/vulkan/commands_backend.cpp @@ -31,11 +31,12 @@ VulkanCommands::~VulkanCommands() void VulkanCommands::begin_buffer(VkRenderPass render_pass) { - if(!current_pool) + if(frame_index>=command_pools.size()) throw invalid_operation("VulkanCommands::begin_buffer"); const VulkanFunctions &vk = device.get_functions(); + CommandPool *current_pool = &command_pools[frame_index]; if(!current_pool->in_use) { current_pool->fence.reset(); @@ -176,15 +177,15 @@ void VulkanCommands::begin_frame(unsigned index) { const VulkanFunctions &vk = device.get_functions(); - unsigned pool_index = index%device.get_n_frames_in_flight(); - if(pool_index>=command_pools.size()) + frame_index = index%device.get_n_frames_in_flight(); + if(frame_index>=command_pools.size()) { - command_pools.reserve(pool_index+1); - for(unsigned i=command_pools.size(); iin_use) { current_pool->fence.wait(); @@ -220,7 +221,7 @@ void VulkanCommands::submit_frame(Semaphore *wait_sem, Semaphore *signal_sem) submit_info.signalSemaphoreCount = (signal_sem ? 1 : 0); submit_info.pSignalSemaphores = &vk_signal_sem; - vk.QueueSubmit(1, &submit_info, current_pool->fence.handle); + vk.QueueSubmit(1, &submit_info, command_pools[frame_index].fence.handle); primary_buffer = 0; } @@ -258,7 +259,7 @@ void VulkanCommands::draw_instanced(const Batch &batch, unsigned count) begin_render_pass(false, 0); pipeline_state->refresh(); - pipeline_state->apply(pass_buffer, fb_is_swapchain); + pipeline_state->apply(pass_buffer, frame_index, fb_is_swapchain); unsigned first_index = batch.get_offset()/batch.get_index_size(); vk.CmdDrawIndexed(pass_buffer, batch.size(), count, first_index, 0, 0); }