From d42c6ab88e6db4b2a9f5ce21e9fd9572f54eceeb Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Thu, 19 Mar 2020 15:31:31 -0600 Subject: [PATCH 1/5] Fix MSVC build issue - remove invalid character On Windows the single quote used in a comment was showing up as some special character that the Microsoft compiler didn't like. Bug #2140 --- glslang/MachineIndependent/parseConst.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glslang/MachineIndependent/parseConst.cpp b/glslang/MachineIndependent/parseConst.cpp index e4f04d9a..7c04743b 100644 --- a/glslang/MachineIndependent/parseConst.cpp +++ b/glslang/MachineIndependent/parseConst.cpp @@ -175,7 +175,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node) if (nodeComps == 1) { // If there is a single scalar parameter to a matrix // constructor, it is used to initialize all the - // components on the matrix’s diagonal, with the + // components on the matrix's diagonal, with the // remaining components initialized to 0.0. if (i == startIndex || (i - startIndex) % (matrixRows + 1) == 0 ) leftUnionArray[i] = rightUnionArray[count]; From c8274e941e1c5cfd484cad8a0a83428e6dade9ca Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Sat, 21 Mar 2020 03:20:25 -0400 Subject: [PATCH 2/5] Make file formatting comply with POSIX and Unix standards UTF-8, LF, no BOM, and newlines at the end of files --- BUILD.bazel | 4 +-- BUILD.gn | 2 +- SPIRV/Logger.cpp | 2 +- Test/foo.h | 2 +- Test/inc2/foo.h | 2 +- _config.yml | 2 +- glslang/Include/glslang_c_shader_types.h | 2 +- glslang/Include/revision.template | 26 +++++++++---------- glslang/MachineIndependent/intermOut.cpp | 2 +- .../propagateNoContraction.cpp | 2 +- glslang/MachineIndependent/reflection.h | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index d70bc7f6..5930608a 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -85,7 +85,7 @@ genrule( "SPIRV/GLSL.ext.KHR.h", "SPIRV/GLSL.ext.NV.h", "SPIRV/GLSL.std.450.h", - "SPIRV/NonSemanticDebugPrintf.h", + "SPIRV/NonSemanticDebugPrintf.h", "SPIRV/spirv.hpp", ], outs = [ @@ -94,7 +94,7 @@ genrule( "include/SPIRV/GLSL.ext.KHR.h", "include/SPIRV/GLSL.ext.NV.h", "include/SPIRV/GLSL.std.450.h", - "include/SPIRV/NonSemanticDebugPrintf.h", + "include/SPIRV/NonSemanticDebugPrintf.h", "include/SPIRV/spirv.hpp", ], cmd = "mkdir -p $(@D)/include/SPIRV && cp $(SRCS) $(@D)/include/SPIRV/", diff --git a/BUILD.gn b/BUILD.gn index 87c28e9d..49b4b0a3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -70,7 +70,7 @@ source_set("glslang_sources") { "SPIRV/InReadableOrder.cpp", "SPIRV/Logger.cpp", "SPIRV/Logger.h", - "SPIRV/NonSemanticDebugPrintf.h", + "SPIRV/NonSemanticDebugPrintf.h", "SPIRV/SPVRemapper.cpp", "SPIRV/SPVRemapper.h", "SPIRV/SpvBuilder.cpp", diff --git a/SPIRV/Logger.cpp b/SPIRV/Logger.cpp index 7ea0c634..cdc8469c 100644 --- a/SPIRV/Logger.cpp +++ b/SPIRV/Logger.cpp @@ -69,4 +69,4 @@ std::string SpvBuildLogger::getAllMessages() const { } // end spv namespace -#endif \ No newline at end of file +#endif diff --git a/Test/foo.h b/Test/foo.h index 7f79340b..236277c3 100644 --- a/Test/foo.h +++ b/Test/foo.h @@ -1 +1 @@ -#error should not be included \ No newline at end of file +#error should not be included diff --git a/Test/inc2/foo.h b/Test/inc2/foo.h index fd09e808..ea1e5ba1 100644 --- a/Test/inc2/foo.h +++ b/Test/inc2/foo.h @@ -1 +1 @@ -float4 i6; \ No newline at end of file +float4 i6; diff --git a/_config.yml b/_config.yml index c50ff38d..e8b995b9 100644 --- a/_config.yml +++ b/_config.yml @@ -1 +1 @@ -theme: jekyll-theme-merlot \ No newline at end of file +theme: jekyll-theme-merlot diff --git a/glslang/Include/glslang_c_shader_types.h b/glslang/Include/glslang_c_shader_types.h index 57552818..769f4c4a 100644 --- a/glslang/Include/glslang_c_shader_types.h +++ b/glslang/Include/glslang_c_shader_types.h @@ -1,4 +1,4 @@ -/** +/** This code is based on the glslang_c_interface implementation by Viktor Latypov **/ diff --git a/glslang/Include/revision.template b/glslang/Include/revision.template index 6c13630b..4a16beeb 100644 --- a/glslang/Include/revision.template +++ b/glslang/Include/revision.template @@ -1,13 +1,13 @@ -// The file revision.h should be updated to the latest version, somehow, on -// check-in, if glslang has changed. -// -// revision.template is the source for revision.h when using SubWCRev as the -// method of updating revision.h. You don't have to do it this way, the -// requirement is only that revision.h gets updated. -// -// revision.h is under source control so that not all consumers of glslang -// source have to figure out how to create revision.h just to get a build -// going. However, if it is not updated, it can be a version behind. - -#define GLSLANG_REVISION "$WCREV$" -#define GLSLANG_DATE "$WCDATE$" +// The file revision.h should be updated to the latest version, somehow, on +// check-in, if glslang has changed. +// +// revision.template is the source for revision.h when using SubWCRev as the +// method of updating revision.h. You don't have to do it this way, the +// requirement is only that revision.h gets updated. +// +// revision.h is under source control so that not all consumers of glslang +// source have to figure out how to create revision.h just to get a build +// going. However, if it is not updated, it can be a version behind. + +#define GLSLANG_REVISION "$WCREV$" +#define GLSLANG_DATE "$WCDATE$" diff --git a/glslang/MachineIndependent/intermOut.cpp b/glslang/MachineIndependent/intermOut.cpp index 53dc35da..2a3149f7 100644 --- a/glslang/MachineIndependent/intermOut.cpp +++ b/glslang/MachineIndependent/intermOut.cpp @@ -1537,4 +1537,4 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree) } // end namespace glslang -#endif // not GLSLANG_WEB \ No newline at end of file +#endif // not GLSLANG_WEB diff --git a/glslang/MachineIndependent/propagateNoContraction.cpp b/glslang/MachineIndependent/propagateNoContraction.cpp index 83a3230f..9def592b 100644 --- a/glslang/MachineIndependent/propagateNoContraction.cpp +++ b/glslang/MachineIndependent/propagateNoContraction.cpp @@ -867,4 +867,4 @@ void PropagateNoContraction(const glslang::TIntermediate& intermediate) } }; -#endif // GLSLANG_WEB \ No newline at end of file +#endif // GLSLANG_WEB diff --git a/glslang/MachineIndependent/reflection.h b/glslang/MachineIndependent/reflection.h index efdc8934..0c33de45 100644 --- a/glslang/MachineIndependent/reflection.h +++ b/glslang/MachineIndependent/reflection.h @@ -220,4 +220,4 @@ protected: #endif // _REFLECTION_INCLUDED -#endif // GLSLANG_WEB \ No newline at end of file +#endif // GLSLANG_WEB From 16bb8881e69197ac3db5fb21cdf75db12eed383d Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Mon, 23 Mar 2020 12:26:53 -0700 Subject: [PATCH 3/5] Fix build on CMake 2.8, and fix Web build And suppress some warnings that are too verbose in Web builds. --- CMakeLists.txt | 7 ++++-- glslang/Include/Types.h | 2 +- .../MachineIndependent/localintermediate.h | 2 +- glslang/OSDependent/Web/CMakeLists.txt | 22 +++++++++++-------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a80cd5f9..b4b0fac4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,7 +142,10 @@ if(ENABLE_GLSLANG_JS) add_compile_options(/Os /GR-) else() add_compile_options(-Os -fno-exceptions) - add_link_options(-Os) + if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + add_compile_options(-Wno-unused-parameter) + add_compile_options(-Wno-unused-variable -Wno-unused-const-variable) + endif() endif() endif(ENABLE_GLSLANG_JS) @@ -150,7 +153,7 @@ endif(ENABLE_GLSLANG_JS) if(${CMAKE_VERSION} VERSION_LESS 3.1) # CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD # remove this block once CMake >=3.1 has fixated in the ecosystem - add_compile_options(-std=c++11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") else() set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index 350b0e89..d4f5e1de 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -945,7 +945,7 @@ public: bool hasAttachment() const { return false; } TLayoutFormat getFormat() const { return ElfNone; } bool isPushConstant() const { return false; } - bool isShaderRecordNV() const { return false; } + bool isShaderRecord() const { return false; } bool hasBufferReference() const { return false; } bool hasBufferReferenceAlign() const { return false; } bool isNonUniform() const { return false; } diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h index 25b8b78a..240944ef 100644 --- a/glslang/MachineIndependent/localintermediate.h +++ b/glslang/MachineIndependent/localintermediate.h @@ -503,7 +503,7 @@ public: bool getAutoMapBindings() const { return false; } bool getAutoMapLocations() const { return false; } int getNumPushConstants() const { return 0; } - void addShaderRecordNVCount() { } + void addShaderRecordCount() { } void addTaskNVCount() { } void setUseVulkanMemoryModel() { } bool usingVulkanMemoryModel() const { return false; } diff --git a/glslang/OSDependent/Web/CMakeLists.txt b/glslang/OSDependent/Web/CMakeLists.txt index 015d6d77..697b0b75 100644 --- a/glslang/OSDependent/Web/CMakeLists.txt +++ b/glslang/OSDependent/Web/CMakeLists.txt @@ -3,27 +3,31 @@ if(ENABLE_GLSLANG_JS) glslang_set_link_args(glslang.js) target_link_libraries(glslang.js glslang SPIRV) + # Link library names that start with "-" are treated as link flags. + # "-Os" should be OK in MSVC; don't use /Os because CMake won't + # treat it as a link flag. + target_link_libraries(glslang.js "-Os") + if(EMSCRIPTEN) set_target_properties(glslang.js PROPERTIES OUTPUT_NAME "glslang" SUFFIX ".js") em_link_pre_js(glslang.js "${CMAKE_CURRENT_SOURCE_DIR}/glslang.pre.js") - target_link_options(glslang.js PRIVATE "SHELL: -Os") - target_link_options(glslang.js PRIVATE "SHELL: --llvm-lto 1") - target_link_options(glslang.js PRIVATE "SHELL: --closure 1") - target_link_options(glslang.js PRIVATE "SHELL: -s MODULARIZE=1") - target_link_options(glslang.js PRIVATE "SHELL: -s ALLOW_MEMORY_GROWTH=1") - target_link_options(glslang.js PRIVATE "SHELL: -s FILESYSTEM=0") + target_link_libraries(glslang.js "--llvm-lto 1") + target_link_libraries(glslang.js "--closure 1") + target_link_libraries(glslang.js "-s MODULARIZE=1") + target_link_libraries(glslang.js "-s ALLOW_MEMORY_GROWTH=1") + target_link_libraries(glslang.js "-s FILESYSTEM=0") if(ENABLE_EMSCRIPTEN_SINGLE_FILE) - target_link_options(glslang.js PRIVATE "SHELL: -s SINGLE_FILE=1") + target_link_libraries(glslang.js "-s SINGLE_FILE=1") endif(ENABLE_EMSCRIPTEN_SINGLE_FILE) if(ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE) - target_link_options(glslang.js PRIVATE "SHELL: -s ENVIRONMENT=node -s BINARYEN_ASYNC_COMPILATION=0") + target_link_libraries(glslang.js "-s ENVIRONMENT=node -s BINARYEN_ASYNC_COMPILATION=0") else() - target_link_options(glslang.js PRIVATE "SHELL: -s ENVIRONMENT=web,worker") + target_link_libraries(glslang.js "-s ENVIRONMENT=web,worker") endif() if(NOT ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE) From 817d0f63d354c968e94767c03d82161756971506 Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Mon, 23 Mar 2020 12:50:33 -0700 Subject: [PATCH 4/5] update README --- README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5188ab46..ff844c02 100755 --- a/README.md +++ b/README.md @@ -209,27 +209,29 @@ With no arguments it builds the full grammar, and with a "web" argument, the web grammar subset (see more about the web subset in the next section). ### Building to WASM for the Web and Node +### Building a standalone JS/WASM library for the Web and Node Use the steps in [Build Steps](#build-steps), with the following notes/exceptions: -* For building the web subset of core glslang: +* `emsdk` needs to be present in your executable search path, *PATH* for + Bash-like environments: + + [Instructions located here](https://emscripten.org/docs/getting_started/downloads.html#sdk-download-and-install) +* Wrap cmake call: `emcmake cmake` +* Set `-DBUILD_TESTING=OFF -DENABLE_OPT=OFF -DINSTALL_GTEST=OFF`. +* Set `-DENABLE_HLSL=OFF` if HLSL is not needed. +* For a standalone JS/WASM library, turn on `-DENABLE_GLSLANG_JS=ON`. +* For building a minimum-size web subset of core glslang: + + turn on `-DENABLE_GLSLANG_WEBMIN=ON` (disables HLSL) + execute `updateGrammar web` from the glslang subdirectory (or if using your own scripts, `m4` needs a `-DGLSLANG_WEB` argument) - + set `-DENABLE_HLSL=OFF -DBUILD_TESTING=OFF -DENABLE_OPT=OFF -DINSTALL_GTEST=OFF` - + turn on `-DENABLE_GLSLANG_JS=ON` - + optionally, for a minimum-size binary, turn on `-DENABLE_GLSLANG_WEBMIN=ON` - + optionally, for GLSL compilation error messages, turn on `-DENABLE_GLSLANG_WEB_DEVEL=ON` -* `emsdk` needs to be present in your executable search path, *PATH* for - Bash-like environments - + [Instructions located - here](https://emscripten.org/docs/getting_started/downloads.html#sdk-download-and-install) -* Wrap cmake call: `emcmake cmake` + + optionally, for GLSL compilation error messages, turn on + `-DENABLE_GLSLANG_WEBMIN_DEVEL=ON` * To get a fully minimized build, make sure to use `brotli` to compress the .js and .wasm files Example: ```sh -emcmake cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_GLSLANG_WEB=ON \ +emcmake cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_GLSLANG_JS=ON \ -DENABLE_HLSL=OFF -DBUILD_TESTING=OFF -DENABLE_OPT=OFF -DINSTALL_GTEST=OFF .. ``` From 9b3baf98816cf62676b5c797a01ef445f418f2a1 Mon Sep 17 00:00:00 2001 From: Geoffrey Martin-Noble Date: Wed, 25 Mar 2020 20:52:43 -0700 Subject: [PATCH 5/5] Add missing braces to if condition The indentation implies this was the intention. Noticed the issue while trying to compile our code with -Werror -Wall --- glslang/MachineIndependent/Initialize.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index cbcbe1ac..d2ece76c 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -8983,9 +8983,10 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion } break; case EShLangIntersect: - if (profile != EEsProfile && version >= 460) + if (profile != EEsProfile && version >= 460) { symbolTable.relateToOperator("reportIntersectionNV", EOpReportIntersection); symbolTable.relateToOperator("reportIntersectionEXT", EOpReportIntersection); + } break; case EShLangAnyHit: if (profile != EEsProfile && version >= 460) {