Fix instance buffer size
This commit is contained in:
1 parent
b2508ce4ff
commit
99d7546e3d
8 files changed
+24
-22
No files matched your search
@@ -1,8 +1,6 @@
|
||||
#ifndef RSE_GRAPHICS_H
|
||||
#define RSE_GRAPHICS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "utilities/rse_commons.h"
|
||||
|
||||
/**
|
||||
@@ -27,4 +25,4 @@ rse_err_t rse_graphics_run(void);
|
||||
*/
|
||||
void rse_graphics_test_function(void);
|
||||
|
||||
#endif /* RSE_GRAPHICS_H */
|
||||
#endif /* RSE_GRAPHICS_H */
|
||||
@@ -6,10 +6,8 @@
|
||||
#include "locale_vulkan.h"
|
||||
#include "utilities/logger.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define MAX_INSTANCE_NUMBER 256
|
||||
|
||||
#define MESH_ID_FREE 0
|
||||
#define MESH_ID_TAKEN 1
|
||||
@@ -117,4 +115,4 @@ size_t get_instances_count(uint16_t mesh_id)
|
||||
size_t get_vertex_offset(uint16_t mesh_id)
|
||||
{
|
||||
return g_meshes[mesh_id].vertex_data.buffer_offset;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "utilities/logger.h"
|
||||
#include "utilities/rse_commons.h"
|
||||
#include "utilities/rse_errors_common.h"
|
||||
#include "rse_font_errors.h"
|
||||
|
||||
#include "rse_math.h"
|
||||
|
||||
|
||||
@@ -20,5 +20,6 @@
|
||||
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
|
||||
#pragma GCC diagnostic ignored "-Wswitch"
|
||||
#pragma GCC diagnostic ignored "-Wparentheses"
|
||||
#include <cstdio>
|
||||
#include "vk_mem_alloc.h"
|
||||
#pragma GCC diagnostic pop
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "vulkan_buffers.h"
|
||||
|
||||
#include "src/vulkan_commons.h"
|
||||
#include "vulkan_errors.h"
|
||||
#include "locale_vulkan.h"
|
||||
#include "utilities/logger.h"
|
||||
@@ -11,7 +12,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#define MAX_VERTEX_BUFFER_SIZE 33554432 /* 32 MB*/
|
||||
#define MAX_INSTANCE_BUFFER_SIZE 8192 /* 8 MB*/
|
||||
|
||||
/* GPU visible buffer */
|
||||
size_t g_vertex_offset = 0;
|
||||
@@ -99,7 +99,7 @@ static rse_err_t create_instance_buffers()
|
||||
size_t iter = 0U;
|
||||
VkDeviceSize buffer_size;
|
||||
|
||||
buffer_size = MAX_VERTEX_BUFFER_SIZE;
|
||||
buffer_size = sizeof(struct rse_instance_data_t) * MAX_INSTANCE_NUMBER;
|
||||
|
||||
for (iter = 0; iter < MAX_MESH_NUMBER; ++iter) {
|
||||
/* Create Instance Buffer */
|
||||
@@ -250,7 +250,7 @@ rse_err_t rse_add_vertices(uint16_t mesh_id,
|
||||
g_vertex_buffer.allocated_size += vertices_size;
|
||||
|
||||
/* Fill staging buffer with index data */
|
||||
memset(staging_buffer.allocation_info.pMappedData, 0, MAX_VERTEX_BUFFER_SIZE);
|
||||
memset(staging_buffer.allocation_info.pMappedData, 0, indices_size);
|
||||
memcpy(staging_buffer.allocation_info.pMappedData, indices, indices_size);
|
||||
copy_buffer(staging_buffer.buffer,
|
||||
index_buffer->buffer,
|
||||
@@ -281,7 +281,7 @@ rse_err_t update_mesh_instances(uint16_t mesh_id, struct rse_instance_data_t* in
|
||||
size_t instance_size = sizeof(struct rse_instance_data_t);
|
||||
|
||||
/* Creating staging buffer*/
|
||||
STATUS_CHECK(create_buffer(MAX_VERTEX_BUFFER_SIZE,
|
||||
STATUS_CHECK(create_buffer(instance_size,
|
||||
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
||||
VMA_MEMORY_USAGE_AUTO_PREFER_HOST,
|
||||
VMA_ALLOCATION_CREATE_MAPPED_BIT
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#define MAX_MESH_NUMBER 256
|
||||
#define MAX_INSTANCE_NUMBER 256
|
||||
|
||||
/**
|
||||
* @brief Represents data within vertex or instance buffer.
|
||||
@@ -106,4 +107,4 @@ rse_err_t create_buffer(const VkDeviceSize size,
|
||||
*/
|
||||
void destroy_buffer(struct rse_vulkan_buffer_t* buffer);
|
||||
|
||||
#endif /* RSE_VULKAN_BUFFERS_H */
|
||||
#endif /* RSE_VULKAN_BUFFERS_H */
|
||||
Reference in new issue
Block a user