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,
|
ctx->dev, ctx->mvp_buffer_mem, 0, mvp_buffer_size, 0,
|
||||||
(void **)&ctx->mvps);
|
(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
|
// Configure descriptor sets to use MVP buffer
|
||||||
for (unsigned i = 0; i < swapchain_img_count; ++i) {
|
for (unsigned i = 0; i < swapchain_img_count; ++i) {
|
||||||
const VkWriteDescriptorSet desc_write = {
|
const VkWriteDescriptorSet desc_write = {
|
||||||
@@ -803,6 +815,10 @@ void gpu_cleanup(const gpu_ctx_t *ctx)
|
|||||||
vkDestroyRenderPass(ctx->dev, ctx->render_pass, nullptr);
|
vkDestroyRenderPass(ctx->dev, ctx->render_pass, nullptr);
|
||||||
vkDestroyPipelineLayout(ctx->dev, ctx->pipeline_layout, 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);
|
vkUnmapMemory(ctx->dev, ctx->mvp_buffer_mem);
|
||||||
vkDestroyBuffer(ctx->dev, ctx->mvp_buffer, nullptr);
|
vkDestroyBuffer(ctx->dev, ctx->mvp_buffer, nullptr);
|
||||||
vkFreeMemory(ctx->dev, ctx->mvp_buffer_mem, nullptr);
|
vkFreeMemory(ctx->dev, ctx->mvp_buffer_mem, nullptr);
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ typedef struct {
|
|||||||
VkBuffer mvp_buffer;
|
VkBuffer mvp_buffer;
|
||||||
VkDeviceMemory mvp_buffer_mem;
|
VkDeviceMemory mvp_buffer_mem;
|
||||||
mvp_t *mvps;
|
mvp_t *mvps;
|
||||||
|
VkBuffer bone_matrix_buffer;
|
||||||
|
VkDeviceMemory bone_matrix_buffer_mem;
|
||||||
|
mat4_t *bone_matrices;
|
||||||
VkPipelineLayout pipeline_layout;
|
VkPipelineLayout pipeline_layout;
|
||||||
VkRenderPass render_pass;
|
VkRenderPass render_pass;
|
||||||
VkPipeline pipeline;
|
VkPipeline pipeline;
|
||||||
|
|||||||
Reference in new issue
Block a user