Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared library use not first-class functionality, not tested #1484

Closed
jengelh opened this issue Aug 25, 2018 · 12 comments
Closed

Shared library use not first-class functionality, not tested #1484

jengelh opened this issue Aug 25, 2018 · 12 comments

Comments

@jengelh
Copy link
Contributor

jengelh commented Aug 25, 2018

Compilation fails in commit e7df8e0; it used to previously work in a515250 (where essentially no libHLSL.so was generated).
Please specify the dependencies of HLSL properly.

/usr/bin/cmake . '-DCMAKE_SHARED_LINKER_FLAGS=-Wl,--no-undefined' -DBUILD_SHARED_LIBS:BOOL=ON

-- The C compiler identification is GNU 8.1.1
-- The CXX compiler identification is GNU 8.1.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Google Mock was not found - tests based on that will not build
-- spirv-tools not linked - illegal SPIRV may be generated for HLSL
-- Configuring done
-- Generating done

$ make VERBOSE=1
[...]
/usr/bin/c++ -fPIC  -Wl,--no-undefined -shared -Wl,-soname,libHLSL.so -o libHLSL.so CMakeFiles/HLSL.dir/hlslAttributes.cpp.o CMakeFiles/HLSL.dir/hlslParseHelper.cpp.o CMakeFiles/HLSL.dir/hlslScanContext.cpp.o CMakeFiles/HLSL.dir/hlslOpMap.cpp.o CMakeFiles/HLSL.dir/hlslTokenStream.cpp.o CMakeFiles/HLSL.dir/hlslGrammar.cpp.o CMakeFiles/HLSL.dir/hlslParseables.cpp.o 
/usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/HLSL.dir/hlslParseHelper.cpp.o: in function `glslang::HlslParseContext::initializeExtensionBehavior()':
hlslParseHelper.cpp:(.text+0x59a): undefined reference to `glslang::TParseVersions::initializeExtensionBehavior()'
/usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/HLSL.dir/hlslParseHelper.cpp.o: in function `glslang::HlslParseContext::parseShaderStrings(glslang::TPpContext&, glslang::TInputScanner&, bool)':
[...]
@johnkslang
Copy link
Member

As stated in #1421, maintenance of dynamic library builds is currently a non goal: It has no testing and most input had been to use glslang only with static linking. Negative judgments of a tool against goals it does not have does not help.

That being said, if there are users that want to contribute fixes for this space, or otherwise enable its support, I am happy to help fix glslang per those contributions. Or, if it is truly a general need, figure out how to more officially add and test this need.

File locations, and many other legacy constructs adopted into glslang from its history, are likely relied on by users and so we need to cautious about changing things around (much as I'd like to). So, contributions that work without breaking things will be easier to get in.

@johnkslang
Copy link
Member

Let's get down to specifics, and stay on topic with this issue.

[The referenced commits (e7df8e0 and a515250) don't seem to have much to do with the reported behavior change, and some of the other criticisms seem triggered by guesses.]

The error glslang::TParseVersions::initializeExtensionBehavior() seems more to do with the addition of a virtual method override, which passed all the Linux, Mac, and Windows build bots. On the other hand, commit e7df8e0 added use of the validator and seems completely unrelated.

With the issue being about something that is not tested by the normal configuration, it will help to:

  1. identify when things really broke
  2. identify what settings you are using that detect the break, despite the normal settings being happy

@jengelh
Copy link
Contributor Author

jengelh commented Sep 10, 2018

Oh - I did not intend to mean e7df8e0 was the culprit; I merely tested these two commits, so the a51..e7d range is still subject to a bisection.

@johnkslang johnkslang changed the title Shared build fails in current master Shared library use not first-class functionality, not tested Nov 9, 2018
@KhronosGroup KhronosGroup deleted a comment from v-fox Nov 9, 2018
@KhronosGroup KhronosGroup deleted a comment from v-fox Nov 9, 2018
@johnkslang
Copy link
Member

This is pending any contribution or constructive suggestion of how to advance to better support of shared linkage objects.

@v-fox
Copy link

v-fox commented Nov 10, 2018

With the issue being about something that is not tested by the normal configuration, it will help to:

1. identify when things really broke

2. identify what settings you are using that detect the break, despite the normal settings being happy

The "settings we are using that detect the break, despite the normal settings being happy" is what all distributions consider proper practice, such as these automated openSUSE builds (see build logs on the right). Notice how I'm the only person on OBS who even bothered trying building vulkan, spirv-{headers,tools}, glslang, shaderc past the breakage spiral. That is because you:

  • don't version your API and put proper SO-versions in libs;
  • don't define API dependencies, let alone build ones;
  • put untested half-backed crap into master branches that doesn't belong there;
  • have no concept of release cycle and feature-targeting from roadmap goals (you are NOT supposed to merge commits of entire features BEFORE testing them out in THEIR ENTIRETY in a development branch that is synced with master, especially if you haven't even defined their dependencies !);
  • probably, don't even have roadmap or any idea what exactly are you trying to achieve;
  • have no concept of coding style, any idea of good & bad coding & maintenance practices.

This is pending any contribution or constructive suggestion of how to advance to better support of shared linkage objects.

Because of that and your insistence on staying in your "safe-space" echo-chamber that as much of "constructive suggestions" that you're going to get. No one wants to deal with that and with you. Bisecting your code is even bigger fool's errand than trying to compile supposed "release" shapshots with your abnormal "normal configuration".

PS: same thing happened in distributions with support for horrible mess of android-tools, by the way. Although, with Mesa being dependant on vulkan, maintainers will persevere somehow this time.

@johnkslang
Copy link
Member

I see several straw man fallacies, some religion, and can guess how you might jump to some of the non-religious conclusions, and yes there is a partially complete process of adapting a Windows' static-linking design to a Linux SO design (contributed by others), while not breaking existing use (which currently works on Max/Linux/Windows).

Rather than argue religiously in the abstract, it will be best to focus on specific issues and constructive action.

Is there a specific action to improve the semantic versioning being used?
Can you contribute the dependencies you want to see?
Is something currently in master that should not be?

(Note some large Khronos-provided features were developed and tested in a fork before appearing here, so appearances are different than reality.)

@jengelh
Copy link
Contributor Author

jengelh commented Nov 10, 2018

Is there a specific action to improve the semantic versioning being used?

That semantic version should be added to the filename; instead of producing (just) libHLSL.so, it should be called libHLSL.so.7. AIUI cmake has something like that in the form of set_target_properties(HLSL PROPERTIES VERSION 7.9.2888 SOVERSION 7).

@akien-mga
Copy link
Contributor

akien-mga commented Dec 10, 2018

I can understand the frustration of package maintainers trying to build glslang as a shared library, as that's what I'm doing now and I spent a couple hours working on fixes in that direction already.

Yet I don't think language as seen in #1484 (comment) is constructive, and throwing a bunch of complaints on a generic issue isn't either.

So back to issue at end (the OP: #1484 (comment)):

This happens because the glslang and HLSL both have a weak dependency on each other (cyclic dependency). HLSL doesn't specify it, which causes this link error when preventing underlinking issues using the link flags -Wl,--as-needed -Wl,--no-undefined.

This patch would solve the underlinking issue (i.e. make HLSL's dependency on glslang explicit):

diff --git a/hlsl/CMakeLists.txt b/hlsl/CMakeLists.txt
index f918d7a1..5696afd8 100644
--- a/hlsl/CMakeLists.txt
+++ b/hlsl/CMakeLists.txt
@@ -27,6 +27,8 @@ if(WIN32 AND BUILD_SHARED_LIBS)
     set_target_properties(HLSL PROPERTIES PREFIX "")
 endif()
 
+target_link_libraries(HLSL glslang)
+
 if(WIN32)
     source_group("Source" FILES ${SOURCES} ${HEADERS})
 endif(WIN32)

But then another issue comes up:

CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):
  "glslang" of type SHARED_LIBRARY
    depends on "HLSL" (weak)
  "HLSL" of type SHARED_LIBRARY
    depends on "glslang" (weak)
At least one of these targets is not a STATIC_LIBRARY.  Cyclic dependencies are allowed only among static libraries.

Cyclic dependencies are not allowed in shared libraries, so there's no easy fix. The proper fix would be to remove the cyclic dependency, probably by removing glslang's dependency on HLSL somehow.

In the meantime, the workaround for distro packagers is to forego their distro's library policy and let the underlinking go through (so remove -Wl,--no-undefined from the link flags).

@akien-mga
Copy link
Contributor

With the attached patch, HLSL links properly, but glslang then has its own linking issues. They're a lot less than what HLSL complains about though (hundreds of glslang symbol calls).

/usr/bin/ld: CMakeFiles/glslang.dir/MachineIndependent/ShaderLang.cpp.o: in function `(anonymous namespace)::CreateBuiltInParseables(TInfoSink&, glslang::EShSource)':
/home/akien/Mageia/Sandbox/_rpm/BUILD/glslang-7.10.2984/glslang/MachineIndependent/ShaderLang.cpp:89: undefined reference to `glslang::TBuiltInParseablesHlsl::TBuiltInParseablesHlsl()'
/usr/bin/ld: CMakeFiles/glslang.dir/MachineIndependent/ShaderLang.cpp.o: in function `ShInitialize':
/home/akien/Mageia/Sandbox/_rpm/BUILD/glslang-7.10.2984/glslang/MachineIndependent/ShaderLang.cpp:1276: undefined reference to `glslang::HlslScanContext::fillInKeywordMap()'
/usr/bin/ld: CMakeFiles/glslang.dir/MachineIndependent/ShaderLang.cpp.o: in function `ShFinalize':
/home/akien/Mageia/Sandbox/_rpm/BUILD/glslang-7.10.2984/glslang/MachineIndependent/ShaderLang.cpp:1378: undefined reference to `glslang::HlslScanContext::deleteKeywordMap()'
/usr/bin/ld: CMakeFiles/glslang.dir/MachineIndependent/ShaderLang.cpp.o: in function `(anonymous namespace)::CreateParseContext(glslang::TSymbolTable&, glslang::TIntermediate&, int, EProfile, glslang::EShSource, EShLanguage, TInfoSink&, glslang::SpvVersion, bool, EShMessages, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/home/akien/Mageia/Sandbox/_rpm/BUILD/glslang-7.10.2984/glslang/MachineIndependent/ShaderLang.cpp:116: undefined reference to `glslang::HlslParseContext::HlslParseContext(glslang::TSymbolTable&, glslang::TIntermediate&, bool, int, EProfile, glslang::SpvVersion const&, EShLanguage, TInfoSink&, std::__cxx11::basic_string<char, std::char_traits<char>, glslang::pool_allocator<char> >, bool, EShMessages)'
commit 9dde31a801343121c9aec1803f6410dea91cda51
Author: Rémi Verschelde <rverschelde@gmail.com>
Date:   Mon Dec 10 13:56:03 2018 +0100

    CMake: Properly link HLSL against glslang
    
    The HLSL library was using glslang symbols without linking against it
    formally. glslang on the contrary was linking against HLSL for no reason.
    
    Underlinking error spotted with GCC's '-Wl,--as-needed -Wl,--no-undefined'.

diff --git a/glslang/CMakeLists.txt b/glslang/CMakeLists.txt
index 5f51476b..ba7268c4 100644
--- a/glslang/CMakeLists.txt
+++ b/glslang/CMakeLists.txt
@@ -92,10 +92,6 @@ if(WIN32 AND BUILD_SHARED_LIBS)
     set_target_properties(glslang PROPERTIES PREFIX "")
 endif()
 
-if(ENABLE_HLSL)
-    target_link_libraries(glslang HLSL)
-endif()
-
 if(WIN32)
     source_group("Public" REGULAR_EXPRESSION "Public/*")
     source_group("MachineIndependent" REGULAR_EXPRESSION "MachineIndependent/[^/]*")
diff --git a/hlsl/CMakeLists.txt b/hlsl/CMakeLists.txt
index f918d7a1..5696afd8 100644
--- a/hlsl/CMakeLists.txt
+++ b/hlsl/CMakeLists.txt
@@ -27,6 +27,8 @@ if(WIN32 AND BUILD_SHARED_LIBS)
     set_target_properties(HLSL PROPERTIES PREFIX "")
 endif()
 
+target_link_libraries(HLSL glslang)
+
 if(WIN32)
     source_group("Source" FILES ${SOURCES} ${HEADERS})
 endif(WIN32)

@jengelh
Copy link
Contributor Author

jengelh commented Dec 10, 2018

Cyclic dependencies are not allowed in shared libraries, so there's no easy fix.

Generally speaking, there are two trivial (or let's say "default") ways of addressing such.

  1. Merge the two libraries into one build target, or
  2. Finding the intersection (usually the cycle in the graph) and factoring that out into a third library, then required by the other two.

While --no-undefined is a possible workaround, that would only work for ELF and not for PE platforms as I understand it.

ben-clayton added a commit to ben-clayton/glslang that referenced this issue Jun 15, 2020
... and stub the HLSL target.

Fixes the building of shared libraries.

This breaks the cyclic dependency between the `glslang` and `hlsl` targets (by essentially removing the `hlsl` target).

The `BUILD.gn` and `BUILD.bazel` build rules already pull the `HLSL` source into the `glslang` target.

`Android.mk` is the only remaining build config that has a dedicated `HLSL` target, but this is explicity static and does not suffer the same link-time issues with the cyclic dependency (we may wish to stub this target too).

Related issue: KhronosGroup#1484, KhronosGroup#2147
Related PR: KhronosGroup#2267
ben-clayton added a commit to ben-clayton/glslang that referenced this issue Jun 16, 2020
... and stub the HLSL target.

Fixes the building of shared libraries.

This breaks the cyclic dependency between the `glslang` and `hlsl` targets (by essentially removing the `hlsl` target).

The `BUILD.gn` and `BUILD.bazel` build rules already pull the `HLSL` source into the `glslang` target.

`Android.mk` is the only remaining build config that has a dedicated `HLSL` target, but this is explicity static and does not suffer the same link-time issues with the cyclic dependency (we may wish to stub this target too).

Related issue: KhronosGroup#1484, KhronosGroup#2147
Related PR: KhronosGroup#2267
@ben-clayton
Copy link
Contributor

#2271 fixes building of shared libraries.

#2277 (draft) starts to tackle versioning, including SONAME.

ben-clayton added a commit to ben-clayton/glslang that referenced this issue Jun 24, 2020
Allows for testing of generation of both static libraries and shared objects.

The old configs are staying in place until I'm confident everything is working correctly.

Issues: KhronosGroup#1421, KhronosGroup#1484, KhronosGroup#2283
ben-clayton added a commit to ben-clayton/glslang that referenced this issue Jun 29, 2020
ben-clayton added a commit to ben-clayton/glslang that referenced this issue Jun 29, 2020
Add `GenericCodeGen` and `MachineIndependent` static library targets.
Privately import both of these into the `glslang` target.
Privately import `MachineIndependent` into the  `SPIRV` target.

This is done to break the dependency of `libglslang.so` non-public APIs from `libspirv.so`,
which will become problematic once `glslang` hides its non-public symbols.

| File                      | Before     |     After  |
|---------------------------|-----------:|-----------:|
| `libGenericCodeGen.a`     |  -         |   `527716` |
| `libglslang.a`            | `68175944` |   `512938` |
| `libHLSL.a`               |     `1428` |     `1428` |
| `libMachineIndependent.a` |  -         | `67132202` |
| `libOGLCompiler.a`        |    `75908` |    `75908` |
| `libOSDependent.a`        |    `23768` |    `23768` |
| `libSPIRV.a`              | `15710210` | `15710210` |
| `libSPVRemapper.a`        |  `3250894` |  `3250894` |

| File                                    | Before     |     After  |
|-----------------------------------------|-----------:|-----------:|
| `libglslang-default-resource-limits.so` |   `117032` |   `117032` |
| `libglslang.so`                         | `22380688` | `22368216` |
| `libHLSL.so`                            |     `7520` |     `7520` |
| `libOGLCompiler.a`                      |    `75908` |    `75908` |
| `libOSDependent.a`                      |    `23768` |    `23768` |
| `libSPIRV.so`                           |  `7288336` | `28151016` |
| `libSPVRemapper.so`                     |  `1940208` |  `1940208` |

Issues: KhronosGroup#2283, KhronosGroup#1484
ben-clayton added a commit to ben-clayton/glslang that referenced this issue Jun 29, 2020
Default to `-fvisibility=hidden`, and annotate the public glslang interface with `GLSLANG_EXPORT` to change the visibility of these cherry-picked symbols to default.
This is also used by Windows builds for `__declspec(dllexport)`-ing the public DLL interface.

This allows us to classify API changes into those that are publicly backwards compatible, and those that are not.

Note that `libSPIRV` will likely need similar treatment.

Issues: KhronosGroup#2283, KhronosGroup#1484
ben-clayton added a commit to ben-clayton/glslang that referenced this issue Jun 29, 2020
ben-clayton added a commit to ben-clayton/glslang that referenced this issue Jun 30, 2020
Add `GenericCodeGen` and `MachineIndependent` static library targets.
Privately import both of these into the `glslang` target.
Privately import `MachineIndependent` into the  `SPIRV` target.

This is done to break the dependency of `libglslang.so` non-public APIs from `libspirv.so`,
which will become problematic once `glslang` hides its non-public symbols.

| File                      | Before     |     After  |
|---------------------------|-----------:|-----------:|
| `libGenericCodeGen.a`     |  -         |   `527716` |
| `libglslang.a`            | `68175944` |   `512938` |
| `libHLSL.a`               |     `1428` |     `1428` |
| `libMachineIndependent.a` |  -         | `67132202` |
| `libOGLCompiler.a`        |    `75908` |    `75908` |
| `libOSDependent.a`        |    `23768` |    `23768` |
| `libSPIRV.a`              | `15710210` | `15710210` |
| `libSPVRemapper.a`        |  `3250894` |  `3250894` |

| File                                    | Before     |     After  |
|-----------------------------------------|-----------:|-----------:|
| `libglslang-default-resource-limits.so` |   `117032` |   `117032` |
| `libglslang.so`                         | `22380688` | `22368216` |
| `libHLSL.so`                            |     `7520` |     `7520` |
| `libOGLCompiler.a`                      |    `75908` |    `75908` |
| `libOSDependent.a`                      |    `23768` |    `23768` |
| `libSPIRV.so`                           |  `7288336` | `28151016` |
| `libSPVRemapper.so`                     |  `1940208` |  `1940208` |

Issues: KhronosGroup#2283, KhronosGroup#1484
ben-clayton added a commit to ben-clayton/glslang that referenced this issue Jun 30, 2020
Add `GenericCodeGen` and `MachineIndependent` static library targets.
Privately import both of these into the `glslang` target.
Privately import `MachineIndependent` into the  `SPIRV` target.

This is done to break the dependency of `libglslang.so` non-public APIs from `libspirv.so`,
which will become problematic once `glslang` hides its non-public symbols.

| File                      | Before     |     After  |
|---------------------------|-----------:|-----------:|
| `libGenericCodeGen.a`     |  -         |   `527716` |
| `libglslang.a`            | `68175944` |   `512938` |
| `libHLSL.a`               |     `1428` |     `1428` |
| `libMachineIndependent.a` |  -         | `67132202` |
| `libOGLCompiler.a`        |    `75908` |    `75908` |
| `libOSDependent.a`        |    `23768` |    `23768` |
| `libSPIRV.a`              | `15710210` | `15710210` |
| `libSPVRemapper.a`        |  `3250894` |  `3250894` |

| File                                    | Before     |     After  |
|-----------------------------------------|-----------:|-----------:|
| `libglslang-default-resource-limits.so` |   `117032` |   `117032` |
| `libglslang.so`                         | `22380688` | `22368216` |
| `libHLSL.so`                            |     `7520` |     `7520` |
| `libOGLCompiler.a`                      |    `75908` |    `75908` |
| `libOSDependent.a`                      |    `23768` |    `23768` |
| `libSPIRV.so`                           |  `7288336` | `28151016` |
| `libSPVRemapper.so`                     |  `1940208` |  `1940208` |

Issues: KhronosGroup#2283, KhronosGroup#1484
ben-clayton added a commit to ben-clayton/glslang that referenced this issue Jun 30, 2020
Default to `-fvisibility=hidden`, and annotate the public glslang interface with `GLSLANG_EXPORT` to change the visibility of these cherry-picked symbols to default.
This is also used by Windows builds for `__declspec(dllexport)`-ing the public DLL interface.

This allows us to classify API changes into those that are publicly backwards compatible, and those that are not.

Note that `libSPIRV` will likely need similar treatment.

Issues: KhronosGroup#2283, KhronosGroup#1484
tangent-vector pushed a commit to shader-slang/glslang that referenced this issue Jul 29, 2020
* wait time increased for the install

* Fix build on CMake 2.8, and fix Web build

And suppress some warnings that are too verbose in Web builds.

* update README

* test names updated

* rayQueryEXT assignment is allowed.

* rayQueryEXT function parameter

* rayQuery test cases added

* compute and fragment shader test_cases added for rayQuery

* const rayFlag defs used in the test cases in stead of numerical values

* .travis updated to origin, rayQueryCheck removed

* spirv.hpp reverted to commit f368dcb

* copyright notice changes removed from unchanged files

* copyright notice changes removed from unchanged files

* copyright notice changes removed from unchanged files

* switch format update

* 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

* pass-by-reference updates

* pass by reference updates

* accelerationStructureEXT - issue KhronosGroup#2152

* accelerationStructureEXT - issue KhronosGroup#2152

* Update spirv-tools known_good to latest stable

* opposite inner condition

* bitwise on boolean

* unused var

* printf format

* Fix KhronosGroup#2163: improve comments for addProcess() and the preamble.

* Remove unused variables.

This CL removes two unused variables from the initialization code.

* Error assigns to objects of rayQueryEXT type.

* Bump revision.

* Build warning: Fix KhronosGroup#2167: Remove nested reuse of 'unreachable'.

* Shader interface matching rework to fix KhronosGroup#2136 (KhronosGroup#2156)

* rework how shader interface block naming rules are handled

* Fixes 2136

According to the spec, shader interfaces (uniform blocks, buffer
blocks, input blocks, output blocks) all should be matched up via
their block names across all compilation units, not instance names.
Also, all block names can be re-used between all 4 interface types
without conflict. This change makes it so all of these blocks are
matched and remapped using block name and not by instance name.
Additional the rule that matched uniform and buffer blocks must
either be anonymous or named (but not nessearily the same name) is
now imposed.

* add warning if instance names differ between matched shader interfaces

* Add test cases from KhronosGroup#2137 which is now fixed as well.

* replace some tab characters with spaces

* buffer blocks and uniform blocks now share the same block namespace

* Remove extra semicolons (KhronosGroup#2170)

This is causing downstream users compiler errors if they have Werror or other
particularly restrictive flags turned on.

* Error message: Finish addressing KhronosGroup#2097, better texture error message.

* Add support for EXT_ray_flags_primitive_culling. (KhronosGroup#2173)

Fixes issue KhronosGroup#2169.

* Get rid of all warnings with MSVC and clang-cl (KhronosGroup#2177)

* Fix KhronosGroup#2178: Allow specialization constants for texel offsets.

* Support multiple swizzled out operands (KhronosGroup#2175)

Swizzled out operands were added in bbbd9a2. This was sufficient
for most tests, but we ran into problems with umulExtended and
imulExtended, which have two.

This CL converts the tracking values to vectors so multiple operands
can be supported.

Test: KHR-GLES31.core.shader_bitfield_operation.*
Test: ctest

* Add support for extension GL_ARB_shader_bit_encoding (KhronosGroup#2183)

* Add support for extension GL_ARB_shader_image_size (KhronosGroup#2185)

* xcode warnings fix (KhronosGroup#2188)

* TPpToken: Fix compiling on clang-10 (KhronosGroup#2189)

* Add support for extension GL_ARB_shader_storage_buffer_object (KhronosGroup#2184)

Enable below features for GL Core version 420:
* layout qualifier "std430"
* storage qualifier "buffer"
* atomic memory functions

* Move to latest SPIR-V header, and bump glslang revision.

* Note about Build Status.

* Move to SPIR-V 1.5 Rev. 3, bump revision, remove a status from README.

* Add support for extension GL_ARB_shading_language_packing (KhronosGroup#2192)

* Remove unused Es310Desktop430 (KhronosGroup#2200)

This variable is no longer used, remove.

* Add support for extension GL_ARB_texture_query_lod. (KhronosGroup#2194)

* Add support for extension GL_ARB_vertex_attrib_64bit (KhronosGroup#2193)

* Fix KhronosGroup#2201: Improve const and copy constructor for TVarLivePair.

* Add support for extension GL_EXT_shader_implicit_conversions
Updated extension management in TIntermediate class.

* Add support for extension GL_EXT_shader_integer_mix (KhronosGroup#2203)

* Add support for es extension GL_EXT_blend_func_extended
* Introduces builtin variables gl_SecondaryFragColorEXT and gl_SecondaryFragDataEXT
* Introduces builtin constant gl_MaxDualSourceDrawBuffersEXT
* enables support for layout qualifier "index" in es profile

* GLSL: Separate out swizzle handling (potentially fixing bugs).

Noticed this when looking at swizzles.  It's at least better structure,
removing hard-to-see early returns, which might be contributing to bugs.

* Fix KhronosGroup#2191: Error check for indexing reference containing unsize array.

* Explicitly mark some enums as unsigned

This allows casting from and to any unsigned value, previously this was
undefined behavior.

This fixes ubsan complaining in `TParseContext::layoutQualifierCheck`,
where `~EShLangComputeMask` is used.

* Fix Web build

* Address KhronosGroup#2211: Improve the copy constructor of TVarLivePair.

* Move to newer version of SPIRV-Tools

* Update tests according to spirv-opt update

We refactored function inlining pass of spirv-opt and it results in
different numbering of result ids in SPIR-V code. This commit updates
test cases to avoid a test failure according to the spirv-opt update.

* Update known good

* Bump version.

* Reserve unused std140 uniform block in reflection, and fix uniform block matrix layout (KhronosGroup#2041)

According to the spec glsl4.60.7:
4.4.5. Uniform and Shader Storage Block Layout Qualifiers:
"The packed qualifier overrides only std140, std430, and shared; other qualifiers are inherited.
When packed is used, no shareable layout is guaranteed. The compiler and linker can optimize
memory use based on what variables actively get used and on other criteria. Offsets must be
queried, as there is no other way of guaranteeing where (and which) variables reside within the
block"

we should reserve std140 block and shared block in reflection.

According to the spec glsl4.60.7:
4.4.5. Uniform and Shader Storage Block Layout Qualifiers:
"The row_major and column_major qualifiers only affect the layout of matrices, including all
matrices contained in structures and arrays they are applied to, to all depths of nesting. These
qualifiers can be applied to other types, but will have no effect."

We need ensure all matrix block member been effect.

Support EShMsgKeepUncalled in reflection

EShMsgKeepUncalled  is a link message for link program.
We need only one option to control uncalled function optimization.
If we set EShMsgKeepUncalled as false in link time, linker won't be keep the uncall function sequence in AST,  and if we set EShMsgKeepUncalled as true in link time, linker will keep all uncalled function sequence in AST.
So, in reflecte time, we just only travers all function sequence. It make EShMsgKeepUncalled  only work at linker, and can effect reflection.

Recursively layout packing to "block member"

layout packing isn't set recursively, it causes TReflection::getOffsets doesn't work correctly.

* Bump version.

* Flatten all interface variables (KhronosGroup#2217)

Specifically, add flattening of arrayed io for geometry and
tesselation shaders. Previously some interface structs just had
builtins split out which caused some interfaces to not be exactly
the same as that of flattened adjacent stages, affecting validation
and correctness.

This obviates builtin splitting. That will be removed in a followup
commit. It was left in for this commit to better exhibit the functional
changes that were made.

Fixes KhronosGroup#1660.

* Add check for DOUBLE in low versions (KhronosGroup#2223)

Add check for DOUBLE in low versions, fix issue KhronosGroup#2206

* Code refine. (KhronosGroup#2227)

* Build: Fix KhronosGroup#2228, by correcting the type used.

* Fix KhronosGroup#2227, which was coded incorrectly, to be simpler/safer.

* Add an option to make Exceptions enabled (KhronosGroup#2239)

* Add an option to make Exceptions enabled

* /EHsc enable exceptions since vs2003

* fix incorrect error when multiple compilation units don't declare layouts (KhronosGroup#2238)

when using multiple compilation units, input/output layouts don't need
to be declared in every unit.

* Do not build glslang-testsuite when ENABLE_CTEST is disabled (KhronosGroup#2240)

* Replace incorrect uint32_t with correct int vars (KhronosGroup#2235)

* Add support for primitive culling layout qualifier. (KhronosGroup#2220)

* Add support for primitive culling layout qualifier.

* Add error checks for primitive flags and negative test.

* Reorder member init to match decl order (KhronosGroup#2241)

Fixes field reorder warning.

* Update spirv tools (KhronosGroup#2246)

* Update known good SPIRV-Tools

* Update test expectations

* Update SPIRV-Tools to stable. Also SPIRV-Headers to TOT. (KhronosGroup#2250)

* Fix missing patch decoration for TessFactor PCF arg (KhronosGroup#2249)

Fixes KhronosGroup#1553

* fix warning unused parameter in release build (KhronosGroup#2251)

* EXT_ray_tracing requires spv1.4 (KhronosGroup#2237)

* EXT_ray_tracing requires spv1.4

* Fix typo.

* Add extension data table.

* Updated feedback #2.

* Remove install to the SPIRV/ folder. (KhronosGroup#2256)

This CL updates the build scripts to only install to glslang/SPIRV
instead of also installing to the SPIRV/ folder. The deprecation notice
is also removed.

Note, this may cause downstream build issues if include directories have
not been updated

Fixes KhronosGroup#1964 KhronosGroup#2216

* Update news for header location change and recommendation.

* Add default descriptorset decoration for acceleration structure (KhronosGroup#2257)

variables.

* HLSL: fix handling of uniform qualifier in entry point parameters (KhronosGroup#2254)

* HLSL: Fix handling of uniforms in entry point parameters

* HLSL: fix handling of "uniform in"

* Tests: Update baseResults of hlsl.function.frag.out for KhronosGroup#2254

* HLSL: fix uniforms in function parameters for opaque types

* HLSL: Recognize POSITION semantic et al in DX9 compatibility mode (KhronosGroup#2255)

* HLSL: Add better diagnostic when using in/out qualifiers in global scope (KhronosGroup#2258)

* Add SPIR-V capabilities needed for spec constants (KhronosGroup#2199)

Fixes KhronosGroup#2198.

* spirv: Support initializers on uniforms (KhronosGroup#1588)

If a uniform has an initializer it will now be given as the optional
initializer operand to the OpVariable instruction.

Fixes: KhronosGroup#1259

Signed-off-by: Neil Roberts <nroberts@igalia.com> (the code)
Signed-off-by: Alejandro Piñeiro <apinheiro@igalia.com> (the tests)
Signed-off-by: Arcady Goldmints-Orlov <agoldmints@igalia.com>

Co-authored-by: Neil Roberts <nroberts@igalia.com>

* Add Shared/Std140 SSBO process & top-level array elements related (KhronosGroup#2231)

* Add Shared/Std140 SSBO process & top-level array elements related
process

1.Add process options for shared/std140 ssbo, following ubo process
2.Add IO Variables reflection option, would keep all input/output
variables in reflection
3.Add Top-level related process, fix top-level array size issues,
following spec
4.Split ssbo/ubo reflection options, merge blowup expanding all into
function blowupActiveAggregate to allow other functions keep same entry
format.

Add options in StandAlone and test symbols.

1. Add options in StandAlone for std140/shared ubo/ssbo and all io variables reflection.
2. Add test for ssbo. When EShReflectionSharedStd140SSBO turns on, generated symbol and output would be different, to remind the difference. Defaultly disabled and nothing would change, nor blocking normal test.

* Add options in runtest script, refresh test results.

Add options in StandAlone:
--reflect-all-io-variables --reflect-shared-std140-ubo --reflect-shared-std140-ssbo

refresh test results.
Now the index, size of unsized array are expected.

* Fix xfb stride limit issue (KhronosGroup#2088)

* Fix xfb_stride limit issue

Unsized array can't apply to transform trace. layout qualifier "offset" require GL_ARB_enhanced_layouts enable or glsl core version > 440.

* Add negative test for xfb limit

* update case result

* Fix compile information issue

Fix compile information issue and test comment issue.

* remove es profile condition, use profileRequires to limit.

* Fix xfb_stride limit issue

Unsized array can't apply to transform trace. layout qualifier "offset" require GL_ARB_enhanced_layouts enable or glsl core version > 440.
Add negative test for xfb limit

* Move es profile check out of version number check

* Adjust error information and related cases

remove the new version check, refine original version check.

* Revert condition for vulkan, and remove redundant test code.

* Use correct type for var storing returned value (KhronosGroup#2263)

* Fix KhronosGroup#2264: OpEntryPoint incorrectly including function parameters.

* Bump code gen version, due to removal of OpEntryPoint operands.

* Fix signed / unsigned mismatch warning (KhronosGroup#2266)

* C Interface: Split SPIR-V C interface to own file

This breaks a cyclic dependency between the SPIRV and glslang build targets.

* HLSL: Fix incorrect case in name of DX9-style cube sampler type (KhronosGroup#2265)

* HLSL: Remove support for having GLSL versions of HLSL intrinsics.

Related to PR KhronosGroup#2265.

* Remove unused function, BaseTypeName (KhronosGroup#2272)

* Remove unused variable. (KhronosGroup#2273)

The `isMat` variable is no longer used in the HLSL parser. Removed.

* CMake: Fold HLSL source into glslang

... and stub the HLSL target.

Fixes the building of shared libraries.

This breaks the cyclic dependency between the `glslang` and `hlsl` targets (by essentially removing the `hlsl` target).

The `BUILD.gn` and `BUILD.bazel` build rules already pull the `HLSL` source into the `glslang` target.

`Android.mk` is the only remaining build config that has a dedicated `HLSL` target, but this is explicity static and does not suffer the same link-time issues with the cyclic dependency (we may wish to stub this target too).

Related issue: KhronosGroup#1484, KhronosGroup#2147
Related PR: KhronosGroup#2267

* Bump version.

* Move hlsl/ source to glslang/HLSL/

Now that the HLSL source files are part of the `glslang` target (KhronosGroup#2271), it makes sense for these to sit in the `glslang` directory.

Changed the case of the directory from `hlsl` to `HLSL` to better match the sibling directories.

* Bump version numbers.

* Build: use better MSVC subfolder names for the previous build changes.

* Add -g0 command line argument

Analogous to gcc, -g0 would strip all debug info.  This is done
regardless of whether optimizations are enabled.

Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>

* Switch ndk_test from gnustl_static to c++_static

gnustl_static is no longer supported.

* Add kokoro configs for android-ndk and cmake

* Update README.md

* Use OpFUnordNotEqual for floating-point !=

The normal IEEE not equal operation tests whether operands are unordered
or not equal (so comparison with a NaN returns true). This corresponds
to the SPIR-V OpFUnordNotEqual, so change to using that.

* Update test results to expect OpFUnordNotEqual

* Update SPIR-V generator version

Change to 10 to reflect the change to generating unordered !=
operations.

* Update test expected files with new magic number

Updating the SPIR-V generator version number changes the output of all
the SPIR-V tests.

* Fixed msvc 2019 nmake compiler warnings with RTTI.
By default cmake generates cxx_flags with `/GR` parameter.
I updated CMAKE_CXX_FLAGS string and replaced `/GR` -> `/GR-`

How to reproduce:

Visual Studio 2019 x64 command port

mkdir build-msvc2019
cd build-msvc2019
cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_LIBDIR=install ..
nmake

COMPILATION BEFORE:

Scanning dependencies of target OSDependent
[  1%] Building CXX object glslang/OSDependent/Windows/CMakeFiles/OSDependent.dir/ossource.cpp.obj
cl : Command line warning D9025 : overriding '/GR' with '/GR-'
ossource.cpp
[  3%] Linking CXX static library OSDependent.lib
[  3%] Built target OSDependent
Scanning dependencies of target OGLCompiler
[  4%] Building CXX object OGLCompilersDLL/CMakeFiles/OGLCompiler.dir/InitializeDll.cpp.obj
cl : Command line warning D9025 : overriding '/GR' with '/GR-'
InitializeDll.cpp
[  6%] Linking CXX static library OGLCompiler.lib
[  6%] Built target OGLCompiler
Scanning dependencies of target glslang
[  7%] Building CXX object glslang/CMakeFiles/glslang.dir/MachineIndependent/glslang_tab.cpp.obj
cl : Command line warning D9025 : overriding '/GR' with '/GR-'
glslang_tab.cpp
[  9%] Building CXX object glslang/CMakeFiles/glslang.dir/MachineIndependent/attribute.cpp.obj
cl : Command line warning D9025 : overriding '/GR' with '/GR-'

FLAGS BEFORE:

-- CMAKE_C_FLAGS:   /DWIN32 /D_WINDOWS /W3
-- CMAKE_CXX_FLAGS: /DWIN32 /D_WINDOWS /W3 /GR /EHsc
-- CMAKE_CXX_FLAGS_DEBUG:   /MDd /Zi /Ob0 /Od /RTC1
-- CMAKE_CXX_FLAGS_RELEASE: /MD /O2 /Ob2 /DNDEBUG

COMPILATION AFTER:

[  1%] Building CXX object glslang/OSDependent/Windows/CMakeFiles/OSDependent.dir/ossource.cpp.obj
ossource.cpp
[  3%] Linking CXX static library OSDependent.lib
[  3%] Built target OSDependent
[  4%] Building CXX object OGLCompilersDLL/CMakeFiles/OGLCompiler.dir/InitializeDll.cpp.obj
InitializeDll.cpp
[  6%] Linking CXX static library OGLCompiler.lib
[  6%] Built target OGLCompiler
[  7%] Building CXX object glslang/CMakeFiles/glslang.dir/MachineIndependent/glslang_tab.cpp.obj
glslang_tab.cpp
[  9%] Building CXX object glslang/CMakeFiles/glslang.dir/MachineIndependent/attribute.cpp.obj

FLAGS AFTER:

-- CMAKE_C_FLAGS:   /DWIN32 /D_WINDOWS /W3
-- CMAKE_CXX_FLAGS: /DWIN32 /D_WINDOWS /W3 /GR- /EHsc
-- CMAKE_CXX_FLAGS_DEBUG:   /MDd /Zi /Ob0 /Od /RTC1
-- CMAKE_CXX_FLAGS_RELEASE: /MD /O2 /Ob2 /DNDEBUG

* Kokoro: Split linux cmake cfgs into static/shared

Allows for testing of generation of both static libraries and shared objects.

The old configs are staying in place until I'm confident everything is working correctly.

Issues: KhronosGroup#1421, KhronosGroup#1484, KhronosGroup#2283

* HLSL: Fix #pragma pack_matrix(row_major) not work on global uniforms

* Add pack_matrix test

* SPV: Partially address KhronosGroup#2293: correct "const in" precision matching.

Track whether formal parameters declare reduced precision and match
that with arguments, and if they differ, make a copy to promote the
precision.

* SPV: Fix KhronosGroup#2293: keep relaxed precision on arg passed to relaxed param

When arguments are copied to make space for a writable formal parameter,
and the formal parameter is relaxed precision, make the copy also
relaxed precision.

* Remove root kokoro/linux-*-cmake configs

These have been superseded by the `static` and `shared` variants in the respective subdirectories.

Issue: KhronosGroup#2283

* CMake: Error on unresolved symbols

Issue: KhronosGroup#1484

* CMake: Compile with -fPIC when building SOs

Without this embedding static libraries into shared libraries may result in link time errors.

Issue: KhronosGroup#2283

* Fixed GCC -Wunused-parameter in hlslParseables.cpp.

Warnings before fix:

[3/7] Building CXX object glslang/CMakeFiles/glslang.dir/HLSL/hlslParseables.cpp.o
../glslang/HLSL/hlslParseables.cpp: In function ‘bool {anonymous}::IsValid(const char*, char, char, char, char, int, int)’:
../glslang/HLSL/hlslParseables.cpp:334:45: warning: unused parameter ‘retOrder’ [-Wunused-parameter]
  334 | inline bool IsValid(const char* cname, char retOrder, char retType, char argOrder, char argType, int dim0, int dim1)
      |                                        ~~~~~^~~~~~~~
../glslang/HLSL/hlslParseables.cpp:334:60: warning: unused parameter ‘retType’ [-Wunused-parameter]
  334 | inline bool IsValid(const char* cname, char retOrder, char retType, char argOrder, char argType, int dim0, int dim1)
      |                                                       ~~~~~^~~~~~~
../glslang/HLSL/hlslParseables.cpp:334:89: warning: unused parameter ‘argType’ [-Wunused-parameter]
  334 | inline bool IsValid(const char* cname, char retOrder, char retType, char argOrder, char argType, int dim0, int dim1)
      |                                                                                    ~~~~~^~~~~~~
../glslang/HLSL/hlslParseables.cpp:334:112: warning: unused parameter ‘dim1’ [-Wunused-parameter]
  334 | inline bool IsValid(const char* cname, char retOrder, char retType, char argOrder, char argType, int dim0, int dim1)
      |                                                                                                            ~~~~^~~~

* SPV: RelaxedPrecision: Generalize fix KhronosGroup#2293 to cover more operations.

This simplifies and enforces use of precision in many more places,
to help avoid accidental loss of RelaxedPrecision through intermediate
operations. Known fixes are:
- ?:
- function return values with mis-matched precision
- precision of function return values when a copy was needed to fix types

* SPV: RelaxedPrecision: use the result precision for texture sampling.

Fix KhronosGroup#2298.

The AST has two precisions, an operation precision and a result precision.
Actual use of GLSL with mediump samplers wants the result precision, so
pick that up instead of the operation precision.

* CMake: break up glslang into smaller static libs

Add `GenericCodeGen` and `MachineIndependent` static library targets.
Privately import both of these into the `glslang` target.
Privately import `MachineIndependent` into the  `SPIRV` target.

This is done to break the dependency of `libglslang.so` non-public APIs from `libspirv.so`,
which will become problematic once `glslang` hides its non-public symbols.

| File                      | Before     |     After  |
|---------------------------|-----------:|-----------:|
| `libGenericCodeGen.a`     |  -         |   `527716` |
| `libglslang.a`            | `68175944` |   `512938` |
| `libHLSL.a`               |     `1428` |     `1428` |
| `libMachineIndependent.a` |  -         | `67132202` |
| `libOGLCompiler.a`        |    `75908` |    `75908` |
| `libOSDependent.a`        |    `23768` |    `23768` |
| `libSPIRV.a`              | `15710210` | `15710210` |
| `libSPVRemapper.a`        |  `3250894` |  `3250894` |

| File                                    | Before     |     After  |
|-----------------------------------------|-----------:|-----------:|
| `libglslang-default-resource-limits.so` |   `117032` |   `117032` |
| `libglslang.so`                         | `22380688` | `22368216` |
| `libHLSL.so`                            |     `7520` |     `7520` |
| `libOGLCompiler.a`                      |    `75908` |    `75908` |
| `libOSDependent.a`                      |    `23768` |    `23768` |
| `libSPIRV.so`                           |  `7288336` | `28151016` |
| `libSPVRemapper.so`                     |  `1940208` |  `1940208` |

Issues: KhronosGroup#2283, KhronosGroup#1484

* glslang: Only export public interface for SOs

Default to `-fvisibility=hidden`, and annotate the public glslang interface with `GLSLANG_EXPORT` to change the visibility of these cherry-picked symbols to default.
This is also used by Windows builds for `__declspec(dllexport)`-ing the public DLL interface.

This allows us to classify API changes into those that are publicly backwards compatible, and those that are not.

Note that `libSPIRV` will likely need similar treatment.

Issues: KhronosGroup#2283, KhronosGroup#1484

* HLSL: Catch error cases earlier, preventing a later assert.

Related to KhronosGroup/SPIRV-Cross#1414.
The real problem is either using DX10 semantics for DX9 or missing
functionality in DX10 parsing.

* Add additional licenses in use to LICENSE.txt

Ideally we'd unify the licenses in use by changing the licenses in the file headers to BSD-3-clause.

Until then, let's correctly list all the licenses currently in use.

Issue: KhronosGroup#2305

* Tests: More broadly use automapping binding/location.

This adds or changes binding/location decorations in 100s of shaders.
It also allows more output (spv.register.autoassign.rangetest.frag)
due to allowing ioMap() to fail.

* SPIRV-Tools and tests: Update to location-validation in SPIRV-Tools.

This introduces five new "Validation failures":
- baseResults/hlsl.semantic.vert: issue with gl_ClipDistance/CullDistance
- baseResults/spv.430.vert: issue gl_ClipDistance
- baseResults/spv.450.tesc: still unknown
- baseResults/spv.dataOut.frag: gl_FragData should not be supported, problem with front end
- baseResults/spv.meshShaderPerViewUserDefined.mesh: seems okay, maybe a problem with SPIRV-Tools

* Bump revision.

* Add missing copyright headers

Add copyright headers to build files and scripts.
Simplifies automated scanning for bad license headers.

* Fix GLSLANG_IS_SHARED_LIBRARY define

It was incorrectly always being set, causing linker warnings for MSVC builds.
Also simplify the preprocessor nesting in `glslang\Public\ShaderLang.h`

* Add config for license-checker and Kokoro scripts.

The `license-checker` is a tool that verifies each file has contains a permitted license header.

See https://github.com/ben-clayton/license-checker for more information.

* Kokoro: Correct the `build_file' path to build.sh

* License headers: s/Google/The Khronos Group

This was a copy-paste screwup, where the first line of the copyright had the company name was updated, but the company name mid way though was not.

* Don't use add_link_options() on old CMake versions

Fixes: KhronosGroup#2315

* gn: Optionally disable optimizations and HLSL

To reduce the binary size of ANGLE, a gn override is added
(glslang_angle) which:

- Controls whether ENABLE_OPT=1 is set
- Customizes the build for the Vulkan backend of ANGLE.  As a first
  step, this removes HLSL functionality which together with no
  optimization shave ~2.5MB off of ANGLE's binary size.

Upcoming changes will add a macro for GLSLANG_ANGLE similar to
GLSLANG_WEB that will strip features from glslang to support only what
ANGLE needs.

Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>

* Add GLSLANG_BUILD_PIC CMake flag

Enables `-fPIC` compiler flag even when building statically.
This is helpful for statically linking a `glslang` target into a shared library.

Simplifies the workarounds seen in google/shaderc#1093 to a `set(GLSLANG_BUILD_PIC 1)`.

* gn: Fix `gn gen --check` by adding missing dependency

Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>

* gn: Fix dawn tests in Chromium

Dawn tests use shaderc, which assumes glslang has HLSL support.  This
change makes HLSL support also follow template arguments, and changes
the target names such that glslang_sources will remain the "has all
features" target and the new glslang_lib_sources would be what ANGLE
would use.

Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>

* Add --quiet option.

Being quiet should have been the default, but I guess it's too late
now to change it.

* Add new rules to .gitignore

`.vscode/` ignores Visual Studio Code user config files
`bazel-*` ignores bazel build system symlinks.
`out/` ignores the default output directory for Visual Studio generated files.

* Add new static targets to VS solution folders

`GenericCodeGen` and `MachineIndependent` were missing from the generated visual studio solutions. Add these.

* Remove GLSLANG_BUILD_PIC flag

On closer inspection, it appears that nearly all the targets use the `POSITION_INDEPENDENT_CODE` target option anyway.
Simplify all this away by always being PIC.

* Use CMake's builtin functionality for PCHs

`glslang_pch()` did manual mangling of the compiler flags to enable pre-compiled headers.
I couldn't get this approach to work with the `MachineIndependent` subdirectory, but fortunately CMake has added first-class support for precompiled headers in 3.16, which does work with subdirectories.

Moved `glslang_pch()` to the other global function declarations.

`glslang_pch()` is a no-op when using CMake earlier than `3.16`.

CMake's PCH implementation does not need the `pch.cpp` files, so just remove them.

* Make sure glslang_angle has a definition in BUILD.gn

Set the value to false if the environment doesn't declare this variable.

* Use GLSLANG_ANGLE to strip features to what ANGLE requires

This change strips a few features similar to GLSLANG_WEB but doesn't
remove every detail like the latter.  It also hardcodes profile/version
to core/450.

In particular, TBuiltIns::initialize is specialized to remove most of
what is not supported or won't be supported by ANGLE.  The result of
this function is parsed with TParseContext::parseShaderStrings which is
a performance bottleneck.

This change shaves about 300KB off of ANGLE's binary size and reduces
the cost of SetupBuiltinSymbolTable to nearly a sixth.

Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>

* Customize glslang.y to GLSLANG_ANGLE

glslang.y is specialized to remove what is not supported or won't be
supported by ANGLE.

This change shaves about 125KB off of ANGLE's binary size with minor
improvement to the cost of SetupBuiltinSymbolTable.

Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>

* Generate build information from CHANGES.md

This PR significantly reworks the way glslang is versioned.

Instead of committing changes to the `GLSLANG_MINOR_VERSION` define in
`glslang/Public/ShaderLang.h`, and using `make-revision` to generate
`GLSLANG_PATCH_LEVEL` in `glslang/Include/revision.h`, all version
information is now derived from the new `CHANGES.md` file.

`CHANGES.md` acts as the single source of truth for glslang version
information, along with a convenient place to put all release notes for
each notable change made.

`CHANGES.md` is parsed using the new `build_info.py` python script.
This script can read basic template files to produce new source files,
which it does to read the new `build_info.h.tmpl` to generate (at build
time) a glslang private header at
`<build-dir>/include/glslang/build_info.h`.
I've written generators for each of the CMake, Bazel, gn, and
`Android.mk` build scripts.

The new version code conforms to the Semantic Versioning 2.0 spec.

This new version is also used by the CMake rules to produce versioned
shared objects, including a major-versioned SONAME.

New APIs:
---------

* `glslang::GetVersion()` returns a `Version` struct with the version
  major, minor, patch and flavor.

Breaking API changes:
---------------------

* The public defines `GLSLANG_MINOR_VERSION` and `GLSLANG_PATCH_LEVEL`
  have been entirely removed.
* `glslang/Public/ShaderLang.h` and `glslang/Include/revision.h` have
  been deleted.
* Instead, `<build-dir>/include/glslang/build_info.h` is created in
  the build directory, and `<build-dir>/include` is a CMake `PUBLIC`
  (dependee-inherited) include directory for the glslang targets.
* `<build-dir>/include/glslang/build_info.h` contains the following
   new #defines:
   `GLSLANG_VERSION_MAJOR`, `GLSLANG_VERSION_MINOR`,
   `GLSLANG_VERSION_PATCH`, `GLSLANG_VERSION_FLAVOR`,
   `GLSLANG_VERSION_GREATER_THAN(major, minor, patch)`,
   `GLSLANG_VERSION_GREATER_OR_EQUAL_TO(major, minor, patch)`,
   `GLSLANG_VERSION_LESS_THAN(major, minor, patch)`,
   `GLSLANG_VERSION_LESS_OR_EQUAL_TO(major, minor, patch)`
*  The CMake install output directory contains a copy of
   `build_info.h` at: `include/glslang/build_info.h`
*  Python3 is now always required to build glslang (likely always
   required for transitive dependency builds).

* Attempt to fix chromium builds

It would seem that `glslang_sources` has a private dependency on `glslang_build_info`, so `glslang_validator` cannot transitively `#include` the generated `glslang/build_info.h` header.

Add `glslang_build_info` as a direct dependency to `glslang_validator`.
Also remove the duplicate dependency on `glslang_build_info` in `glslang_sources_common`

Note: This is a speculative fix as I can build Chromium fine without these changes.
Not sure what's different between these configs.

* Fix CMake rules when nesting CMake projects

`${CMAKE_SOURCE_DIR}` points to the outer project root, not the current directory.

Fixes building of `glslang` when included into another CMake project.

* Common: include standard headers before doing any defines

currently, due to

```c++
\#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) || defined MINGW_HAS_SECURE_API
    #include <basetsd.h>
    #ifndef snprintf
    #define snprintf sprintf_s
    #endif
    #define safe_vsprintf(buf,max,format,args) vsnprintf_s((buf), (max), (max), (format), (args))
```

defining `snprintf` to `sprintf_s` essentially unconditionally, this will break the
stdio.h+cstdio system header for mingw-w64 g++ in msys2 with shaderc
google/shaderc#1065

an alternative change would be
https://raw.githubusercontent.com/shinchiro/mpv-winbuild-cmake/master/packages/glslang-0001-fix-gcc-10.1-error.patch
in which the `|| defined MINGW_HAS_SECURE_API` part is removed

Signed-off-by: Christopher Degawa <ccom@randomderp.com>

* Add missing comma from license-checker.cfg

Fixes license checker presubmit.

* Fix KhronosGroup#2329: don't use invalid initializers.

* Fix a couple lines that were too long, to retrigger bots.

* Revert "Merge pull request KhronosGroup#2330 from ShabbyX/optimize_for_angle"

This reverts commit 1ee5d1c, reversing
changes made to 906d48a.

* Fix comma in licence checker.

* Kokoro: Print test output to stdout

* CMake: Move project() to top of CMakeLists.txt

Also remove `NOTICE` from message() about PCHs - it seems to print this in the actual message, contrary to the documentation where it is used as a severity.

* Add bison license to LICENSE.txt

* Non-determinism: Remove test file that seems to trigger non-determinism.

This problem needs to be fixed, but in parallel, we need to see master
and any other changes to it passing all tests.

The removed test is ray-tracing centric, and may indicate non-determinism
in recent code added for that functionality.

* Fix recently found non-determinism with gl_WorldToObject3x4EXT.

* Give build_info.py the executable bit

* runtests: Check error codes, set LD_LIBRARY_PATH

`glslangValidator` will only return [the codes 0..6](https://github.com/KhronosGroup/glslang/blob/b481744aea1ecf52ee4591afaa0f5e270b9d1636/StandAlone/StandAlone.cpp#L117-L125). Fail the test if anything else is returned (like due to the exe crashing).

Also set `LD_LIBRARY_PATH` to contain the `lib` directory before calling glslang.

* GLSL/SPV: Propagaet precision qualifier from function to return value.

When a return value's type has no precision qualification (e.g., the return
expression is formed from a constructor), and the formal function return type
has a precision qualification, back propagate that from the return type to the
type of the return value's expression.

* Add new rules for update of license-checker

`license-checker` will be updated to support `**` based wildcards. As part of this, `license-checker` will now traverse into subdirectories that would previously be excluded when the parent directory is excluded.

This change adds new rules that work with both the old version and new, to ease migration.

* Update license-checker.cfg with simplified rules

`license-checker` has been updated to support `**` wildcards simplifying the ruless, and multiple license configs.

Add a new config for the bison generated files to ensure their licenses don't change.

* build_info: Fix parsing of versions with no flavor

* Finalize glslang 10.15.3847

* Start glslang 11.0.0

* Drop support for VS2013

This was scheduled for today - 20th July 2020.

Updates Appveyor configs to use VS2015 instead.

* also search global variables assignment for live variables

when traversing the AST to find live UBOs etc, also traverse
references to global module-level variables, incase they are
being filled in from UBOs etc.

* Simplify PoolAlloc with use of thread_local.

glslang is using C++ 11, which has first class support for variables of the `thread_local` storage class.

By dropping the use of the `OS_[GS]etTLSValue`, we can simplify the logic, and have it support a thread-local default allocator if none is provided.

Issue: KhronosGroup#2346

* Deprecate InitializeDll functions

These were only used for TThreadPool, which now uses `thread_local`.

* SPV: Update to the latest SPIR-V headers.

* Limit visibility of symbols for internal libraries

Also remove `SPIRV/doc.cpp` from the `SPVRemapper` target as this
is part of `SPIRV`, causing ODR violations. Instead have
`SPVRemapper` link against `SPIRV`.

Fixes ODR violations.

* Add changes for SPV_EXT_shader_atomic_float_add

* Update spirv-tools known-good to most recent stable

Co-authored-by: Neslisah Torosdagli <neslisah.torosdagli@amd.com>
Co-authored-by: Kai Ninomiya <kainino@chromium.org>
Co-authored-by: John Kessenich <johnkslang@users.noreply.github.com>
Co-authored-by: Geoffrey Martin-Noble <gcmn@google.com>
Co-authored-by: Neslisah Torosdagli <neslimsah@yahoo.com>
Co-authored-by: Greg Fischer <greg@lunarg.com>
Co-authored-by: ntfs.hard <ntfs.hard@gmail.com>
Co-authored-by: John Kessenich <cepheus@frii.com>
Co-authored-by: dan sinclair <dsinclair@google.com>
Co-authored-by: alelenv <alele@nvidia.com>
Co-authored-by: Malcolm Bechard <mbechard@users.noreply.github.com>
Co-authored-by: Ryan Harrison <rharrison@google.com>
Co-authored-by: alelenv <40001162+alelenv@users.noreply.github.com>
Co-authored-by: Malacath-92 <h.baensch.92@gmail.com>
Co-authored-by: Cody Northrop <cnorthrop@google.com>
Co-authored-by: pmistryNV <63069047+pmistryNV@users.noreply.github.com>
Co-authored-by: MennoVink <mennovink20@hotmail.com>
Co-authored-by: Phillip Stephens <antidote.crk@gmail.com>
Co-authored-by: dan sinclair <dj2@everburning.com>
Co-authored-by: Pankaj Mistry <pmistry@nvidia.com>
Co-authored-by: Sebastian Neubauer <sebastian.neubauer@amd.com>
Co-authored-by: Felix Maier <xilefmai@gmail.com>
Co-authored-by: Jaebaek Seo <duke.acacia@gmail.com>
Co-authored-by: Roy.li <lryer@msn.com>
Co-authored-by: Chow <laddoc@outlook.com>
Co-authored-by: nihui <shuizhuyuanluo@126.com>
Co-authored-by: David Neto <dneto@google.com>
Co-authored-by: alan-baker <alanbaker@google.com>
Co-authored-by: rdb <rdb@users.noreply.github.com>
Co-authored-by: Ricardo Garcia <47594367+rg3igalia@users.noreply.github.com>
Co-authored-by: Alejandro Piñeiro <apinheiro@igalia.com>
Co-authored-by: Neil Roberts <nroberts@igalia.com>
Co-authored-by: Ben Clayton <bclayton@google.com>
Co-authored-by: Shahbaz Youssefi <ShabbyX@gmail.com>
Co-authored-by: Graeme Leese <gleese@broadcom.com>
Co-authored-by: Evgeny Proydakov <e.proydakov@gmail.com>
Co-authored-by: lriki <lriki.net@gmail.com>
Co-authored-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Co-authored-by: Christopher Degawa <ccom@randomderp.com>
Co-authored-by: Malcolm Bechard <malcolm@derivative.ca>
Co-authored-by: johnkslang <john@johnkgo.com>
Co-authored-by: Vikram Kushwaha <vkushwaha@nvidia.com>
@arcady-lunarg
Copy link
Contributor

This is becoming first class functionality now and is even tested in CI to some extent, though Windows doesn't yet have testing in CI and there isn't ABI compatibility testing yet either. We'll track the remaining few things that need to be done under #2283.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants