aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLGLSLCodeGenerator.cpp
diff options
context:
space:
mode:
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);