Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix/workflow: add cross-platform build tests #2

Merged
merged 8 commits into from
Feb 15, 2024
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
16 changes: 8 additions & 8 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: CMake on multiple platforms

on:
push:
branches: [ "main" ]
branches: [ "main", "bugfix/workflow" ]
pull_request:
branches: [ "main" ]

Expand Down Expand Up @@ -53,19 +53,25 @@ 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/[email protected]
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
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# 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 }}
Expand All @@ -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 }}
2 changes: 1 addition & 1 deletion 3dgs/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void Renderer::initializeVulkan() {
configuration.enableVulkanValidationLayers);

context->createInstance();
auto surface = vk::SurfaceKHR{window->createSurface(context)};
auto surface = static_cast<vk::SurfaceKHR>(window->createSurface(context));
context->selectPhysicalDevice(configuration.physicalDeviceId, surface);

vk::PhysicalDeviceFeatures pdf{};
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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] <input_file.ply>
Expand Down
1 change: 1 addition & 0 deletions shaders/precomp_cov3d.comp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#version 450
#extension GL_GOOGLE_include_directive : enable
#include "./common.glsl"

#ifdef DEBUG
Expand Down
1 change: 1 addition & 0 deletions shaders/prefix_sum.comp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#version 450
#extension GL_GOOGLE_include_directive : enable
#include "./common.glsl"

#ifdef DEBUG
Expand Down
1 change: 1 addition & 0 deletions shaders/preprocess.comp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#version 450
#extension GL_GOOGLE_include_directive : enable
#include "./common.glsl"


Expand Down
1 change: 1 addition & 0 deletions shaders/preprocess_sort.comp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#version 450
#extension GL_GOOGLE_include_directive : enable
#include "./common.glsl"

#extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable
Expand Down
1 change: 1 addition & 0 deletions shaders/render.comp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#version 450
#extension GL_GOOGLE_include_directive : enable
#include "./common.glsl"

#extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable
Expand Down
1 change: 1 addition & 0 deletions shaders/tile_boundary.comp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#version 450
#extension GL_GOOGLE_include_directive : enable
#include "./common.glsl"

#extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable
Expand Down
8 changes: 4 additions & 4 deletions vulkan/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Utils.h"

Buffer::Buffer(const std::shared_ptr<VulkanContext>& _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),
Expand All @@ -23,7 +23,7 @@ Buffer::Buffer(const std::shared_ptr<VulkanContext>& _context, uint32_t size, vk
bufferInfo.setQueueFamilyIndexCount(2).setPQueueFamilyIndices(queueFamilyIndices);
}

VkBufferCreateInfo vkBufferInfo = bufferInfo;
auto vkBufferInfo = static_cast<VkBufferCreateInfo>(bufferInfo);

VmaAllocationCreateInfo allocInfo = {};
allocInfo.usage = vmaUsage;
Expand All @@ -40,7 +40,7 @@ Buffer::Buffer(const std::shared_ptr<VulkanContext>& _context, uint32_t size, vk
if (res != VK_SUCCESS) {
throw std::runtime_error("Failed to create buffer");
}
buffer = vkBuffer;
buffer = static_cast<vk::Buffer>(vkBuffer);
}

Buffer Buffer::createStagingBuffer(uint32_t size) {
Expand Down Expand Up @@ -119,7 +119,7 @@ std::shared_ptr<Buffer> Buffer::staging(std::shared_ptr<VulkanContext> context,
false);
}

std::shared_ptr<Buffer> Buffer::storage(std::shared_ptr<VulkanContext> context, uint64_t size, bool concurrentSharing, VkDeviceSize alignment) {
std::shared_ptr<Buffer> Buffer::storage(std::shared_ptr<VulkanContext> context, uint64_t size, bool concurrentSharing, vk::DeviceSize alignment) {
return std::make_shared<Buffer>(context, size, vk::BufferUsageFlagBits::eStorageBuffer | vk::BufferUsageFlagBits::eTransferDst | vk::BufferUsageFlagBits::eTransferSrc,
VMA_MEMORY_USAGE_GPU_ONLY, VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT,
concurrentSharing, alignment);
Expand Down
2 changes: 1 addition & 1 deletion vulkan/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Buffer : public std::enable_shared_from_this<Buffer> {

static std::shared_ptr<Buffer> staging(std::shared_ptr<VulkanContext> context, unsigned long size);

static std::shared_ptr<Buffer> storage(std::shared_ptr<VulkanContext> context, uint64_t size, bool concurrentSharing = false, VkDeviceSize alignment = 0);
static std::shared_ptr<Buffer> storage(std::shared_ptr<VulkanContext> context, uint64_t size, bool concurrentSharing = false, vk::DeviceSize alignment = 0);

void upload(const void *data, uint32_t size, uint32_t offset = 0);

Expand Down
Loading