Make GrGLProgram inform GrGLGpu when it changes the bound program
This error "worked" in normal rendering since Ganesh would always immediately use the same program after it was compiled. This is no longer true with pre-compilation of a DDL's programs.
Bug: 1056730
Change-Id: I9abbb8ecbd0612dfb828e6cc0888e9db09850048
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292818
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index e8f0884..17938d4 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -26,6 +26,43 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
+sk_sp<GrGLProgram> GrGLProgram::Make(
+ GrGLGpu* gpu,
+ const GrGLSLBuiltinUniformHandles& builtinUniforms,
+ GrGLuint programID,
+ const UniformInfoArray& uniforms,
+ const UniformInfoArray& textureSamplers,
+ const VaryingInfoArray& pathProcVaryings,
+ std::unique_ptr<GrGLSLPrimitiveProcessor> geometryProcessor,
+ std::unique_ptr<GrGLSLXferProcessor> xferProcessor,
+ std::unique_ptr<std::unique_ptr<GrGLSLFragmentProcessor>[]> fps,
+ int fragmentProcessorCnt,
+ std::unique_ptr<Attribute[]> attributes,
+ int vertexAttributeCnt,
+ int instanceAttributeCnt,
+ int vertexStride,
+ int instanceStride) {
+ sk_sp<GrGLProgram> program(new GrGLProgram(gpu,
+ builtinUniforms,
+ programID,
+ uniforms,
+ textureSamplers,
+ pathProcVaryings,
+ std::move(geometryProcessor),
+ std::move(xferProcessor),
+ std::move(fps),
+ fragmentProcessorCnt,
+ std::move(attributes),
+ vertexAttributeCnt,
+ instanceAttributeCnt,
+ vertexStride,
+ instanceStride));
+ // Assign texture units to sampler uniforms one time up front.
+ gpu->flushProgram(program);
+ program->fProgramDataManager.setSamplerUniforms(textureSamplers, 0);
+ return program;
+}
+
GrGLProgram::GrGLProgram(
GrGLGpu* gpu,
const GrGLSLBuiltinUniformHandles& builtinUniforms,
@@ -35,7 +72,7 @@
const VaryingInfoArray& pathProcVaryings,
std::unique_ptr<GrGLSLPrimitiveProcessor> geometryProcessor,
std::unique_ptr<GrGLSLXferProcessor> xferProcessor,
- std::unique_ptr<std::unique_ptr<GrGLSLFragmentProcessor>[]> fragmentProcessors,
+ std::unique_ptr<std::unique_ptr<GrGLSLFragmentProcessor>[]> fps,
int fragmentProcessorCnt,
std::unique_ptr<Attribute[]> attributes,
int vertexAttributeCnt,
@@ -46,7 +83,7 @@
, fProgramID(programID)
, fPrimitiveProcessor(std::move(geometryProcessor))
, fXferProcessor(std::move(xferProcessor))
- , fFragmentProcessors(std::move(fragmentProcessors))
+ , fFragmentProcessors(std::move(fps))
, fFragmentProcessorCnt(fragmentProcessorCnt)
, fAttributes(std::move(attributes))
, fVertexAttributeCnt(vertexAttributeCnt)
@@ -56,9 +93,6 @@
, fGpu(gpu)
, fProgramDataManager(gpu, programID, uniforms, pathProcVaryings)
, fNumTextureSamplers(textureSamplers.count()) {
- // Assign texture units to sampler uniforms one time up front.
- GL_CALL(UseProgram(fProgramID));
- fProgramDataManager.setSamplerUniforms(textureSamplers, 0);
}
GrGLProgram::~GrGLProgram() {