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>
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
(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
void emitCmp(sw::Shader::Control cmpOp, TIntermTyped *dst, TIntermNode *left, TIntermNode *right, int index = 0);\r
void argument(sw::Shader::SourceParameter ¶meter, 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
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
(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
void emitCmp(sw::Shader::Control cmpOp, TIntermTyped *dst, TIntermNode *left, TIntermNode *right, int index = 0);\r
void argument(sw::Shader::SourceParameter ¶meter, 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