aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLGLSLCodeGenerator.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-02-16 14:49:57 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-16 20:27:43 +0000
commit50afc1765511a8d4850fe97aacf8714b609bfd5a (patch)
treefd7b6874542c53463b856f3ff8d1258dc389a21d /src/sksl/SkSLGLSLCodeGenerator.cpp
parent3bf12c60e265b09f282c9cc0fea1219b0b1b1088 (diff)
Fixed a couple of spots where sksl didn't have proper array support.
vec2 x[3] worked, but vec2[3] x didn't. Interface blocks also did not work with array sizes. BUG=skia: Change-Id: I45b424891db46804f1e3c1f4793470b7b501a6de Reviewed-on: https://skia-review.googlesource.com/8523 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Ben Wagner <benjaminwagner@google.com>
Diffstat (limited to 'src/sksl/SkSLGLSLCodeGenerator.cpp')
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index 4b1eea3451..18cfba79e9 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -584,19 +584,35 @@ void GLSLCodeGenerator::writeModifiers(const Modifiers& modifiers,
}
void GLSLCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) {
- if (intf.fVariable.fName == "gl_PerVertex") {
+ if (intf.fTypeName == "gl_PerVertex") {
return;
}
this->writeModifiers(intf.fVariable.fModifiers, true);
- this->writeLine(intf.fVariable.fType.name() + " {");
+ this->writeLine(intf.fTypeName + " {");
fIndentation++;
- for (const auto& f : intf.fVariable.fType.fields()) {
+ const Type* structType = &intf.fVariable.fType;
+ while (structType->kind() == Type::kArray_Kind) {
+ structType = &structType->componentType();
+ }
+ for (const auto& f : structType->fields()) {
this->writeModifiers(f.fModifiers, false);
this->writeType(*f.fType);
this->writeLine(" " + f.fName + ";");
}
fIndentation--;
- this->writeLine("};");
+ this->write("}");
+ if (intf.fInstanceName.size()) {
+ this->write(" ");
+ this->write(intf.fInstanceName);
+ for (const auto& size : intf.fSizes) {
+ this->write("[");
+ if (size) {
+ this->writeExpression(*size, kTopLevel_Precedence);
+ }
+ this->write("]");
+ }
+ }
+ this->writeLine(";");
}
void GLSLCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, bool global) {