Add basic loader for gltf

Added loading of avocado. Something is still wrong though,
becaus I cannot see the seed. But basic functionality is there.
This commit is contained in:
Piotr Krygier
2026-03-19 21:00:39 +01:00
parent 984a56a8e8
commit 99fb36d9fd
14 changed files with 186 additions and 32 deletions
+9 -3
View File
@@ -210,8 +210,11 @@ rse_err_t add_vertices(struct graphics_context_t* context,
size_t vertices_count,
const struct vertex_t* vertices,
size_t indices_count,
const uint16_t* indices)
uint16_t* indices)
{
// static uint16_t last_index = 0U;
// uint16_t max_index = 0U;
// size_t idx = 0U;
rse_err_t status = RSE_ERROR_NO_ERROR;
struct vulkan_buffer_t staging_buffer;
size_t vertices_size = sizeof(vertices[0]) * vertices_count;
@@ -235,6 +238,7 @@ rse_err_t add_vertices(struct graphics_context_t* context,
copy_buffer(context, staging_buffer.buffer, vertex_buffer->buffer, vertices_size, vertex_buffer->allocated_size);
vertex_buffer->allocated_size += vertices_size;
/* Fill staging buffer with index data */
memcpy(staging_buffer.allocation_info.pMappedData, indices, indices_size);
copy_buffer(context, staging_buffer.buffer, index_buffer->buffer, indices_size, index_buffer->allocated_size);
@@ -274,6 +278,7 @@ rse_err_t buffers_update(struct graphics_context_t* context)
sizeof(VkDrawIndexedIndirectCommand) * context->mesh_data.mesh_count;
struct vulkan_buffer_t staging_buffer;
struct mesh_t* mesh = NULL;
uint32_t indices_count = 0U;
rse_malloc(draw_indirect_commands_buffer, draw_indirect_commands_buffer_size);
for (iter = 0U; iter < context->mesh_data.mesh_count; ++iter) {
@@ -295,13 +300,14 @@ rse_err_t buffers_update(struct graphics_context_t* context)
draw_indirect_command->firstInstance = 0;
draw_indirect_command->vertexOffset = 0;
} else {
draw_indirect_command->firstIndex = context->mesh_data.mesh_bucket[iter - 1].index_count;
draw_indirect_command->firstIndex = indices_count;
draw_indirect_command->firstInstance = draw_indirect_commands_buffer[iter - 1].firstInstance +
draw_indirect_commands_buffer[iter - 1].instanceCount;
draw_indirect_command->vertexOffset = (context->mesh_data.mesh_bucket[iter - 1].vertex_count);
draw_indirect_command->vertexOffset = (context->mesh_data.mesh_bucket[iter - 1].vertex_count + draw_indirect_commands_buffer[iter-1].vertexOffset);
}
draw_indirect_command->indexCount = mesh->index_count;
draw_indirect_command->instanceCount = mesh->instances_count;
indices_count += mesh->index_count;
}
/* Copy Draw indirect commands into buffer */