Commit 73e3ce78 by Rex Xu

SPV: Handle matrix's OpFConvert vector by vector.

parent 9db3117e
...@@ -137,7 +137,7 @@ protected: ...@@ -137,7 +137,7 @@ protected:
spv::Id createBinaryMatrixOperation(spv::Op, spv::Decoration precision, spv::Decoration noContraction, spv::Id typeId, spv::Id left, spv::Id right); spv::Id createBinaryMatrixOperation(spv::Op, spv::Decoration precision, spv::Decoration noContraction, spv::Id typeId, spv::Id left, spv::Id right);
spv::Id createUnaryOperation(glslang::TOperator op, spv::Decoration precision, spv::Decoration noContraction, spv::Id typeId, spv::Id operand,glslang::TBasicType typeProxy); spv::Id createUnaryOperation(glslang::TOperator op, spv::Decoration precision, spv::Decoration noContraction, spv::Id typeId, spv::Id operand,glslang::TBasicType typeProxy);
spv::Id createUnaryMatrixOperation(spv::Op, spv::Decoration precision, spv::Decoration noContraction, spv::Id typeId, spv::Id operand,glslang::TBasicType typeProxy); spv::Id createUnaryMatrixOperation(spv::Op, spv::Decoration precision, spv::Decoration noContraction, spv::Id typeId, spv::Id operand,glslang::TBasicType typeProxy);
spv::Id createConversion(glslang::TOperator op, spv::Decoration precision, spv::Id destTypeId, spv::Id operand); spv::Id createConversion(glslang::TOperator op, spv::Decoration precision, spv::Decoration noContraction, spv::Id destTypeId, spv::Id operand, glslang::TBasicType typeProxy);
spv::Id makeSmearedConstant(spv::Id constant, int vectorSize); spv::Id makeSmearedConstant(spv::Id constant, int vectorSize);
spv::Id createAtomicOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, std::vector<spv::Id>& operands, glslang::TBasicType typeProxy); spv::Id createAtomicOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, std::vector<spv::Id>& operands, glslang::TBasicType typeProxy);
spv::Id createInvocationsOperation(glslang::TOperator, spv::Id typeId, spv::Id operand); spv::Id createInvocationsOperation(glslang::TOperator, spv::Id typeId, spv::Id operand);
...@@ -1071,7 +1071,7 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI ...@@ -1071,7 +1071,7 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
// it could be a conversion // it could be a conversion
if (! result) if (! result)
result = createConversion(node->getOp(), precision, convertGlslangToSpvType(node->getType()), operand); result = createConversion(node->getOp(), precision, noContraction, convertGlslangToSpvType(node->getType()), operand, node->getOperand()->getBasicType());
// if not, then possibly an operation // if not, then possibly an operation
if (! result) if (! result)
...@@ -3331,7 +3331,7 @@ spv::Id TGlslangToSpvTraverser::createUnaryMatrixOperation(spv::Op op, spv::Deco ...@@ -3331,7 +3331,7 @@ spv::Id TGlslangToSpvTraverser::createUnaryMatrixOperation(spv::Op op, spv::Deco
return builder.setPrecision(builder.createCompositeConstruct(typeId, results), precision); return builder.setPrecision(builder.createCompositeConstruct(typeId, results), precision);
} }
spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Decoration precision, spv::Id destType, spv::Id operand) spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Decoration precision, spv::Decoration noContraction, spv::Id destType, spv::Id operand, glslang::TBasicType typeProxy)
{ {
spv::Op convOp = spv::OpNop; spv::Op convOp = spv::OpNop;
spv::Id zero = 0; spv::Id zero = 0;
...@@ -3400,6 +3400,8 @@ spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Dec ...@@ -3400,6 +3400,8 @@ spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Dec
case glslang::EOpConvDoubleToFloat: case glslang::EOpConvDoubleToFloat:
case glslang::EOpConvFloatToDouble: case glslang::EOpConvFloatToDouble:
convOp = spv::OpFConvert; convOp = spv::OpFConvert;
if (builder.isMatrixType(destType))
return createUnaryMatrixOperation(convOp, precision, noContraction, destType, operand, typeProxy);
break; break;
case glslang::EOpConvFloatToInt: case glslang::EOpConvFloatToInt:
......
#version 140 #version 420
in mat3x4 m1; in mat3x4 m1;
in mat3x4 m2; in mat3x4 m2;
...@@ -11,6 +11,7 @@ out vec4 color; ...@@ -11,6 +11,7 @@ out vec4 color;
void main() void main()
{ {
mat3x4 sum34; mat3x4 sum34;
dmat3x4 dm;
vec3 sum3; vec3 sum3;
vec4 sum4; vec4 sum4;
...@@ -22,6 +23,8 @@ void main() ...@@ -22,6 +23,8 @@ void main()
sum34 += f / m1; sum34 += f / m1;
sum34 += f; sum34 += f;
sum34 -= f; sum34 -= f;
dm = dmat3x4(sum34);
sum34 = mat3x4(dm);
sum3 = v4 * m2; sum3 = v4 * m2;
sum4 = m2 * v3; sum4 = m2 * v3;
...@@ -33,10 +36,8 @@ void main() ...@@ -33,10 +36,8 @@ void main()
color = sum4; color = sum4;
//spv if (m1 != sum34) ++sum34;
++sum34; --sum34;
// else
--sum34;
sum34 += mat3x4(f); sum34 += mat3x4(f);
sum34 += mat3x4(v3, f, v3, f, v3, f); sum34 += mat3x4(v3, f, v3, f, v3, f);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment