diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2018-07-11 13:59:03 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-11 18:30:38 +0000 |
commit | ad77dce5e145b684b826238b8c65d89f6cce60a6 (patch) | |
tree | a74e30e5c39cc990b1d4296dd1f42528d0b7a46a /src | |
parent | 37329b33326ef50e4279404df10037dccf5d9cba (diff) |
fix for persistent shader cache
Bug: skia:
Change-Id: I43b4dc58ab4dde3fa8140de0d73134c38f7d79db
Reviewed-on: https://skia-review.googlesource.com/140566
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 3 | ||||
-rw-r--r-- | src/gpu/gl/GrGLDefines.h | 4 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.cpp | 65 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.h | 2 |
4 files changed, 44 insertions, 30 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 5cb23427c5..f120b6d09d 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -600,10 +600,9 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, } if (fProgramBinarySupport) { GrGLint count; - GR_GL_GetIntegerv(gli, GR_GL_NUM_SHADER_BINARY_FORMATS, &count); + GR_GL_GetIntegerv(gli, GR_GL_NUM_PROGRAM_BINARY_FORMATS, &count); fProgramBinarySupport = count > 0; } - // Requires fTextureRedSupport, fTextureSwizzleSupport, msaa support, ES compatibility have // already been detected. this->initConfigTable(contextOptions, ctxInfo, gli, shaderCaps); diff --git a/src/gpu/gl/GrGLDefines.h b/src/gpu/gl/GrGLDefines.h index 30d0a4c2f9..8e7809f642 100644 --- a/src/gpu/gl/GrGLDefines.h +++ b/src/gpu/gl/GrGLDefines.h @@ -559,7 +559,6 @@ #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 @@ -852,6 +851,9 @@ #define GR_GL_SHADER_BINARY_FORMATS 0x8DF8 #define GR_GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +/* Program Binary */ +#define GR_GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE + /* Shader Precision-Specified Types */ #define GR_GL_LOW_FLOAT 0x8DF0 #define GR_GL_MEDIUM_FLOAT 0x8DF1 diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index a883d7e397..524ffa4e8c 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -132,6 +132,37 @@ bool GrGLProgramBuilder::compileAndAttachShaders(GrGLSLShaderBuilder& shader, *outInputs); } +void GrGLProgramBuilder::computeCountsAndStrides(GrGLuint programID, + const GrPrimitiveProcessor& primProc, + bool bindAttribLocations) { + fVertexAttributeCnt = primProc.numVertexAttributes(); + fInstanceAttributeCnt = primProc.numInstanceAttributes(); + fAttributes.reset( + new GrGLProgram::Attribute[fVertexAttributeCnt + fInstanceAttributeCnt]); + auto addAttr = [&](int i, const auto& a, size_t* stride) { + fAttributes[i].fType = a.type(); + fAttributes[i].fOffset = *stride; + *stride += a.sizeAlign4(); + fAttributes[i].fLocation = i; + if (bindAttribLocations) { + GL_CALL(BindAttribLocation(programID, i, a.name())); + } + }; + fVertexStride = 0; + int i = 0; + for (; i < fVertexAttributeCnt; i++) { + addAttr(i, primProc.vertexAttribute(i), &fVertexStride); + SkASSERT(fAttributes[i].fOffset == primProc.debugOnly_vertexAttributeOffset(i)); + } + SkASSERT(fVertexStride == primProc.debugOnly_vertexStride()); + fInstanceStride = 0; + for (int j = 0; j < fInstanceAttributeCnt; j++, ++i) { + addAttr(i, primProc.instanceAttribute(j), &fInstanceStride); + SkASSERT(fAttributes[i].fOffset == primProc.debugOnly_instanceAttributeOffset(j)); + } + SkASSERT(fInstanceStride == primProc.debugOnly_instanceStride()); +} + GrGLProgram* GrGLProgramBuilder::finalize() { TRACE_EVENT0("skia", TRACE_FUNC); @@ -175,10 +206,13 @@ GrGLProgram* GrGLProgramBuilder::finalize() { 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); + if (cached) { + if (inputs.fRTHeight) { + this->addRTHeightUniform(SKSL_RTHEIGHT_NAME); + } + this->computeCountsAndStrides(programID, primProc, false); + } } else { cached = false; } @@ -228,30 +262,7 @@ GrGLProgram* GrGLProgramBuilder::finalize() { // NVPR actually requires a vertex shader to compile bool useNvpr = primProc.isPathRendering(); if (!useNvpr) { - fVertexAttributeCnt = primProc.numVertexAttributes(); - fInstanceAttributeCnt = primProc.numInstanceAttributes(); - fAttributes.reset( - new GrGLProgram::Attribute[fVertexAttributeCnt + fInstanceAttributeCnt]); - auto addAttr = [&](int i, const auto& a, size_t* stride) { - fAttributes[i].fType = a.type(); - fAttributes[i].fOffset = *stride; - *stride += a.sizeAlign4(); - fAttributes[i].fLocation = i; - GL_CALL(BindAttribLocation(programID, i, a.name())); - }; - fVertexStride = 0; - int i = 0; - for (; i < fVertexAttributeCnt; i++) { - addAttr(i, primProc.vertexAttribute(i), &fVertexStride); - SkASSERT(fAttributes[i].fOffset == primProc.debugOnly_vertexAttributeOffset(i)); - } - SkASSERT(fVertexStride == primProc.debugOnly_vertexStride()); - fInstanceStride = 0; - for (int j = 0; j < fInstanceAttributeCnt; j++, ++i) { - addAttr(i, primProc.instanceAttribute(j), &fInstanceStride); - SkASSERT(fAttributes[i].fOffset == primProc.debugOnly_instanceAttributeOffset(j)); - } - SkASSERT(fInstanceStride == primProc.debugOnly_instanceStride()); + this->computeCountsAndStrides(programID, primProc, true); } if (primProc.willUseGeoShader()) { diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h index dd21a6d500..64e426900c 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.h +++ b/src/gpu/gl/builders/GrGLProgramBuilder.h @@ -62,6 +62,8 @@ private: SkTDArray<GrGLuint>* shaderIds, const SkSL::Program::Settings& settings, SkSL::Program::Inputs* outInputs); + void computeCountsAndStrides(GrGLuint programID, const GrPrimitiveProcessor& primProc, + bool bindAttribLocations); GrGLProgram* finalize(); void bindProgramResourceLocations(GrGLuint programID); bool checkLinkStatus(GrGLuint programID); |