aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLIRGenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sksl/SkSLIRGenerator.cpp')
-rw-r--r--src/sksl/SkSLIRGenerator.cpp46
1 files changed, 11 insertions, 35 deletions
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index a793ddd952..ba1476e275 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -143,16 +143,10 @@ static void fill_caps(const SKSL_CAPS_CLASS& caps,
void IRGenerator::start(const Program::Settings* settings,
std::vector<std::unique_ptr<ProgramElement>>* inherited) {
- if (fStarted) {
- this->popSymbolTable();
- }
fSettings = settings;
fCapsMap.clear();
if (settings->fCaps) {
fill_caps(*settings->fCaps, &fCapsMap);
- } else {
- fCapsMap.insert(std::make_pair(String("integerSupport"),
- Program::Settings::Value(true)));
}
this->pushSymbolTable();
fInvocations = -1;
@@ -173,6 +167,11 @@ void IRGenerator::start(const Program::Settings* settings,
}
}
+void IRGenerator::finish() {
+ this->popSymbolTable();
+ fSettings = nullptr;
+}
+
std::unique_ptr<Extension> IRGenerator::convertExtension(const ASTExtension& extension) {
return std::unique_ptr<Extension>(new Extension(extension.fOffset, extension.fName));
}
@@ -682,26 +681,6 @@ void IRGenerator::convertFunction(const ASTFunction& f) {
parameters.push_back(var);
}
- if (f.fName == "main") {
- if (fKind == Program::kPipelineStage_Kind) {
- bool valid = parameters.size() == 3 &&
- parameters[0]->fType == *fContext.fInt_Type &&
- parameters[0]->fModifiers.fFlags == 0 &&
- parameters[1]->fType == *fContext.fInt_Type &&
- parameters[1]->fModifiers.fFlags == 0 &&
- parameters[2]->fType == *fContext.fHalf4_Type &&
- parameters[2]->fModifiers.fFlags == (Modifiers::kIn_Flag |
- Modifiers::kOut_Flag);
- if (!valid) {
- fErrors.error(f.fOffset, "pipeline stage 'main' must be declared main(int, "
- "int, inout half4)");
- return;
- }
- } else if (parameters.size()) {
- fErrors.error(f.fOffset, "shader 'main' must have zero parameters");
- }
- }
-
// find existing declaration
const FunctionDeclaration* decl = nullptr;
auto entry = (*fSymbolTable)[f.fName];
@@ -772,11 +751,6 @@ void IRGenerator::convertFunction(const ASTFunction& f) {
decl->fDefined = true;
std::shared_ptr<SymbolTable> old = fSymbolTable;
AutoSymbolTable table(this);
- if (f.fName == "main" && fKind == Program::kPipelineStage_Kind) {
- parameters[0]->fModifiers.fLayout.fBuiltin = SK_MAIN_X_BUILTIN;
- parameters[1]->fModifiers.fLayout.fBuiltin = SK_MAIN_Y_BUILTIN;
- parameters[2]->fModifiers.fLayout.fBuiltin = SK_OUTCOLOR_BUILTIN;
- }
for (size_t i = 0; i < parameters.size(); i++) {
fSymbolTable->addWithoutOwnership(parameters[i]->fName, decl->fParameters[i]);
}
@@ -1669,15 +1643,17 @@ std::unique_ptr<Expression> IRGenerator::convertNumberConstructor(
}
if (type.isFloat() && args.size() == 1 && args[0]->fKind == Expression::kFloatLiteral_Kind) {
double value = ((FloatLiteral&) *args[0]).fValue;
- return std::unique_ptr<Expression>(new FloatLiteral(offset, value, &type));
+ return std::unique_ptr<Expression>(new FloatLiteral(fContext, offset, value, &type));
}
if (type.isFloat() && args.size() == 1 && args[0]->fKind == Expression::kIntLiteral_Kind) {
int64_t value = ((IntLiteral&) *args[0]).fValue;
- return std::unique_ptr<Expression>(new FloatLiteral(offset, (double) value, &type));
+ return std::unique_ptr<Expression>(new FloatLiteral(fContext, offset, (double) value,
+ &type));
}
if (args[0]->fKind == Expression::kIntLiteral_Kind && (type == *fContext.fInt_Type ||
type == *fContext.fUInt_Type)) {
- return std::unique_ptr<Expression>(new IntLiteral(offset,
+ return std::unique_ptr<Expression>(new IntLiteral(fContext,
+ offset,
((IntLiteral&) *args[0]).fValue,
&type));
}
@@ -1975,7 +1951,7 @@ std::unique_ptr<Expression> IRGenerator::getCap(int offset, String name) {
found->second.literal(fContext, offset)));
}
-std::unique_ptr<Expression> IRGenerator::getArg(int offset, String name) const {
+std::unique_ptr<Expression> IRGenerator::getArg(int offset, String name) {
auto found = fSettings->fArgs.find(name);
if (found == fSettings->fArgs.end()) {
fErrors.error(offset, "unknown argument '" + name + "'");