aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/builders
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2016-12-09 17:22:59 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-12 16:42:34 +0000
commitce33f10677630e34187b661a02161378d8304d68 (patch)
tree570afa6dc9fc971ab1b886563a04b48cfd41156b /src/gpu/gl/builders
parentf44703a87f532b3f593d91605d66d52c6bbc45c9 (diff)
added sk_FragCoord support to skslc
BUG=skia: Change-Id: If78a4d08121699f87659f0d2e35f3edbf1867401 Reviewed-on: https://skia-review.googlesource.com/5408 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/gpu/gl/builders')
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp25
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.h5
-rw-r--r--src/gpu/gl/builders/GrGLShaderStringBuilder.cpp19
-rw-r--r--src/gpu/gl/builders/GrGLShaderStringBuilder.h4
4 files changed, 37 insertions, 16 deletions
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index cc29022456..045593ff42 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -69,7 +69,9 @@ const GrCaps* GrGLProgramBuilder::caps() const {
bool GrGLProgramBuilder::compileAndAttachShaders(GrGLSLShaderBuilder& shader,
GrGLuint programId,
GrGLenum type,
- SkTDArray<GrGLuint>* shaderIds) {
+ SkTDArray<GrGLuint>* shaderIds,
+ const SkSL::Program::Settings& settings,
+ SkSL::Program::Inputs* outInputs) {
GrGLGpu* gpu = this->gpu();
GrGLuint shaderId = GrGLCompileAndAttachShader(gpu->glContext(),
programId,
@@ -77,7 +79,9 @@ bool GrGLProgramBuilder::compileAndAttachShaders(GrGLSLShaderBuilder& shader,
shader.fCompilerStrings.begin(),
shader.fCompilerStringLengths.begin(),
shader.fCompilerStrings.count(),
- gpu->stats());
+ gpu->stats(),
+ settings,
+ outInputs);
if (!shaderId) {
return false;
@@ -100,8 +104,13 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
this->finalizeShaders();
// compile shaders and bind attributes / uniforms
+ SkSL::Program::Settings settings;
+ settings.fCaps = this->gpu()->glCaps().shaderCaps();
+ settings.fFlipY = this->pipeline().getRenderTarget()->origin() != kTopLeft_GrSurfaceOrigin;
+ SkSL::Program::Inputs inputs;
SkTDArray<GrGLuint> shadersToDelete;
- if (!this->compileAndAttachShaders(fVS, programID, GR_GL_VERTEX_SHADER, &shadersToDelete)) {
+ if (!this->compileAndAttachShaders(fVS, programID, GR_GL_VERTEX_SHADER, &shadersToDelete,
+ settings, &inputs)) {
this->cleanupProgram(programID, shadersToDelete);
return nullptr;
}
@@ -117,16 +126,22 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
}
if (primProc.willUseGeoShader() &&
- !this->compileAndAttachShaders(fGS, programID, GR_GL_GEOMETRY_SHADER, &shadersToDelete)) {
+ !this->compileAndAttachShaders(fGS, programID, GR_GL_GEOMETRY_SHADER, &shadersToDelete,
+ settings, &inputs)) {
this->cleanupProgram(programID, shadersToDelete);
return nullptr;
}
- if (!this->compileAndAttachShaders(fFS, programID, GR_GL_FRAGMENT_SHADER, &shadersToDelete)) {
+ if (!this->compileAndAttachShaders(fFS, programID, GR_GL_FRAGMENT_SHADER, &shadersToDelete,
+ settings, &inputs)) {
this->cleanupProgram(programID, shadersToDelete);
return nullptr;
}
+ if (inputs.fRTHeight) {
+ this->addRTHeightUniform(SKSL_RTHEIGHT_NAME);
+ }
+
this->bindProgramResourceLocations(programID);
GL_CALL(LinkProgram(programID));
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index a88f278b93..84d6d91a57 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -14,6 +14,7 @@
#include "gl/GrGLVaryingHandler.h"
#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "ir/SkSLProgram.h"
class GrFragmentProcessor;
class GrGLContextInfo;
@@ -46,7 +47,9 @@ private:
bool compileAndAttachShaders(GrGLSLShaderBuilder& shader,
GrGLuint programId,
GrGLenum type,
- SkTDArray<GrGLuint>* shaderIds);
+ SkTDArray<GrGLuint>* shaderIds,
+ const SkSL::Program::Settings& settings,
+ SkSL::Program::Inputs* outInputs);
GrGLProgram* finalize();
void bindProgramResourceLocations(GrGLuint programID);
bool checkLinkStatus(GrGLuint programID);
diff --git a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
index bd4921b650..df44edd07e 100644
--- a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
@@ -44,7 +44,9 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
const char** strings,
int* lengths,
int count,
- GrGpu::Stats* stats) {
+ GrGpu::Stats* stats,
+ const SkSL::Program::Settings& settings,
+ SkSL::Program::Inputs* outInputs) {
const GrGLInterface* gli = glCtx.interface();
GrGLuint shaderId;
@@ -65,21 +67,20 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
SkString glsl;
if (type == GR_GL_VERTEX_SHADER || type == GR_GL_FRAGMENT_SHADER) {
SkSL::Compiler& compiler = *glCtx.compiler();
- SkDEBUGCODE(bool result = )compiler.toGLSL(type == GR_GL_VERTEX_SHADER
- ? SkSL::Program::kVertex_Kind
+ std::unique_ptr<SkSL::Program> program;
+ program = compiler.convertProgram(
+ type == GR_GL_VERTEX_SHADER ? SkSL::Program::kVertex_Kind
: SkSL::Program::kFragment_Kind,
- sksl,
- *glCtx.caps()->shaderCaps(),
- &glsl);
-#ifdef SK_DEBUG
- if (!result) {
+ sksl,
+ settings);
+ if (!program || !compiler.toGLSL(*program, &glsl)) {
SkDebugf("SKSL compilation error\n----------------------\n");
SkDebugf("SKSL:\n");
dump_string(sksl);
SkDebugf("\nErrors:\n%s\n", compiler.errorText().c_str());
SkDEBUGFAIL("SKSL compilation failed!\n");
}
-#endif
+ *outInputs = program->fInputs;
} else {
// TODO: geometry shader support in sksl.
SkASSERT(type == GR_GL_GEOMETRY_SHADER);
diff --git a/src/gpu/gl/builders/GrGLShaderStringBuilder.h b/src/gpu/gl/builders/GrGLShaderStringBuilder.h
index 71fce6a95a..242fe617e0 100644
--- a/src/gpu/gl/builders/GrGLShaderStringBuilder.h
+++ b/src/gpu/gl/builders/GrGLShaderStringBuilder.h
@@ -20,6 +20,8 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
const char** strings,
int* lengths,
int count,
- GrGpu::Stats*);
+ GrGpu::Stats*,
+ const SkSL::Program::Settings& settings,
+ SkSL::Program::Inputs* inputs);
#endif