From 8b0b7c4c074c8f20386b92b0a741440ec1baee17 Mon Sep 17 00:00:00 2001 From: shg8 <38004233+shg8@users.noreply.github.com> Date: Wed, 14 Feb 2024 21:57:22 -0800 Subject: [PATCH] bugfix/workflow: add cross-platform build tests (#2) * Add Vulkan SDK directory to CMake configure * Remove tests * Trigger actions on current branch * Fix workflow * Update Vulkan SDK dependencies * Add explicit conversions <-> C types * Fix glm error for MSBuild * Add badge to README --- .github/workflows/cmake-multi-platform.yml | 16 ++++++++-------- 3dgs/Renderer.cpp | 2 +- CMakeLists.txt | 6 +++--- README.md | 14 +++++++++++--- shaders/precomp_cov3d.comp | 1 + shaders/prefix_sum.comp | 1 + shaders/preprocess.comp | 1 + shaders/preprocess_sort.comp | 1 + shaders/render.comp | 1 + shaders/tile_boundary.comp | 1 + vulkan/Buffer.cpp | 8 ++++---- vulkan/Buffer.h | 2 +- 12 files changed, 34 insertions(+), 20 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index ca05f28..899e477 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -4,7 +4,7 @@ name: CMake on multiple platforms on: push: - branches: [ "main" ] + branches: [ "main", "bugfix/workflow" ] pull_request: branches: [ "main" ] @@ -53,12 +53,17 @@ jobs: shell: bash run: | echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + echo "vulkan-sdk-dir=${{ github.workspace }}/VULKAN_SDK" >> "$GITHUB_OUTPUT" + + - name: Install dependencies + if: matrix.os == 'ubuntu-latest' + run: sudo apt-get update && sudo apt-get install -y libglfw3-dev libglm-dev - name: Prepare Vulkan SDK uses: humbletim/setup-vulkan-sdk@v1.2.0 with: vulkan-query-version: 1.3.204.0 - vulkan-components: Vulkan-Headers, Vulkan-Loader, Glslang, SPIRV-Tools + vulkan-components: Vulkan-Headers, Vulkan-Loader, Glslang vulkan-use-cache: true - name: Configure CMake @@ -66,6 +71,7 @@ jobs: # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type run: > cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DVULKAN_SDK=${{ steps.strings.outputs.vulkan-sdk-dir }} -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} @@ -74,9 +80,3 @@ jobs: - name: Build # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} - - - name: Test - working-directory: ${{ steps.strings.outputs.build-output-dir }} - # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest --build-config ${{ matrix.build_type }} diff --git a/3dgs/Renderer.cpp b/3dgs/Renderer.cpp index 5cad722..8524309 100644 --- a/3dgs/Renderer.cpp +++ b/3dgs/Renderer.cpp @@ -66,7 +66,7 @@ void Renderer::initializeVulkan() { configuration.enableVulkanValidationLayers); context->createInstance(); - auto surface = vk::SurfaceKHR{window->createSurface(context)}; + auto surface = static_cast(window->createSurface(context)); context->selectPhysicalDevice(configuration.physicalDeviceId, surface); vk::PhysicalDeviceFeatures pdf{}; diff --git a/CMakeLists.txt b/CMakeLists.txt index 68bde6e..2c5565a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ include(FetchContent) set(CMAKE_CXX_STANDARD 20) -find_package(Vulkan COMPONENTS glslc) +find_package(Vulkan COMPONENTS glslangValidator) if (WIN32) FetchContent_Declare( @@ -72,7 +72,7 @@ foreach (GLSL ${GLSL_SOURCE_FILES}) add_custom_command( OUTPUT ${SPIRV} COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/shaders/" - COMMAND ${Vulkan_GLSLC_EXECUTABLE} ${GLSL} -o ${SPIRV} ${GLSLC_DEFINE} "--target-env=vulkan1.2" + COMMAND ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} "--target-env" "vulkan1.2" -V ${GLSL} -o ${SPIRV} ${GLSLC_DEFINE} DEPENDS ${GLSL}) list(APPEND SPIRV_BINARY_FILES ${SPIRV}) endforeach (GLSL) @@ -106,7 +106,7 @@ add_executable(vulkan_splatting main.cpp add_dependencies(vulkan_splatting Shaders) -target_include_directories(vulkan_splatting PUBLIC ${Vulkan_INCLUDE_DIRS} ${GLM_INCLUDE_DIRS}) +target_include_directories(vulkan_splatting PUBLIC ${Vulkan_INCLUDE_DIRS} ${GLM_INCLUDE_DIRS} ${glm_SOURCE_DIR}) target_link_libraries(vulkan_splatting PUBLIC glfw libenvpp::libenvpp) target_link_libraries(vulkan_splatting PUBLIC Vulkan::Vulkan) diff --git a/README.md b/README.md index b0a20d4..c56da2e 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,27 @@ # VulkanSplatting VulkanSplatting is an (not-yet-highly-) optimized, cross-platform implementation of [Gaussian Splatting](https://repo-sam.inria.fr/fungraph/3d-gaussian-splatting/) using the [Vulkan API](https://www.khronos.org/vulkan/) and compute pipelines. +[![Windows + Linux](https://github.com/shg8/VulkanSplatting/actions/workflows/cmake-multi-platform.yml/badge.svg?branch=main)](https://github.com/shg8/VulkanSplatting/actions/workflows/cmake-multi-platform.yml) + ## Building ### Linux VulkanSplatting requires the following dependencies: -`Vulkan headers, Vulkan validation layers, glslc, glfw, glm` -The easiest way to install them is through the [LunarG Vulkan SDK](https://www.lunarg.com/vulkan-sdk/). Alternatively, there shouldn't be any problems using these packages from your distro as long as they're reasonably update-to-date. +`Vulkan headers, Vulkan validation layers, glslangValidator, glfw, glm` + +The easiest way to install the first three is through the [LunarG Vulkan SDK](https://www.lunarg.com/vulkan-sdk/). Alternatively, you can install the corresponding packages from your distro. For Ubuntu, the packages to install are `vulkan-headers, vulkan-validationlayers, glslang-dev, libglfw3-dev, libglm-dev`. + ### Windows -After installing [LunarG Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) with all the required components (see the Linux section), set the `VULKAN_SDK` environmental variable to the install path. Alternatively, pass "-DVULKAN_SDK=\INSTALL\LOCATION\OF\YOUR\SDK" to CMake. A full CMake configure command is as follows: +After installing [LunarG Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) with all the required components (see the Linux section), set the `VULKAN_SDK` environmental variable to the install path. Alternatively, pass "-DVULKAN_SDK=\INSTALL\LOCATION\OF\YOUR\SDK" to CMake. + +A full CMake configure command is as follows: ``` mkdir .\VulkanSplatting\build cmake -DCMAKE_BUILD_TYPE=Release -DVULKAN_SDK=\INSTALL\LOCATION\OF\YOUR\SDK -S .\VulkanSplatting -B .\VulkanSplatting\build ``` + Only Ninja has been tested as a generator on Windows, but other generators should work as well. To use ninja, add `-G Ninja` to the configure command and make sure that the binary is available in your PATH. + ## Command Line Usage ``` ./vulkan_splatting [options] diff --git a/shaders/precomp_cov3d.comp b/shaders/precomp_cov3d.comp index 64bb1f7..f776b8c 100644 --- a/shaders/precomp_cov3d.comp +++ b/shaders/precomp_cov3d.comp @@ -1,4 +1,5 @@ #version 450 +#extension GL_GOOGLE_include_directive : enable #include "./common.glsl" #ifdef DEBUG diff --git a/shaders/prefix_sum.comp b/shaders/prefix_sum.comp index e12a62b..dec1f85 100644 --- a/shaders/prefix_sum.comp +++ b/shaders/prefix_sum.comp @@ -1,4 +1,5 @@ #version 450 +#extension GL_GOOGLE_include_directive : enable #include "./common.glsl" #ifdef DEBUG diff --git a/shaders/preprocess.comp b/shaders/preprocess.comp index 7529cd5..e46e3f0 100644 --- a/shaders/preprocess.comp +++ b/shaders/preprocess.comp @@ -1,4 +1,5 @@ #version 450 +#extension GL_GOOGLE_include_directive : enable #include "./common.glsl" diff --git a/shaders/preprocess_sort.comp b/shaders/preprocess_sort.comp index f793d3c..265d802 100644 --- a/shaders/preprocess_sort.comp +++ b/shaders/preprocess_sort.comp @@ -1,4 +1,5 @@ #version 450 +#extension GL_GOOGLE_include_directive : enable #include "./common.glsl" #extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable diff --git a/shaders/render.comp b/shaders/render.comp index e24f720..96e94ec 100644 --- a/shaders/render.comp +++ b/shaders/render.comp @@ -1,4 +1,5 @@ #version 450 +#extension GL_GOOGLE_include_directive : enable #include "./common.glsl" #extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable diff --git a/shaders/tile_boundary.comp b/shaders/tile_boundary.comp index 3c1fd1a..bfe7ba4 100644 --- a/shaders/tile_boundary.comp +++ b/shaders/tile_boundary.comp @@ -1,4 +1,5 @@ #version 450 +#extension GL_GOOGLE_include_directive : enable #include "./common.glsl" #extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable diff --git a/vulkan/Buffer.cpp b/vulkan/Buffer.cpp index bf65e44..3abbd46 100644 --- a/vulkan/Buffer.cpp +++ b/vulkan/Buffer.cpp @@ -5,7 +5,7 @@ #include "Utils.h" Buffer::Buffer(const std::shared_ptr& _context, uint32_t size, vk::BufferUsageFlags usage, - VmaMemoryUsage vmaUsage, VmaAllocationCreateFlags flags, bool shared, VkDeviceSize alignment) + VmaMemoryUsage vmaUsage, VmaAllocationCreateFlags flags, bool shared, vk::DeviceSize alignment) : context(_context), size(size), usage(usage), @@ -23,7 +23,7 @@ Buffer::Buffer(const std::shared_ptr& _context, uint32_t size, vk bufferInfo.setQueueFamilyIndexCount(2).setPQueueFamilyIndices(queueFamilyIndices); } - VkBufferCreateInfo vkBufferInfo = bufferInfo; + auto vkBufferInfo = static_cast(bufferInfo); VmaAllocationCreateInfo allocInfo = {}; allocInfo.usage = vmaUsage; @@ -40,7 +40,7 @@ Buffer::Buffer(const std::shared_ptr& _context, uint32_t size, vk if (res != VK_SUCCESS) { throw std::runtime_error("Failed to create buffer"); } - buffer = vkBuffer; + buffer = static_cast(vkBuffer); } Buffer Buffer::createStagingBuffer(uint32_t size) { @@ -119,7 +119,7 @@ std::shared_ptr Buffer::staging(std::shared_ptr context, false); } -std::shared_ptr Buffer::storage(std::shared_ptr context, uint64_t size, bool concurrentSharing, VkDeviceSize alignment) { +std::shared_ptr Buffer::storage(std::shared_ptr context, uint64_t size, bool concurrentSharing, vk::DeviceSize alignment) { return std::make_shared(context, size, vk::BufferUsageFlagBits::eStorageBuffer | vk::BufferUsageFlagBits::eTransferDst | vk::BufferUsageFlagBits::eTransferSrc, VMA_MEMORY_USAGE_GPU_ONLY, VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, concurrentSharing, alignment); diff --git a/vulkan/Buffer.h b/vulkan/Buffer.h index 788c8fa..e94908d 100644 --- a/vulkan/Buffer.h +++ b/vulkan/Buffer.h @@ -25,7 +25,7 @@ class Buffer : public std::enable_shared_from_this { static std::shared_ptr staging(std::shared_ptr context, unsigned long size); - static std::shared_ptr storage(std::shared_ptr context, uint64_t size, bool concurrentSharing = false, VkDeviceSize alignment = 0); + static std::shared_ptr storage(std::shared_ptr context, uint64_t size, bool concurrentSharing = false, vk::DeviceSize alignment = 0); void upload(const void *data, uint32_t size, uint32_t offset = 0);