Skip to content
Open
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
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ build
*.so
*.a

# Ignore Daemon-Vulkan generated Graphics Engine files
src/engine/renderer-vulkan/GraphicsCore/ExecutionGraph/SPIRV.h
src/engine/renderer-vulkan/GraphicsCore/ExecutionGraph/SPIRVBin.h
src/engine/renderer-vulkan/GraphicsEngine/Buffers.glsl
src/engine/renderer-vulkan/GraphicsEngine/Images.glsl
src/engine/renderer-vulkan/GraphicsShared/SPIRVIDs.h

#ignore editor temporary files
.*.swp
.#*
Expand Down Expand Up @@ -57,5 +64,8 @@ external_deps/*
.vs
.vscode

# Ignore python cache
*.pyc

#ignore removed recastnavigation submodule
libs/recastnavigation
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ endif()
include(DaemonSourceGenerator)
include(DaemonPlatform)

include( DaemonVulkan )

################################################################################
# Configuration options
################################################################################
Expand Down Expand Up @@ -108,7 +110,7 @@ if(NOT DAEMON_EXTERNAL_APP)
endif()

if (BUILD_CLIENT)
# option(USE_VULKAN "Use Vulkan rendering API instead of OpenGL." OFF)
option(USE_VULKAN "Use Vulkan rendering API instead of OpenGL." OFF)
endif()

option(USE_SMP "Compile with support for running the renderer in a separate thread" ON)
Expand Down Expand Up @@ -929,10 +931,14 @@ if (BUILD_CLIENT)
Tests ${CLIENTTESTLIST}
)

# Generate GLSL include files.
daemon_embed_files("EngineShaders" "${GLSL_EMBED_DIR}" "${GLSL_EMBED_LIST}" "TEXT" "client-objects")
if (USE_VULKAN)
GenerateVulkanShaders( client-objects )
else()
# Generate GLSL include files.
daemon_embed_files("EngineShaders" "${GLSL_EMBED_DIR}" "${GLSL_EMBED_LIST}" "TEXT" "client-objects")

daemon_embed_files(ConsoleFont "${CMAKE_CURRENT_SOURCE_DIR}/libs/unifont" unifont.otf BINARY client-objects)
daemon_embed_files(ConsoleFont "${CMAKE_CURRENT_SOURCE_DIR}/libs/unifont" unifont.otf BINARY client-objects)
endif()
endif()

if (BUILD_SERVER)
Expand Down
6 changes: 6 additions & 0 deletions COPYING.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
------------------------------------------------------ Daemon-Vulkan License ---
Daemon-Vulkan's Vulkan renderer and shader parser (all files in
src/engine/renderer-vulkan and cmake\DaemonVulkan\VulkanShaderParser.cpp) are
licensed under the NEW BSD LICENSE. This license is contained in full in the
file named LICENSE-DAEMON-VULKAN.txt.

------------------------------------------------------------- Daemon License ---
Daemon is licensed under the NEW BSD LICENSE. This license is contained in
full in the file named LICENSE.txt. Please be aware of the exceptions to this
Expand Down
25 changes: 25 additions & 0 deletions LICENSE-DAEMON-VULKAN.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Daemon-Vulkan BSD Source Code
Copyright (c) 2025-2026 Reaper
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Reaper nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL REAPER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
143 changes: 143 additions & 0 deletions cmake/DaemonVulkan.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# =============================================================================
# Daemon-Vulkan BSD Source Code
# Copyright (c) 2025-2026 Reaper
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the Reaper nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL REAPER BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================

option( VULKAN_SPIRV_OUT "Output text SPIR-V files alongside the binary format." ON )
option( VULKAN_SPIRV_OPTIMISE "Enable SPIR-V optimisations." ON )
option( VULKAN_SPIRV_LTO "Enable link-time SPIR-V optimisations." ON )

set( VULKAN_SPIRV_DEBUG "default" CACHE STRING "glslangValidator debug options (remove: g0, non-semantic: gV)")
set_property( CACHE VULKAN_SPIRV_DEBUG PROPERTY STRINGS default remove non-semantic )

if( USE_VULKAN )
add_executable( VulkanShaderParser "${DAEMON_DIR}/cmake/DaemonVulkan/VulkanShaderParser.cpp" )

set( GRAPHICS_CORE_PATH ${DAEMON_DIR}/src/engine/renderer-vulkan/GraphicsCore/ )
set( GRAPHICS_ENGINE_PATH ${DAEMON_DIR}/src/engine/renderer-vulkan/GraphicsEngine/ )
set( GRAPHICS_SHARED_PATH ${DAEMON_DIR}/src/engine/renderer-vulkan/GraphicsShared/ )
set( GRAPHICS_ENGINE_PROCESSED_PATH ${DAEMON_GENERATED_DIR}/DaemonVulkan/GraphicsEngine/ )
target_compile_definitions( VulkanShaderParser PRIVATE "-DDAEMON_VULKAN_GRAPHICS_CORE_PATH=\"${GRAPHICS_CORE_PATH}\"" )
target_compile_definitions( VulkanShaderParser PRIVATE "-DDAEMON_VULKAN_GRAPHICS_ENGINE_PATH=\"${GRAPHICS_ENGINE_PATH}\"" )
target_compile_definitions( VulkanShaderParser PRIVATE "-DDAEMON_VULKAN_GRAPHICS_SHARED_PATH=\"${GRAPHICS_SHARED_PATH}\"" )
target_compile_definitions( VulkanShaderParser PRIVATE "-DDAEMON_VULKAN_GRAPHICS_ENGINE_PROCESSED_PATH=\"${GRAPHICS_ENGINE_PROCESSED_PATH}\"" )

file( MAKE_DIRECTORY ${GRAPHICS_ENGINE_PROCESSED_PATH} )

file( MAKE_DIRECTORY ${DAEMON_GENERATED_DIR}/DaemonVulkan/GraphicsEngine/processed/ )
file( MAKE_DIRECTORY ${DAEMON_GENERATED_DIR}/DaemonVulkan/GraphicsEngine/spirv/ )
file( MAKE_DIRECTORY ${DAEMON_GENERATED_DIR}/DaemonVulkan/GraphicsEngine/bin/ )
endif()

macro( GenerateVulkanShaders target )
# Pre-processing for #insert/#include
foreach( src IN LISTS graphicsEngineList )
set( graphicsEngineProcessedList ${graphicsEngineProcessedList} ${src} )
list( APPEND graphicsEngineOutputList ${GRAPHICS_ENGINE_PROCESSED_PATH}processed/${src} )

get_filename_component( name "${src}" NAME_WE )

if( VULKAN_SPIRV_OUT )
set( spirvAsmPath ${DAEMON_GENERATED_DIR}/DaemonVulkan/GraphicsEngine/spirv/${name}.spirv )
endif()

set( spirvBinPath ${DAEMON_GENERATED_DIR}/DaemonVulkan/GraphicsEngine/bin/${name}.spirvBin )

list( APPEND graphicsEngineOutputList ${spirvAsmPath} )
list( APPEND graphicsEngineOutputList ${spirvBinPath} )
endforeach()

# glslang
find_program( glslangV glslang HINTS /usr/bin /usr/local/bin $ENV{VULKAN_SDK}/Bin/ $ENV{VULKAN_SDK}/Bin32/ )

if( glslangV STREQUAL "glslangV-NOTFOUND" )
message( FATAL_ERROR "glslang not found; make sure you have the Vulkan SDK installed or build glslang from source" )
endif()

set( spirvOptions --target-env vulkan1.3 --glsl-version 460 -e main -l -t )

if( VULKAN_SPIRV_OUT )
set( spirvOut "ON" )
else()
set( spirvOut "OFF" )
endif()

if( NOT VULKAN_SPIRV_OPTIMISE )
set( spirvOptions ${spirvOptions} -Od )
endif()

if( VULKAN_SPIRV_LTO )
set( spirvOptions ${spirvOptions} --lto )
endif()

if( VULKAN_SPIRV_DEBUG STREQUAL "remove" )
set( spirvOptions ${spirvOptions} -g0 )
elseif( VULKAN_SPIRV_DEBUG STREQUAL "non-semantic" )
set( spirvOptions ${spirvOptions} -gV )
endif()

message( STATUS \"${glslangV} ${spirvOptions}\" ${spirvOut} ${graphicsEngineProcessedList} )

add_custom_command(
COMMAND VulkanShaderParser \"${glslangV} ${spirvOptions}\" ${spirvOut} ${graphicsEngineProcessedList}
DEPENDS ${graphicsEngineIDEList} ${graphicsSharedList} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DaemonVulkan.cmake VulkanShaderParser
OUTPUT ${graphicsEngineOutputList} ${GRAPHICS_CORE_PATH}/ExecutionGraph/SPIRVBin.h ${GRAPHICS_CORE_PATH}/ExecutionGraph/SPIRV.h
COMMENT "Generating Vulkan Graphics Engine: ${graphicsEngineProcessedList}"
)

#add_custom_target( VulkanShaderParserTarget ALL
# DEPENDS "${graphicsEngineOutputList}" ${GRAPHICS_CORE_PATH}/ExecutionGraph/SPIRVBin.h ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DaemonVulkan.cmake
#)

# file( STRINGS ${GRAPHICS_ENGINE_PROCESSED_PATH}ShaderStages stagesList )

foreach( src IN LISTS graphicsEngineList )
set( srcPath ${GRAPHICS_ENGINE_PROCESSED_PATH}processed/${src} )

get_filename_component( name "${src}" NAME_WE )

set( spirvAsmPath ${DAEMON_GENERATED_DIR}/DaemonVulkan/GraphicsEngine/spirv/${name}.spirv )

set( spirvBinPath ${DAEMON_GENERATED_DIR}/DaemonVulkan/GraphicsEngine/bin/${name}.spirvBin )

list( POP_FRONT stagesList stage )

#add_custom_command(
# OUTPUT ${spirvBinPath}
# COMMAND ${glslangV} ${spirvOptions} -S ${stage} -V ${srcPath} -o ${spirvBinPath} -H > ${spirvAsmPath}
# DEPENDS ${srcPath}
# COMMENT "Generating Vulkan graphics engine binaries: ${src}"
#)

list( APPEND spirvBinList ${spirvBinPath} )
endforeach()

#add_custom_target( VulkanShaderBin ALL
# DEPENDS "${graphicsEngineOutputList}" ${GRAPHICS_CORE_PATH}/ExecutionGraph/SPIRVBin.h ${GRAPHICS_CORE_PATH}/ExecutionGraph/SPIRV.h ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DaemonVulkan.cmake
#)

target_sources( ${target} PRIVATE ${GRAPHICS_CORE_PATH}/ExecutionGraph/SPIRVBin.h ${GRAPHICS_CORE_PATH}/ExecutionGraph/SPIRV.h )
endmacro()
Loading
Loading