diff options
author | 2016-07-07 08:49:11 -0700 | |
---|---|---|
committer | 2016-07-07 08:49:11 -0700 | |
commit | a7f29640f6ab4eb50962a9d9f12d01ac2ce8b471 (patch) | |
tree | b2ab8bb78abede727cf680cfeca76e385bd7205b /src/gpu/gl | |
parent | d5f6e9a759891473b8211efb90f665b14a85b830 (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
Committed: https://skia.googlesource.com/skia/+/42eafa4bc00354b132ad114d22ed6b95d8849891
Review-Url: https://codereview.chromium.org/2066993003
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 7 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index a37d72e26b..9972690487 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -23,6 +23,7 @@ #include "glsl/GrGLSL.h" #include "glsl/GrGLSLCaps.h" #include "glsl/GrGLSLPLSPathRendering.h" +#include "instanced/GLInstancedRendering.h" #include "SkMipMap.h" #include "SkPixmap.h" #include "SkStrokeRec.h" @@ -46,6 +47,8 @@ /////////////////////////////////////////////////////////////////////////////// +using gr_instanced::InstancedRendering; +using gr_instanced::GLInstancedRendering; static const GrGLenum gXfermodeEquation2Blend[] = { // Basic OpenGL blend equations. @@ -475,6 +478,10 @@ void GrGLGpu::disconnect(DisconnectType type) { /////////////////////////////////////////////////////////////////////////////// +InstancedRendering* GrGLGpu::createInstancedRenderingIfSupported() { + return GLInstancedRendering::CreateIfSupported(this); +} + void GrGLGpu::onResetContext(uint32_t resetBits) { // we don't use the zb at all if (resetBits & kMisc_GrGLBackendState) { diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index c8edbb9c28..5cc0facea6 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -28,6 +28,8 @@ class GrPipeline; class GrNonInstancedMesh; class GrSwizzle; +namespace gr_instanced { class GLInstancedRendering; } + #ifdef SK_DEBUG #define PROGRAM_CACHE_STATS #endif @@ -54,6 +56,8 @@ public: return static_cast<GrGLPathRendering*>(pathRendering()); } + gr_instanced::InstancedRendering* createInstancedRenderingIfSupported() override; + // Used by GrGLProgram to configure OpenGL state. void bindTexture(int unitIdx, const GrTextureParams& params, bool allowSRGBInputs, GrGLTexture* texture); @@ -595,6 +599,7 @@ private: typedef GrGpu INHERITED; friend class GrGLPathRendering; // For accessing setTextureUnit. + friend class gr_instanced::GLInstancedRendering; // For accessing flushGLState. }; #endif |