-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automated shader compilation, glslangValidator support.
Shader are now compiled to SPIR-V binary at CMake configuration time. For CI environment missing glslc, support glslangValidator for fallback shader compilation path.
- Loading branch information
1 parent
94391f4
commit 6252728
Showing
30 changed files
with
126 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ jobs: | |
uses: humbletim/[email protected] | ||
with: | ||
vulkan-query-version: latest | ||
vulkan-components: Vulkan-Headers, Vulkan-Loader | ||
vulkan-components: Vulkan-Headers, Vulkan-Loader, Glslang, SPIRV-Tools | ||
vulkan-use-cache: true | ||
|
||
- name: Install Ninja and build dependencies | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ jobs: | |
uses: humbletim/[email protected] | ||
with: | ||
vulkan-query-version: latest | ||
vulkan-components: Vulkan-Headers, Vulkan-Loader | ||
vulkan-components: Vulkan-Headers, Vulkan-Loader, Glslang, SPIRV-Tools | ||
vulkan-use-cache: true | ||
|
||
- name: Install latest LLVM, Ninja and build dependencies | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ jobs: | |
uses: humbletim/[email protected] | ||
with: | ||
vulkan-query-version: latest | ||
vulkan-components: Vulkan-Headers, Vulkan-Loader | ||
vulkan-components: Vulkan-Headers, Vulkan-Loader, Glslang, SPIRV-Tools | ||
vulkan-use-cache: true | ||
|
||
- name: Export GitHub Actions cache environment variables | ||
|
@@ -36,7 +36,7 @@ jobs: | |
- name: Enable Developer Command Prompt | ||
uses: ilammy/msvc-dev-cmd@v1 | ||
with: | ||
toolset: 14.40 | ||
toolset: 14.42 | ||
|
||
- name: Configure | ||
run: cmake --preset=default | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
function(target_link_shaders TARGET) | ||
if (${Vulkan_glslc_FOUND}) | ||
message(STATUS "Using Vulkan glslc for shader compilation.") | ||
elseif (NOT ${Vulkan_glslc_FOUND} AND ${Vulkan_glslangValidator_FOUND}) | ||
message(WARNING "Vulkan glslc not found, using glslangValidator for shader compilation instead. Modifying indirectly included files will NOT trigger recompilation.") | ||
else() | ||
message(FATAL_ERROR "No shader compiler found.") | ||
endif () | ||
|
||
foreach (source IN LISTS ARGN) | ||
# Get filename from source. | ||
cmake_path(GET source FILENAME filename) | ||
|
||
# Make source path absolute. | ||
cmake_path(ABSOLUTE_PATH source OUTPUT_VARIABLE source) | ||
|
||
set(output "shader/${filename}.spv") | ||
|
||
if (${Vulkan_glslc_FOUND}) | ||
set(depfile "shader_depfile/${filename}.d") | ||
add_custom_command( | ||
OUTPUT "${output}" | ||
COMMAND ${Vulkan_GLSLC_EXECUTABLE} -MD -MF "${depfile}" $<$<NOT:$<CONFIG:Debug>>:-O> --target-env=vulkan1.2 "${source}" -o "${output}" | ||
DEPENDS "${source}" | ||
BYPRODUCTS "${depfile}" | ||
COMMENT "Compiling SPIRV: ${source} -> ${output}" | ||
DEPFILE "${depfile}" | ||
VERBATIM | ||
COMMAND_EXPAND_LISTS | ||
) | ||
elseif (${Vulkan_glslangValidator_FOUND}) | ||
add_custom_command( | ||
OUTPUT "${output}" | ||
COMMAND ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} -V --target-env vulkan1.2 "${source}" -o "${output}" | ||
DEPENDS "${source}" | ||
COMMENT "Compiling SPIRV: ${source} -> ${output}" | ||
VERBATIM | ||
COMMAND_EXPAND_LISTS | ||
) | ||
endif () | ||
|
||
# Make target depends on output shader file. | ||
string(CONFIGURE "${TARGET}_${filename}" shader_target) | ||
add_custom_target("${shader_target}" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${output}") | ||
add_dependencies("${TARGET}" "${shader_target}") | ||
endforeach () | ||
|
||
target_compile_definitions(${TARGET} PRIVATE COMPILED_SHADER_DIR="shader") | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#version 450 | ||
#extension GL_GOOGLE_include_directive : require | ||
|
||
#include "cubemap.glsl" | ||
#include "pbr.glsl" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters