Remove pipeline-stage workarounds from the GLSL code generator.

These checks don't appear to be useful; the methods in question are
overloaded anyway, and don't access the INHERITED:: methods.

Change-Id: I2ae637b7fb7f2281dc00fe148fbbbccb464cded9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314885
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
John Stiles 2020-09-02 15:44:18 -04:00 committed by Skia Commit-Bot
parent 72de11581b
commit fffe3844ef

View File

@ -1212,44 +1212,47 @@ void GLSLCodeGenerator::writeSetting(const Setting& s) {
void GLSLCodeGenerator::writeFunction(const FunctionDefinition& f) { void GLSLCodeGenerator::writeFunction(const FunctionDefinition& f) {
fSetupFragPositionLocal = false; fSetupFragPositionLocal = false;
fSetupFragCoordWorkaround = false; fSetupFragCoordWorkaround = false;
if (fProgramKind != Program::kPipelineStage_Kind) {
this->writeTypePrecision(f.fDeclaration.fReturnType); // The pipeline-stage code generator can't use functions written this way, so make sure we don't
this->writeType(f.fDeclaration.fReturnType); // accidentally end up here.
this->write(" " + f.fDeclaration.fName + "("); SkASSERT(fProgramKind != Program::kPipelineStage_Kind);
const char* separator = "";
for (const auto& param : f.fDeclaration.fParameters) { this->writeTypePrecision(f.fDeclaration.fReturnType);
this->write(separator); this->writeType(f.fDeclaration.fReturnType);
separator = ", "; this->write(" " + f.fDeclaration.fName + "(");
this->writeModifiers(param->fModifiers, false); const char* separator = "";
std::vector<int> sizes; for (const auto& param : f.fDeclaration.fParameters) {
const Type* type = &param->fType; this->write(separator);
while (type->kind() == Type::kArray_Kind) { separator = ", ";
sizes.push_back(type->columns()); this->writeModifiers(param->fModifiers, false);
type = &type->componentType(); std::vector<int> sizes;
} const Type* type = &param->fType;
this->writeTypePrecision(*type); while (type->kind() == Type::kArray_Kind) {
this->writeType(*type); sizes.push_back(type->columns());
this->write(" " + param->fName); type = &type->componentType();
for (int s : sizes) { }
if (s <= 0) { this->writeTypePrecision(*type);
this->write("[]"); this->writeType(*type);
} else { this->write(" " + param->fName);
this->write("[" + to_string(s) + "]"); for (int s : sizes) {
} if (s <= 0) {
this->write("[]");
} else {
this->write("[" + to_string(s) + "]");
} }
} }
this->writeLine(") {");
fIndentation++;
} }
this->writeLine(") {");
fIndentation++;
fFunctionHeader = ""; fFunctionHeader = "";
OutputStream* oldOut = fOut; OutputStream* oldOut = fOut;
StringStream buffer; StringStream buffer;
fOut = &buffer; fOut = &buffer;
this->writeStatements(f.fBody->as<Block>().fStatements); this->writeStatements(f.fBody->as<Block>().fStatements);
if (fProgramKind != Program::kPipelineStage_Kind) {
fIndentation--; fIndentation--;
this->writeLine("}"); this->writeLine("}");
}
fOut = oldOut; fOut = oldOut;
this->write(fFunctionHeader); this->write(fFunctionHeader);
@ -1736,9 +1739,7 @@ void GLSLCodeGenerator::writeInputVars() {
} }
bool GLSLCodeGenerator::generateCode() { bool GLSLCodeGenerator::generateCode() {
if (fProgramKind != Program::kPipelineStage_Kind) { this->writeHeader();
this->writeHeader();
}
if (Program::kGeometry_Kind == fProgramKind && if (Program::kGeometry_Kind == fProgramKind &&
fProgram.fSettings.fCaps->geometryShaderExtensionString()) { fProgram.fSettings.fCaps->geometryShaderExtensionString()) {
this->writeExtension(fProgram.fSettings.fCaps->geometryShaderExtensionString()); this->writeExtension(fProgram.fSettings.fCaps->geometryShaderExtensionString());