From 9926f4bf652e2a526a2f94a85547ed8cfe7d1b7b Mon Sep 17 00:00:00 2001 From: Chris Dalton Date: Wed, 17 May 2017 15:15:50 -0600 Subject: [PATCH] Add drawArraysBaseVertexIsBroken flag A non-zero base vertex in glDrawArrays appears to not always work on Adreno. Bug: skia:6650 Change-Id: I301eaba8c7790ed814a2ab8d8c53dd2b9e0d77d1 Reviewed-on: https://skia-review.googlesource.com/17083 Commit-Queue: Chris Dalton Reviewed-by: Brian Salomon --- src/gpu/gl/GrGLCaps.cpp | 4 ++++ src/gpu/gl/GrGLCaps.h | 7 +++++++ src/gpu/gl/GrGLGpu.cpp | 12 +++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 977670d657..ba0531676a 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -54,6 +54,7 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, fSRGBDecodeDisableSupport = false; fSRGBDecodeDisableAffectsMipmaps = false; fClearToOpaqueBlackIsBroken = false; + fDrawArraysBaseVertexIsBroken = false; fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag; @@ -573,6 +574,9 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, fClearToOpaqueBlackIsBroken = true; } #endif + if (kQualcomm_GrGLVendor == ctxInfo.vendor()) { + fDrawArraysBaseVertexIsBroken = true; + } // Requires fTextureRedSupport, fTextureSwizzleSupport, msaa support, ES compatibility have // already been detected. diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index bba4d8e033..6948583935 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -360,6 +360,12 @@ public: } bool clearToOpaqueBlackIsBroken() const { return fClearToOpaqueBlackIsBroken; } + + // Adreno/MSAA drops a draw on the imagefiltersbase GM if the base vertex param to + // glDrawArrays is nonzero. + // https://bugs.chromium.org/p/skia/issues/detail?id=6650 + bool drawArraysBaseVertexIsBroken() const { return fDrawArraysBaseVertexIsBroken; } + bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, bool* rectsMustMatch, bool* disallowSubrect) const override; @@ -432,6 +438,7 @@ private: bool fSRGBDecodeDisableSupport : 1; bool fSRGBDecodeDisableAffectsMipmaps : 1; bool fClearToOpaqueBlackIsBroken : 1; + bool fDrawArraysBaseVertexIsBroken : 1; uint32_t fBlitFramebufferFlags; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 51fef2c823..c52d1d141f 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -2649,7 +2649,7 @@ void GrGLGpu::draw(const GrPipeline& pipeline, for (const GrMesh::PatternBatch batch : mesh) { this->setupGeometry(primProc, mesh.indexBuffer(), mesh.vertexBuffer(), batch.fBaseVertex); - // mesh.baseVertex() was accounted for by setupGeometry. + // batch.fBaseVertex was accounted for by setupGeometry. if (this->glCaps().drawRangeElementsSupport()) { // We assume here that the GrMeshDrawOps that generated the mesh used the full // 0..vertexCount()-1 range. @@ -2665,8 +2665,14 @@ void GrGLGpu::draw(const GrPipeline& pipeline, fStats.incNumDraws(); } } else { - this->setupGeometry(primProc, mesh.indexBuffer(), mesh.vertexBuffer(), 0); - GL_CALL(DrawArrays(primType, mesh.baseVertex(), mesh.vertexCount())); + if (this->glCaps().drawArraysBaseVertexIsBroken()) { + this->setupGeometry(primProc, mesh.indexBuffer(), mesh.vertexBuffer(), + mesh.baseVertex()); + GL_CALL(DrawArrays(primType, 0, mesh.vertexCount())); + } else { + this->setupGeometry(primProc, mesh.indexBuffer(), mesh.vertexBuffer(), 0); + GL_CALL(DrawArrays(primType, mesh.baseVertex(), mesh.vertexCount())); + } fStats.incNumDraws(); } }