Cleanup program building a bit
This CL:
now passes the GrProgramDesc as a const&
returns GrGLProgram as an sk_sp
makes the parameter ordering more consistent
makes GrVkPipelineState no longer ref-counted
This is pulled out of the DDL pre-compile CL which touches this portion of the code.
Bug: skia:9455
Change-Id: Id4d06f93450e276de5a2662be330ae9523026244
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268777
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 6c12794..012140f 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -45,21 +45,22 @@
cleanup_shaders(gpu, shaderIDs);
}
-GrGLProgram* GrGLProgramBuilder::CreateProgram(GrRenderTarget* renderTarget,
- const GrProgramInfo& programInfo,
- GrProgramDesc* desc,
+sk_sp<GrGLProgram> GrGLProgramBuilder::CreateProgram(
GrGLGpu* gpu,
+ GrRenderTarget* renderTarget,
+ const GrProgramDesc& desc,
+ const GrProgramInfo& programInfo,
const GrGLPrecompiledProgram* precompiledProgram) {
ATRACE_ANDROID_FRAMEWORK_ALWAYS("shader_compile");
GrAutoLocaleSetter als("C");
// create a builder. This will be handed off to effects so they can use it to add
// uniforms, varyings, textures, etc
- GrGLProgramBuilder builder(gpu, renderTarget, programInfo, desc);
+ GrGLProgramBuilder builder(gpu, renderTarget, desc, programInfo);
auto persistentCache = gpu->getContext()->priv().getPersistentCache();
if (persistentCache && !precompiledProgram) {
- sk_sp<SkData> key = SkData::MakeWithoutCopy(desc->asKey(), desc->keyLength());
+ sk_sp<SkData> key = SkData::MakeWithoutCopy(desc.asKey(), desc.keyLength());
builder.fCached = persistentCache->load(*key);
// the eventual end goal is to completely skip emitAndInstallProcs on a cache hit, but it's
// doing necessary setup in addition to generating the SkSL code. Currently we are only able
@@ -75,9 +76,9 @@
GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu,
GrRenderTarget* renderTarget,
- const GrProgramInfo& programInfo,
- GrProgramDesc* desc)
- : INHERITED(renderTarget, programInfo, desc)
+ const GrProgramDesc& desc,
+ const GrProgramInfo& programInfo)
+ : INHERITED(renderTarget, desc, programInfo)
, fGpu(gpu)
, fVaryingHandler(this)
, fUniformHandler(this)
@@ -159,7 +160,7 @@
if (!this->gpu()->getContext()->priv().getPersistentCache()) {
return;
}
- sk_sp<SkData> key = SkData::MakeWithoutCopy(this->desc()->asKey(), this->desc()->keyLength());
+ sk_sp<SkData> key = SkData::MakeWithoutCopy(this->desc().asKey(), this->desc().keyLength());
if (fGpu->glCaps().programBinarySupport()) {
// binary cache
GrGLsizei length = 0;
@@ -198,7 +199,7 @@
}
}
-GrGLProgram* GrGLProgramBuilder::finalize(const GrGLPrecompiledProgram* precompiledProgram) {
+sk_sp<GrGLProgram> GrGLProgramBuilder::finalize(const GrGLPrecompiledProgram* precompiledProgram) {
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
// verify we can get a program id
@@ -541,22 +542,22 @@
}
}
-GrGLProgram* GrGLProgramBuilder::createProgram(GrGLuint programID) {
- return new GrGLProgram(fGpu,
- fUniformHandles,
- programID,
- fUniformHandler.fUniforms,
- fUniformHandler.fSamplers,
- fVaryingHandler.fPathProcVaryingInfos,
- std::move(fGeometryProcessor),
- std::move(fXferProcessor),
- std::move(fFragmentProcessors),
- fFragmentProcessorCnt,
- std::move(fAttributes),
- fVertexAttributeCnt,
- fInstanceAttributeCnt,
- fVertexStride,
- fInstanceStride);
+sk_sp<GrGLProgram> GrGLProgramBuilder::createProgram(GrGLuint programID) {
+ return sk_sp<GrGLProgram>(new GrGLProgram(fGpu,
+ fUniformHandles,
+ programID,
+ fUniformHandler.fUniforms,
+ fUniformHandler.fSamplers,
+ fVaryingHandler.fPathProcVaryingInfos,
+ std::move(fGeometryProcessor),
+ std::move(fXferProcessor),
+ std::move(fFragmentProcessors),
+ fFragmentProcessorCnt,
+ std::move(fAttributes),
+ fVertexAttributeCnt,
+ fInstanceAttributeCnt,
+ fVertexStride,
+ fInstanceStride));
}
bool GrGLProgramBuilder::PrecompileProgram(GrGLPrecompiledProgram* precompiledProgram,