Always include surface origin in keys for program/pipeline state
This was effectively happening before, but only after we (always) failed
to find an entry without the origin. If we ever have a system that can
determine ahead of time that we won't depend on surface origin, we can
update this logic. For now, just simplify the code and remove the
useless cache lookups.
Change-Id: I2b6178a8a83a48f33fdc066e185a2a4c13aa8ddc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229284
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp
index 7523292..1213132 100644
--- a/src/gpu/gl/GrGLGpuProgramCache.cpp
+++ b/src/gpu/gl/GrGLGpuProgramCache.cpp
@@ -90,13 +90,12 @@
GrCapsDebugf(gpu->caps(), "Failed to gl program descriptor!\n");
return nullptr;
}
+ // If we knew the shader won't depend on origin, we could skip this (and use the same program
+ // for both origins). Instrumenting all fragment processors would be difficult and error prone.
+ desc.setSurfaceOriginKey(GrGLSLFragmentShaderBuilder::KeyForSurfaceOrigin(origin));
+
std::unique_ptr<Entry>* entry = fMap.find(desc);
if (!entry) {
- // Didn't find an origin-independent version, check with the specific origin
- desc.setSurfaceOriginKey(GrGLSLFragmentShaderBuilder::KeyForSurfaceOrigin(origin));
- entry = fMap.find(desc);
- }
- if (!entry) {
// We have a cache miss
#ifdef PROGRAM_CACHE_STATS
++fCacheMisses;