From d889c250f9e500c84f34533398e82aa9e5d5a0ae Mon Sep 17 00:00:00 2001 From: Matthew Smith Date: Thu, 2 Nov 2023 18:43:42 +0000 Subject: [PATCH] system glslang --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -469,6 +469,17 @@ elseif(UNIX) endif() endif() +# glslang package does not export a -config.cmake file. +option(GLSLANG_TARGET_DIR "Absolute path to glslangTargets.cmake directory") +include("${GLSLANG_TARGET_DIR}/OSDependentTargets.cmake") +include("${GLSLANG_TARGET_DIR}/OGLCompilerTargets.cmake") +include("${GLSLANG_TARGET_DIR}/HLSLTargets.cmake") +include("${GLSLANG_TARGET_DIR}/glslangTargets.cmake") +include("${GLSLANG_TARGET_DIR}/SPIRVTargets.cmake") +if(NOT TARGET glslang OR NOT TARGET SPIRV) + message(FATAL_ERROR "glslang or SPIRV target not found") +endif() + add_subdirectory(renderdoc) # these variables are handled within the CMakeLists.txt in qrenderdoc, --- a/renderdoc/CMakeLists.txt +++ b/renderdoc/CMakeLists.txt @@ -604,7 +604,7 @@ endif() add_library(renderdoc SHARED ${renderdoc_objects}) target_compile_definitions(renderdoc ${RDOC_DEFINITIONS}) target_include_directories(renderdoc ${RDOC_INCLUDES}) -target_link_libraries(renderdoc ${RDOC_LIBRARIES}) +target_link_libraries(renderdoc ${RDOC_LIBRARIES} glslang glslang-default-resource-limits SPIRV) add_dependencies(renderdoc renderdoc_libentry) --- a/renderdoc/data/glsl_shaders.cpp +++ b/renderdoc/data/glsl_shaders.cpp @@ -26,8 +26,8 @@ #include "common/common.h" #include "common/formatting.h" #include "driver/shaders/spirv/glslang_compile.h" -#include "glslang/glslang/Public/ResourceLimits.h" -#include "glslang/glslang/Public/ShaderLang.h" +#include +#include #include "os/os_specific.h" #define GLSL_HEADERS(HEADER) \ --- a/renderdoc/driver/gl/gl_shader_refl.cpp +++ b/renderdoc/driver/gl/gl_shader_refl.cpp @@ -26,8 +26,8 @@ #include #include #include "driver/shaders/spirv/glslang_compile.h" -#include "glslang/glslang/Public/ResourceLimits.h" -#include "glslang/glslang/Public/ShaderLang.h" +#include +#include #include "gl_driver.h" template <> --- a/renderdoc/driver/shaders/spirv/CMakeLists.txt +++ b/renderdoc/driver/shaders/spirv/CMakeLists.txt @@ -1,98 +1,3 @@ -set(glslang_dir ${RDOC_SOURCE_DIR}/3rdparty/glslang) -set(glslang_sources - ${glslang_dir}/OGLCompilersDLL/InitializeDll.cpp - ${glslang_dir}/OGLCompilersDLL/InitializeDll.h - ${glslang_dir}/SPIRV/GlslangToSpv.cpp - ${glslang_dir}/SPIRV/GlslangToSpv.h - ${glslang_dir}/SPIRV/GLSL.std.450.h - ${glslang_dir}/SPIRV/GLSL.ext.ARM.h - ${glslang_dir}/SPIRV/GLSL.ext.AMD.h - ${glslang_dir}/SPIRV/GLSL.ext.EXT.h - ${glslang_dir}/SPIRV/GLSL.ext.KHR.h - ${glslang_dir}/SPIRV/GLSL.ext.NV.h - ${glslang_dir}/SPIRV/NonSemanticDebugPrintf.h - ${glslang_dir}/SPIRV/NonSemanticShaderDebugInfo100.h - ${glslang_dir}/SPIRV/hex_float.h - ${glslang_dir}/SPIRV/InReadableOrder.cpp - ${glslang_dir}/SPIRV/Logger.cpp - ${glslang_dir}/SPIRV/Logger.h - ${glslang_dir}/SPIRV/SpvBuilder.cpp - ${glslang_dir}/SPIRV/SpvBuilder.h - ${glslang_dir}/SPIRV/SpvTools.cpp - ${glslang_dir}/SPIRV/SpvTools.h - ${glslang_dir}/SPIRV/SpvPostProcess.cpp - ${glslang_dir}/SPIRV/spvIR.h - ${glslang_dir}/glslang/GenericCodeGen/CodeGen.cpp - ${glslang_dir}/glslang/GenericCodeGen/Link.cpp - ${glslang_dir}/glslang/Include/arrays.h - ${glslang_dir}/glslang/Include/BaseTypes.h - ${glslang_dir}/glslang/Include/Common.h - ${glslang_dir}/glslang/Include/ConstantUnion.h - ${glslang_dir}/glslang/Include/InfoSink.h - ${glslang_dir}/glslang/Include/InitializeGlobals.h - ${glslang_dir}/glslang/Include/intermediate.h - ${glslang_dir}/glslang/Include/PoolAlloc.h - ${glslang_dir}/glslang/Include/ResourceLimits.h - ${glslang_dir}/glslang/Include/SpirvIntrinsics.h - ${glslang_dir}/glslang/Include/revision.h - ${glslang_dir}/glslang/Include/ShHandle.h - ${glslang_dir}/glslang/Include/Types.h - ${glslang_dir}/glslang/MachineIndependent/Constant.cpp - ${glslang_dir}/glslang/MachineIndependent/glslang_tab.cpp - ${glslang_dir}/glslang/MachineIndependent/glslang_tab.cpp.h - ${glslang_dir}/glslang/MachineIndependent/gl_types.h - ${glslang_dir}/glslang/MachineIndependent/iomapper.cpp - ${glslang_dir}/glslang/MachineIndependent/iomapper.h - ${glslang_dir}/glslang/MachineIndependent/gl_types.h - ${glslang_dir}/glslang/MachineIndependent/InfoSink.cpp - ${glslang_dir}/glslang/MachineIndependent/Initialize.cpp - ${glslang_dir}/glslang/MachineIndependent/Initialize.h - ${glslang_dir}/glslang/MachineIndependent/Intermediate.cpp - ${glslang_dir}/glslang/MachineIndependent/intermOut.cpp - ${glslang_dir}/glslang/MachineIndependent/IntermTraverse.cpp - ${glslang_dir}/glslang/MachineIndependent/limits.cpp - ${glslang_dir}/glslang/MachineIndependent/linkValidate.cpp - ${glslang_dir}/glslang/MachineIndependent/LiveTraverser.h - ${glslang_dir}/glslang/MachineIndependent/localintermediate.h - ${glslang_dir}/glslang/MachineIndependent/parseConst.cpp - ${glslang_dir}/glslang/MachineIndependent/ParseContextBase.cpp - ${glslang_dir}/glslang/MachineIndependent/ParseHelper.cpp - ${glslang_dir}/glslang/MachineIndependent/ParseHelper.h - ${glslang_dir}/glslang/MachineIndependent/PoolAlloc.cpp - ${glslang_dir}/glslang/MachineIndependent/propagateNoContraction.cpp - ${glslang_dir}/glslang/MachineIndependent/propagateNoContraction.h - ${glslang_dir}/glslang/MachineIndependent/preprocessor/PpAtom.cpp - ${glslang_dir}/glslang/MachineIndependent/preprocessor/PpContext.cpp - ${glslang_dir}/glslang/MachineIndependent/preprocessor/PpContext.h - ${glslang_dir}/glslang/MachineIndependent/preprocessor/Pp.cpp - ${glslang_dir}/glslang/MachineIndependent/preprocessor/PpScanner.cpp - ${glslang_dir}/glslang/MachineIndependent/preprocessor/PpTokens.cpp - ${glslang_dir}/glslang/MachineIndependent/preprocessor/PpTokens.h - ${glslang_dir}/glslang/MachineIndependent/reflection.cpp - ${glslang_dir}/glslang/MachineIndependent/reflection.h - ${glslang_dir}/glslang/MachineIndependent/RemoveTree.cpp - ${glslang_dir}/glslang/MachineIndependent/RemoveTree.h - ${glslang_dir}/glslang/MachineIndependent/ScanContext.h - ${glslang_dir}/glslang/MachineIndependent/Scan.cpp - ${glslang_dir}/glslang/MachineIndependent/Scan.h - ${glslang_dir}/glslang/MachineIndependent/ShaderLang.cpp - ${glslang_dir}/glslang/MachineIndependent/SpirvIntrinsics.cpp - ${glslang_dir}/glslang/MachineIndependent/SymbolTable.cpp - ${glslang_dir}/glslang/MachineIndependent/SymbolTable.h - ${glslang_dir}/glslang/MachineIndependent/Versions.cpp - ${glslang_dir}/glslang/MachineIndependent/Versions.h - ${glslang_dir}/glslang/MachineIndependent/attribute.cpp - ${glslang_dir}/glslang/MachineIndependent/attribute.h - ${glslang_dir}/glslang/OSDependent/osinclude.h - ${glslang_dir}/glslang/ResourceLimits/ResourceLimits.cpp - ${glslang_dir}/glslang/Public/ShaderLang.h - ${glslang_dir}/glslang/Public/ResourceLimits.h) - -if(UNIX) - list(APPEND glslang_sources - ${glslang_dir}/glslang/OSDependent/Unix/ossource.cpp) -endif() - set(sources glslang_compile.cpp glslang_compile.h @@ -115,38 +20,20 @@ set(sources spirv_processor.h spirv_disassemble.cpp spirv_stringise.cpp - var_dispatch_helpers.h - ${glslang_sources}) + var_dispatch_helpers.h) add_definitions(-DAMD_EXTENSIONS) add_definitions(-DNV_EXTENSIONS) -set_property(SOURCE ${glslang_sources} - PROPERTY COMPILE_FLAGS "-Wno-ignored-qualifiers -Wno-strict-aliasing -Wno-unreachable-code-break") - -# GCC 7.0 and above needs -Wno-implicit-fallthrough -if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.9) - set_property(SOURCE ${glslang_sources} - APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-implicit-fallthrough") -endif() - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set_property(SOURCE ${glslang_sources} - APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-unknown-warning-option -Wno-shadow -Wno-shorten-64-to-32") - set_property(SOURCE spirv_debug.cpp spirv_debug_glsl450.cpp spirv_debug_setup.cpp spirv_processor.cpp APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-shadow -Wno-shorten-64-to-32") - - if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.9) - set_property(SOURCE ${glslang_dir}/glslang/MachineIndependent/iomapper.cpp - APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-deprecated-copy") - endif() endif() add_library(rdoc_spirv OBJECT ${sources}) target_compile_definitions(rdoc_spirv ${RDOC_DEFINITIONS}) -target_include_directories(rdoc_spirv ${RDOC_INCLUDES} ${glslang_dir}) +target_include_directories(rdoc_spirv ${RDOC_INCLUDES}) --- a/renderdoc/driver/shaders/spirv/glslang_compile.cpp +++ b/renderdoc/driver/shaders/spirv/glslang_compile.cpp @@ -29,9 +29,9 @@ #undef min #undef max -#include "glslang/glslang/Include/Types.h" -#include "glslang/glslang/Public/ResourceLimits.h" -#include "glslang/glslang/Public/ShaderLang.h" +#include +#include +#include static bool glslang_inited = false; rdcarray *allocatedShaders = NULL; --- a/renderdoc/driver/shaders/spirv/spirv_compile.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_compile.cpp @@ -31,9 +31,9 @@ #undef min #undef max -#include "glslang/SPIRV/GlslangToSpv.h" -#include "glslang/glslang/Public/ResourceLimits.h" -#include "glslang/glslang/Public/ShaderLang.h" +#include +#include +#include rdcstr rdcspv::Compile(const rdcspv::CompilationSettings &settings, const rdcarray &sources, rdcarray &spirv) -- 2.42.0