Бранимир Караџић 4 лет назад
Родитель
Сommit
f41da45662

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

@@ -2543,7 +2543,7 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
         int row = 0;
         int col = 0;
 
-        for (int arg = 0; arg < (int)sources.size(); ++arg) {
+        for (int arg = 0; arg < (int)sources.size() && col < numCols; ++arg) {
             Id argComp = sources[arg];
             for (int comp = 0; comp < getNumComponents(sources[arg]); ++comp) {
                 if (getNumComponents(sources[arg]) > 1) {
@@ -2555,6 +2555,10 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
                     row = 0;
                     col++;
                 }
+                if (col == numCols) {
+                    // If more components are provided than fit the matrix, discard the rest.
+                    break;
+                }
             }
         }
     }

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

@@ -1677,7 +1677,9 @@ public:
     virtual TIntermTyped* getCondition() const { return condition; }
     virtual void setCondition(TIntermTyped* c) { condition = c; }
     virtual TIntermNode* getTrueBlock() const { return trueBlock; }
+    virtual void setTrueBlock(TIntermTyped* tb) { trueBlock = tb; }
     virtual TIntermNode* getFalseBlock() const { return falseBlock; }
+    virtual void setFalseBlock(TIntermTyped* fb) { falseBlock = fb; }
     virtual       TIntermSelection* getAsSelectionNode()       { return this; }
     virtual const TIntermSelection* getAsSelectionNode() const { return this; }
 

+ 6 - 1
3rdparty/glslang/glslang/MachineIndependent/Constant.cpp

@@ -529,7 +529,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
             case EbtDouble:
             case EbtFloat16:
             case EbtFloat: newConstArray[i].setDConst(-unionArray[i].getDConst()); break;
-            case EbtInt:   newConstArray[i].setIConst(-unionArray[i].getIConst()); break;
+            // Note: avoid UBSAN error regarding negating 0x80000000
+            case EbtInt:   newConstArray[i].setIConst(
+                                unionArray[i].getIConst() == 0x80000000
+                                    ? -0x7FFFFFFF - 1
+                                    : -unionArray[i].getIConst());
+                           break;
             case EbtUint:  newConstArray[i].setUConst(static_cast<unsigned int>(-static_cast<int>(unionArray[i].getUConst())));  break;
 #ifndef GLSLANG_WEB
             case EbtInt8:  newConstArray[i].setI8Const(-unionArray[i].getI8Const()); break;