diff options
author | Chris Dalton <csmartdalton@google.com> | 2018-04-16 13:19:58 -0600 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-16 21:23:20 +0000 |
commit | da40cd271ce1e86c5bd24c3b5780483ce785bc93 (patch) | |
tree | eb8e6dc675148396ad29299830488a728dcaf990 | |
parent | d234afdc2e562d395925ca3ac8294398608271a6 (diff) |
Add glFlush workaround for instanced draws on Skylake
Bug: skia:
Change-Id: I1292cc423b4d3d7fc2a9035d3ad251ad7e00f0f6
Reviewed-on: https://skia-review.googlesource.com/121700
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 6 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.h | 7 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 22 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 5 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUtil.cpp | 17 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUtil.h | 1 |
6 files changed, 51 insertions, 7 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 4eedbd8c39..3299416c5b 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -59,6 +59,7 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, fDisallowTexSubImageForUnormConfigTexturesEverBoundToFBO = false; fUseDrawInsteadOfAllRenderTargetWrites = false; fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines = false; + fRequiresFlushBetweenNonAndInstancedDraws = false; fProgramBinarySupport = false; fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag; @@ -2270,6 +2271,10 @@ void GrGLCaps::applyDriverCorrectnessWorkarounds(const GrGLContextInfo& ctxInfo, fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines = true; } + if (kIntelSkylake_GrGLRenderer == ctxInfo.renderer()) { + fRequiresFlushBetweenNonAndInstancedDraws = true; + } + // Our Chromebook with kPowerVRRogue_GrGLRenderer seems to crash when glDrawArraysInstanced is // given 1 << 15 or more instances. if (kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) { @@ -2496,6 +2501,7 @@ void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) { SkASSERT(!fDisallowTexSubImageForUnormConfigTexturesEverBoundToFBO); SkASSERT(!fUseDrawInsteadOfAllRenderTargetWrites); SkASSERT(!fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines); + SkASSERT(!fRequiresFlushBetweenNonAndInstancedDraws); } if (GrContextOptions::Enable::kNo == options.fUseDrawInsteadOfGLClear) { fUseDrawToClearColor = false; diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index ede2a17578..c564cf1d50 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -392,6 +392,12 @@ public: return fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines; } + // Intel Skylake instanced draws get corrupted if we mix them with normal ones. Adding a flush + // in between seems to resolve this. + bool requiresFlushBetweenNonAndInstancedDraws() const { + return fRequiresFlushBetweenNonAndInstancedDraws; + } + // 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. @@ -501,6 +507,7 @@ private: bool fDisallowTexSubImageForUnormConfigTexturesEverBoundToFBO : 1; bool fUseDrawInsteadOfAllRenderTargetWrites : 1; bool fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines : 1; + bool fRequiresFlushBetweenNonAndInstancedDraws : 1; int fMaxInstancesPerDrawArraysWithoutCrashing; uint32_t fBlitFramebufferFlags; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 574dd9ae41..85c9fb2891 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -461,6 +461,9 @@ void GrGLGpu::onResetContext(uint32_t resetBits) { fHWVertexArrayState.invalidate(); fHWBufferState[kVertex_GrBufferType].invalidate(); fHWBufferState[kIndex_GrBufferType].invalidate(); + if (this->glCaps().requiresFlushBetweenNonAndInstancedDraws()) { + fRequiresFlushBeforeNextInstancedDraw = true; + } } if (resetBits & kRenderTarget_GrGLBackendState) { @@ -2485,6 +2488,9 @@ void GrGLGpu::flushRenderTargetNoColorWrites(GrGLRenderTarget* target, bool disa } } #endif + if (this->glCaps().requiresFlushBetweenNonAndInstancedDraws()) { + fRequiresFlushBeforeNextInstancedDraw = false; + } fHWBoundRenderTargetUniqueID = rtID; this->flushViewport(target->getViewport()); } @@ -2618,6 +2624,9 @@ void GrGLGpu::sendMeshToGpu(const GrPrimitiveProcessor& primProc, GrPrimitiveTyp this->setupGeometry(primProc, nullptr, vertexBuffer, 0, nullptr, 0); GL_CALL(DrawArrays(glPrimType, baseVertex, vertexCount)); } + if (this->glCaps().requiresFlushBetweenNonAndInstancedDraws()) { + fRequiresFlushBeforeNextInstancedDraw = true; + } fStats.incNumDraws(); } @@ -2638,6 +2647,9 @@ void GrGLGpu::sendIndexedMeshToGpu(const GrPrimitiveProcessor& primProc, } else { GL_CALL(DrawElements(glPrimType, indexCount, GR_GL_UNSIGNED_SHORT, indices)); } + if (this->glCaps().requiresFlushBetweenNonAndInstancedDraws()) { + fRequiresFlushBeforeNextInstancedDraw = true; + } fStats.incNumDraws(); } @@ -2646,6 +2658,11 @@ void GrGLGpu::sendInstancedMeshToGpu(const GrPrimitiveProcessor& primProc, GrPri int vertexCount, int baseVertex, const GrBuffer* instanceBuffer, int instanceCount, int baseInstance) { + if (fRequiresFlushBeforeNextInstancedDraw) { + SkASSERT(this->glCaps().requiresFlushBetweenNonAndInstancedDraws()); + GL_CALL(Flush()); + fRequiresFlushBeforeNextInstancedDraw = false; + } GrGLenum glPrimType = gr_primitive_type_to_gl_mode(primitiveType); int maxInstances = this->glCaps().maxInstancesPerDrawArraysWithoutCrashing(instanceCount); for (int i = 0; i < instanceCount; i += maxInstances) { @@ -2662,6 +2679,11 @@ void GrGLGpu::sendIndexedInstancedMeshToGpu(const GrPrimitiveProcessor& primProc int baseIndex, const GrBuffer* vertexBuffer, int baseVertex, const GrBuffer* instanceBuffer, int instanceCount, int baseInstance) { + if (fRequiresFlushBeforeNextInstancedDraw) { + SkASSERT(this->glCaps().requiresFlushBetweenNonAndInstancedDraws()); + GL_CALL(Flush()); + fRequiresFlushBeforeNextInstancedDraw = false; + } const GrGLenum glPrimType = gr_primitive_type_to_gl_mode(primitiveType); GrGLvoid* indices = reinterpret_cast<void*>(indexBuffer->baseOffset() + sizeof(uint16_t) * baseIndex); diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 4858963271..43df889913 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -628,8 +628,9 @@ private: return (wide ? 0x2 : 0x0) | (tall ? 0x1 : 0x0); } - float fHWMinSampleShading; - GrPrimitiveType fLastPrimitiveType; + float fHWMinSampleShading; + GrPrimitiveType fLastPrimitiveType; + bool fRequiresFlushBeforeNextInstancedDraw = false; typedef GrGpu INHERITED; friend class GrGLPathRendering; // For accessing setTextureUnit. diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp index 54bf0d3700..0d622f5e3d 100644 --- a/src/gpu/gl/GrGLUtil.cpp +++ b/src/gpu/gl/GrGLUtil.cpp @@ -350,17 +350,24 @@ GrGLRenderer GrGLGetRendererFromStrings(const char* rendererString, } int intelNumber; - n = sscanf(rendererString, "Intel(R) Iris(TM) Graphics %d", &intelNumber); - if (1 != n) { - n = sscanf(rendererString, "Intel(R) HD Graphics %d", &intelNumber); - } - if (1 == n) { + if (sscanf(rendererString, "Intel(R) Iris(TM) Graphics %d", &intelNumber) || + sscanf(rendererString, "Intel(R) Iris(TM) Pro Graphics %d", &intelNumber) || + sscanf(rendererString, "Intel(R) Iris(TM) Pro Graphics P%d", &intelNumber) || + sscanf(rendererString, "Intel(R) Iris(R) Graphics %d", &intelNumber) || + sscanf(rendererString, "Intel(R) Iris(R) Pro Graphics %d", &intelNumber) || + sscanf(rendererString, "Intel(R) Iris(R) Pro Graphics P%d", &intelNumber) || + sscanf(rendererString, "Intel(R) HD Graphics %d", &intelNumber) || + sscanf(rendererString, "Intel(R) HD Graphics P%d", &intelNumber)) { + if (intelNumber >= 4000 && intelNumber < 5000) { return kIntel4xxx_GrGLRenderer; } if (intelNumber >= 6000 && intelNumber < 7000) { return kIntel6xxx_GrGLRenderer; } + if (intelNumber >= 500 && intelNumber < 600) { + return kIntelSkylake_GrGLRenderer; + } } // The AMD string can have a somewhat arbitrary preamble (see skbug.com/7195) diff --git a/src/gpu/gl/GrGLUtil.h b/src/gpu/gl/GrGLUtil.h index 5280834de1..96d024d8b8 100644 --- a/src/gpu/gl/GrGLUtil.h +++ b/src/gpu/gl/GrGLUtil.h @@ -61,6 +61,7 @@ enum GrGLRenderer { kIntel4xxx_GrGLRenderer, /** Either HD 6xxx or Iris 6xxx */ kIntel6xxx_GrGLRenderer, + kIntelSkylake_GrGLRenderer, kGalliumLLVM_GrGLRenderer, kMali4xx_GrGLRenderer, /** T-6xx, T-7xx, or T-8xx */ |