aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLGLSLCodeGenerator.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-06-02 13:52:38 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-02 13:57:39 +0000
commitaffa6a3da87e9ea85f1d4fe3137b5bccbbc56f92 (patch)
treeccaa2cbc3e395a140b25f23bf250e948525a1541 /src/sksl/SkSLGLSLCodeGenerator.cpp
parent370c2b304a35297d36fcee91e3b6ac516091434d (diff)
Revert "Fixed an issue with sksl variable declarations"
This reverts commit 88bd8edcff23dc9cf31b664cba7ba73b235318b0. Reason for revert: unhappy bots Original change's description: > Fixed an issue with sksl variable declarations > > There was an issue where multiple variables defined in the same > declaration were not being sequenced appropriately during analysis, so > 'int x = 0, y = x + 1' would report that x was undefined. > > Bug: skia: > Change-Id: I882f7e216467306f6a6013a0a34aac30a4c60744 > Reviewed-on: https://skia-review.googlesource.com/18313 > Reviewed-by: Chris Dalton <csmartdalton@google.com> > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > TBR=csmartdalton@google.com,ethannicholas@google.com No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Change-Id: Ibc68674289dce70b6173a347a0e78bb0f1e6db1b Reviewed-on: https://skia-review.googlesource.com/18457 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLGLSLCodeGenerator.cpp')
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.cpp38
1 files changed, 14 insertions, 24 deletions
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index c3168e3ed3..d67f7182f8 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -619,33 +619,26 @@ void GLSLCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) {
void GLSLCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, bool global) {
ASSERT(decl.fVars.size() > 0);
- bool wroteType = false;
- for (const auto& stmt : decl.fVars) {
- if (stmt->fKind == Statement::kNop_Kind) {
- continue;
- }
- VarDeclaration& var = (VarDeclaration&) *stmt;
- if (wroteType) {
- this->write(", ");
- } else {
- this->writeModifiers(var.fVar->fModifiers, global);
- this->writeType(decl.fBaseType);
- this->write(" ");
- wroteType = true;
- }
- this->write(var.fVar->fName);
- for (const auto& size : var.fSizes) {
+ this->writeModifiers(decl.fVars[0]->fVar->fModifiers, global);
+ this->writeType(decl.fBaseType);
+ String separator(" ");
+ for (const auto& var : decl.fVars) {
+ ASSERT(var->fVar->fModifiers == decl.fVars[0]->fVar->fModifiers);
+ this->write(separator);
+ separator = String(", ");
+ this->write(var->fVar->fName);
+ for (const auto& size : var->fSizes) {
this->write("[");
if (size) {
this->writeExpression(*size, kTopLevel_Precedence);
}
this->write("]");
}
- if (var.fValue) {
+ if (var->fValue) {
this->write(" = ");
- this->writeExpression(*var.fValue, kTopLevel_Precedence);
+ this->writeExpression(*var->fValue, kTopLevel_Precedence);
}
- if (!fFoundImageDecl && var.fVar->fType == *fContext.fImage2D_Type) {
+ if (!fFoundImageDecl && var->fVar->fType == *fContext.fImage2D_Type) {
if (fProgram.fSettings.fCaps->imageLoadStoreExtensionString()) {
fHeader.writeText("#extension ");
fHeader.writeText(fProgram.fSettings.fCaps->imageLoadStoreExtensionString());
@@ -654,9 +647,7 @@ void GLSLCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, bool g
fFoundImageDecl = true;
}
}
- if (wroteType) {
- this->write(";");
- }
+ this->write(";");
}
void GLSLCodeGenerator::writeStatement(const Statement& s) {
@@ -838,8 +829,7 @@ bool GLSLCodeGenerator::generateCode() {
case ProgramElement::kVar_Kind: {
VarDeclarations& decl = (VarDeclarations&) *e;
if (decl.fVars.size() > 0) {
- int builtin =
- ((VarDeclaration&) *decl.fVars[0]).fVar->fModifiers.fLayout.fBuiltin;
+ int builtin = decl.fVars[0]->fVar->fModifiers.fLayout.fBuiltin;
if (builtin == -1) {
// normal var
this->writeVarDeclarations(decl, true);