From 1668eec79e96bad3e74a0893150aa80ccd8e4b3c Mon Sep 17 00:00:00 2001 From: firewire Date: Sat, 11 Apr 2026 17:48:56 -0400 Subject: [PATCH] Actions workflow + slang, glsl compilation + asset copy --- .gitea/workflows/build.yml | 73 +++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 16 ++++++++ assets/shaders/shader.slang | 34 +++++++++++++++++ cmake/copy_files.cmake | 11 ++++++ oatmeal/cmake/glsl.cmake | 5 +-- oatmeal/cmake/slang.cmake | 5 +-- 6 files changed, 136 insertions(+), 8 deletions(-) create mode 100644 .gitea/workflows/build.yml create mode 100644 assets/shaders/shader.slang create mode 100644 cmake/copy_files.cmake diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..7c5d8ca --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,73 @@ +on: [push, pull_request] + +name: Build + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + persist-credentials: true + + - name: Checkout lfs + run: | + git lfs install --local + AUTH=$(git config --local http.${{ github.server_url }}/.extraheader) + git config --local --unset http.${{ github.server_url }}/.extraheader + git config --local http.${{ github.server_url }}/${{ github.repository }}.git/info/lfs/objects/batch.extraheader "$AUTH" + git lfs pull + + - name: Apt update + run: sudo apt update + + - name: Installing build chain + run: sudo apt-get install pigz libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev libglu1-mesa-dev libwayland-dev libxkbcommon-dev ninja-build g++ clang pkg-config cmake vulkan-tools vulkan-validationlayers glslc libglfw3 libglfw3-dev libtbb-dev -y; + + - name: Cache CPM + uses: actions/cache@v5 + with: + path: "~/.cache/CPM/" + key: ${{ runner.os }}-CPM + + - name: Install Vulkan SDK + uses: jakoch/install-vulkan-sdk-action@v1 + + - name: Configure debug + run: cd scripts; CPM_SOURCE_CACHE="~/.cache/CPM/" ./configure-debug.sh + + - name: Configure release + run: cd scripts; CPM_SOURCE_CACHE="~/.cache/CPM/" ./configure-release.sh + + - name: Configure RelWithDeb + run: cd scripts; CPM_SOURCE_CACHE="~/.cache/CPM/" ./configure-relwithdeb.sh + + - name: Build debug + run: cd scripts; ./build-debug.sh + + - name: Build release + run: cd scripts; ./build-release.sh + + - name: Build Release with debug info + run: cd scripts; ./build-relwithdeb.sh + + - name: Copy assets + run: |- + cp -r build/debug/assets bin/Debug; + cp -r build/release/assets bin/Release; + cp -r build/relwithdeb/assets bin/RelWithDeb; + + - name: Packaging + run: |- + tar -I 'pigz -9' -cf oatmeal-debug-amd64.tar.gz bin/Debug; + tar -I 'pigz -9' -cf oatmeal-rel-amd64.tar.gz bin/Release; + tar -I 'pigz -9' -cf oatmeal-relwithdeb-amd64.tar.gz bin/Relwithdeb; + + - uses: akkuman/gitea-release-action@v1 + with: + files: |- + oatmeal-debug-amd64.tar.gz + oatmeal-rel-amd64.tar.gz + oatmeal-relwithdeb-amd64.tar.gz diff --git a/CMakeLists.txt b/CMakeLists.txt index 085fbe8..6176ffd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,22 @@ foreach(cmake_file ${CMAKE_FILES}) include(${cmake_file}) endforeach() +# TODO: Add a check to disable compiling the examples + +set(ASSET_DIR "assets/") +set(SHADERS_DIR "assets/shaders") + +create_copy_folder_target(copy_assets ${CMAKE_CURRENT_SOURCE_DIR}/assets ${CMAKE_CURRENT_BINARY_DIR}/assets) +create_slang_shader_target(slang_shaders + "${SHADERS_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}/${SHADERS_DIR}" +) +create_glslc_shader_target(glsl_shaders + "${SHADERS_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}/${SHADERS_DIR}" +) + + add_subdirectory(examples/shared) add_subdirectory(examples/basicGLFWWindow) diff --git a/assets/shaders/shader.slang b/assets/shaders/shader.slang new file mode 100644 index 0000000..c514bdd --- /dev/null +++ b/assets/shaders/shader.slang @@ -0,0 +1,34 @@ +struct VSInput { + float3 inPosition; + float3 inColor; + float2 inTexCoord; +}; + +struct UniformBuffer { + float4x4 model; + float4x4 view; + float4x4 proj; +}; +ConstantBuffer ubo; + +struct VSOutput { + float4 pos : SV_Position; + float3 color; + float2 fragTexCoord; +}; + +[shader("vertex")] +VSOutput vertMain(VSInput input) { + VSOutput output; + output.pos = mul(ubo.proj, mul(ubo.view, mul(ubo.model, float4(input.inPosition, 1.0)))); + output.color = input.inColor; + output.fragTexCoord = input.inTexCoord; + return output; +} + +Sampler2D texture; + +[shader("fragment")] +float4 fragMain(VSOutput vertIn) : SV_Target { + return float4(texture.Sample(vertIn.fragTexCoord).rgb, 1.0); +} diff --git a/cmake/copy_files.cmake b/cmake/copy_files.cmake new file mode 100644 index 0000000..8a29a49 --- /dev/null +++ b/cmake/copy_files.cmake @@ -0,0 +1,11 @@ + +function(create_copy_folder_target target_name src dst) + add_custom_target(${target_name} + COMMAND + ${CMAKE_COMMAND} + -E copy_directory + ${src} + ${dst} + COMMENT "Copying ${src} to ${dst}" +) +endfunction() diff --git a/oatmeal/cmake/glsl.cmake b/oatmeal/cmake/glsl.cmake index 6b89d39..812d128 100644 --- a/oatmeal/cmake/glsl.cmake +++ b/oatmeal/cmake/glsl.cmake @@ -31,7 +31,4 @@ function(create_glslc_shader_target TARGET SOURCE_DIR OUTPUT_DIR) add_custom_target(${TARGET} ALL DEPENDS ${OUTPUT_FILES}) endfunction() -create_glslc_shader_target(glsl_shaders - "${SHADERS_DIR}" - "${CMAKE_CURRENT_BINARY_DIR}/${SHADERS_DIR}" -) + diff --git a/oatmeal/cmake/slang.cmake b/oatmeal/cmake/slang.cmake index 9ce9b92..cdaa0bb 100644 --- a/oatmeal/cmake/slang.cmake +++ b/oatmeal/cmake/slang.cmake @@ -30,7 +30,4 @@ function(create_slang_shader_target TARGET SOURCE_DIR OUTPUT_DIR) add_custom_target(${TARGET} ALL DEPENDS ${OUTPUT_FILES}) endfunction() -create_slang_shader_target(slang_shaders - "${SHADERS_DIR}" - "${CMAKE_CURRENT_BINARY_DIR}/${SHADERS_DIR}" -) +