[BROKEN] This compiles if we use fastgltf 0.9.0, but it says Error::UnsupportedVersion for the file. Earlier versions can't compile because either simdjson has code errors, or the .a/.so is missing important functions.

This commit is contained in:
Zed A. Shaw 2025-12-20 00:36:55 -05:00
parent 85d792e257
commit dbda70e3a0
7 changed files with 185 additions and 7 deletions

View file

@ -14,7 +14,7 @@
#define VMA_IMPLEMENTATION
#include "vk_mem_alloc.h"
constexpr bool bUseValidationLayers = true;
constexpr bool bUseValidationLayers = false;
VulkanEngine* loadedEngine = nullptr;
@ -202,6 +202,7 @@ void VulkanEngine::draw_geometry(VkCommandBuffer cmd)
vkCmdDraw(cmd, 3, 1, 0, 0);
// draw rectangle
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, _meshPipeline);
GPUDrawPushConstants push_constants{
@ -215,6 +216,30 @@ void VulkanEngine::draw_geometry(VkCommandBuffer cmd)
vkCmdDrawIndexed(cmd, 6, 1, 0, 0, 0);
// draw monkey
size_t model_idx = 2; // 0 cube; 1 sphere; 2 monkey
push_constants.vertexBuffer = testMeshes[model_idx]->meshBuffers.vertexBufferAddress;
vkCmdPushConstants(cmd,
_meshPipelineLayout,
VK_SHADER_STAGE_VERTEX_BIT,
0,
sizeof(GPUDrawPushConstants),
&push_constants);
vkCmdBindIndexBuffer(cmd,
testMeshes[model_idx]->meshBuffers.indexBuffer.buffer,
0,
VK_INDEX_TYPE_UINT32);
vkCmdDrawIndexed(cmd,
testMeshes[model_idx]->surfaces[0].count,
1,
testMeshes[model_idx]->surfaces[0].startIndex,
0, 0);
vkCmdEndRendering(cmd);
}
@ -711,7 +736,6 @@ void VulkanEngine::destroy_buffer(const AllocatedBuffer& buffer)
vmaDestroyBuffer(_allocator, buffer.buffer, buffer.allocation);
}
GPUMeshBuffers VulkanEngine::uploadMesh(std::span<uint32_t> indices, std::span<Vertex> vertices)
{
const size_t vertexBufferSize = vertices.size() * sizeof(Vertex);
@ -796,6 +820,11 @@ void VulkanEngine::init_default_data() {
rectangle = uploadMesh(rect_indices, rect_vertices);
auto basicmesh = loadGltfMeshes(this, "basicmesh.glb");
assert(basicmesh != std::nullopt && "Failed to load basicmesh.glb");
testMeshes = *basicmesh;
_mainDeletionQueue.push_function([&](){
destroy_buffer(rectangle.indexBuffer);
destroy_buffer(rectangle.vertexBuffer);