diff --git a/cmake/ports/glslang/CONTROL b/cmake/ports/glslang/CONTROL deleted file mode 100644 index 74a2530e4c1..00000000000 --- a/cmake/ports/glslang/CONTROL +++ /dev/null @@ -1,3 +0,0 @@ -Source: glslang -Version: untagged-048c4dbc7f021224a933-1 -Description: Khronos reference front-end for GLSL and ESSL, and sample SPIR-V generator diff --git a/cmake/ports/glslang/copyright b/cmake/ports/glslang/copyright deleted file mode 100644 index dfffea6a8c1..00000000000 --- a/cmake/ports/glslang/copyright +++ /dev/null @@ -1,35 +0,0 @@ -// -//Copyright (C) 2002-2005 3Dlabs Inc. Ltd. -//Copyright (C) 2012-2013 LunarG, Inc. -// -//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 3Dlabs Inc. Ltd. 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 THE -//COPYRIGHT HOLDERS OR CONTRIBUTORS 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. -// diff --git a/cmake/ports/glslang/portfile.cmake b/cmake/ports/glslang/portfile.cmake index 72d62d26f37..37034ce1674 100644 --- a/cmake/ports/glslang/portfile.cmake +++ b/cmake/ports/glslang/portfile.cmake @@ -1,26 +1,55 @@ -include(vcpkg_common_functions) - vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO KhronosGroup/glslang - REF untagged-048c4dbc7f021224a933 - SHA512 e3097dd2db88320982d7da1ddce138839daf3251935909c3998a114aeadd408760b26b2d7c7ee547fb0519895ac1853a45c23df2eecf61135849b080252e9dec - HEAD_REF master + OUT_SOURCE_PATH SOURCE_PATH + REPO KhronosGroup/glslang + REF "${VERSION}" + SHA512 45ec1a23a390319b9270761cf8befb832ac8b4bc215b211c41a543553a97e5ccf17c134c34d8fdbed6efe887a9a7c2f0a955d1bfe1add9e04cc3e95b12e1973a + HEAD_REF master +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + opt ENABLE_OPT + opt ALLOW_EXTERNAL_SPIRV_TOOLS + tools ENABLE_GLSLANG_BINARIES + rtti ENABLE_RTTI +) + +if (ENABLE_GLSLANG_BINARIES) + vcpkg_find_acquire_program(PYTHON3) + get_filename_component(PYTHON_PATH ${PYTHON3} DIRECTORY) + vcpkg_add_to_path("${PYTHON_PATH}") +endif () + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBUILD_EXTERNAL=OFF + -DGLSLANG_TESTS=OFF + ${FEATURE_OPTIONS} ) -vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA - OPTIONS -DCMAKE_DEBUG_POSTFIX=d +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/glslang DO_NOT_DELETE_PARENT_CONFIG_PATH) +vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/glslang-config.cmake" + [[${PACKAGE_PREFIX_DIR}/lib/cmake/glslang/glslang-targets.cmake]] + [[${CMAKE_CURRENT_LIST_DIR}/glslang-targets.cmake]] ) +file(REMOVE_RECURSE CONFIG_PATH "${CURRENT_PACKAGES_DIR}/lib/cmake" "${CURRENT_PACKAGES_DIR}/debug/lib/cmake") + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/glslang/Public/ShaderLang.h" "ifdef GLSLANG_IS_SHARED_LIBRARY" "if 1") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/glslang/Include/glslang_c_interface.h" "ifdef GLSLANG_IS_SHARED_LIBRARY" "if 1") +endif() + +vcpkg_copy_pdbs() -vcpkg_install_cmake() +if (ENABLE_GLSLANG_BINARIES) + vcpkg_copy_tools(TOOL_NAMES glslang glslangValidator spirv-remap AUTO_CLEAN) +endif () -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) -file(RENAME "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/tools") -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") -# Handle copyright -file(COPY ${CMAKE_CURRENT_LIST_DIR}/copyright DESTINATION ${CURRENT_PACKAGES_DIR}/share/glslang) +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") diff --git a/cmake/ports/glslang/usage b/cmake/ports/glslang/usage new file mode 100644 index 00000000000..ee64499dddb --- /dev/null +++ b/cmake/ports/glslang/usage @@ -0,0 +1,4 @@ +glslang provides CMake targets: + + find_package(glslang CONFIG REQUIRED) + target_link_libraries(main PRIVATE glslang::glslang glslang::glslang-default-resource-limits glslang::SPIRV glslang::SPVRemapper) diff --git a/cmake/ports/glslang/vcpkg.json b/cmake/ports/glslang/vcpkg.json new file mode 100644 index 00000000000..139ddcc38a9 --- /dev/null +++ b/cmake/ports/glslang/vcpkg.json @@ -0,0 +1,32 @@ +{ + "name": "glslang", + "version": "14.0.0", + "description": "Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.", + "homepage": "https://github.com/KhronosGroup/glslang", + "license": "Apache-2.0 AND BSD-3-Clause AND MIT AND GPL-3.0-or-later", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "opt": { + "description": "Build with spirv-opt capability", + "dependencies": [ + "spirv-tools" + ] + }, + "rtti": { + "description": "Build with dynamic typeinfo" + }, + "tools": { + "description": "Build the glslangValidator and spirv-remap binaries", + "supports": "!ios" + } + } +} diff --git a/cmake/ports/hifi-host-tools/CONTROL b/cmake/ports/hifi-host-tools/CONTROL index ec8eda965e6..e59635a6042 100644 --- a/cmake/ports/hifi-host-tools/CONTROL +++ b/cmake/ports/hifi-host-tools/CONTROL @@ -1,4 +1,4 @@ Source: hifi-host-tools Version: 0 Description: Host build system compatible tools for building High Fidelity applications -Build-Depends: hifi-scribe, glslang, spirv-cross, spirv-tools +Build-Depends: hifi-scribe, glslang[opt,tools], spirv-cross, spirv-tools diff --git a/cmake/ports/spirv-cross/CONTROL b/cmake/ports/spirv-cross/CONTROL deleted file mode 100644 index 9068608da6a..00000000000 --- a/cmake/ports/spirv-cross/CONTROL +++ /dev/null @@ -1,3 +0,0 @@ -Source: spirv-cross -Version: 2018-08-07-1 -Description: SPIRV-Cross is a practical tool and library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages. diff --git a/cmake/ports/spirv-cross/portfile.cmake b/cmake/ports/spirv-cross/portfile.cmake index 6495e82bc35..60d4364916b 100644 --- a/cmake/ports/spirv-cross/portfile.cmake +++ b/cmake/ports/spirv-cross/portfile.cmake @@ -1,33 +1,46 @@ -include(vcpkg_common_functions) - vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO KhronosGroup/SPIRV-Cross - REF 2018-08-07 - SHA512 1ac6ee6b2864d950199d4e856ae1576f9435827501baa5d53821a973cd68aaa03ec428094bf74c570784997baac5b2e3802ddc7f02844e2ee546741fa726bf91 + REF vulkan-sdk-${VERSION} + SHA512 56172ce2a766ea83a04701a3253a17fb611c66e25303448d7ca34d507b0476f4d14420021066b382ae6f35a1b1ee4b35443e2e0475b468552f3bd1ad3413e3af HEAD_REF master ) -vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA - OPTIONS -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=OFF -) +if(VCPKG_TARGET_IS_IOS) + message(STATUS "Using iOS triplet. Executables won't be created...") + set(BUILD_CLI OFF) +else() + set(BUILD_CLI ON) +endif() -vcpkg_install_cmake() +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=OFF + -DSPIRV_CROSS_CLI=${BUILD_CLI} + -DSPIRV_CROSS_SKIP_INSTALL=OFF + -DSPIRV_CROSS_ENABLE_C_API=ON +) +vcpkg_cmake_install() vcpkg_copy_pdbs() +vcpkg_fixup_pkgconfig() -foreach(COMPONENT core cpp glsl hlsl msl reflect util) - vcpkg_fixup_cmake_targets(CONFIG_PATH share/spirv_cross_${COMPONENT}/cmake TARGET_PATH share/spirv_cross_${COMPONENT}) +foreach(COMPONENT core c cpp glsl hlsl msl reflect util) + vcpkg_cmake_config_fixup(CONFIG_PATH share/spirv_cross_${COMPONENT}/cmake PACKAGE_NAME spirv_cross_${COMPONENT}) endforeach() +if(BUILD_CLI) + vcpkg_copy_tools(TOOL_NAMES spirv-cross AUTO_CLEAN) +endif() + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" +) + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") + file(GLOB EXES "${CURRENT_PACKAGES_DIR}/bin/*") file(COPY ${EXES} DESTINATION ${CURRENT_PACKAGES_DIR}/tools) - -# cleanup -configure_file(${SOURCE_PATH}/LICENSE ${CURRENT_PACKAGES_DIR}/share/spirv-cross/copyright COPYONLY) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin) diff --git a/cmake/ports/spirv-cross/vcpkg.json b/cmake/ports/spirv-cross/vcpkg.json new file mode 100644 index 00000000000..2d9603c7298 --- /dev/null +++ b/cmake/ports/spirv-cross/vcpkg.json @@ -0,0 +1,17 @@ +{ + "name": "spirv-cross", + "version": "1.3.280.0", + "description": "SPIRV-Cross is a practical tool and library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages.", + "homepage": "https://github.com/KhronosGroup/SPIRV-Cross", + "dependencies": [ + "spirv-headers", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/tools/shadergen.py b/tools/shadergen.py index 1f4acae9153..49581eefdf2 100644 --- a/tools/shadergen.py +++ b/tools/shadergen.py @@ -15,7 +15,7 @@ # # Target dependant Custom rule on the SHADER_FILE # if (ANDROID) # set(GLPROFILE LINUX_GL) - # else() + # else() # if (APPLE) # set(GLPROFILE MAC_GL) # elseif(UNIX) @@ -157,7 +157,7 @@ def executeSubprocess(processArgs): if (0 != processResult.returncode): raise RuntimeError('Call to "{}" failed.\n\narguments:\n{}\n\nstdout:\n{}\n\nstderr:\n{}'.format( processArgs[0], - ' '.join(processArgs[1:]), + ' '.join(processArgs[1:]), processResult.stdout.decode('utf-8'), processResult.stderr.decode('utf-8'))) @@ -166,8 +166,8 @@ def executeSubprocess(processArgs): def processCommand(line): global args global scribeDepCache - glslangExec = args.tools_dir + '/glslangValidator' - spirvCrossExec = args.tools_dir + '/spirv-cross' + glslangExec = args.tools_dir + '/glslang/glslangValidator' + spirvCrossExec = args.tools_dir + '/spirv-cross/spirv-cross' spirvOptExec = args.tools_dir + '/spirv-opt' params = line.split(';') dialect = params.pop(0) @@ -188,12 +188,12 @@ def processCommand(line): scribeOutputDir = os.path.abspath(os.path.join(unoptGlslFile, os.pardir)) - # Serialize checking and creation of the output directory to avoid occasional + # Serialize checking and creation of the output directory to avoid occasional # crashes global folderMutex folderMutex.acquire() if not os.path.exists(scribeOutputDir): - os.makedirs(scribeOutputDir) + os.makedirs(scribeOutputDir) folderMutex.release() scribeDeps = scribeDepCache.getOrGen(scribeFile, libs, dialect, variant, defines) @@ -217,7 +217,7 @@ def processCommand(line): executeSubprocess(scribeArgs) # Generate the un-optimized output - executeSubprocess([glslangExec, '-V110', '-o', upoptSpirvFile, unoptGlslFile]) + executeSubprocess([glslangExec, '-V100', '-o', upoptSpirvFile, unoptGlslFile]) # Optimize the SPIRV executeSubprocess([spirvOptExec, '-O', '-o', spirvFile, upoptSpirvFile]) @@ -233,7 +233,7 @@ def processCommand(line): if (dialect == '410'): spirvCrossArgs.append('--no-420pack-extension') executeSubprocess(spirvCrossArgs) else: - # This logic is necessary because cmake will agressively keep re-executing the shadergen + # This logic is necessary because cmake will agressively keep re-executing the shadergen # code otherwise Path(unoptGlslFile).touch() Path(upoptSpirvFile).touch()