Batch up draws into triangle fans as large as possible when drawing convex
edge AA polys, so we minimize state changes and GL calls. This requires
querying GL for the maximum number of fragment uniforms. It also makes the
shader generator produce custom shaders for the number of relevant edges.
This gives a ~5X speedup on the "Shapes" SampleApp.
Review URL: http://codereview.appspot.com/4536070/
git-svn-id: http://skia.googlecode.com/svn/trunk@1380 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrGpuGL.cpp b/gpu/src/GrGpuGL.cpp
index e8c7afb..5a2d2bd 100644
--- a/gpu/src/GrGpuGL.cpp
+++ b/gpu/src/GrGpuGL.cpp
@@ -16,6 +16,7 @@
#include "GrGpuGL.h"
#include "GrMemory.h"
+#include "GrTypes.h"
static const GrGLuint GR_MAX_GLUINT = ~0;
static const GrGLint GR_INVAL_GLINT = ~0;
@@ -201,6 +202,16 @@
GR_GL_GetIntegerv(GR_GL_MAX_TEXTURE_UNITS, &maxTextureUnits);
GrAssert(maxTextureUnits > kNumStages);
}
+ if (GR_GL_SUPPORT_ES2) {
+ GR_GL_GetIntegerv(GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS,
+ &fMaxFragmentUniformVectors);
+ } else if (GR_GL_SUPPORT_DESKTOP) {
+ GrGLint max;
+ GR_GL_GetIntegerv(GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max);
+ fMaxFragmentUniformVectors = max / 4;
+ } else {
+ fMaxFragmentUniformVectors = 16;
+ }
////////////////////////////////////////////////////////////////////////////
// Check for supported features.
@@ -2064,3 +2075,9 @@
}
}
}
+
+int GrGpuGL::getMaxEdges() const {
+ // FIXME: This is a pessimistic estimate based on how many other things
+ // want to add uniforms. This should be centralized somewhere.
+ return GR_CT_MIN(fMaxFragmentUniformVectors - 8, kMaxEdges);
+}