Restructure things a little to enable multiple models

This commit is contained in:
Camden Dixie O'Brien committed 2025-10-03 22:33:11 +01:00
1 parent 4c3fe8d8f7
commit f3aa7435ec
3 files changed
+235 -184

No files matched your search

+31 -19
View File
@@ -33,13 +33,6 @@ typedef struct {
VkShaderModule frag_shader;
VkDescriptorSetLayout desc_set_layout;
VkDescriptorPool desc_pool;
VkDescriptorSet desc_sets[MAX_FRAMES_IN_FLIGHT];
VkBuffer mvp_buffer;
VkDeviceMemory mvp_buffer_mem;
mvp_t *mvps;
VkBuffer bone_matrix_buffer;
VkDeviceMemory bone_matrix_buffer_mem;
mat4_t *bone_matrices;
VkPipelineLayout pipeline_layout;
VkRenderPass render_pass;
VkPipeline pipeline;
@@ -48,22 +41,41 @@ typedef struct {
VkFence in_flight;
VkSemaphore render_fin;
VkSemaphore img_avail;
VkBuffer vertex_buf;
VkDeviceMemory vertex_buf_mem;
VkBuffer index_buf;
VkDeviceMemory index_buf_mem;
size_t index_count;
size_t bone_count;
VkBuffer staging_buf;
VkDeviceMemory staging_mem;
void *staging_ptr;
VkCommandPool transient_cmd_pool;
uint32_t active_img_index;
} gpu_ctx_t;
typedef struct {
const char *application_name;
GLFWwindow *window;
} gpu_config_t;
mvp_t *mvp_ptr;
mat4_t *bone_ptr;
VkBuffer vertex_buf;
VkDeviceMemory vertex_mem;
VkBuffer index_buf;
VkDeviceMemory index_mem;
VkDescriptorSet desc_sets[MAX_FRAMES_IN_FLIGHT];
VkBuffer mvp_buf;
VkDeviceMemory mvp_mem;
VkBuffer bone_buf;
VkDeviceMemory bone_mem;
size_t index_count;
size_t bone_count;
} gpu_model_t;
void gpu_init(gpu_ctx_t *ctx, const gpu_config_t *config, model_t model);
void gpu_init(gpu_ctx_t *ctx, GLFWwindow *window, const char *name);
void gpu_cleanup(const gpu_ctx_t *ctx);
void gpu_render(
const gpu_ctx_t *ctx, const mvp_t *mvp, const mat4_t *bone_matrices);
void gpu_model_load(
const gpu_ctx_t *ctx, const model_t *model, gpu_model_t *out);
void gpu_model_cleanup(const gpu_ctx_t *ctx, const gpu_model_t *model);
void gpu_render_begin(gpu_ctx_t *ctx);
void gpu_render_model(
const gpu_ctx_t *ctx, const gpu_model_t *model, const mvp_t *mvp,
const mat4_t *bone_matrices);
void gpu_render_submit(gpu_ctx_t *ctx);
#endif