diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2018-03-13 09:53:02 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-13 16:36:02 +0000 |
commit | 98ad5b7a4bcab3cb9a9bcd2e1a63976133515806 (patch) | |
tree | fef66a57f22c54ca49d316ab011974f551d6a9a3 /src/gpu | |
parent | 0118e9756d92d3c56b9e05842d7c828f37f68159 (diff) |
Fixed some shader cache issues
We now check GL_NUM_SHADER_BINARY_FORMATS to ensure that it is greater
than zero, and handle errors that occur when we try to install a
cached shader by falling back to using GLSL.
Bug: skia:
Change-Id: I1ac46243e9c561d15e1b4190b68afbf514fc8079
Reviewed-on: https://skia-review.googlesource.com/113820
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 5 | ||||
-rw-r--r-- | src/gpu/gl/GrGLDefines.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.cpp | 22 |
3 files changed, 22 insertions, 7 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index aec7a37e1b..3041518cf7 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -583,6 +583,11 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, } else if (version >= GR_GL_VER(3, 0)) { fProgramBinarySupport = true; } + if (fProgramBinarySupport) { + GrGLint count; + GR_GL_GetIntegerv(gli, GR_GL_NUM_SHADER_BINARY_FORMATS, &count); + fProgramBinarySupport = count > 0; + } // Requires fTextureRedSupport, fTextureSwizzleSupport, msaa support, ES compatibility have // already been detected. diff --git a/src/gpu/gl/GrGLDefines.h b/src/gpu/gl/GrGLDefines.h index e5e74eb68e..645397316b 100644 --- a/src/gpu/gl/GrGLDefines.h +++ b/src/gpu/gl/GrGLDefines.h @@ -558,6 +558,8 @@ #define GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 #define GR_GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A #define GR_GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE 0x8F63 +#define GR_GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GR_GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 /* StencilFunction */ #define GR_GL_NEVER 0x0200 diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index 7ca7506687..8fb3589df7 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -156,7 +156,7 @@ GrGLProgram* GrGLProgramBuilder::finalize() { settings.fSharpenTextures = this->gpu()->getContext()->contextPriv().sharpenMipmappedTextures(); SkSL::Program::Inputs inputs; SkTDArray<GrGLuint> shadersToDelete; - bool cached = nullptr != fCached.get(); + bool cached = fGpu->glCaps().programBinarySupport() && nullptr != fCached.get(); if (cached) { this->bindProgramResourceLocations(programID); // cache hit, just hand the binary to GL @@ -164,15 +164,23 @@ GrGLProgram* GrGLProgramBuilder::finalize() { size_t offset = 0; memcpy(&inputs, bytes + offset, sizeof(inputs)); offset += sizeof(inputs); - if (inputs.fRTHeight) { - this->addRTHeightUniform(SKSL_RTHEIGHT_NAME); - } int binaryFormat; memcpy(&binaryFormat, bytes + offset, sizeof(binaryFormat)); offset += sizeof(binaryFormat); - GL_CALL(ProgramBinary(programID, binaryFormat, (void*) (bytes + offset), - fCached->size() - offset)); - } else { + GrGLClearErr(this->gpu()->glInterface()); + GR_GL_CALL_NOERRCHECK(this->gpu()->glInterface(), + ProgramBinary(programID, binaryFormat, (void*) (bytes + offset), + fCached->size() - offset)); + if (GR_GL_GET_ERROR(this->gpu()->glInterface()) == GR_GL_NO_ERROR) { + if (inputs.fRTHeight) { + this->addRTHeightUniform(SKSL_RTHEIGHT_NAME); + } + cached = this->checkLinkStatus(programID); + } else { + cached = false; + } + } + if (!cached) { // cache miss, compile shaders if (fFS.fForceHighPrecision) { settings.fForceHighPrecision = true; |