aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/instanced/GLInstancedRendering.h
diff options
context:
space:
mode:
authorGravatar csmartdalton <csmartdalton@google.com>2016-06-30 12:15:49 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-06-30 12:15:49 -0700
commit42eafa4bc00354b132ad114d22ed6b95d8849891 (patch)
tree06cf28b2181094aa53d1232381dafa9d5d28d385 /src/gpu/instanced/GLInstancedRendering.h
parenta71b89866deeea26eb7fd9d41eb3d28ce60ee92a (diff)
Begin instanced rendering for simple shapes
Adds a module that performs instanced rendering and starts using it for a select subset of draws on Mac GL platforms. The instance processor can currently handle rects, ovals, round rects, and double round rects. It can generalize shapes as round rects in order to improve batching. The instance processor also employs new drawing algorithms, irrespective of instanced rendering, that improve GPU-side performance (e.g. sample mask, different triangle layouts, etc.). This change only scratches the surface of instanced rendering. The majority of draws still only have one instance. Future work may include: * Passing coord transforms through the texel buffer. * Sending FP uniforms through instanced vertex attribs. * Using instanced rendering for more draws (stencil writes, drawAtlas, etc.). * Adding more shapes to the instance processor’s repertoire. * Batching draws that have mismatched scissors (analyzing draw bounds, inserting clip planes, etc.). * Bindless textures. * Uber shaders. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2066993003 Review-Url: https://codereview.chromium.org/2066993003
Diffstat (limited to 'src/gpu/instanced/GLInstancedRendering.h')
-rw-r--r--src/gpu/instanced/GLInstancedRendering.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/gpu/instanced/GLInstancedRendering.h b/src/gpu/instanced/GLInstancedRendering.h
new file mode 100644
index 0000000000..569e6e3160
--- /dev/null
+++ b/src/gpu/instanced/GLInstancedRendering.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef gr_instanced_GLInstancedRendering_DEFINED
+#define gr_instanced_GLInstancedRendering_DEFINED
+
+#include "gl/GrGLBuffer.h"
+#include "instanced/InstancedRendering.h"
+
+class GrGLGpu;
+
+#define GR_GL_LOG_INSTANCED_BATCHES 0
+
+namespace gr_instanced {
+
+class GLInstancedRendering final : public InstancedRendering {
+public:
+ static GLInstancedRendering* CreateIfSupported(GrGLGpu*);
+ ~GLInstancedRendering() override;
+
+private:
+ GLInstancedRendering(GrGLGpu*, AntialiasMode lastSupportedAAMode);
+
+ GrGLGpu* glGpu() const;
+
+ Batch* createBatch() override;
+
+ void onBeginFlush(GrResourceProvider*) override;
+ void onDraw(const GrPipeline&, const InstanceProcessor&, const Batch*) override;
+ void onEndFlush() override;
+ void onResetGpuResources(ResetType) override;
+
+ void flushInstanceAttribs(int baseInstance);
+
+ struct GLDrawCmdInfo {
+ int fInstanceCount;
+#if GR_GL_LOG_INSTANCED_BATCHES
+ IndexRange fGeometry;
+#endif
+ };
+
+ GrGLuint fVertexArrayID;
+ SkAutoTUnref<GrGLBuffer> fInstanceBuffer;
+ SkAutoTUnref<GrGLBuffer> fDrawIndirectBuffer;
+ SkAutoSTMalloc<1024, GLDrawCmdInfo> fGLDrawCmdsInfo;
+ uint32_t fInstanceAttribsBufferUniqueId;
+ int fInstanceAttribsBaseInstance;
+
+ class GLBatch;
+
+ typedef InstancedRendering INHERITED;
+};
+
+}
+
+#endif