From 75acd0104448d7c5f43f99700decff39b8a034b2 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Fri, 3 Feb 2023 00:15:19 +0100 Subject: Graphics pipeline and rendering implementation --- api-test/command-buffer.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'api-test/command-buffer.cpp') diff --git a/api-test/command-buffer.cpp b/api-test/command-buffer.cpp index b130d3d..78b1505 100644 --- a/api-test/command-buffer.cpp +++ b/api-test/command-buffer.cpp @@ -12,7 +12,7 @@ void command_buffer::start() const { VkCommandBufferBeginInfo begin_info{ .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, .pNext = nullptr, - .flags = 0U, + .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, .pInheritanceInfo = nullptr }; @@ -112,7 +112,8 @@ void command_buffer::copy(handle buffer_handle, ::handleget_pipeline(params.pipeline); const auto& bindless = vkdevice::get_render_device()->get_bindingmodel(); - vkCmdBindDescriptorSets(vk_command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, bindless.layout, static_cast(BindlessSetType::UNIFORMS), 1U, &bindless.sets[BindlessSetType::UNIFORMS], 1U, ¶ms.uniforms_offset); + vkCmdBindDescriptorSets(vk_command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, bindless.layout, static_cast(BindlessSetType::INSTANCES_UNIFORMS), 1U, &bindless.sets[BindlessSetType::INSTANCES_UNIFORMS], 1U, ¶ms.uniforms_offset); + vkCmdBindDescriptorSets(vk_command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, bindless.layout, static_cast(BindlessSetType::DRAWS_UNIFORMS), 1U, &bindless.sets[BindlessSetType::DRAWS_UNIFORMS], 1U, ¶ms.uniforms_offset); vkCmdBindPipeline(vk_command_buffer, pipeline.bind_point, pipeline.vk_pipeline); @@ -179,10 +180,21 @@ void graphics_command_buffer::begin_renderpass(const renderpass_params& params) } void graphics_command_buffer::render(const draw_params& params) const { - const auto& pipeline = vkdevice::get_render_device()->get_pipeline(params.pipeline); + auto* device = vkdevice::get_render_device(); + const auto& pipeline = device->get_pipeline(params.pipeline); + + const auto& bindless = device->get_bindingmodel(); + vkCmdBindDescriptorSets(vk_command_buffer, pipeline.bind_point, bindless.layout, static_cast(BindlessSetType::DRAWS_UNIFORMS), 1U, &bindless.sets[BindlessSetType::DRAWS_UNIFORMS], 1U, ¶ms.uniforms_offset); vkCmdBindPipeline(vk_command_buffer, pipeline.bind_point, pipeline.vk_pipeline); - vkCmdDraw(vk_command_buffer, params.vertex_count, params.instance_count, 0U, 0U); + + if (params.index_buffer.is_valid()) { + const auto& index_buffer = device->get_buffer(params.index_buffer); + vkCmdBindIndexBuffer(vk_command_buffer, index_buffer.vk_buffer, 0U, VK_INDEX_TYPE_UINT16); + vkCmdDrawIndexed(vk_command_buffer, params.vertex_count, params.instance_count, params.index_offset, static_cast(params.vertex_offset), 0U); + } else { + vkCmdDraw(vk_command_buffer, params.vertex_count, params.instance_count, params.vertex_offset, 0U); + } } void graphics_command_buffer::end_renderpass() const { -- cgit v1.3