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

Add CI and use vcpkg. #1

Merged
merged 37 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ba8bc29
WIP: Add CI.
stripe2933 Jul 20, 2024
6de0482
WIP: Add CI.
stripe2933 Jul 20, 2024
21aeb34
WIP: Add CI.
stripe2933 Jul 20, 2024
3aa75ed
WIP: Add CI.
stripe2933 Jul 20, 2024
15552fe
WIP: Add CI.
stripe2933 Jul 20, 2024
86d81f0
WIP: Add CI.
stripe2933 Jul 20, 2024
0039a71
WIP: Add CI.
stripe2933 Jul 20, 2024
6ac1d2d
WIP: Add CI.
stripe2933 Jul 20, 2024
df24851
WIP: Add CI.
stripe2933 Jul 20, 2024
6f8b68a
WIP: Add CI.
stripe2933 Jul 20, 2024
5ab772e
WIP: Add CI.
stripe2933 Jul 20, 2024
cdc1ddf
WIP: Add CI.
stripe2933 Jul 20, 2024
e98fd6a
WIP: Add CI.
stripe2933 Jul 20, 2024
9577b10
WIP: Add CI.
stripe2933 Jul 20, 2024
0a369db
WIP: Add CI.
stripe2933 Jul 21, 2024
6274e7e
MSVC C++20 module specific fixes.
stripe2933 Jul 21, 2024
cedaef6
Use CPM.cmake to manage dependency.
stripe2933 Jul 21, 2024
565226b
Apply patch only if USE_VCPKG enabled.
stripe2933 Jul 21, 2024
4d5dccb
Apply patch only if USE_VCPKG enabled.
stripe2933 Jul 21, 2024
50eb89c
Apply patch only if USE_VCPKG enabled.
stripe2933 Jul 21, 2024
97ae723
Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
ab903f3
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
67279d5
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
d6a79ef
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
96bed34
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
964fcde
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
64d3cba
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
ba7bbaa
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
48722e1
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
c0590a1
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
8bce4b4
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
4c91719
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
18fb203
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
c596ca5
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
0540dbf
WIP: Use vku with vcpkg overlays.
stripe2933 Jul 21, 2024
7f90b3a
Remove log printing.
stripe2933 Jul 21, 2024
a859990
Update CI.
stripe2933 Jul 21, 2024
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: 4 additions & 0 deletions .github/workflows/clang-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(CMAKE_C_COMPILER /usr/bin/clang-18)
set(CMAKE_CXX_COMPILER /usr/bin/clang++-18)
set(CMAKE_CXX_FLAGS "-stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++ -lc++abi")
53 changes: 53 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Linux

env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

on:
push:
paths:
- '**'
- '!README.md'
- '!LICENSE.txt'
- '!doc/**'
- '!.github/workflows/*.yml'
- '.github/workflows/linux.yml'

jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Install Vulkan SDK
uses: humbletim/[email protected]
with:
vulkan-query-version: latest
vulkan-components: Vulkan-Headers, Vulkan-Loader
vulkan-use-cache: true

- name: Install Ninja and build dependencies
run: |
sudo apt-get install ninja-build xorg-dev libc++-dev libc++abi-dev

- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: Configure
run: |
cmake --preset=vcpkg \
-DCMAKE_C_COMPILER="/usr/bin/clang-18" \
-DCMAKE_CXX_COMPILER="/usr/bin/clang++-18" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_OVERLAY_TRIPLETS=".github/workflows/triplets" \
-DVCPKG_TARGET_TRIPLET="x64-linux-clang" \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -lc++abi"

- name: Build
run: cmake --build build --config release
5 changes: 5 additions & 0 deletions .github/workflows/triplets/x64-linux-clang.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../clang-toolchain.cmake)
48 changes: 48 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Windows

env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

on:
push:
paths:
- '**'
- '!README.md'
- '!LICENSE.txt'
- '!doc/**'
- '!.github/workflows/*.yml'
- '.github/workflows/windows.yml'

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1
with:
toolset: 14.40

- name: Install Vulkan SDK
uses: humbletim/[email protected]
with:
vulkan-query-version: latest
vulkan-components: Vulkan-Headers, Vulkan-Loader
vulkan-use-cache: true

- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: Configure
run: |
cmake --preset=vcpkg `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"

- name: Build
run: cmake --build build --config release
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ project(vk-deferred LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_MODULE_STD 1)

# ----------------
# Include CPM.cmake.
# ----------------

file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake
${CMAKE_CURRENT_BINARY_DIR}/CPM.cmake
)
include(${CMAKE_CURRENT_BINARY_DIR}/CPM.cmake)

# ----------------
# External dependencies.
# ----------------
Expand Down
11 changes: 10 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
"name": "default",
"displayName": "Default",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}"
"binaryDir": "${sourceDir}/build"
},
{
"name": "vcpkg",
"displayName": "vcpkg-based dependency management",
"inherits": "default",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_OVERLAY_PORTS": "${sourceDir}/overlays"
}
}
]
}
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# vk-deferred

![Linux](https://github.com/stripe2933/vk-deferred/actions/workflows/linux.yml/badge.svg)
![Windows](https://github.com/stripe2933/vk-deferred/actions/workflows/windows.yml/badge.svg)

![Running screenshot](doc/images/running-screenshot.png)

A minimal Vulkan deferred rendering demonstration.
Expand All @@ -8,7 +11,7 @@ A minimal Vulkan deferred rendering demonstration.

This project requires support for C++20 modules and the C++23 standard library. The supported compiler is:
- Clang 18.1.2
- ~~MSVC 19.40 (Older versions may fail to compile due to various MSVC module bugs)~~ (currently being tested)
- ~~MSVC 19.40 (Older versions may fail to compile due to various MSVC module bugs)~~ (currently not working with internal compiler error: I'll investigate it!)

Additionally, the following build tools are required:
- CMake 3.30
Expand All @@ -19,23 +22,47 @@ Additionally, the following build tools are required:
This project depends on:
- [GLFW](https://github.com/glfw/glfw)
- [glm](https://github.com/g-truc/glm)
- [Vulkan-Hpp](https://github.com/KhronosGroup/Vulkan-Hpp)
- [VulkanMemoryAllocator-Hpp](https://github.com/YaaZ/VulkanMemoryAllocator-Hpp)
- My own Vulkan-Hpp helper library, [vku](https://github.com/stripe2933/vku/tree/module) (branch `module`)
- My own Vulkan-Hpp helper library, [vku](https://github.com/stripe2933/vku/tree/module) (branch `module`), which has the following dependencies:
- [Vulkan-Hpp](https://github.com/KhronosGroup/Vulkan-Hpp)
- [VulkanMemoryAllocator-Hpp](https://github.com/YaaZ/VulkanMemoryAllocator-Hpp)

### Build Steps

To install `vku`, refer to the repository's [README](https://github.com/stripe2933/vku/tree/module/README.md) and follow the instructions.
### 1. Using vcpkg

> [!TIP]
> This project uses GitHub Runner to ensure build compatibility on both Linux and Windows, with dependency management handled by vcpkg. You can check the workflow files in the [.github/workflows](.github/workflows) folder.

This project, along with its dependency `vku`, supports vcpkg for dependency management. Follow these steps to build the project:

```sh
git clone https://github.com/stripe2933/vk-deferred
cd vk-deferred
cmake --preset=default # Or use your own CMakeUserPresets.json to override the configuration settings.
cmake --preset=vcpkg # Or use your own configuration preset that inherits from the "vcpkg" preset.
cmake --build build -t vk-deferred
```

The executable will be located in the build folder.

### 2. Manual Dependency Setup

If your system already has the required dependencies installed, and the following CMake commands are available:

```cmake
find_package(VulkanMemoryAllocator REQUIRED)
find_package(VulkanMemoryAllocator-Hpp REQUIRED)
find_package(vku REQUIRED)
```

You can build the project with these commands:

```sh
git clone https://github.com/stripe2933/vk-deferred
cd vk-deferred
cmake --preset=default
cmake --build build -t vk-deferred
```

### Shader compilation

All shaders are located in the [shaders](/shaders) folder and need to be manually compiled into `<shader-filename>.spv` before the application launch. To make this easier, script files are available for you:
Expand Down
3 changes: 3 additions & 0 deletions descriptor_set_layouts.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export module vk_deferred:descriptor_set_layouts;

#ifdef _MSC_VER
import std;
#endif
import vku;

export struct DeferredLightRendererDescriptorSetLayout final : vku::DescriptorSetLayouts<2> {
Expand Down
28 changes: 28 additions & 0 deletions overlays/vku/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO stripe2933/vku
REF v0.1.0-test8
SHA512 c832e3779215f55240df0f868bfb1513d9d4e4d4434c6610607517b251e251f6a13325e3e447c7c73628e79767f93401a2ced09fc473a464577599fac519a272
HEAD_REF module
PATCHES vcpkg-deps.patch
)

# Module project doesn't use header files.
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)

vcpkg_cmake_configure(SOURCE_PATH "${SOURCE_PATH}")
vcpkg_cmake_install()

file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/share)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/cmake/vku ${CURRENT_PACKAGES_DIR}/debug/share/vku)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share)
file(RENAME ${CURRENT_PACKAGES_DIR}/cmake/vku ${CURRENT_PACKAGES_DIR}/share/vku)

vcpkg_cmake_config_fixup(PACKAGE_NAME "vku")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/cmake" "${CURRENT_PACKAGES_DIR}/debug/cmake")

file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" COPYONLY)
4 changes: 4 additions & 0 deletions overlays/vku/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vku provides CMake targets:

find_package(vku CONFIG REQUIRED)
target_link_libraries(main PRIVATE vku::vku)
61 changes: 61 additions & 0 deletions overlays/vku/vcpkg-deps.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Subject: [PATCH] vcpkg-based dependency management.
---
Index: extlibs/module-ports/vk_mem_alloc.cppm
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/extlibs/module-ports/vk_mem_alloc.cppm b/extlibs/module-ports/vk_mem_alloc.cppm
--- a/extlibs/module-ports/vk_mem_alloc.cppm (revision b857b0b68629b4e2c34b60a4a0b1692807918ce0)
+++ b/extlibs/module-ports/vk_mem_alloc.cppm (date 1721580719051)
@@ -1,6 +1,6 @@
module;
#define VMA_IMPLEMENTATION
-#include <vk_mem_alloc.hpp>
+#include <vulkan-memory-allocator-hpp/vk_mem_alloc.hpp>
export module vk_mem_alloc_hpp;

export namespace VMA_HPP_NAMESPACE {
Index: cmake/config.cmake.in
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/cmake/config.cmake.in b/cmake/config.cmake.in
--- a/cmake/config.cmake.in (revision b857b0b68629b4e2c34b60a4a0b1692807918ce0)
+++ b/cmake/config.cmake.in (date 1721580719048)
@@ -5,6 +5,6 @@
include(CMakeFindDependencyMacro)
find_dependency(Vulkan 1.3.256)
find_dependency(VulkanMemoryAllocator)
-find_dependency(VulkanMemoryAllocator-Hpp)
+find_dependency(unofficial-vulkan-memory-allocator-hpp)

check_required_components(@PROJECT_NAME@)
\ No newline at end of file
Index: CMakeLists.txt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt (revision b857b0b68629b4e2c34b60a4a0b1692807918ce0)
+++ b/CMakeLists.txt (date 1721580719055)
@@ -28,7 +28,7 @@

find_package(Vulkan 1.3.256 REQUIRED)
find_package(VulkanMemoryAllocator CONFIG REQUIRED)
-find_package(VulkanMemoryAllocator-Hpp CONFIG REQUIRED)
+find_package(unofficial-vulkan-memory-allocator-hpp CONFIG REQUIRED)

# ----------------
# Module configurations for the external dependencies.
@@ -63,7 +63,7 @@
target_link_libraries(VulkanMemoryAllocator-Hpp_module PUBLIC
Vulkan::Vulkan
GPUOpen::VulkanMemoryAllocator
- VulkanMemoryAllocator-Hpp::VulkanMemoryAllocator-Hpp
+ unofficial::VulkanMemoryAllocator-Hpp::VulkanMemoryAllocator-Hpp
)

add_library(VulkanMemoryAllocator-Hpp::module ALIAS VulkanMemoryAllocator-Hpp_module)
19 changes: 19 additions & 0 deletions overlays/vku/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "vku",
"version": "0.1.0",
"homepage": "https://github.com/stripe2933/vku",
"description": "Vulkan simplifications.",
"license": "MIT",
"dependencies": [
{
"name" : "vcpkg-cmake",
"host" : true
},
{
"name" : "vcpkg-cmake-config",
"host" : true
},
"vulkan-memory-allocator",
"vulkan-memory-allocator-hpp"
]
}
1 change: 1 addition & 0 deletions overlays/vulkan/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
4 changes: 4 additions & 0 deletions overlays/vulkan/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "vulkan",
"version": "1.3.283"
}
3 changes: 3 additions & 0 deletions pipelines.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export module vk_deferred:pipelines;

#ifdef _MSC_VER
import std;
#endif
export import glm;
export import vulkan_hpp;
import vku;
Expand Down
3 changes: 3 additions & 0 deletions render_passes.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export module vk_deferred:render_passes;

#ifdef _MSC_VER
import std;
#endif
import vku;
export import vulkan_hpp;

Expand Down
14 changes: 14 additions & 0 deletions vcpkg-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"default-registry": {
"kind": "git",
"baseline": "7aeffc91033ad35cc4e2c152f213a866ec6c11ac",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "artifact",
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
"name": "microsoft"
}
]
}
Loading
Loading