aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLIRGenerator.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-08-17 11:07:59 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-17 15:08:17 +0000
commit1d816b92bb7cf2258007f3f74ffd143b89f25d01 (patch)
tree07fb1e8e2631208eb007a4abdfe130db91e6cfc2 /src/sksl/SkSLIRGenerator.cpp
parent23f92277b916a4bdf11c320799ac9248af60a62e (diff)
Revert "Switched highp float to highfloat and mediump float to half."
This reverts commit 88d99c63878c2d3d340120f0321676f72afcb4f0. Reason for revert: Believed to be causing unit test failures in Chrome roll: https://build.chromium.org/p/tryserver.chromium.android/builders/linux_android_rel_ng/builds/364433 https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Ftryserver.chromium.android%2Flinux_android_rel_ng%2F364433%2F%2B%2Frecipes%2Fsteps%2Fcontent_browsertests__with_patch__on_Android%2F0%2Flogs%2FWebRtcCaptureFromElementBrowserTest.VerifyCanvasWebGLCaptureColor%2F0 Original change's description: > Switched highp float to highfloat and mediump float to half. > > The ultimate goal is to end up with "float" and "half", but this > intermediate step uses "highfloat" so that it is clear if I missed a > "float" somewhere. Once this lands, a subsequent CL will switch all > "highfloats" back to "floats". > > Bug: skia: > Change-Id: Ia13225c7a0a0a2901e07665891c473d2500ddcca > Reviewed-on: https://skia-review.googlesource.com/31000 > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > Reviewed-by: Brian Salomon <bsalomon@google.com> TBR=bsalomon@google.com,csmartdalton@google.com,ethannicholas@google.com Change-Id: I8bfa97547ac3920d433665f161d27df3f15c83aa No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/35705 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/sksl/SkSLIRGenerator.cpp')
-rw-r--r--src/sksl/SkSLIRGenerator.cpp65
1 files changed, 21 insertions, 44 deletions
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index 50f58092fe..a46a9312c1 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -17,6 +17,7 @@
#include "ast/SkSLASTFloatLiteral.h"
#include "ast/SkSLASTIndexSuffix.h"
#include "ast/SkSLASTIntLiteral.h"
+#include "ast/SkSLASTPrecision.h"
#include "ir/SkSLBinaryExpression.h"
#include "ir/SkSLBoolLiteral.h"
#include "ir/SkSLBreakStatement.h"
@@ -980,15 +981,8 @@ static bool determine_binary_type(const Context& context,
*outResultType = context.fBool_Type.get();
return left.canCoerceTo(*context.fBool_Type) &&
right.canCoerceTo(*context.fBool_Type);
+ case Token::STAR: // fall through
case Token::STAREQ:
- if (left.kind() == Type::kScalar_Kind) {
- *outLeftType = &left;
- *outRightType = &left;
- *outResultType = &left;
- return right.canCoerceTo(left);
- }
- // fall through
- case Token::STAR:
if (is_matrix_multiply(left, right)) {
// determine final component type
if (determine_binary_type(context, Token::STAR, left.componentType(),
@@ -1028,22 +1022,12 @@ static bool determine_binary_type(const Context& context,
isLogical = false;
validMatrixOrVectorOp = true;
break;
- case Token::PLUSEQ:
- case Token::MINUSEQ:
- case Token::SLASHEQ:
- case Token::PERCENTEQ:
- case Token::SHLEQ:
- case Token::SHREQ:
- if (left.kind() == Type::kScalar_Kind) {
- *outLeftType = &left;
- *outRightType = &left;
- *outResultType = &left;
- return right.canCoerceTo(left);
- }
- // fall through
case Token::PLUS: // fall through
+ case Token::PLUSEQ: // fall through
case Token::MINUS: // fall through
+ case Token::MINUSEQ: // fall through
case Token::SLASH: // fall through
+ case Token::SLASHEQ: // fall through
isLogical = false;
validMatrixOrVectorOp = true;
break;
@@ -1057,23 +1041,9 @@ static bool determine_binary_type(const Context& context,
validMatrixOrVectorOp = false;
}
bool isVectorOrMatrix = left.kind() == Type::kVector_Kind || left.kind() == Type::kMatrix_Kind;
- if (left.kind() == Type::kScalar_Kind && right.kind() == Type::kScalar_Kind &&
- right.canCoerceTo(left)) {
- if (left.priority() > right.priority()) {
- *outLeftType = &left;
- *outRightType = &left;
- } else {
- *outLeftType = &right;
- *outRightType = &right;
- }
- if (isLogical) {
- *outResultType = context.fBool_Type.get();
- } else {
- *outResultType = &left;
- }
- return true;
- }
- if (right.canCoerceTo(left) && isVectorOrMatrix && validMatrixOrVectorOp) {
+ // FIXME: incorrect for shift
+ if (right.canCoerceTo(left) && (left.kind() == Type::kScalar_Kind ||
+ (isVectorOrMatrix && validMatrixOrVectorOp))) {
*outLeftType = &left;
*outRightType = &left;
if (isLogical) {
@@ -1510,17 +1480,18 @@ std::unique_ptr<Expression> IRGenerator::convertNumberConstructor(
to_string((uint64_t) args.size()) + ")");
return nullptr;
}
- if (type == args[0]->fType) {
+ if (type.isFloat() && args[0]->fType.isFloat()) {
return std::move(args[0]);
}
- if (type.isFloat() && args.size() == 1 && args[0]->fKind == Expression::kFloatLiteral_Kind) {
- double value = ((FloatLiteral&) *args[0]).fValue;
- return std::unique_ptr<Expression>(new FloatLiteral(fContext, position, value, &type));
+ if (type.isSigned() && args[0]->fType.isSigned()) {
+ return std::move(args[0]);
+ }
+ if (type.isUnsigned() && args[0]->fType.isUnsigned()) {
+ return std::move(args[0]);
}
if (type.isFloat() && args.size() == 1 && args[0]->fKind == Expression::kIntLiteral_Kind) {
int64_t value = ((IntLiteral&) *args[0]).fValue;
- return std::unique_ptr<Expression>(new FloatLiteral(fContext, position, (double) value,
- &type));
+ return std::unique_ptr<Expression>(new FloatLiteral(fContext, position, (double) value));
}
if (args[0]->fKind == Expression::kIntLiteral_Kind && (type == *fContext.fInt_Type ||
type == *fContext.fUInt_Type)) {
@@ -1977,12 +1948,14 @@ void IRGenerator::markWrittenTo(const Expression& expr, bool readWrite) {
void IRGenerator::convertProgram(String text,
SymbolTable& types,
+ Modifiers::Flag* defaultPrecision,
std::vector<std::unique_ptr<ProgramElement>>* out) {
Parser parser(text, types, fErrors);
std::vector<std::unique_ptr<ASTDeclaration>> parsed = parser.file();
if (fErrors.errorCount()) {
return;
}
+ *defaultPrecision = Modifiers::kHighp_Flag;
for (size_t i = 0; i < parsed.size(); i++) {
ASTDeclaration& decl = *parsed[i];
switch (decl.fKind) {
@@ -2029,6 +2002,10 @@ void IRGenerator::convertProgram(String text,
}
break;
}
+ case ASTDeclaration::kPrecision_Kind: {
+ *defaultPrecision = ((ASTPrecision&) decl).fPrecision;
+ break;
+ }
default:
ABORT("unsupported declaration: %s\n", decl.description().c_str());
}