Nomic vulkan backend licensed under the Software for Open Models License (SOM), version 1.0.
This commit is contained in:
parent
acfc5478ff
commit
4cdaa3c9cb
97 changed files with 13550 additions and 26 deletions
106
kompute/cmake/bin2h.cmake
Normal file
106
kompute/cmake/bin2h.cmake
Normal file
|
@ -0,0 +1,106 @@
|
|||
##################################################################################
|
||||
# Based on: https://github.com/sivachandran/cmake-bin2h
|
||||
#
|
||||
# Copyright 2020 Sivachandran Paramasivam
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
##################################################################################
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
# Function to wrap a given string into multiple lines at the given column position.
|
||||
# Parameters:
|
||||
# VARIABLE - The name of the CMake variable holding the string.
|
||||
# AT_COLUMN - The column position at which string will be wrapped.
|
||||
function(WRAP_STRING)
|
||||
set(oneValueArgs VARIABLE AT_COLUMN)
|
||||
cmake_parse_arguments(WRAP_STRING "${options}" "${oneValueArgs}" "" ${ARGN})
|
||||
|
||||
string(LENGTH ${${WRAP_STRING_VARIABLE}} stringLength)
|
||||
math(EXPR offset "0")
|
||||
|
||||
while(stringLength GREATER 0)
|
||||
|
||||
if(stringLength GREATER ${WRAP_STRING_AT_COLUMN})
|
||||
math(EXPR length "${WRAP_STRING_AT_COLUMN}")
|
||||
else()
|
||||
math(EXPR length "${stringLength}")
|
||||
endif()
|
||||
|
||||
string(SUBSTRING ${${WRAP_STRING_VARIABLE}} ${offset} ${length} line)
|
||||
set(lines "${lines}\n${line}")
|
||||
|
||||
math(EXPR stringLength "${stringLength} - ${length}")
|
||||
math(EXPR offset "${offset} + ${length}")
|
||||
endwhile()
|
||||
|
||||
set(${WRAP_STRING_VARIABLE} "${lines}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Function to embed contents of a file as byte array in C/C++ header file(.h). The header file
|
||||
# will contain a byte array and integer variable holding the size of the array.
|
||||
# Parameters
|
||||
# SOURCE_FILE - The path of source file whose contents will be embedded in the header file.
|
||||
# VARIABLE_NAME - The name of the variable for the byte array. The string "_SIZE" will be append
|
||||
# to this name and will be used a variable name for size variable.
|
||||
# HEADER_FILE - The path of header file.
|
||||
# APPEND - If specified appends to the header file instead of overwriting it
|
||||
# NULL_TERMINATE - If specified a null byte(zero) will be append to the byte array. This will be
|
||||
# useful if the source file is a text file and we want to use the file contents
|
||||
# as string. But the size variable holds size of the byte array without this
|
||||
# null byte.
|
||||
# HEADER_NAMESPACE - The namespace, where the array should be located in.
|
||||
# IS_BIG_ENDIAN - If set to true, will not revers the byte order for the uint32_t to match the
|
||||
# big endian system architecture
|
||||
# Usage:
|
||||
# bin2h(SOURCE_FILE "Logo.png" HEADER_FILE "Logo.h" VARIABLE_NAME "LOGO_PNG")
|
||||
function(BIN2H)
|
||||
set(options APPEND NULL_TERMINATE)
|
||||
set(oneValueArgs SOURCE_FILE VARIABLE_NAME HEADER_FILE)
|
||||
cmake_parse_arguments(BIN2H "${options}" "${oneValueArgs}" "" ${ARGN})
|
||||
|
||||
# reads source file contents as hex string
|
||||
file(READ ${BIN2H_SOURCE_FILE} hexString HEX)
|
||||
string(LENGTH ${hexString} hexStringLength)
|
||||
|
||||
# appends null byte if asked
|
||||
if(BIN2H_NULL_TERMINATE)
|
||||
set(hexString "${hexString}00")
|
||||
endif()
|
||||
|
||||
# wraps the hex string into multiple lines at column 32(i.e. 16 bytes per line)
|
||||
wrap_string(VARIABLE hexString AT_COLUMN 32)
|
||||
math(EXPR arraySize "${hexStringLength} / 8")
|
||||
|
||||
# adds '0x' prefix and comma suffix before and after every byte respectively
|
||||
if(IS_BIG_ENDIAN)
|
||||
message(STATUS "Interpreting shader in big endian...")
|
||||
string(REGEX REPLACE "([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])" "0x\\1\\2\\3\\4, " arrayValues ${hexString})
|
||||
else()
|
||||
message(STATUS "Interpreting shader in little endian...")
|
||||
string(REGEX REPLACE "([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])" "0x\\4\\3\\2\\1, " arrayValues ${hexString})
|
||||
endif()
|
||||
# removes trailing comma
|
||||
string(REGEX REPLACE ", $" "" arrayValues ${arrayValues})
|
||||
|
||||
# converts the variable name into proper C identifier
|
||||
string(MAKE_C_IDENTIFIER "${BIN2H_VARIABLE_NAME}" BIN2H_VARIABLE_NAME)
|
||||
string(TOUPPER "${BIN2H_VARIABLE_NAME}" BIN2H_VARIABLE_NAME)
|
||||
|
||||
# declares byte array and the length variables
|
||||
set(namespaceStart "namespace ${HEADER_NAMESPACE} {")
|
||||
set(namespaceEnd "} // namespace ${HEADER_NAMESPACE}")
|
||||
set(arrayIncludes "#pragma once\n#include <array>\n#include <cstdint>")
|
||||
set(arrayDefinition "const std::array<uint32_t, ${arraySize}> ${BIN2H_VARIABLE_NAME} = { ${arrayValues} };")
|
||||
|
||||
set(declarations "${arrayIncludes}\n\n${namespaceStart}\n${arrayDefinition}\n${namespaceEnd}\n\n")
|
||||
if(BIN2H_APPEND)
|
||||
file(APPEND ${BIN2H_HEADER_FILE} "${declarations}")
|
||||
else()
|
||||
file(WRITE ${BIN2H_HEADER_FILE} "${declarations}")
|
||||
endif()
|
||||
endfunction()
|
19
kompute/cmake/bin_file_to_header.cmake
Normal file
19
kompute/cmake/bin_file_to_header.cmake
Normal file
|
@ -0,0 +1,19 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
if(${INPUT_SHADER_FILE} STREQUAL "")
|
||||
message(FATAL_ERROR "No input file path provided via 'INPUT_SHADER_FILE'.")
|
||||
endif()
|
||||
|
||||
if(${OUTPUT_HEADER_FILE} STREQUAL "")
|
||||
message(FATAL_ERROR "No output file path provided via 'OUTPUT_HEADER_FILE'.")
|
||||
endif()
|
||||
|
||||
if(${HEADER_NAMESPACE} STREQUAL "")
|
||||
message(FATAL_ERROR "No header namespace provided via 'HEADER_NAMESPACE'.")
|
||||
endif()
|
||||
|
||||
include(bin2h.cmake)
|
||||
|
||||
get_filename_component(BINARY_FILE_CONTENT ${INPUT_SHADER_FILE} NAME)
|
||||
bin2h(SOURCE_FILE ${INPUT_SHADER_FILE} HEADER_FILE ${OUTPUT_HEADER_FILE} VARIABLE_NAME ${BINARY_FILE_CONTENT} HEADER_NAMESPACE ${HEADER_NAMESPACE})
|
||||
file(APPEND ${OUTPUT_HEADER_FILE} "\n")
|
139
kompute/cmake/check_vulkan_version.cmake
Normal file
139
kompute/cmake/check_vulkan_version.cmake
Normal file
|
@ -0,0 +1,139 @@
|
|||
# Current issue: Only checks the result of GPU0
|
||||
function(check_vulkan_version)
|
||||
cmake_parse_arguments(VULKAN_CHECK_VERSION "" "INCLUDE_DIR" "" ${ARGN})
|
||||
message(STATUS "Ensuring the currently installed driver supports the Vulkan version requested by the Vulkan Header.")
|
||||
|
||||
# Get the current Vulkan Header version (e.g. 1.2.189).
|
||||
# This snippet is based on: https://gitlab.kitware.com/cmake/cmake/-/blob/v3.23.1/Modules/FindVulkan.cmake#L140-156
|
||||
if(VULKAN_CHECK_VERSION_INCLUDE_DIR)
|
||||
set(VULKAN_CORE_H ${VULKAN_CHECK_VERSION_INCLUDE_DIR}/vulkan/vulkan_core.h)
|
||||
if(EXISTS ${VULKAN_CORE_H})
|
||||
file(STRINGS ${VULKAN_CORE_H} VULKAN_HEADER_VERSION_LINE REGEX "^#define VK_HEADER_VERSION ")
|
||||
string(REGEX MATCHALL "[0-9]+" VULKAN_HEADER_VERSION "${VULKAN_HEADER_VERSION_LINE}")
|
||||
file(STRINGS ${VULKAN_CORE_H} VULKAN_HEADER_VERSION_LINE2 REGEX "^#define VK_HEADER_VERSION_COMPLETE ")
|
||||
if(NOT ${VULKAN_HEADER_VERSION_LINE2} STREQUAL "")
|
||||
string(REGEX MATCHALL "[0-9]+" VULKAN_HEADER_VERSION2 "${VULKAN_HEADER_VERSION_LINE2}")
|
||||
list(LENGTH VULKAN_HEADER_VERSION2 _len)
|
||||
# Versions >= 1.2.175 have an additional numbers in front of e.g. '0, 1, 2' instead of '1, 2'
|
||||
if(_len EQUAL 3)
|
||||
list(REMOVE_AT VULKAN_HEADER_VERSION2 0)
|
||||
endif()
|
||||
list(APPEND VULKAN_HEADER_VERSION2 ${VULKAN_HEADER_VERSION})
|
||||
list(JOIN VULKAN_HEADER_VERSION2 "." VULKAN_HEADER_VERSION)
|
||||
else()
|
||||
file(STRINGS ${VULKAN_CORE_H} VULKAN_HEADER_API_VERSION_1_2 REGEX "^#define VK_API_VERSION_1_2.*")
|
||||
if(NOT ${VULKAN_HEADER_API_VERSION_1_2} STREQUAL "")
|
||||
set(VULKAN_HEADER_VERSION "1.2.${VULKAN_HEADER_VERSION}")
|
||||
else()
|
||||
file(STRINGS ${VULKAN_CORE_H} VULKAN_HEADER_API_VERSION_1_1 REGEX "^#define VK_API_VERSION_1_1.*")
|
||||
if(NOT ${VULKAN_HEADER_API_VERSION_1_1} STREQUAL "")
|
||||
set(VULKAN_HEADER_VERSION "1.1.${VULKAN_HEADER_VERSION}")
|
||||
else()
|
||||
message(FATAL_ERROR "'${VULKAN_CORE_H}' does not contain a supported Vulkan version. Probably because its < 1.2.0.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "'${VULKAN_CORE_H}' does not exist. Try calling 'find_package(Vulkan REQUIRED)' before you call this function or set 'Vulkan_INCLUDE_DIR' manually!")
|
||||
return()
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid Vulkan include directory given. Try calling 'find_package(Vulkan REQUIRED)' before you call this function or set 'Vulkan_INCLUDE_DIR' manually!")
|
||||
return()
|
||||
endif()
|
||||
message(STATUS "Found Vulkan Header version: ${VULKAN_HEADER_VERSION}")
|
||||
|
||||
# Get Vulkan version supported by driver
|
||||
find_program(VULKAN_INFO_PATH NAMES vulkaninfo)
|
||||
if(VULKAN_INFO_PATH STREQUAL "VULKAN_INFO_PATH-NOTFOUND")
|
||||
message(FATAL_ERROR "vulkaninfo not found. The Vulkan SDK might not be installed properly. If you know what you are doing, you can disable the Vulkan version check by setting 'KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK' to 'ON' (-DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON).")
|
||||
return()
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND "vulkaninfo"
|
||||
OUTPUT_VARIABLE VULKAN_INFO_OUTPUT
|
||||
RESULT_VARIABLE VULKAN_INFO_RETURN)
|
||||
if(NOT ${VULKAN_INFO_RETURN} EQUAL 0)
|
||||
message(FATAL_ERROR "Running vulkaninfo failed with return code ${VULKAN_INFO_RETURN}. Make sure you have 'vulkan-tools' installed. Result:\n${VULKAN_INFO_OUTPUT}?")
|
||||
return()
|
||||
else()
|
||||
message(STATUS "Running vulkaninfo was successful. Parsing the output...")
|
||||
endif()
|
||||
|
||||
# Check if running vulkaninfo was successfully
|
||||
string(FIND "${VULKAN_INFO_OUTPUT}" "Vulkan Instance Version" VULKAN_INFO_SUCCESSFUL)
|
||||
if(VULKAN_INFO_SUCCESSFUL LESS 0)
|
||||
message(FATAL_ERROR "Running vulkaninfo failed. Make sure you have 'vulkan-tools' installed and DISPLAY is configured. If you know what you are doing, you can disable the Vulkan version check by setting 'KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK' to 'ON' (-DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON). Result:\n${VULKAN_INFO_OUTPUT}?")
|
||||
endif()
|
||||
|
||||
string(REGEX MATCHALL "(GPU[0-9]+)" GPU_IDS "${VULKAN_INFO_OUTPUT}")
|
||||
if(NOT GPU_IDS)
|
||||
message(FATAL_ERROR "No GPU supporting Vulkan found in vulkaninfo. Does your GPU (driver) support Vulkan?")
|
||||
endif()
|
||||
|
||||
string(REGEX MATCHALL "apiVersion[ ]*=[ ]*[0-9a-fA-F]*[ ]*[(]*([0-9]+[.][0-9]+[.][0-9]+)[)]*" GPU_API_VERSIONS ${VULKAN_INFO_OUTPUT})
|
||||
if(NOT GPU_API_VERSIONS)
|
||||
message(FATAL_ERROR "No valid Vulkan API version found in vulkaninfo. Does your GPU (driver) support Vulkan?")
|
||||
endif()
|
||||
|
||||
# Check length
|
||||
# message(FATAL_ERROR "GPUS: ${GPU_IDS}")
|
||||
list(LENGTH GPU_IDS GPU_IDS_LENGTH)
|
||||
list(LENGTH GPU_API_VERSIONS GPU_API_VERSIONS_LENGTH)
|
||||
if(NOT ${GPU_IDS_LENGTH} EQUAL ${GPU_API_VERSIONS_LENGTH})
|
||||
message(FATAL_ERROR "Found ${GPU_IDS_LENGTH} GPUs, but ${GPU_API_VERSIONS_LENGTH} API versions in vulkaninfo. We expected to find an equal amount of them.")
|
||||
endif()
|
||||
|
||||
# Compare versions
|
||||
set(VALID_GPU "")
|
||||
set(VALID_VULKAN_VERSION "")
|
||||
math(EXPR ITER_LEN "${GPU_IDS_LENGTH} - 1")
|
||||
foreach(INDEX RANGE ${ITER_LEN})
|
||||
list(GET GPU_IDS ${INDEX} GPU)
|
||||
list(GET GPU_API_VERSIONS ${INDEX} API_VERSION)
|
||||
|
||||
# Extract API version
|
||||
if(${API_VERSION} MATCHES "apiVersion[ ]*=[ ]*[0-9a-fA-F]*[ ]*[(]*([0-9]+[.][0-9]+[.][0-9]+)[)]*")
|
||||
set(VULKAN_DRIVER_VERSION ${CMAKE_MATCH_1})
|
||||
else()
|
||||
message(FATAL_ERROR "API version match failed. This should not have happened...")
|
||||
endif()
|
||||
|
||||
message(STATUS "${GPU} supports Vulkan API version '${VULKAN_DRIVER_VERSION}'.")
|
||||
|
||||
# Compare driver and header version
|
||||
if(${VULKAN_DRIVER_VERSION} VERSION_LESS ${VULKAN_HEADER_VERSION})
|
||||
# Version missmatch. Let us check if the minor version is the same.
|
||||
if(${VULKAN_DRIVER_VERSION} MATCHES "[0-9]+[.]([0-9]+)[.][0-9]+")
|
||||
set(VULKAN_DRIVER_MINOR_VERSION ${CMAKE_MATCH_1})
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid Vulkan driver version '${VULKAN_DRIVER_VERSION}' found. Expected version in the following format: '[0-9]+.[0-9]+.[0-9]+'")
|
||||
endif()
|
||||
if(${VULKAN_HEADER_VERSION} MATCHES "[0-9]+[.]([0-9]+)[.][0-9]+")
|
||||
set(VULKAN_HEADER_MINOR_VERSION ${CMAKE_MATCH_1})
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid Vulkan Header version '${VULKAN_HEADER_VERSION}' found. Expected version in the following format: '[0-9]+.[0-9]+.[0-9]+'")
|
||||
endif()
|
||||
|
||||
if(${VULKAN_DRIVER_MINOR_VERSION} EQUAL ${VULKAN_HEADER_MINOR_VERSION})
|
||||
message(WARNING "Your GPU driver does not support Vulkan > ${VULKAN_DRIVER_VERSION}, but you try to use Vulkan Header ${VULKAN_HEADER_VERSION}. At least your driver supports the same minor version (${VULKAN_DRIVER_MINOR_VERSION}), so this should be fine but keep it in mind in case you encounter any strange behavior.")
|
||||
set(VALID_GPU ${GPU})
|
||||
set(VALID_VULKAN_VERSION ${VULKAN_DRIVER_VERSION})
|
||||
break()
|
||||
else()
|
||||
message(STATUS "${GPU} does not support Vulkan > ${VULKAN_DRIVER_VERSION}.")
|
||||
endif()
|
||||
else()
|
||||
set(VALID_GPU ${GPU})
|
||||
set(VALID_VULKAN_VERSION ${VULKAN_DRIVER_VERSION})
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if("${VALID_GPU}" STREQUAL "")
|
||||
message(FATAL_ERROR "None of your GPUs supports Vulkan Header ${VULKAN_HEADER_VERSION}. Please try updating your driver, or downgrade your Vulkan headers. If you know what you are doing, you can disable the Vulkan version check by setting 'KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK' to 'ON' (-DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON).")
|
||||
else()
|
||||
message("Valid GPU (${VALID_GPU}) for Vulkan header version ${VULKAN_HEADER_VERSION} found. ${VALID_GPU} supports up to Vulkan ${VALID_VULKAN_VERSION}.")
|
||||
endif()
|
||||
|
||||
endfunction()
|
35
kompute/cmake/code_coverage.cmake
Normal file
35
kompute/cmake/code_coverage.cmake
Normal file
|
@ -0,0 +1,35 @@
|
|||
# Code coverage
|
||||
set(CMAKE_BUILD_TYPE COVERAGE CACHE INTERNAL "Coverage build enabled")
|
||||
message(STATUS "Enabling gcov support")
|
||||
|
||||
if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(COVERAGE_FLAG "--coverage")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS_COVERAGE
|
||||
"-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage"
|
||||
CACHE STRING "Flags used by the C++ compiler during coverage builds."
|
||||
FORCE)
|
||||
set(CMAKE_C_FLAGS_COVERAGE
|
||||
"-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage"
|
||||
CACHE STRING "Flags used by the C compiler during coverage builds."
|
||||
FORCE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE
|
||||
""
|
||||
CACHE STRING "Flags used for linking binaries during coverage builds."
|
||||
FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
|
||||
""
|
||||
CACHE STRING "Flags used by the shared libraries linker during coverage builds."
|
||||
FORCE)
|
||||
|
||||
set(CODECOV_DIR ${CMAKE_CURRENT_BINARY_DIR}/codecov/)
|
||||
set(CODECOV_DIR_LCOV ${CODECOV_DIR}lcov/)
|
||||
set(CODECOV_FILENAME_LCOV_INFO lcov.info)
|
||||
set(CODECOV_FILENAME_LCOV_INFO_FULL lcov_full.info)
|
||||
set(CODECOV_DIR_HTML ${CODECOV_DIR}html/)
|
||||
|
||||
mark_as_advanced(CMAKE_CXX_FLAGS_COVERAGE
|
||||
CMAKE_C_FLAGS_COVERAGE
|
||||
CMAKE_EXE_LINKER_FLAGS_COVERAGE
|
||||
CMAKE_SHARED_LINKER_FLAGS_COVERAGE)
|
15
kompute/cmake/deprecation_warnings.cmake
Normal file
15
kompute/cmake/deprecation_warnings.cmake
Normal file
|
@ -0,0 +1,15 @@
|
|||
if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD)
|
||||
message(FATAL_ERROR "'KOMPUTE_OPT_REPO_SUBMODULE_BUILD' got replaced by 'KOMPUTE_OPT_USE_BUILT_IN_SPDLOG', 'KOMPUTE_OPT_USE_BUILT_IN_FMT', 'KOMPUTE_OPT_USE_BUILT_IN_GOOGLE_TEST', 'KOMPUTE_OPT_USE_BUILT_IN_PYBIND11' and 'KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER'. Please use them instead.")
|
||||
endif()
|
||||
|
||||
if(KOMPUTE_OPT_BUILD_AS_SHARED_LIB)
|
||||
message(FATAL_ERROR "'KOMPUTE_OPT_BUILD_AS_SHARED_LIB' is deprecated and should not be used. Instead use the default 'BUILD_SHARED_LIBS' CMake switch.")
|
||||
endif()
|
||||
|
||||
if(KOMPUTE_OPT_BUILD_SINGLE_HEADER)
|
||||
message(FATAL_ERROR "'KOMPUTE_OPT_BUILD_SINGLE_HEADER' is deprecated and should not be used. The single header will now always be build and can be included via '#include<kompute/kompute.h>'.")
|
||||
endif()
|
||||
|
||||
if(KOMPUTE_OPT_ENABLE_SPDLOG)
|
||||
message(FATAL_ERROR "'KOMPUTE_OPT_ENABLE_SPDLOG' is deprecated and should not be used. It got replaced by 'KOMPUTE_OPT_LOG_LEVEL'. This option can be set to a variety of log levels (e.g. 'Off', 'Trace', 'Debug', 'Default', ...).")
|
||||
endif()
|
8
kompute/cmake/komputeConfig.cmake.in
Normal file
8
kompute/cmake/komputeConfig.cmake.in
Normal file
|
@ -0,0 +1,8 @@
|
|||
include(CMakeFindDependencyMacro)
|
||||
@PACKAGE_INIT@
|
||||
|
||||
find_dependency(VULKAN REQUIRED)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/komputeTargets.cmake)
|
||||
|
||||
check_required_components(kompute)
|
43
kompute/cmake/vulkan_shader_compiler.cmake
Normal file
43
kompute/cmake/vulkan_shader_compiler.cmake
Normal file
|
@ -0,0 +1,43 @@
|
|||
function(vulkan_compile_shader)
|
||||
find_program(GLS_LANG_VALIDATOR_PATH NAMES glslangValidator)
|
||||
if(GLS_LANG_VALIDATOR_PATH STREQUAL "GLS_LANG_VALIDATOR_PATH-NOTFOUND")
|
||||
message(FATAL_ERROR "glslangValidator not found.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
cmake_parse_arguments(SHADER_COMPILE "" "INFILE;OUTFILE;NAMESPACE;RELATIVE_PATH" "" ${ARGN})
|
||||
set(SHADER_COMPILE_INFILE_FULL "${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_COMPILE_INFILE}")
|
||||
set(SHADER_COMPILE_SPV_FILE_FULL "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_COMPILE_INFILE}.spv")
|
||||
set(SHADER_COMPILE_HEADER_FILE_FULL "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_COMPILE_OUTFILE}")
|
||||
|
||||
if(NOT SHADER_COMPILE_RELATIVE_PATH)
|
||||
set(SHADER_COMPILE_RELATIVE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
endif()
|
||||
|
||||
# .comp -> .spv
|
||||
add_custom_command(OUTPUT "${SHADER_COMPILE_SPV_FILE_FULL}"
|
||||
COMMAND "${GLS_LANG_VALIDATOR_PATH}"
|
||||
ARGS "-V"
|
||||
"${SHADER_COMPILE_INFILE_FULL}"
|
||||
"-o"
|
||||
"${SHADER_COMPILE_SPV_FILE_FULL}"
|
||||
COMMENT "Compile vulkan compute shader from file '${SHADER_COMPILE_INFILE_FULL}' to '${SHADER_COMPILE_SPV_FILE_FULL}'."
|
||||
MAIN_DEPENDENCY "${SHADER_COMPILE_INFILE_FULL}")
|
||||
|
||||
# Check if big or little endian
|
||||
include (TestBigEndian)
|
||||
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
|
||||
|
||||
# .spv -> .hpp
|
||||
add_custom_command(OUTPUT "${SHADER_COMPILE_HEADER_FILE_FULL}"
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS "-DINPUT_SHADER_FILE=${SHADER_COMPILE_SPV_FILE_FULL}"
|
||||
"-DOUTPUT_HEADER_FILE=${SHADER_COMPILE_HEADER_FILE_FULL}"
|
||||
"-DHEADER_NAMESPACE=${SHADER_COMPILE_NAMESPACE}"
|
||||
"-DIS_BIG_ENDIAN=${IS_BIG_ENDIAN}"
|
||||
"-P"
|
||||
"${SHADER_COMPILE_RELATIVE_PATH}/bin_file_to_header.cmake"
|
||||
WORKING_DIRECTORY "${SHADER_COMPILE_RELATIVE_PATH}"
|
||||
COMMENT "Converting compiled shader '${SHADER_COMPILE_SPV_FILE_FULL}' to header file '${SHADER_COMPILE_HEADER_FILE_FULL}'."
|
||||
MAIN_DEPENDENCY "${SHADER_COMPILE_SPV_FILE_FULL}")
|
||||
endfunction()
|
Loading…
Add table
Add a link
Reference in a new issue