From 86810460eed75c19beb9f524e75c193edfa9ddfd Mon Sep 17 00:00:00 2001 From: quou Date: Sat, 28 Dec 2024 18:21:11 +1100 Subject: index buffers --- video.cpp | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'video.cpp') diff --git a/video.cpp b/video.cpp index 3dc1e61..7bb420d 100644 --- a/video.cpp +++ b/video.cpp @@ -1829,13 +1829,33 @@ void Context::submit( VkDeviceSize offset = (VkDeviceSize)binding->offset; vkCmdBindVertexBuffers(ctx->cb, 0, 1, &buf, &offset); } - vkCmdDraw( - ctx->cb, - draw.vertex_count, - draw.instance_count, - draw.first_vertex, - draw.first_instance - ); + if (draw.inds.id) { + const Index_Buffer_Binding& inds = draw.inds; + VkBuffer buf = ((Buffer_Vk*)&dev->get_buffer(inds.id))->buf; + VkDeviceSize offset = (VkDeviceSize)inds.offset; + vkCmdBindIndexBuffer( + ctx->cb, + buf, + offset, + VK_INDEX_TYPE_UINT16 + ); + vkCmdDrawIndexed( + ctx->cb, + draw.vertex_count, + draw.instance_count, + draw.first_vertex, + draw.vertex_offset, + draw.first_instance + ); + } else { + vkCmdDraw( + ctx->cb, + draw.vertex_count, + draw.instance_count, + draw.first_vertex, + draw.first_instance + ); + } ctx->end_rp(rpo); pso.on_submit(); if (dso) -- cgit v1.2.3-54-g00ecf