diff options
author | 2017-05-31 12:51:23 -0600 | |
---|---|---|
committer | 2017-05-31 20:40:20 +0000 | |
commit | 1d6163577c8a4f1372208e2c9e03b1a69906d385 (patch) | |
tree | fdacaa2e860d507bafca16cef0cb6e6e7861a1aa /src/gpu/gl/GrGLCaps.cpp | |
parent | fa6d865215b48fac4ee24c120736e500d418f641 (diff) |
Add support for instanced draws
Adds an instance buffer to GrMesh and instance attribs to
GrPrimitiveProcessor. Implements support in GL and Vulkan. Adds unit
tests for instanced rendering with GrMesh.
Bug: skia:
Change-Id: If1a9920feb9366f346b8c37cf914713c49129b3a
Reviewed-on: https://skia-review.googlesource.com/16200
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/gpu/gl/GrGLCaps.cpp')
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index df905a4f0f..a39b744574 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -38,7 +38,6 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, fDirectStateAccessSupport = false; fDebugSupport = false; fES2CompatibilitySupport = false; - fDrawInstancedSupport = false; fDrawIndirectSupport = false; fMultiDrawIndirectSupport = false; fBaseInstanceSupport = false; @@ -185,6 +184,20 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, } if (kGL_GrGLStandard == standard) { + // 3.1 has draw_instanced but not instanced_arrays, for the time being we only care about + // instanced arrays, but we could make this more granular if we wanted + fInstanceAttribSupport = + version >= GR_GL_VER(3, 2) || + (ctxInfo.hasExtension("GL_ARB_draw_instanced") && + ctxInfo.hasExtension("GL_ARB_instanced_arrays")); + } else { + fInstanceAttribSupport = + version >= GR_GL_VER(3, 0) || + (ctxInfo.hasExtension("GL_EXT_draw_instanced") && + ctxInfo.hasExtension("GL_EXT_instanced_arrays")); + } + + if (kGL_GrGLStandard == standard) { if (version >= GR_GL_VER(3, 0)) { fBindFragDataLocationSupport = true; } @@ -529,20 +542,6 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, } if (kGL_GrGLStandard == standard) { - // 3.1 has draw_instanced but not instanced_arrays, for the time being we only care about - // instanced arrays, but we could make this more granular if we wanted - fDrawInstancedSupport = - version >= GR_GL_VER(3, 2) || - (ctxInfo.hasExtension("GL_ARB_draw_instanced") && - ctxInfo.hasExtension("GL_ARB_instanced_arrays")); - } else { - fDrawInstancedSupport = - version >= GR_GL_VER(3, 0) || - (ctxInfo.hasExtension("GL_EXT_draw_instanced") && - ctxInfo.hasExtension("GL_EXT_instanced_arrays")); - } - - if (kGL_GrGLStandard == standard) { fDrawIndirectSupport = version >= GR_GL_VER(4,0) || ctxInfo.hasExtension("GL_ARB_draw_indirect"); fBaseInstanceSupport = version >= GR_GL_VER(4,2); @@ -850,6 +849,13 @@ void GrGLCaps::initGLSL(const GrGLContextInfo& ctxInfo) { } } + if (kGL_GrGLStandard == standard) { + shaderCaps->fVertexIDSupport = true; + } else { + // Desktop GLSL 3.30 == ES GLSL 3.00. + shaderCaps->fVertexIDSupport = ctxInfo.glslGeneration() >= k330_GrGLSLGeneration; + } + // The Tegra3 compiler will sometimes never return if we have min(abs(x), 1.0), so we must do // the abs first in a separate expression. if (kTegra3_GrGLRenderer == ctxInfo.renderer()) { @@ -1242,7 +1248,6 @@ SkString GrGLCaps::dump() const { r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); r.appendf("Direct state access support: %s\n", (fDirectStateAccessSupport ? "YES": "NO")); r.appendf("Debug support: %s\n", (fDebugSupport ? "YES": "NO")); - r.appendf("Draw instanced support: %s\n", (fDrawInstancedSupport ? "YES" : "NO")); r.appendf("Draw indirect support: %s\n", (fDrawIndirectSupport ? "YES" : "NO")); r.appendf("Multi draw indirect support: %s\n", (fMultiDrawIndirectSupport ? "YES" : "NO")); r.appendf("Base instance support: %s\n", (fBaseInstanceSupport ? "YES" : "NO")); |