Бранимир Караџић пре 5 година
родитељ
комит
8d5c7eae3a

+ 35 - 0
3rdparty/glslang/LICENSE.txt

@@ -298,6 +298,41 @@ APACHE LICENSE, VERSION 2.0
    See the License for the specific language governing permissions and
    limitations under the License.
 
+
+--------------------------------------------------------------------------------
+GPL 3 with special bison exception
+--------------------------------------------------------------------------------
+
+   Bison implementation for Yacc-like parsers in C
+
+   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+   As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.
+
 --------------------------------------------------------------------------------
 ================================================================================
 --------------------------------------------------------------------------------

+ 4 - 4
3rdparty/glslang/SPIRV/GlslangToSpv.cpp

@@ -1722,7 +1722,7 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
                 spv::StorageClass sc = builder.getStorageClass(id);
                 // Before SPIR-V 1.4, we only want to include Input and Output.
                 // Starting with SPIR-V 1.4, we want all globals.
-                if ((glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_4 && sc != spv::StorageClassFunction) ||
+                if ((glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_4 && builder.isGlobalStorage(id)) ||
                     (sc == spv::StorageClassInput || sc == spv::StorageClassOutput)) {
                     iOSet.insert(id);
                 }
@@ -2056,9 +2056,9 @@ std::pair<spv::Id, spv::Id> TGlslangToSpvTraverser::getForcedType(glslang::TBuil
         // builtins. During visitBinary we insert a transpose
         case glslang::EbvWorldToObject3x4:
         case glslang::EbvObjectToWorld3x4: {
-            std::pair<spv::Id, spv::Id> ret(builder.makeMatrixType(builder.makeFloatType(32), 4, 3),
-                builder.makeMatrixType(builder.makeFloatType(32), 3, 4)
-            );
+            spv::Id mat43 = builder.makeMatrixType(builder.makeFloatType(32), 4, 3);
+            spv::Id mat34 = builder.makeMatrixType(builder.makeFloatType(32), 3, 4);
+            std::pair<spv::Id, spv::Id> ret(mat43, mat34);
             return ret;
         }
         default:

+ 5 - 3
3rdparty/glslang/SPIRV/SpvBuilder.cpp

@@ -2722,14 +2722,16 @@ Id Builder::accessChainLoad(Decoration precision, Decoration nonUniform, Id resu
                 setPrecision(id, precision);
             } else {
                 Id lValue = NoResult;
-                if (spvVersion >= Spv_1_4) {
+                if (spvVersion >= Spv_1_4 && isValidInitializer(accessChain.base)) {
                     // make a new function variable for this r-value, using an initializer,
                     // and mark it as NonWritable so that downstream it can be detected as a lookup
                     // table
-                    lValue = createVariable(NoPrecision, StorageClassFunction, getTypeId(accessChain.base), "indexable", accessChain.base);
+                    lValue = createVariable(NoPrecision, StorageClassFunction, getTypeId(accessChain.base),
+                        "indexable", accessChain.base);
                     addDecoration(lValue, DecorationNonWritable);
                 } else {
-                    lValue = createVariable(NoPrecision, StorageClassFunction, getTypeId(accessChain.base), "indexable");
+                    lValue = createVariable(NoPrecision, StorageClassFunction, getTypeId(accessChain.base),
+                        "indexable");
                     // store into it
                     createStore(accessChain.base, lValue);
                 }

+ 7 - 0
3rdparty/glslang/SPIRV/SpvBuilder.h

@@ -248,6 +248,13 @@ public:
         { return module.getInstruction(resultId)->getImmediateOperand(0); }
     StorageClass getStorageClass(Id resultId) const { return getTypeStorageClass(getTypeId(resultId)); }
 
+    bool isVariableOpCode(Op opcode) const { return opcode == OpVariable; }
+    bool isVariable(Id resultId) const { return isVariableOpCode(getOpCode(resultId)); }
+    bool isGlobalStorage(Id resultId) const { return getStorageClass(resultId) != StorageClassFunction; }
+    bool isGlobalVariable(Id resultId) const { return isVariable(resultId) && isGlobalStorage(resultId); }
+    // See if a resultId is valid for use as an initializer.
+    bool isValidInitializer(Id resultId) const { return isConstant(resultId) || isGlobalVariable(resultId); }
+
     int getScalarTypeWidth(Id typeId) const
     {
         Id scalarTypeId = getScalarTypeId(typeId);

+ 11 - 12
3rdparty/glslang/build_info.py

@@ -38,6 +38,17 @@
 #define _COMMON_INCLUDED_
 
 #include <sstream>
+#include <algorithm>
+#include <cassert>
+#include <cstdio>
+#include <cstdlib>
+#include <list>
+#include <map>
+#include <set>
+#include <string>
+#include <unordered_map>
+#include <unordered_set>
+#include <vector>
 
 #if defined(__ANDROID__) || (defined(_MSC_VER) && _MSC_VER < 1700)
 
@@ -94,18 +105,6 @@ std::string to_string(const T& val) {
     #pragma warning(disable : 4201) // nameless union
 #endif
 
-#include <set>
-#include <unordered_set>
-#include <vector>
-#include <map>
-#include <unordered_map>
-#include <list>
-#include <algorithm>
-#include <string>
-#include <cstdio>
-#include <cstdlib>
-#include <cassert>
-
 #include "PoolAlloc.h"
 
 //

+ 1 - 0
3rdparty/glslang/glslang/Include/intermediate.h

@@ -1231,6 +1231,7 @@ public:
     TOperator getFlowOp() const { return flowOp; }
     TIntermTyped* getExpression() const { return expression; }
     void setExpression(TIntermTyped* pExpression) { expression = pExpression; }
+    void updatePrecision(TPrecisionQualifier parentPrecision);
 protected:
     TOperator flowOp;
     TIntermTyped* expression;

+ 29 - 3
3rdparty/glslang/glslang/MachineIndependent/Intermediate.cpp

@@ -2777,6 +2777,22 @@ TIntermBranch* TIntermediate::addBranch(TOperator branchOp, TIntermTyped* expres
     return node;
 }
 
+// Propagate precision from formal function return type to actual return type,
+// and on to its subtree.
+void TIntermBranch::updatePrecision(TPrecisionQualifier parentPrecision)
+{
+    TIntermTyped* exp = getExpression();
+    if (exp == nullptr)
+        return;
+
+    if (exp->getBasicType() == EbtInt || exp->getBasicType() == EbtUint ||
+        exp->getBasicType() == EbtFloat || exp->getBasicType() == EbtFloat16) {
+        if (parentPrecision != EpqNone && exp->getQualifier().precision == EpqNone) {
+            exp->propagatePrecision(parentPrecision);
+        }
+    }
+}
+
 //
 // This is to be executed after the final root is put on top by the parsing
 // process.
@@ -3284,9 +3300,11 @@ bool TIntermediate::promoteUnary(TIntermUnary& node)
     return true;
 }
 
+// Propagate precision qualifiers *up* from children to parent.
 void TIntermUnary::updatePrecision()
 {
-    if (getBasicType() == EbtInt || getBasicType() == EbtUint || getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
+    if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
+        getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
         if (operand->getQualifier().precision > getQualifier().precision)
             getQualifier().precision = operand->getQualifier().precision;
     }
@@ -3782,9 +3800,12 @@ bool TIntermediate::promoteAggregate(TIntermAggregate& node)
     return false;
 }
 
+// Propagate precision qualifiers *up* from children to parent, and then
+// back *down* again to the children's subtrees.
 void TIntermBinary::updatePrecision()
 {
-    if (getBasicType() == EbtInt || getBasicType() == EbtUint || getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
+     if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
+         getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
         getQualifier().precision = std::max(right->getQualifier().precision, left->getQualifier().precision);
         if (getQualifier().precision != EpqNone) {
             left->propagatePrecision(getQualifier().precision);
@@ -3793,9 +3814,14 @@ void TIntermBinary::updatePrecision()
     }
 }
 
+// Recursively propagate precision qualifiers *down* the subtree of the current node,
+// until reaching a node that already has a precision qualifier or otherwise does
+// not participate in precision propagation.
 void TIntermTyped::propagatePrecision(TPrecisionQualifier newPrecision)
 {
-    if (getQualifier().precision != EpqNone || (getBasicType() != EbtInt && getBasicType() != EbtUint && getBasicType() != EbtFloat && getBasicType() != EbtFloat16))
+    if (getQualifier().precision != EpqNone ||
+        (getBasicType() != EbtInt && getBasicType() != EbtUint &&
+         getBasicType() != EbtFloat && getBasicType() != EbtFloat16))
         return;
 
     getQualifier().precision = newPrecision;

+ 10 - 5
3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp

@@ -1415,23 +1415,28 @@ TIntermNode* TParseContext::handleReturnValue(const TSourceLoc& loc, TIntermType
 #endif
 
     functionReturnsValue = true;
+    TIntermBranch* branch = nullptr;
     if (currentFunctionType->getBasicType() == EbtVoid) {
         error(loc, "void function cannot return a value", "return", "");
-        return intermediate.addBranch(EOpReturn, loc);
+        branch = intermediate.addBranch(EOpReturn, loc);
     } else if (*currentFunctionType != value->getType()) {
         TIntermTyped* converted = intermediate.addConversion(EOpReturn, *currentFunctionType, value);
         if (converted) {
             if (*currentFunctionType != converted->getType())
                 error(loc, "cannot convert return value to function return type", "return", "");
             if (version < 420)
-                warn(loc, "type conversion on return values was not explicitly allowed until version 420", "return", "");
-            return intermediate.addBranch(EOpReturn, converted, loc);
+                warn(loc, "type conversion on return values was not explicitly allowed until version 420",
+                     "return", "");
+            branch = intermediate.addBranch(EOpReturn, converted, loc);
         } else {
             error(loc, "type does not match, or is not convertible to, the function's return type", "return", "");
-            return intermediate.addBranch(EOpReturn, value, loc);
+            branch = intermediate.addBranch(EOpReturn, value, loc);
         }
     } else
-        return intermediate.addBranch(EOpReturn, value, loc);
+        branch = intermediate.addBranch(EOpReturn, value, loc);
+
+    branch->updatePrecision(currentFunctionType->getQualifier().precision);
+    return branch;
 }
 
 // See if the operation is being done in an illegal location.

+ 7 - 1
3rdparty/glslang/license-checker.cfg

@@ -21,7 +21,13 @@
                 "glslang/OSDependent/Web/glslang.*.js",
 
                 "glslang/MachineIndependent/glslang_tab.cpp",
-                "glslang/MachineIndependent/glslang_tab.cpp.h"
+                "glslang/MachineIndependent/glslang_tab.cpp.h",
+
+                "**.md",
+                "build/**",
+                "out/**",
+                "Test/**",
+                "External/spirv-tools/**"
             ]
         }
     ],