From 2490708486b1b249b8aeeabd66652d7ed8bc4789 Mon Sep 17 00:00:00 2001 From: Alejandro Saucedo Date: Tue, 25 Aug 2020 08:39:23 +0100 Subject: [PATCH] Added fully functional build shaders with dependencies on folders --- CMakeLists.txt | 3 +-- LICENSE | 2 +- scripts/convert_shaders.py | 22 +++++++++++++++++++ single_include/kompute/Kompute.hpp | 20 +++++++++++++++++ src/CMakeLists.txt | 9 ++++---- .../kompute/shaders/shadermachinelearning.hpp | 20 +++++++++++++++++ src/include/kompute/shaders/shaderopmult.hpp | 20 +++++++++++++++++ 7 files changed, 88 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34a96bbd0..60f80d275 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,13 +5,12 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -option(KOMPUTE_OPT_INSTALL_PYTHON_REQS "Enable if you want to install python reqs" OFF) option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" ON) # Allow scripts to call main kompute Makefile function(kompute_make KOMPUTE_MAKE_TARGET) add_custom_target(${KOMPUTE_MAKE_TARGET} - COMMAND make -C ${PROJECT_SOURCE_DIR} ${KOMPUTE_MAKE_TARGET} ${ARGN}) + COMMAND make -C ${PROJECT_SOURCE_DIR} ${KOMPUTE_MAKE_TARGET}) endfunction() add_subdirectory(src) diff --git a/LICENSE b/LICENSE index 4e3ea61e1..26947cd23 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2020 Alejandro Saucedo +Copyright 2020 The Institute for Ethical AI & Machine Learning Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/scripts/convert_shaders.py b/scripts/convert_shaders.py index 0ed297b55..b5cea27e1 100644 --- a/scripts/convert_shaders.py +++ b/scripts/convert_shaders.py @@ -16,6 +16,27 @@ CWD=os.path.dirname(os.path.abspath(__file__)) XXD_LINUX_CMD="xxd" XXD_WINDOWS_CMD=os.path.abspath(os.path.join(CWD, "..\\external\\bin\\", "xxd.exe")) +SHADER_GENERATED_NOTICE = """/* + THIS FILE HAS BEEN AUTOMATICALLY GENERATED - DO NOT EDIT + + --- + + Copyright 2020 The Institute for Ethical AI & Machine Learning + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +""" + @click.command() @click.option( "--shader-path", @@ -112,6 +133,7 @@ def run_cli( header_file_define = "SHADEROP_" + header_file.replace(".", "_").upper() logger.debug(f"Converting to hpp: {file_name}") with open(os.path.join(header_path, header_file), "w+") as fstream: + fstream.write(f"{SHADER_GENERATED_NOTICE}\n") fstream.write(f"#ifndef {header_file_define}\n") fstream.write(f"#define {header_file_define}\n\n") fstream.write("namespace kp {\n") diff --git a/single_include/kompute/Kompute.hpp b/single_include/kompute/Kompute.hpp index a80c28bd0..812a6f980 100755 --- a/single_include/kompute/Kompute.hpp +++ b/single_include/kompute/Kompute.hpp @@ -1,3 +1,23 @@ +/* + THIS FILE HAS BEEN AUTOMATICALLY GENERATED - DO NOT EDIT + + --- + + Copyright 2020 The Institute for Ethical AI & Machine Learning + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + #ifndef SHADEROP_SHADEROPMULT_HPP #define SHADEROP_SHADEROPMULT_HPP diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f05706292..e5e8b3159 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,9 +3,10 @@ find_package(fmt REQUIRED) find_package(spdlog REQUIRED) find_package(Vulkan REQUIRED) -kompute_make(install_python_reqs) -kompute_make(build_shaders) -kompute_make(build_single_header) +kompute_make(build_shaders + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include) +kompute_make(build_single_header + OUTPUT ${PROJECT_SOURCE_DIR}/single_include) file(GLOB kompute_CPP "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" @@ -31,8 +32,6 @@ add_dependencies(kompute build_shaders build_single_header) -add_dependencies(kompute - install_python_reqs) add_library(kompute::kompute ALIAS kompute) diff --git a/src/include/kompute/shaders/shadermachinelearning.hpp b/src/include/kompute/shaders/shadermachinelearning.hpp index cfee3ef09..68f079936 100755 --- a/src/include/kompute/shaders/shadermachinelearning.hpp +++ b/src/include/kompute/shaders/shadermachinelearning.hpp @@ -1,3 +1,23 @@ +/* + THIS FILE HAS BEEN AUTOMATICALLY GENERATED - DO NOT EDIT + + --- + + Copyright 2020 The Institute for Ethical AI & Machine Learning + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + #ifndef SHADEROP_SHADERMACHINELEARNING_HPP #define SHADEROP_SHADERMACHINELEARNING_HPP diff --git a/src/include/kompute/shaders/shaderopmult.hpp b/src/include/kompute/shaders/shaderopmult.hpp index 6df8746d4..4dc60e4f2 100755 --- a/src/include/kompute/shaders/shaderopmult.hpp +++ b/src/include/kompute/shaders/shaderopmult.hpp @@ -1,3 +1,23 @@ +/* + THIS FILE HAS BEEN AUTOMATICALLY GENERATED - DO NOT EDIT + + --- + + Copyright 2020 The Institute for Ethical AI & Machine Learning + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + #ifndef SHADEROP_SHADEROPMULT_HPP #define SHADEROP_SHADEROPMULT_HPP