summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--video.cpp34
-rw-r--r--video.hpp7
2 files changed, 34 insertions, 7 deletions
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)
diff --git a/video.hpp b/video.hpp
index 453423b..d524d81 100644
--- a/video.hpp
+++ b/video.hpp
@@ -169,12 +169,19 @@ struct Vertex_Buffer_Binding {
int target;
};
+struct Index_Buffer_Binding {
+ Buffer_Id id;
+ size_t offset;
+};
+
struct Draw {
Vertex_Buffer_Binding* verts;
+ Index_Buffer_Binding inds;
int vertex_count;
int instance_count;
int first_vertex;
int first_instance;
+ int vertex_offset;
};
struct Device;