Fix instance buffer size

This commit is contained in:
Piotr Krygier committed 2025-06-20 13:44:33 +02:00
1 parent b2508ce4ff
commit 99d7546e3d
8 files changed
+16 -14

No files matched your search

+2 -2
View File
@@ -5,7 +5,7 @@ custom_commands = cd GLFW && mkdir build && cd build && cmake .. -D BUILD_SHARED
[Vulkan-SDK] [Vulkan-SDK]
dl_url = https://sdk.lunarg.com/sdk/download/1.3.250.1/linux/vulkansdk-linux-x86_64-1.3.250.1.tar.gz dl_url = https://sdk.lunarg.com/sdk/download/1.3.250.1/linux/vulkansdk-linux-x86_64-1.3.250.1.tar.gz
custom_commands = tar -xf Vulkan-SDK && mv 1.3.250.1 vulkan && rm Vulkan-SDK custom_commands = tar -xf Vulkan-SDK && mv 1.3.250.1 vulkan && rm Vulkan-SDK && cd vulkan && ./vulkansdk -j 4 glslang vulkan-headers loader layers tools shaderc vulkan-extensionlayer
[vma] [vma]
git_url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git git_url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
@@ -22,4 +22,4 @@ tag = master
[FreeType] [FreeType]
dl_url = https://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.gz dl_url = https://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.gz
custom_commands = tar -xf freetype-2.10.0.tar.gz mv freetype-2.10.0 freetype && rm freetype-2.10.0.tar.gz && cmake -E make_directory build && cmake -E chdir build cmake -D BUILD_SHARED_LIBS:BOOL=true .. && cmake --build build custom_commands = tar -xf FreeType && mv freetype-2.10.0 freetype && rm FreeType && cd freetype && cmake -E make_directory build && cmake -E chdir build cmake -D BUILD_SHARED_LIBS:BOOL=true .. && cmake --build build
-2
View File
@@ -1,8 +1,6 @@
#ifndef RSE_GRAPHICS_H #ifndef RSE_GRAPHICS_H
#define RSE_GRAPHICS_H #define RSE_GRAPHICS_H
#include <stdint.h>
#include "utilities/rse_commons.h" #include "utilities/rse_commons.h"
/** /**
-2
View File
@@ -6,10 +6,8 @@
#include "locale_vulkan.h" #include "locale_vulkan.h"
#include "utilities/logger.h" #include "utilities/logger.h"
#include <stdlib.h>
#include <string.h> #include <string.h>
#define MAX_INSTANCE_NUMBER 256
#define MESH_ID_FREE 0 #define MESH_ID_FREE 0
#define MESH_ID_TAKEN 1 #define MESH_ID_TAKEN 1
-1
View File
@@ -9,7 +9,6 @@
#include "utilities/logger.h" #include "utilities/logger.h"
#include "utilities/rse_commons.h" #include "utilities/rse_commons.h"
#include "utilities/rse_errors_common.h" #include "utilities/rse_errors_common.h"
#include "rse_font_errors.h"
#include "rse_math.h" #include "rse_math.h"
+1
View File
@@ -20,5 +20,6 @@
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#pragma GCC diagnostic ignored "-Wswitch" #pragma GCC diagnostic ignored "-Wswitch"
#pragma GCC diagnostic ignored "-Wparentheses" #pragma GCC diagnostic ignored "-Wparentheses"
#include <cstdio>
#include "vk_mem_alloc.h" #include "vk_mem_alloc.h"
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
+4 -4
View File
@@ -1,5 +1,6 @@
#include "vulkan_buffers.h" #include "vulkan_buffers.h"
#include "src/vulkan_commons.h"
#include "vulkan_errors.h" #include "vulkan_errors.h"
#include "locale_vulkan.h" #include "locale_vulkan.h"
#include "utilities/logger.h" #include "utilities/logger.h"
@@ -11,7 +12,6 @@
#include <string.h> #include <string.h>
#define MAX_VERTEX_BUFFER_SIZE 33554432 /* 32 MB*/ #define MAX_VERTEX_BUFFER_SIZE 33554432 /* 32 MB*/
#define MAX_INSTANCE_BUFFER_SIZE 8192 /* 8 MB*/
/* GPU visible buffer */ /* GPU visible buffer */
size_t g_vertex_offset = 0; size_t g_vertex_offset = 0;
@@ -99,7 +99,7 @@ static rse_err_t create_instance_buffers()
size_t iter = 0U; size_t iter = 0U;
VkDeviceSize buffer_size; 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) { for (iter = 0; iter < MAX_MESH_NUMBER; ++iter) {
/* Create Instance Buffer */ /* Create Instance Buffer */
@@ -250,7 +250,7 @@ rse_err_t rse_add_vertices(uint16_t mesh_id,
g_vertex_buffer.allocated_size += vertices_size; g_vertex_buffer.allocated_size += vertices_size;
/* Fill staging buffer with index data */ /* 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); memcpy(staging_buffer.allocation_info.pMappedData, indices, indices_size);
copy_buffer(staging_buffer.buffer, copy_buffer(staging_buffer.buffer,
index_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); size_t instance_size = sizeof(struct rse_instance_data_t);
/* Creating staging buffer*/ /* Creating staging buffer*/
STATUS_CHECK(create_buffer(MAX_VERTEX_BUFFER_SIZE, STATUS_CHECK(create_buffer(instance_size,
VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
VMA_MEMORY_USAGE_AUTO_PREFER_HOST, VMA_MEMORY_USAGE_AUTO_PREFER_HOST,
VMA_ALLOCATION_CREATE_MAPPED_BIT VMA_ALLOCATION_CREATE_MAPPED_BIT
+1
View File
@@ -9,6 +9,7 @@
#include <stdint.h> #include <stdint.h>
#define MAX_MESH_NUMBER 256 #define MAX_MESH_NUMBER 256
#define MAX_INSTANCE_NUMBER 256
/** /**
* @brief Represents data within vertex or instance buffer. * @brief Represents data within vertex or instance buffer.
+8 -3
View File
@@ -35,19 +35,24 @@ class Dependency:
break break
def download(self): def download(self):
dl_counter = 0
# Git repository # Git repository
if hasattr(self, "git_url") and self.git_url: if hasattr(self, "git_url") and self.git_url:
repo = git.Repo.clone_from(self.git_url, os.path.join(REPO_DIR, self.name)) repo = git.Repo.clone_from(self.git_url, os.path.join(REPO_DIR, self.name))
repo.git.checkout(self.tag) repo.git.checkout(self.tag)
elif hasattr(self, "dl_url") and self.dl_url: elif hasattr(self, "dl_url") and self.dl_url:
while dl_counter < 10:
response = requests.get(self.dl_url) response = requests.get(self.dl_url)
if response.status_code == 200: # everything went fine if response.status_code == 200: # everything went fine
open(os.path.join(REPO_DIR, self.name), "wb").write(response.content) open(os.path.join(REPO_DIR, self.name), "wb").write(response.content)
break
dl_counter += 1
print("Failed to download {}. Retrying {}th time...", self.name, dl_counter)
time.sleep(5.0)
if hasattr(self, "custom_commands") and self.custom_commands: if hasattr(self, "custom_commands") and self.custom_commands:
p = subprocess.Popen(self.custom_commands, shell=True) p = subprocess.run(self.custom_commands, shell=True)
p.chek_returncode()
def main(): def main():
if not os.path.isdir(REPO_DIR): if not os.path.isdir(REPO_DIR):