]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/pipelinestate_backend.cpp
Add a wrapper class for recording Vulkan commands
[libs/gl.git] / source / backends / vulkan / pipelinestate_backend.cpp
index d14bc00c6539bb3c9509fab26abf4610cd151d1f..7deae24c9b09b59ada978489feb1bdfd6b1637a9 100644 (file)
@@ -386,10 +386,9 @@ unsigned VulkanPipelineState::fill_descriptor_writes(unsigned index, unsigned fr
        return n_writes;
 }
 
-void VulkanPipelineState::apply(VkCommandBuffer command_buffer, const VulkanPipelineState *last, unsigned frame, bool negative_viewport) const
+void VulkanPipelineState::apply(const VulkanCommandRecorder &vkCmd, const VulkanPipelineState *last, unsigned frame, bool negative_viewport) const
 {
        const PipelineState &self = *static_cast<const PipelineState *>(this);
-       const VulkanFunctions &vk = device.get_functions();
 
        if(!last)
        {
@@ -424,14 +423,14 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer, const VulkanPipe
        }
 
        if(unapplied&PipelineState::SHPROG)
-               vk.CmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, handle);
+               vkCmd.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, handle);
 
        if(unapplied&PipelineState::VERTEX_SETUP)
                if(const VertexSetup *vs = self.vertex_setup)
                {
-                       vk.CmdBindVertexBuffers(command_buffer, 0, vs->n_bindings, vs->buffers, vs->offsets);
+                       vkCmd.BindVertexBuffers(0, vs->n_bindings, vs->buffers, vs->offsets);
                        VkIndexType index_type = static_cast<VkIndexType>(get_vulkan_index_type(vs->get_index_type()));
-                       vk.CmdBindIndexBuffer(command_buffer, vs->get_index_buffer()->handle, 0, index_type);
+                       vkCmd.BindIndexBuffer(vs->get_index_buffer()->handle, 0, index_type);
                }
 
        if(!self.uniform_blocks.empty())
@@ -440,7 +439,7 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer, const VulkanPipe
                if(first_block.used && first_block.binding==ReflectData::PUSH_CONSTANT)
                {
                        const UniformBlock &pc_block = *first_block.block;
-                       vk.CmdPushConstants(command_buffer, self.shprog->layout_handle, self.shprog->stage_flags,
+                       vkCmd.PushConstants(self.shprog->layout_handle, self.shprog->stage_flags,
                                pc_block.get_offset(), pc_block.get_data_size(), pc_block.get_data_pointer());
                }
        }
@@ -453,7 +452,7 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer, const VulkanPipe
                        descriptor_set_handles.push_back(device.get_descriptor_pool().get_descriptor_set(
                                self.descriptor_set_slots[i], self, i, frame));
 
-               vk.CmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, self.shprog->layout_handle,
+               vkCmd.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, self.shprog->layout_handle,
                        first_changed_desc_set, descriptor_set_handles.size(), descriptor_set_handles.data(), 0, 0);
        }
 
@@ -476,7 +475,7 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer, const VulkanPipe
                        }
                        viewport.minDepth = 0.0f;
                        viewport.maxDepth = 1.0f;
-                       vk.CmdSetViewport(command_buffer, 0, 1, &viewport);
+                       vkCmd.SetViewport(0, 1, &viewport);
                }
 
                if(unapplied&PipelineState::SCISSOR)
@@ -487,7 +486,7 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer, const VulkanPipe
                        scissor.offset.y = scissor_rect.bottom;
                        scissor.extent.width = scissor_rect.width;
                        scissor.extent.height = scissor_rect.height;
-                       vk.CmdSetScissor(command_buffer, 0, 1, &scissor);
+                       vkCmd.SetScissor(0, 1, &scissor);
                }
        }