diff options
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrCaps.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 9 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.h | 10 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 12 |
4 files changed, 29 insertions, 4 deletions
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp index a0e435a9c3..f4c7de7304 100644 --- a/src/gpu/GrCaps.cpp +++ b/src/gpu/GrCaps.cpp @@ -149,6 +149,8 @@ void GrCaps::dumpJSON(SkJSONWriter* writer) const { writer->appendBool("Cross context texture support", fCrossContextTextureSupport); writer->appendBool("Draw Instead of Clear [workaround]", fUseDrawInsteadOfClear); + writer->appendBool("Blacklist Coverage Counting Path Renderer [workaround]", + fBlacklistCoverageCounting); writer->appendBool("Prefer VRAM Use over flushes [workaround]", fPreferVRAMUseOverFlushes); if (this->advancedBlendEquationSupport()) { diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 3b401e65a1..088e5cbbdd 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -62,6 +62,7 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines = false; fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag; + fMaxInstancesPerDrawArraysWithoutCrashing = 0; fShaderCaps.reset(new GrShaderCaps(contextOptions)); @@ -595,6 +596,12 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines = true; } + // Our Chromebook with kPowerVRRogue_GrGLRenderer seems to crash when glDrawArraysInstanced is + // given 1 << 15 or more instances. + if (kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) { + fMaxInstancesPerDrawArraysWithoutCrashing = 0x7fff; + } + // Texture uploads sometimes seem to be ignored to textures bound to FBOS on Tegra3. if (kTegra3_GrGLRenderer == ctxInfo.renderer()) { fDisallowTexSubImageForUnormConfigTexturesEverBoundToFBO = true; @@ -1374,6 +1381,8 @@ void GrGLCaps::onDumpJSON(SkJSONWriter* writer) const { fDisallowTexSubImageForUnormConfigTexturesEverBoundToFBO); writer->appendBool("Intermediate texture for all updates of textures bound to FBOs", fUseDrawInsteadOfAllRenderTargetWrites); + writer->appendBool("Max instances per glDrawArraysInstanced without crashing (or zero)", + fMaxInstancesPerDrawArraysWithoutCrashing); writer->beginArray("configs"); diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 68cbc9bf16..5140aeea2f 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -399,6 +399,15 @@ public: return fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines; } + // Returns the observed maximum number of instances the driver can handle in a single call to + // glDrawArraysInstanced without crashing, or 'pendingInstanceCount' if this + // workaround is not necessary. + // NOTE: the return value may be larger than pendingInstanceCount. + int maxInstancesPerDrawArraysWithoutCrashing(int pendingInstanceCount) const { + return fMaxInstancesPerDrawArraysWithoutCrashing ? fMaxInstancesPerDrawArraysWithoutCrashing + : pendingInstanceCount; + } + bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, bool* rectsMustMatch, bool* disallowSubrect) const override; @@ -479,6 +488,7 @@ private: bool fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines : 1; uint32_t fBlitFramebufferFlags; + int fMaxInstancesPerDrawArraysWithoutCrashing; /** Number type of the components (with out considering number of bits.) */ enum FormatType { diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 8190206d8f..10dabe4629 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -2619,10 +2619,14 @@ void GrGLGpu::sendInstancedMeshToGpu(const GrPrimitiveProcessor& primProc, GrPri int vertexCount, int baseVertex, const GrBuffer* instanceBuffer, int instanceCount, int baseInstance) { - const GrGLenum glPrimType = gr_primitive_type_to_gl_mode(primitiveType); - this->setupGeometry(primProc, nullptr, vertexBuffer, 0, instanceBuffer, baseInstance); - GL_CALL(DrawArraysInstanced(glPrimType, baseVertex, vertexCount, instanceCount)); - fStats.incNumDraws(); + GrGLenum glPrimType = gr_primitive_type_to_gl_mode(primitiveType); + int maxInstances = this->glCaps().maxInstancesPerDrawArraysWithoutCrashing(instanceCount); + for (int i = 0; i < instanceCount; i += maxInstances) { + this->setupGeometry(primProc, nullptr, vertexBuffer, 0, instanceBuffer, baseInstance + i); + GL_CALL(DrawArraysInstanced(glPrimType, baseVertex, vertexCount, + SkTMin(instanceCount - i, maxInstances))); + fStats.incNumDraws(); + } } void GrGLGpu::sendIndexedInstancedMeshToGpu(const GrPrimitiveProcessor& primProc, |