Create buffer for bone matrices
This commit is contained in:
1 parent
1aaf5a53b8
commit
e42986adc3
2 files changed
+19
No files matched your search
@@ -462,6 +462,18 @@ void gpu_init(gpu_ctx_t *ctx, const gpu_config_t *config, model_t model)
|
||||
ctx->dev, ctx->mvp_buffer_mem, 0, mvp_buffer_size, 0,
|
||||
(void **)&ctx->mvps);
|
||||
|
||||
// Create and map bone matrix buffer
|
||||
const size_t bone_matrix_buffer_size
|
||||
= swapchain_img_count * model.bone_count * sizeof(mat4_t);
|
||||
create_buffer(
|
||||
ctx, bone_matrix_buffer_size, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
|
||||
| VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||
&ctx->bone_matrix_buffer, &ctx->bone_matrix_buffer_mem);
|
||||
vkMapMemory(
|
||||
ctx->dev, ctx->bone_matrix_buffer_mem, 0, bone_matrix_buffer_size, 0,
|
||||
(void **)&ctx->bone_matrices);
|
||||
|
||||
// Configure descriptor sets to use MVP buffer
|
||||
for (unsigned i = 0; i < swapchain_img_count; ++i) {
|
||||
const VkWriteDescriptorSet desc_write = {
|
||||
@@ -803,6 +815,10 @@ void gpu_cleanup(const gpu_ctx_t *ctx)
|
||||
vkDestroyRenderPass(ctx->dev, ctx->render_pass, nullptr);
|
||||
vkDestroyPipelineLayout(ctx->dev, ctx->pipeline_layout, nullptr);
|
||||
|
||||
vkUnmapMemory(ctx->dev, ctx->bone_matrix_buffer_mem);
|
||||
vkDestroyBuffer(ctx->dev, ctx->bone_matrix_buffer, nullptr);
|
||||
vkFreeMemory(ctx->dev, ctx->bone_matrix_buffer_mem, nullptr);
|
||||
|
||||
vkUnmapMemory(ctx->dev, ctx->mvp_buffer_mem);
|
||||
vkDestroyBuffer(ctx->dev, ctx->mvp_buffer, nullptr);
|
||||
vkFreeMemory(ctx->dev, ctx->mvp_buffer_mem, nullptr);
|
||||
|
||||
Reference in new issue
Block a user