Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion 3dgs/GSScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct VertexStorage {
void GSScene::load(const std::shared_ptr<VulkanContext>&context) {
auto startTime = std::chrono::high_resolution_clock::now();

std::ifstream plyFile(filename);
std::ifstream plyFile(filename, std::ios::binary);
loadPlyHeader(plyFile);

vertexBuffer = createBuffer(context, header.numVertices * sizeof(Vertex));
Expand All @@ -32,6 +32,8 @@ void GSScene::load(const std::shared_ptr<VulkanContext>&context) {

for (auto i = 0; i < header.numVertices; i++) {
static_assert(sizeof(VertexStorage) == 62 * sizeof(float));
assert(plyFile.is_open());
assert(!plyFile.eof());
VertexStorage vertexStorage;
plyFile.read(reinterpret_cast<char *>(&vertexStorage), sizeof(VertexStorage));
verteces[i].position = glm::vec4(vertexStorage.position, 1.0f);
Expand Down
3 changes: 2 additions & 1 deletion 3dgs/GSScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class GSScene {
public:
explicit GSScene(const std::string& filename)
: filename(filename) {
if (!std::filesystem::exists(filename)) {
std::filesystem::path file = std::filesystem::current_path() / filename;
if (!std::filesystem::exists(file)) {
throw std::runtime_error("File does not exist");
}
}
Expand Down
6 changes: 3 additions & 3 deletions 3dgs/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
#include <glm/gtc/quaternion.hpp>

#include "../vulkan/Utils.h"
#include "radix_sort/platforms/vk/radix_sort_vk.h"

#define SORT_ALLOCATE_MULTIPLIER 1000
#define SORT_ALLOCATE_MULTIPLIER 100

void Renderer::initialize() {
initializeVulkan();
Expand Down Expand Up @@ -74,6 +73,7 @@ void Renderer::initializeVulkan() {
vk::PhysicalDeviceVulkan11Features pdf11{};
vk::PhysicalDeviceVulkan12Features pdf12{};
pdf.shaderInt64 = true;
pdf12.shaderFloat16 = true;
pdf12.shaderBufferInt64Atomics = true;
pdf12.shaderSharedInt64Atomics = true;

Expand Down Expand Up @@ -569,5 +569,5 @@ void Renderer::updateUniforms() {
}

Renderer::~Renderer() {
radix_sort_vk_destroy(radixSortPipeline, context->device.get(), nullptr);

}
5 changes: 0 additions & 5 deletions 3dgs/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "../vulkan/pipelines/ComputePipeline.h"
#include "../vulkan/Swapchain.h"
#include <glm/gtc/quaternion.hpp>
#include <radix_sort/platforms/vk/radix_sort_vk.h>

struct RendererConfiguration {
bool enableVulkanValidationLayers = false;
Expand Down Expand Up @@ -117,10 +116,6 @@ class Renderer {
vk::UniqueCommandBuffer preprocessCommandBuffer;
vk::UniqueCommandBuffer renderCommandBuffer;

const radix_sort_vk_target_t* radixSortTarget;
radix_sort_vk_t* radixSortPipeline;
radix_sort_vk_memory_requirements_t radixSortRequirements = {};

uint32_t currentImageIndex;

std::vector<vk::UniqueSemaphore> renderFinishedSemaphores;
Expand Down
45 changes: 35 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,49 @@ project(vulkan_splatting)

include(FetchContent)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)

find_package(Vulkan COMPONENTS glslc)

find_package(glfw3 3.3 REQUIRED)
find_package(glm REQUIRED)
if (MSVC)
FetchContent_Declare(
glfw
GIT_REPOSITORY https://github.com/glfw/glfw
GIT_TAG 3.3.9
)

FetchContent_GetProperties(glfw)
if (NOT glfw_POPULATED)
FetchContent_Populate(glfw)

set(GLFW_INSTALL OFF CACHE INTERNAL "Create GLFW installation target")
set(GLFW_BUILD_DOCS OFF CACHE INTERNAL "Build GLFW documentation")
set(GLFW_BUILD_TESTS OFF CACHE INTERNAL "Build GLFW test programs")
set(GLFW_BUILD_EXAMPLES OFF CACHE INTERNAL "Build GLFW examples")

add_subdirectory(${glfw_SOURCE_DIR} ${glfw_BINARY_DIR})
endif()

SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:mainCRTStartup")

FetchContent_Declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm
GIT_TAG 1.0.0
)
FetchContent_MakeAvailable(glm)
else ()
find_package(glfw3 3.3 REQUIRED)
find_package(glm REQUIRED)
endif ()

find_program(glslc_executable NAMES glslc HINTS Vulkan::glslc)

FetchContent_Declare(libenvpp
GIT_REPOSITORY https://github.com/ph3at/libenvpp.git
GIT_TAG v1.0.0
)
FetchContent_MakeAvailable(libenvpp)

FetchContent_Declare(fuchsia_radix_sort GIT_REPOSITORY https://github.com/juliusikkala/fuchsia_radix_sort.git GIT_TAG main)
FetchContent_MakeAvailable(fuchsia_radix_sort)

if (APPLE)
add_compile_definitions(__APPLE__)
endif ()
Expand All @@ -45,7 +70,7 @@ foreach (GLSL ${GLSL_SOURCE_FILES})
add_custom_command(
OUTPUT ${SPIRV}
COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/shaders/"
COMMAND ${glslc_executable} ${GLSL} -o ${SPIRV} ${GLSLC_DEFINE} "--target-env=vulkan1.2"
COMMAND ${Vulkan_GLSLC_EXECUTABLE} ${GLSL} -o ${SPIRV} ${GLSLC_DEFINE} "--target-env=vulkan1.2"
DEPENDS ${GLSL})
list(APPEND SPIRV_BINARY_FILES ${SPIRV})
endforeach (GLSL)
Expand Down Expand Up @@ -79,9 +104,9 @@ add_executable(vulkan_splatting main.cpp

add_dependencies(vulkan_splatting Shaders)

target_include_directories(vulkan_splatting PUBLIC ${Vulkan_INCLUDE_DIRS} ${GLM_INCLUDE_DIRS} ${VK_RADIX_SORT_INCLUDE_DIRS})
target_include_directories(vulkan_splatting PUBLIC ${Vulkan_INCLUDE_DIRS} ${GLM_INCLUDE_DIRS})

target_link_libraries(vulkan_splatting PUBLIC glfw libenvpp::libenvpp vk-radix-sort)
target_link_libraries(vulkan_splatting PUBLIC glfw libenvpp::libenvpp)
target_link_libraries(vulkan_splatting PUBLIC Vulkan::Vulkan)

add_custom_command(TARGET vulkan_splatting POST_BUILD
Expand Down
2 changes: 1 addition & 1 deletion shaders/preprocess_sort.comp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void main() {
uint64_t tileIndex = i + j * tileX;
// assert(tileIndex <= 1900, "key <= 1900 %d", tileIndex);

uint depthBits = floatBitsToUint(float16_t(attr[index].depth));
uint depthBits = floatBitsToUint(attr[index].depth);
uint64_t k = (tileIndex << 32) | uint64_t(depthBits);
keys[ind] = k;
payloads[ind] = index;
Expand Down
3 changes: 3 additions & 0 deletions vulkan/VulkanContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ VulkanContext::VulkanContext(const std::vector<std::string> &instance_extensions
deviceExtensions.push_back("VK_KHR_portability_subset");
deviceExtensions.push_back(VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME);
#endif
if (validation_layers_enabled) {
instanceExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
}
auto getInstanceProcAddr = dl.getProcAddress<PFN_vkGetInstanceProcAddr>(
"vkGetInstanceProcAddr");
VULKAN_HPP_DEFAULT_DISPATCHER.init(getInstanceProcAddr);
Expand Down