Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: src/sksl/SkSLCompiler.cpp

Issue 2288033003: Turned on SkSL->GLSL compiler (Closed)
Patch Set: changed <iostream> to <ostream> Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/sksl/SkSLCompiler.h ('k') | src/sksl/SkSLContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/sksl/SkSLCompiler.cpp
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index d2ad81223e8c495e73546e4375b09f84db1b1eef..9eeacd082de1870f76135a21b9d88d91c0f25a0b 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -10,11 +10,13 @@
#include <fstream>
#include <streambuf>
+#include "ast/SkSLASTPrecision.h"
#include "SkSLIRGenerator.h"
#include "SkSLParser.h"
#include "SkSLSPIRVCodeGenerator.h"
#include "ir/SkSLExpression.h"
#include "ir/SkSLIntLiteral.h"
+#include "ir/SkSLModifiersDeclaration.h"
#include "ir/SkSLSymbolTable.h"
#include "ir/SkSLVarDeclaration.h"
#include "SkMutex.h"
@@ -23,15 +25,15 @@
// include the built-in shader symbols as static strings
-static std::string SKSL_INCLUDE =
+static const char* SKSL_INCLUDE =
#include "sksl.include"
;
-static std::string SKSL_VERT_INCLUDE =
+static const char* SKSL_VERT_INCLUDE =
#include "sksl_vert.include"
;
-static std::string SKSL_FRAG_INCLUDE =
+static const char* SKSL_FRAG_INCLUDE =
#include "sksl_frag.include"
;
@@ -97,6 +99,7 @@ Compiler::Compiler()
ADD_TYPE(Sampler1D);
ADD_TYPE(Sampler2D);
ADD_TYPE(Sampler3D);
+ ADD_TYPE(SamplerExternalOES);
ADD_TYPE(SamplerCube);
ADD_TYPE(Sampler2DRect);
ADD_TYPE(Sampler1DArray);
@@ -128,8 +131,9 @@ Compiler::Compiler()
ADD_TYPE(GSampler2DArrayShadow);
ADD_TYPE(GSamplerCubeArrayShadow);
- std::vector<std::unique_ptr<ProgramElement>> ignored;
- this->internalConvertProgram(SKSL_INCLUDE, &ignored);
+ Modifiers::Flag ignored1;
+ std::vector<std::unique_ptr<ProgramElement>> ignored2;
+ this->internalConvertProgram(SKSL_INCLUDE, &ignored1, &ignored2);
ASSERT(!fErrorCount);
}
@@ -138,12 +142,14 @@ Compiler::~Compiler() {
}
void Compiler::internalConvertProgram(std::string text,
+ Modifiers::Flag* defaultPrecision,
std::vector<std::unique_ptr<ProgramElement>>* result) {
Parser parser(text, *fTypes, *this);
std::vector<std::unique_ptr<ASTDeclaration>> parsed = parser.file();
if (fErrorCount) {
return;
}
+ *defaultPrecision = Modifiers::kHighp_Flag;
for (size_t i = 0; i < parsed.size(); i++) {
ASTDeclaration& decl = *parsed[i];
switch (decl.fKind) {
@@ -164,6 +170,14 @@ void Compiler::internalConvertProgram(std::string text,
}
break;
}
+ case ASTDeclaration::kModifiers_Kind: {
+ std::unique_ptr<ModifiersDeclaration> f = fIRGenerator->convertModifiersDeclaration(
+ (ASTModifiersDeclaration&) decl);
+ if (f) {
+ result->push_back(std::move(f));
+ }
+ break;
+ }
case ASTDeclaration::kInterfaceBlock_Kind: {
std::unique_ptr<InterfaceBlock> i = fIRGenerator->convertInterfaceBlock(
(ASTInterfaceBlock&) decl);
@@ -179,6 +193,10 @@ void Compiler::internalConvertProgram(std::string text,
}
break;
}
+ case ASTDeclaration::kPrecision_Kind: {
+ *defaultPrecision = ((ASTPrecision&) decl).fPrecision;
+ break;
+ }
default:
ABORT("unsupported declaration: %s\n", decl.description().c_str());
}
@@ -190,16 +208,18 @@ std::unique_ptr<Program> Compiler::convertProgram(Program::Kind kind, std::strin
fErrorCount = 0;
fIRGenerator->pushSymbolTable();
std::vector<std::unique_ptr<ProgramElement>> elements;
+ Modifiers::Flag ignored;
switch (kind) {
case Program::kVertex_Kind:
- this->internalConvertProgram(SKSL_VERT_INCLUDE, &elements);
+ this->internalConvertProgram(SKSL_VERT_INCLUDE, &ignored, &elements);
break;
case Program::kFragment_Kind:
- this->internalConvertProgram(SKSL_FRAG_INCLUDE, &elements);
+ this->internalConvertProgram(SKSL_FRAG_INCLUDE, &ignored, &elements);
break;
}
- this->internalConvertProgram(text, &elements);
- auto result = std::unique_ptr<Program>(new Program(kind, std::move(elements),
+ Modifiers::Flag defaultPrecision;
+ this->internalConvertProgram(text, &defaultPrecision, &elements);
+ auto result = std::unique_ptr<Program>(new Program(kind, defaultPrecision, std::move(elements),
fIRGenerator->fSymbolTable));;
fIRGenerator->popSymbolTable();
this->writeErrorCount();
« no previous file with comments | « src/sksl/SkSLCompiler.h ('k') | src/sksl/SkSLContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698