From 74a09844c2755356dd8d7d2e1457e29a7f431648 Mon Sep 17 00:00:00 2001 From: orbea Date: Sat, 1 Feb 2020 15:12:25 -0800 Subject: [PATCH] qb: Support building with a system version of glslang. --- Makefile.common | 23 +++++++++++++++++++---- deps/glslang/glslang.cpp | 5 +++++ qb/config.libs.sh | 33 +++++++++++++++++++++++++++++++++ qb/config.params.sh | 2 ++ 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/Makefile.common b/Makefile.common index 3d072607a8..332e4cfcc2 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1547,8 +1547,8 @@ ifeq ($(HAVE_SHADERS_COMMON), 1) OBJ += gfx/video_shader_parse.o endif -ifeq ($(HAVE_GLSLANG), 1) - DEFINES += -DHAVE_GLSLANG +ifeq ($(HAVE_BUILTINGLSLANG), 1) + HAVE_GLSLANG_COMMON = 1 ifneq ($(findstring Win32,$(OS)),) GLSLANG_PLATFORM := Windows @@ -1562,8 +1562,7 @@ ifeq ($(HAVE_GLSLANG), 1) -I$(DEPS_DIR)/glslang/glslang \ -I$(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent \ -I$(DEPS_DIR)/glslang/glslang/glslang/Public \ - -I$(DEPS_DIR)/glslang/glslang/SPIRV \ - -I$(DEPS_DIR)/glslang + -I$(DEPS_DIR)/glslang/glslang/SPIRV GLSLANG_SOURCES := \ $(wildcard $(DEPS_DIR)/glslang/*.cpp) \ @@ -1578,7 +1577,23 @@ ifeq ($(HAVE_GLSLANG), 1) DEFINES += -DENABLE_HLSL GLSLANG_SOURCES += $(wildcard $(DEPS_DIR)/glslang/glslang/hlsl/*.cpp) endif +else ifeq ($(HAVE_GLSLANG),1) + HAVE_GLSLANG_COMMON = 1 + GLSLANG_SOURCES := $(DEPS_DIR)/glslang/glslang.cpp + # The order of these libs are somewhat specific + LIBS += $(GLSLANG_LIBS) \ + $(GLSLANG_OSDEPENDENT_LIBS) \ + $(GLSLANG_OGLCOMPILER_LIBS) \ + $(GLSLANG_HLSL_LIBS) \ + $(GLSLANG_SPIRV_LIBS) \ + $(GLSLANG_SPIRV_TOOLS_OPT_LIBS) \ + $(GLSLANG_SPIRV_TOOLS_LIBS) +endif + +ifeq ($(HAVE_GLSLANG_COMMON), 1) + DEFINES += -DHAVE_GLSLANG + INCLUDE_DIRS += -I$(DEPS_DIR)/glslang OBJ += $(GLSLANG_SOURCES:.cpp=.o) endif diff --git a/deps/glslang/glslang.cpp b/deps/glslang/glslang.cpp index 0ca6c838d7..0dd86a45b7 100644 --- a/deps/glslang/glslang.cpp +++ b/deps/glslang/glslang.cpp @@ -15,8 +15,13 @@ #include "glslang.hpp" +#ifdef HAVE_BUILTINGLSLANG #include "glslang/glslang/Public/ShaderLang.h" #include "glslang/SPIRV/GlslangToSpv.h" +#elif HAVE_GLSLANG +#include +#include +#endif #include #include #include diff --git a/qb/config.libs.sh b/qb/config.libs.sh index b37bd5eff2..8e50aa5421 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -564,6 +564,39 @@ check_enabled CXX SLANG slang 'The C++ compiler is' false check_enabled CXX GLSLANG glslang 'The C++ compiler is' false check_enabled CXX SPIRV_CROSS SPIRV-Cross 'The C++ compiler is' false +check_enabled GLSLANG BUILTINGLSLANG 'builtin glslang' 'glslang is' true + +if [ "$HAVE_GLSLANG" != no ]; then + check_header cxx GLSLANG \ + glslang/Public/ShaderLang.h \ + glslang/SPIRV/GlslangToSpv.h + + check_lib cxx GLSLANG -lglslang + check_lib cxx GLSLANG_OSDEPENDENT -lOSDependent + check_lib cxx GLSLANG_OGLCOMPILER -lOGLCompiler + check_lib cxx GLSLANG_HLSL -lHLSL + check_lib cxx GLSLANG_SPIRV -lSPIRV + check_lib cxx GLSLANG_SPIRV_TOOLS_OPT -lSPIRV-Tools-opt + check_lib cxx GLSLANG_SPIRV_TOOLS -lSPIRV-Tools + + if [ "$HAVE_GLSLANG" = no ] || + [ "$HAVE_GLSLANG_OSDEPENDENT" = no ] || + [ "$HAVE_GLSLANG_OGLCOMPILER" = no ] || + [ "$HAVE_GLSLANG_HLSL" = no ] || + [ "$HAVE_GLSLANG_SPIRV" = no ] || + [ "$HAVE_GLSLANG_SPIRV_TOOLS_OPT" = no ] || + [ "$HAVE_GLSLANG_SPIRV_TOOLS" = no ]; then + if [ "$HAVE_BUILTINGLSLANG" != yes ]; then + die : 'Notice: System glslang libraries not found, disabling glslang support.' + HAVE_GLSLANG=no + else + HAVE_GLSLANG=yes + fi + else + HAVE_GLSLANG=yes + fi +fi + check_enabled SLANG GLSLANG glslang 'slang is' false check_enabled SLANG SPIRV_CROSS SPIRV-Cross 'slang is' false check_enabled SLANG OPENGL_CORE 'OpenGL core' 'slang is' false diff --git a/qb/config.params.sh b/qb/config.params.sh index f4150397ce..ed3fdfd784 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -161,6 +161,8 @@ HAVE_SLANG=auto # slang support C89_SLANG=no HAVE_GLSLANG=auto # glslang support (requires C++11) C89_GLSLANG=no +HAVE_BUILTINGLSLANG=auto # Bake in glslang support +C89_BUILTINGLSLANG=no HAVE_SPIRV_CROSS=auto # SPIRV-Cross support (requires C++11) C89_SPIRV_CROSS=no HAVE_METAL=no # Metal support (macOS-only)