From 9ba02bd87df6fb9f912536b8fe0f89c0f19d0401 Mon Sep 17 00:00:00 2001 From: shg8 <38004233+shg8@users.noreply.github.com> Date: Fri, 16 Feb 2024 03:34:40 -0600 Subject: [PATCH] bugfix/plypath: fix file path checking (#8) * Fix path checking * Decrease reserved memory --- 3dgs/GSScene.h | 6 +++--- 3dgs/Renderer.cpp | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/3dgs/GSScene.h b/3dgs/GSScene.h index b308149..4f43b5b 100644 --- a/3dgs/GSScene.h +++ b/3dgs/GSScene.h @@ -24,9 +24,9 @@ class GSScene { public: explicit GSScene(const std::string& filename) : filename(filename) { - std::filesystem::path file = std::filesystem::current_path() / filename; - if (!std::filesystem::exists(file)) { - throw std::runtime_error("File does not exist"); + // check if file exists + if (!std::filesystem::exists(filename)) { + throw std::runtime_error("File does not exist: " + filename); } } diff --git a/3dgs/Renderer.cpp b/3dgs/Renderer.cpp index 8524309..b9dea8c 100644 --- a/3dgs/Renderer.cpp +++ b/3dgs/Renderer.cpp @@ -13,7 +13,7 @@ #include "../vulkan/Utils.h" -#define SORT_ALLOCATE_MULTIPLIER 100 +#define SORT_ALLOCATE_MULTIPLIER 10 void Renderer::initialize() { initializeVulkan(); @@ -446,6 +446,9 @@ void Renderer::recordRenderCommandBuffer(uint32_t currentFrame) { uint32_t numInstances = totalSumBufferHost->readOne(); // std::cout << "Num instances: " << numInstances << std::endl; + if (numInstances > scene->getNumVertices() * SORT_ALLOCATE_MULTIPLIER) { + throw std::runtime_error("Gaussian instantiation out of memory"); + } assert(numInstances <= scene->getNumVertices() * SORT_ALLOCATE_MULTIPLIER); for (auto i = 0; i < 8; i++) { sortHistPipeline->bind(renderCommandBuffer, 0, i % 2 == 0 ? 0 : 1);