Use noperspective interpolation for 2D draws
Adds a mechanism to notify GrGLSLVaryingHandler that a shader will not
emit geometry in perspective. This gives it a chance to use the
noperspective keyword if it is supported.
Updates the existing processors to notify the varying handler when
there is no perspective.
Begins using the noperspective keyword in GrGLGpu internal shaders.
Web scenes with observable benefit (Pixel C, gpu config):
tabl_nofolo.skp 4.62 -> 3.33 ms 28%
desk_tigersvg.skp 26.5 -> 24 ms 9%
desk_pokemonwiki.skp 16.1 -> 14.9 ms 7%
tabl_deviantart.skp 3.97 -> 3.7 ms 7%
desk_gws.skp 3.85 -> 3.65 ms 5%
Also adds new methods for creating varyings with flat interpolation.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1673093002
Review URL: https://codereview.chromium.org/1673093002
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 79bb22e..6dc5ee8 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -596,6 +596,24 @@
glslCaps->fBindlessTextureSupport = ctxInfo.hasExtension("GL_NV_bindless_texture");
+ if (kGL_GrGLStandard == standard) {
+ glslCaps->fFlatInterpolationSupport = ctxInfo.glslGeneration() >= k130_GrGLSLGeneration;
+ } else {
+ glslCaps->fFlatInterpolationSupport =
+ ctxInfo.glslGeneration() >= k330_GrGLSLGeneration; // This is the value for GLSL ES 3.0.
+ }
+
+ if (kGL_GrGLStandard == standard) {
+ glslCaps->fNoPerspectiveInterpolationSupport =
+ ctxInfo.glslGeneration() >= k130_GrGLSLGeneration;
+ } else {
+ if (ctxInfo.hasExtension("GL_NV_shader_noperspective_interpolation")) {
+ glslCaps->fNoPerspectiveInterpolationSupport = true;
+ glslCaps->fNoPerspectiveInterpolationExtensionString =
+ "GL_NV_shader_noperspective_interpolation";
+ }
+ }
+
// Adreno GPUs have a tendency to drop tiles when there is a divide-by-zero in a shader
glslCaps->fDropsTileOnZeroDivide = kQualcomm_GrGLVendor == ctxInfo.vendor();