OSDN Git Service

Fixed the compound-assignment-type-combination.html test
authorAlexis Hetu <sugoi@google.com>
Thu, 20 Nov 2014 15:47:04 +0000 (10:47 -0500)
committerAlexis Hétu <sugoi@google.com>
Fri, 21 Nov 2014 19:42:51 +0000 (19:42 +0000)
The fix is in 2 parts:
1) Multiplying a matrix by a float was failing due to attempting
to use the matrix's index on the float, thus going out of bounds.
2) Multiplying a vector or matrix by vectors or matrices of a
different size was not causing a failure, but now it does.

BUG=18450319

Change-Id: Ie01a77eb32d7d52fcd0a803f3e5efc24c625dbfd
Reviewed-on: https://swiftshader-review.googlesource.com/1450
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
src/OpenGL/compiler/OutputASM.cpp
src/OpenGL/compiler/OutputASM.h
src/Radiance/compiler/OutputASM.cpp
src/Radiance/compiler/OutputASM.h

index e8aa3f3..ff73893 100644 (file)
@@ -1432,7 +1432,7 @@ namespace sh
                        TIntermTyped *arg = argument->getAsTyped();\r
                        const TType &type = arg->getType();\r
                        const TTypeList *structure = type.getStruct();\r
-                       ASSERT(index < arg->totalRegisterCount());\r
+                       index = (index >= arg->totalRegisterCount()) ? arg->totalRegisterCount() - 1 : index;\r
 \r
                        int size = registerSize(type, index);\r
 \r
@@ -1522,8 +1522,15 @@ namespace sh
                       (swizzleElement(leftSwizzle, swizzleElement(rightSwizzle, 3)) << 6);\r
        }\r
 \r
-       void OutputASM::assignLvalue(TIntermTyped *dst, TIntermNode *src)\r
+       void OutputASM::assignLvalue(TIntermTyped *dst, TIntermTyped *src)\r
        {\r
+               if(src &&\r
+                       ((src->isVector() && (!dst->isVector() || (dst->getNominalSize() != dst->getNominalSize()))) ||\r
+                        (src->isMatrix() && (!dst->isMatrix() || (src->getNominalSize() != dst->getNominalSize())))))\r
+               {\r
+                       return mContext.error(src->getLine(), "Result type should match the l-value type in compound assignment", src->isVector() ? "vector" : "matrix");\r
+               }\r
+\r
                TIntermBinary *binary = dst->getAsBinaryNode();\r
 \r
                if(binary && binary->getOp() == EOpIndexIndirect && dst->isScalar())\r
index ae6cfa7..4f0ae3d 100644 (file)
@@ -113,7 +113,7 @@ namespace sh
                void emitCmp(sw::Shader::Control cmpOp, TIntermTyped *dst, TIntermNode *left, TIntermNode *right, int index = 0);\r
                void argument(sw::Shader::SourceParameter &parameter, TIntermNode *argument, int index = 0);\r
                void copy(TIntermTyped *dst, TIntermNode *src, int offset = 0);\r
-               void assignLvalue(TIntermTyped *dst, TIntermNode *src);\r
+               void assignLvalue(TIntermTyped *dst, TIntermTyped *src);\r
                int lvalue(sw::Shader::DestinationParameter &dst, Temporary &address, TIntermTyped *node);\r
                sw::Shader::ParameterType registerType(TIntermTyped *operand);\r
                int registerIndex(TIntermTyped *operand);\r
index b85edf6..07b4bf0 100644 (file)
@@ -1432,7 +1432,7 @@ namespace sh
                        TIntermTyped *arg = argument->getAsTyped();\r
                        const TType &type = arg->getType();\r
                        const TTypeList *structure = type.getStruct();\r
-                       ASSERT(index < arg->totalRegisterCount());\r
+                       index = (index >= arg->totalRegisterCount()) ? arg->totalRegisterCount() - 1 : index;\r
 \r
                        int size = registerSize(type, index);\r
 \r
@@ -1522,8 +1522,15 @@ namespace sh
                       (swizzleElement(leftSwizzle, swizzleElement(rightSwizzle, 3)) << 6);\r
        }\r
 \r
-       void OutputASM::assignLvalue(TIntermTyped *dst, TIntermNode *src)\r
+       void OutputASM::assignLvalue(TIntermTyped *dst, TIntermTyped *src)\r
        {\r
+               if(src &&\r
+                       ((src->isVector() && (!dst->isVector() || (dst->getNominalSize() != dst->getNominalSize()))) ||\r
+                        (src->isMatrix() && (!dst->isMatrix() || (src->getNominalSize() != dst->getNominalSize())))))\r
+               {\r
+                       return mContext.error(src->getLine(), "Result type should match the l-value type in compound assignment", src->isVector() ? "vector" : "matrix");\r
+               }\r
+\r
                TIntermBinary *binary = dst->getAsBinaryNode();\r
 \r
                if(binary && binary->getOp() == EOpIndexIndirect && dst->isScalar())\r
index a40fc36..fb58700 100644 (file)
@@ -113,7 +113,7 @@ namespace sh
                void emitCmp(sw::Shader::Control cmpOp, TIntermTyped *dst, TIntermNode *left, TIntermNode *right, int index = 0);\r
                void argument(sw::Shader::SourceParameter &parameter, TIntermNode *argument, int index = 0);\r
                void copy(TIntermTyped *dst, TIntermNode *src, int offset = 0);\r
-               void assignLvalue(TIntermTyped *dst, TIntermNode *src);\r
+               void assignLvalue(TIntermTyped *dst, TIntermTyped *src);\r
                int lvalue(sw::Shader::DestinationParameter &dst, Temporary &address, TIntermTyped *node);\r
                sw::Shader::ParameterType registerType(TIntermTyped *operand);\r
                int registerIndex(TIntermTyped *operand);\r