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.cpp61
1 files changed, 33 insertions, 28 deletions
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index d08c9135e1..f0c97a319d 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -887,41 +887,44 @@ void GLSLCodeGenerator::writeSetting(const Setting& s) {
}
void GLSLCodeGenerator::writeFunction(const FunctionDefinition& f) {
- this->writeTypePrecision(f.fDeclaration.fReturnType);
- this->writeType(f.fDeclaration.fReturnType);
- this->write(" " + f.fDeclaration.fName + "(");
- const char* separator = "";
- for (const auto& param : f.fDeclaration.fParameters) {
- this->write(separator);
- separator = ", ";
- this->writeModifiers(param->fModifiers, false);
- std::vector<int> sizes;
- const Type* type = &param->fType;
- while (type->kind() == Type::kArray_Kind) {
- sizes.push_back(type->columns());
- type = &type->componentType();
- }
- this->writeTypePrecision(*type);
- this->writeType(*type);
- this->write(" " + param->fName);
- for (int s : sizes) {
- if (s <= 0) {
- this->write("[]");
- } else {
- this->write("[" + to_string(s) + "]");
+ if (fProgramKind != Program::kPipelineStage_Kind) {
+ this->writeTypePrecision(f.fDeclaration.fReturnType);
+ this->writeType(f.fDeclaration.fReturnType);
+ this->write(" " + f.fDeclaration.fName + "(");
+ const char* separator = "";
+ for (const auto& param : f.fDeclaration.fParameters) {
+ this->write(separator);
+ separator = ", ";
+ this->writeModifiers(param->fModifiers, false);
+ std::vector<int> sizes;
+ const Type* type = &param->fType;
+ while (type->kind() == Type::kArray_Kind) {
+ sizes.push_back(type->columns());
+ type = &type->componentType();
+ }
+ this->writeTypePrecision(*type);
+ this->writeType(*type);
+ this->write(" " + param->fName);
+ for (int s : sizes) {
+ if (s <= 0) {
+ this->write("[]");
+ } else {
+ this->write("[" + to_string(s) + "]");
+ }
}
}
+ this->writeLine(") {");
+ fIndentation++;
}
- this->writeLine(") {");
-
fFunctionHeader = "";
OutputStream* oldOut = fOut;
StringStream buffer;
fOut = &buffer;
- fIndentation++;
this->writeStatements(((Block&) *f.fBody).fStatements);
- fIndentation--;
- this->writeLine("}");
+ if (fProgramKind != Program::kPipelineStage_Kind) {
+ fIndentation--;
+ this->writeLine("}");
+ }
fOut = oldOut;
this->write(fFunctionHeader);
@@ -1316,7 +1319,9 @@ void GLSLCodeGenerator::writeProgramElement(const ProgramElement& e) {
bool GLSLCodeGenerator::generateCode() {
fProgramKind = fProgram.fKind;
- this->writeHeader();
+ if (fProgramKind != Program::kPipelineStage_Kind) {
+ this->writeHeader();
+ }
if (Program::kGeometry_Kind == fProgramKind &&
fProgram.fSettings.fCaps->geometryShaderExtensionString()) {
this->writeExtension(fProgram.fSettings.fCaps->geometryShaderExtensionString());