Chromium Code Reviews| Index: src/gpu/gl/builders/GrGLProgramBuilder.cpp |
| diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp |
| index 1e6251ba66b007b4d5ba9efdb3c5f809373626f9..7f94961adce39a0ff01f60d9b1c15f02e8169054 100644 |
| --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp |
| +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp |
| @@ -16,6 +16,7 @@ |
| #include "gl/GrGLXferProcessor.h" |
| #include "GrAutoLocaleSetter.h" |
| #include "GrCoordTransform.h" |
| +#include "GrGLPathProgramBuilder.h" |
| #include "GrGLProgramBuilder.h" |
| #include "GrTexture.h" |
| #include "SkRTConf.h" |
| @@ -24,33 +25,6 @@ |
| #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) |
| #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) |
| -/////////////////////////////////////////////////////////////////////////////////////////////////// |
| - |
| -class GrGLNvprProgramBuilder : public GrGLProgramBuilder { |
| -public: |
| - GrGLNvprProgramBuilder(GrGLGpu* gpu, const DrawArgs& args) |
| - : INHERITED(gpu, args) {} |
| - |
| - GrGLProgram* createProgram(GrGLuint programID) override { |
| - // this is just for nvpr es, which has separable varyings that are plugged in after |
| - // building |
| - GrGLPathProcessor* pathProc = |
| - static_cast<GrGLPathProcessor*>(fGeometryProcessor->fGLProc.get()); |
| - pathProc->resolveSeparableVaryings(fGpu, programID); |
| - return SkNEW_ARGS(GrGLNvprProgram, (fGpu, this->desc(), fUniformHandles, programID, |
| - fUniforms, |
| - fGeometryProcessor, |
| - fXferProcessor, fFragmentProcessors.get())); |
| - } |
| - |
| -private: |
| - typedef GrGLProgramBuilder INHERITED; |
| -}; |
| - |
| - |
| - |
| -////////////////////////////////////////////////////////////////////////////// |
| - |
| const int GrGLProgramBuilder::kVarsPerBlock = 8; |
| GrGLProgram* GrGLProgramBuilder::CreateProgram(const DrawArgs& args, GrGLGpu* gpu) { |
| @@ -80,7 +54,7 @@ GrGLProgramBuilder* GrGLProgramBuilder::CreateProgramBuilder(const DrawArgs& arg |
| SkASSERT(gpu->glCaps().shaderCaps()->pathRenderingSupport() && |
| !args.fPrimitiveProcessor->willUseGeoShader() && |
| args.fPrimitiveProcessor->numAttribs() == 0); |
| - return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, args)); |
| + return SkNEW_ARGS(GrGLPathProgramBuilder, (gpu, args)); |
| } else { |
| return SkNEW_ARGS(GrGLProgramBuilder, (gpu, args)); |
| } |
| @@ -99,6 +73,7 @@ GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, const DrawArgs& args) |
| , fArgs(args) |
| , fGpu(gpu) |
| , fUniforms(kVarsPerBlock) { |
| + |
|
joshualitt
2015/06/23 14:07:24
extra newline
Kimmo Kinnunen
2015/06/25 12:38:11
Done.
|
| } |
| void GrGLProgramBuilder::addVarying(const char* name, |
| @@ -125,6 +100,18 @@ void GrGLProgramBuilder::addPassThroughAttribute(const GrPrimitiveProcessor::Att |
| fFS.codeAppendf("%s = %s;", output, v.fsIn()); |
| } |
| +GrGLProgramBuilder::SeparableVaryingHandle GrGLProgramBuilder::addSeparableVarying(const char*, |
| + GrGLVertToFrag*, |
| + GrSLPrecision) { |
| + // This call is not used for non-NVPR backends. However, the polymorphism between |
| + // GrPrimitiveProcessor, GrGLPrimitiveProcessor and GrGLProgramBuilder does not allow for |
| + // a system where GrGLPathProcessor would be able to refer to a primitive-specific builder |
| + // that would understand separable varyings. Thus separable varyings need to be present |
| + // early in the inheritance chain of builders. |
| + SkASSERT(false); |
| + return SeparableVaryingHandle(); |
| +} |
| + |
| void GrGLProgramBuilder::nameVariable(SkString* out, char prefix, const char* name) { |
| if ('\0' == prefix) { |
| *out = name; |
| @@ -421,11 +408,8 @@ GrGLProgram* GrGLProgramBuilder::finalize() { |
| return NULL; |
| } |
| - bool usingBindUniform = fGpu->glInterface()->fFunctions.fBindUniformLocation != NULL; |
| - if (usingBindUniform) { |
| - this->bindUniformLocations(programID); |
| - } |
| - fFS.bindFragmentShaderLocations(programID); |
| + this->bindProgramResourceLocations(programID); |
| + |
| GL_CALL(LinkProgram(programID)); |
| // Calling GetProgramiv is expensive in Chromium. Assume success in release builds. |
| @@ -436,21 +420,24 @@ GrGLProgram* GrGLProgramBuilder::finalize() { |
| if (checkLinked) { |
| checkLinkStatus(programID); |
| } |
| - if (!usingBindUniform) { |
| - this->resolveUniformLocations(programID); |
| - } |
| + this->resolveProgramResourceLocations(programID); |
| this->cleanupShaders(shadersToDelete); |
| return this->createProgram(programID); |
| } |
| -void GrGLProgramBuilder::bindUniformLocations(GrGLuint programID) { |
| - int count = fUniforms.count(); |
| - for (int i = 0; i < count; ++i) { |
| - GL_CALL(BindUniformLocation(programID, i, fUniforms[i].fVariable.c_str())); |
| - fUniforms[i].fLocation = i; |
| +void GrGLProgramBuilder::bindProgramResourceLocations(GrGLuint programID) { |
| + bool usingBindUniform = fGpu->glInterface()->fFunctions.fBindUniformLocation != NULL; |
| + if (usingBindUniform) { |
| + int count = fUniforms.count(); |
| + for (int i = 0; i < count; ++i) { |
| + GL_CALL(BindUniformLocation(programID, i, fUniforms[i].fVariable.c_str())); |
| + fUniforms[i].fLocation = i; |
| + } |
| } |
| + |
| + fFS.bindFragmentShaderLocations(programID); |
| } |
| bool GrGLProgramBuilder::checkLinkStatus(GrGLuint programID) { |
| @@ -477,12 +464,15 @@ bool GrGLProgramBuilder::checkLinkStatus(GrGLuint programID) { |
| return SkToBool(linked); |
| } |
| -void GrGLProgramBuilder::resolveUniformLocations(GrGLuint programID) { |
| - int count = fUniforms.count(); |
| - for (int i = 0; i < count; ++i) { |
| - GrGLint location; |
| - GL_CALL_RET(location, GetUniformLocation(programID, fUniforms[i].fVariable.c_str())); |
| - fUniforms[i].fLocation = location; |
| +void GrGLProgramBuilder::resolveProgramResourceLocations(GrGLuint programID) { |
| + bool usingBindUniform = fGpu->glInterface()->fFunctions.fBindUniformLocation != NULL; |
| + if (!usingBindUniform) { |
| + int count = fUniforms.count(); |
| + for (int i = 0; i < count; ++i) { |
| + GrGLint location; |
| + GL_CALL_RET(location, GetUniformLocation(programID, fUniforms[i].fVariable.c_str())); |
| + fUniforms[i].fLocation = location; |
| + } |
| } |
| } |