Add GrThreadSafePipelineBuilder
GrThreadSafePipelineBuilder is the generic, base object the
GrContextThreadSafeProxy will hold. Each backend will create a
backend-specific version that is shared between the direct context
and the (possibly many) utility contexts.
Right now GrThreadSafePipelineBuilder just holds the pipeline
creation stats. Relatedly only GrGLGpu::ProgramCache and
GrVkResourceProvider::PipelineStateCache currently derive from
the new class (since they are the only backends that generate
pipeline stats).
Change-Id: I58f441c5c2b870bb5970c29cba19d1775864d52e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378320
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 7b43170..61d3ac1 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -387,6 +387,9 @@
fPathRendering.reset();
fCopyProgramArrayBuffer.reset();
fMipmapProgramArrayBuffer.reset();
+ if (fProgramCache) {
+ fProgramCache->reset();
+ }
fHWProgram.reset();
if (fHWProgramID) {
@@ -461,6 +464,7 @@
}
fHWProgram.reset();
+ fProgramCache->reset();
fProgramCache.reset();
fHWProgramID = 0;
@@ -482,6 +486,14 @@
fFinishCallbacks.callAll(/* doDelete */ DisconnectType::kCleanup == type);
}
+GrThreadSafePipelineBuilder* GrGLGpu::pipelineBuilder() {
+ return fProgramCache.get();
+}
+
+sk_sp<GrThreadSafePipelineBuilder> GrGLGpu::refPipelineBuilder() {
+ return fProgramCache;
+}
+
///////////////////////////////////////////////////////////////////////////////
void GrGLGpu::onResetContext(uint32_t resetBits) {
@@ -3065,15 +3077,16 @@
std::unique_ptr<SkSL::Program> program = GrSkSLtoGLSL(this, SkSL::ProgramKind::kVertex,
sksl, settings, &glsl, errorHandler);
GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fCopyPrograms[progIdx].fProgram,
- GR_GL_VERTEX_SHADER, glsl, &fStats, errorHandler);
+ GR_GL_VERTEX_SHADER, glsl, fProgramCache->stats(),
+ errorHandler);
SkASSERT(program->fInputs.isEmpty());
sksl.assign(fshaderTxt.c_str(), fshaderTxt.size());
program = GrSkSLtoGLSL(this, SkSL::ProgramKind::kFragment, sksl, settings, &glsl,
errorHandler);
GrGLuint fshader = GrGLCompileAndAttachShader(*fGLContext, fCopyPrograms[progIdx].fProgram,
- GR_GL_FRAGMENT_SHADER, glsl, &fStats,
- errorHandler);
+ GR_GL_FRAGMENT_SHADER, glsl,
+ fProgramCache->stats(), errorHandler);
SkASSERT(program->fInputs.isEmpty());
GL_CALL(LinkProgram(fCopyPrograms[progIdx].fProgram));
@@ -3218,15 +3231,16 @@
std::unique_ptr<SkSL::Program> program = GrSkSLtoGLSL(this, SkSL::ProgramKind::kVertex,
sksl, settings, &glsl, errorHandler);
GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fMipmapPrograms[progIdx].fProgram,
- GR_GL_VERTEX_SHADER, glsl, &fStats, errorHandler);
+ GR_GL_VERTEX_SHADER, glsl,
+ fProgramCache->stats(), errorHandler);
SkASSERT(program->fInputs.isEmpty());
sksl.assign(fshaderTxt.c_str(), fshaderTxt.size());
program = GrSkSLtoGLSL(this, SkSL::ProgramKind::kFragment, sksl, settings, &glsl,
errorHandler);
GrGLuint fshader = GrGLCompileAndAttachShader(*fGLContext, fMipmapPrograms[progIdx].fProgram,
- GR_GL_FRAGMENT_SHADER, glsl, &fStats,
- errorHandler);
+ GR_GL_FRAGMENT_SHADER, glsl,
+ fProgramCache->stats(), errorHandler);
SkASSERT(program->fInputs.isEmpty());
GL_CALL(LinkProgram(fMipmapPrograms[progIdx].fProgram));
@@ -3675,14 +3689,14 @@
bool GrGLGpu::compile(const GrProgramDesc& desc, const GrProgramInfo& programInfo) {
SkASSERT(!(GrProcessor::CustomFeatures::kSampleLocations & programInfo.requestedFeatures()));
- Stats::ProgramCacheResult stat;
+ GrThreadSafePipelineBuilder::Stats::ProgramCacheResult stat;
sk_sp<GrGLProgram> tmp = fProgramCache->findOrCreateProgram(desc, programInfo, &stat);
if (!tmp) {
return false;
}
- return stat != Stats::ProgramCacheResult::kHit;
+ return stat != GrThreadSafePipelineBuilder::Stats::ProgramCacheResult::kHit;
}
#if GR_TEST_UTILS