aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-06-12 10:24:42 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-12 14:46:20 +0000
commit6d9c88bd6ad28d8869f81131bcc4620f65c222cc (patch)
treec23f311fa6f19134e236e55b32d74537062d7d3b
parentce9514c6cd91c7225ec0d7ccfffd1d964cb1ac6a (diff)
Modify Adreno 3xx workaround to toggle face culling rather than call glFlush.
This fixes some correctness issues introduced by the previous workaround in MSAA gm images. It hopefully improves performance regressions introduced in MSAA benchmarks from calling glFlush. A comment on the workaround is updated to indicate that the original line-drop-out bug was seen on the N5 running driver 127.0. It simply showed up in different GMs that on the N7 running 127.0 Bug: skia:6755 Change-Id: Ief066fd9b223c043a80e7fe07ff13aac07a48970 Reviewed-on: https://skia-review.googlesource.com/19481 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
-rw-r--r--src/gpu/gl/GrGLCaps.cpp10
-rw-r--r--src/gpu/gl/GrGLCaps.h10
-rw-r--r--src/gpu/gl/GrGLGpu.cpp28
3 files changed, 16 insertions, 32 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 867fef32bd..8287580fbe 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -57,7 +57,7 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
fClearTextureSupport = false;
fDrawArraysBaseVertexIsBroken = false;
fUseDrawToClearStencilClip = false;
- fRequiresFlushToDrawLinesAfterNonLines = false;
+ fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines = false;
fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag;
@@ -535,15 +535,13 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
// - A Galaxy J5 (Adreno 306) running Android 6 with driver 140.0
// - A Nexus 7 2013 (Adreno 320) running Android 5 with driver 104.0
// - A Nexus 7 2013 (Adreno 320) running Android 6 with driver 127.0
+ // - A Nexus 5 (Adreno 330) running Android 6 with driver 127.0
// and not produced on:
// - A Nexus 7 2013 (Adreno 320) running Android 4 with driver 53.0
- // - A Nexus 5 (Adreno 330) running Android 6 with driver 127.0
- // The Nexus 5 and Nexus 7 with driver 127.0 had different git hashes in the GL_VERSION string
- // so it seems that either the N5's branch didn't have the bug or the bug affects Adreno 320
- // and 306 but not a 330. Further dissection is left to a future unfortunate soul if necessary.
+ // The particular lines that get dropped from test images varies across different devices.
if (kAdreno3xx_GrGLRenderer == ctxInfo.renderer() && kQualcomm_GrGLDriver == ctxInfo.driver() &&
ctxInfo.driverVersion() > GR_GL_DRIVER_VER(53, 0)) {
- fRequiresFlushToDrawLinesAfterNonLines = true;
+ fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines = true;
}
// Texture uploads sometimes seem to be ignored to textures bound to FBOS on Tegra3.
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 4fb8b7104f..7d81d23481 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -374,10 +374,10 @@ public:
/// op instead of using glClear seems to resolve the issue.
bool useDrawToClearStencilClip() const { return fUseDrawToClearStencilClip; }
- // At least some Adreno 3xx drivers draw lines incorrectly if there is not a flush after
- // non-line draws under some not fully understood circumstances.
- bool requiresFlushToDrawLinesAfterNonLines() const {
- return fRequiresFlushToDrawLinesAfterNonLines;
+ // At least some Adreno 3xx drivers draw lines incorrectly after drawing non-lines. Toggling
+ // face culling on and off seems to resolve this.
+ bool requiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines() const {
+ return fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines;
}
bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
@@ -456,7 +456,7 @@ private:
bool fClearTextureSupport : 1;
bool fDrawArraysBaseVertexIsBroken : 1;
bool fUseDrawToClearStencilClip : 1;
- bool fRequiresFlushToDrawLinesAfterNonLines : 1;
+ bool fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines : 1;
uint32_t fBlitFramebufferFlags;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index aaffcbb33b..a2efeaa047 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2471,8 +2471,14 @@ void GrGLGpu::draw(const GrPipeline& pipeline,
glRT->getViewport(), glRT->origin());
}
}
-
+ if (this->glCaps().requiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines() &&
+ GrIsPrimTypeLines(meshes[i].primitiveType()) &&
+ !GrIsPrimTypeLines(fLastPrimitiveType)) {
+ GL_CALL(Enable(GR_GL_CULL_FACE));
+ GL_CALL(Disable(GR_GL_CULL_FACE));
+ }
meshes[i].sendToGpu(primProc, this);
+ fLastPrimitiveType = meshes[i].primitiveType();
}
#if SWAP_PER_DRAW
@@ -2492,10 +2498,6 @@ void GrGLGpu::draw(const GrPipeline& pipeline,
void GrGLGpu::sendMeshToGpu(const GrPrimitiveProcessor& primProc, GrPrimitiveType primitiveType,
const GrBuffer* vertexBuffer, int vertexCount, int baseVertex) {
const GrGLenum glPrimType = gPrimitiveType2GLMode[primitiveType];
- if (this->glCaps().requiresFlushToDrawLinesAfterNonLines() &&
- GrIsPrimTypeLines(primitiveType) && !GrIsPrimTypeLines(fLastPrimitiveType)) {
- GL_CALL(Flush());
- }
if (this->glCaps().drawArraysBaseVertexIsBroken()) {
this->setupGeometry(primProc, nullptr, vertexBuffer, baseVertex, nullptr, 0);
GL_CALL(DrawArrays(glPrimType, 0, vertexCount));
@@ -2503,7 +2505,6 @@ void GrGLGpu::sendMeshToGpu(const GrPrimitiveProcessor& primProc, GrPrimitiveTyp
this->setupGeometry(primProc, nullptr, vertexBuffer, 0, nullptr, 0);
GL_CALL(DrawArrays(glPrimType, baseVertex, vertexCount));
}
- fLastPrimitiveType = primitiveType;
fStats.incNumDraws();
}
@@ -2512,10 +2513,6 @@ void GrGLGpu::sendIndexedMeshToGpu(const GrPrimitiveProcessor& primProc,
int indexCount, int baseIndex, uint16_t minIndexValue,
uint16_t maxIndexValue, const GrBuffer* vertexBuffer,
int baseVertex) {
- if (this->glCaps().requiresFlushToDrawLinesAfterNonLines() &&
- GrIsPrimTypeLines(primitiveType) && !GrIsPrimTypeLines(fLastPrimitiveType)) {
- GL_CALL(Flush());
- }
const GrGLenum glPrimType = gPrimitiveType2GLMode[primitiveType];
GrGLvoid* const indices = reinterpret_cast<void*>(indexBuffer->baseOffset() +
sizeof(uint16_t) * baseIndex);
@@ -2528,7 +2525,6 @@ void GrGLGpu::sendIndexedMeshToGpu(const GrPrimitiveProcessor& primProc,
} else {
GL_CALL(DrawElements(glPrimType, indexCount, GR_GL_UNSIGNED_SHORT, indices));
}
- fLastPrimitiveType = primitiveType;
fStats.incNumDraws();
}
@@ -2537,14 +2533,9 @@ void GrGLGpu::sendInstancedMeshToGpu(const GrPrimitiveProcessor& primProc, GrPri
int vertexCount, int baseVertex,
const GrBuffer* instanceBuffer, int instanceCount,
int baseInstance) {
- if (this->glCaps().requiresFlushToDrawLinesAfterNonLines() &&
- GrIsPrimTypeLines(primitiveType) && !GrIsPrimTypeLines(fLastPrimitiveType)) {
- GL_CALL(Flush());
- }
const GrGLenum glPrimType = gPrimitiveType2GLMode[primitiveType];
this->setupGeometry(primProc, nullptr, vertexBuffer, 0, instanceBuffer, baseInstance);
GL_CALL(DrawArraysInstanced(glPrimType, baseVertex, vertexCount, instanceCount));
- fLastPrimitiveType = primitiveType;
fStats.incNumDraws();
}
@@ -2554,10 +2545,6 @@ void GrGLGpu::sendIndexedInstancedMeshToGpu(const GrPrimitiveProcessor& primProc
int baseIndex, const GrBuffer* vertexBuffer,
int baseVertex, const GrBuffer* instanceBuffer,
int instanceCount, int baseInstance) {
- if (this->glCaps().requiresFlushToDrawLinesAfterNonLines() &&
- GrIsPrimTypeLines(primitiveType) && !GrIsPrimTypeLines(fLastPrimitiveType)) {
- GL_CALL(Flush());
- }
const GrGLenum glPrimType = gPrimitiveType2GLMode[primitiveType];
GrGLvoid* indices = reinterpret_cast<void*>(indexBuffer->baseOffset() +
sizeof(uint16_t) * baseIndex);
@@ -2565,7 +2552,6 @@ void GrGLGpu::sendIndexedInstancedMeshToGpu(const GrPrimitiveProcessor& primProc
instanceBuffer, baseInstance);
GL_CALL(DrawElementsInstanced(glPrimType, indexCount, GR_GL_UNSIGNED_SHORT, indices,
instanceCount));
- fLastPrimitiveType = primitiveType;
fStats.incNumDraws();
}