aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ericrk <ericrk@chromium.org>2016-05-10 14:36:53 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-10 14:36:53 -0700
commit154349b6fff27a19533ae528d43a5b52e4e11d3d (patch)
tree913b84fcfdef2e855d9f753bf54aca7d82a3b29b
parentf077324e1317fe2825c8a7969bf159b4efed2ba5 (diff)
Disable unpack row length when uploading mips
When uploading multiple mip levels, the current path which uses GL_UNPACK_ROW_LENGTH doesn't work (it fails to reset this value, and is set incorrectly for subsequent mip levels). This leads to crashes as the buffer Skia provides to GL is not sized correctly. This change temporarily disables the GL_UNPACK_ROW_LENGTH path when we are uploading mips. This path was an optimization, so everything should continue working as expected. This is a temporary workaround until we can re-structure the code to set GL_UNPACK_ROW_LENGTH per mip level. BUG=609612 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1965973002 Review-Url: https://codereview.chromium.org/1965973002
-rw-r--r--src/gpu/gl/GrGLGpu.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 8c5951dbdc..6b03df3e10 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1278,7 +1278,12 @@ bool GrGLGpu::uploadTexData(const GrSurfaceDesc& desc,
restoreGLRowLength = false;
const size_t rowBytes = texelsShallowCopy[currentMipLevel].fRowBytes;
- if (caps.unpackRowLengthSupport() && !swFlipY) {
+
+ // TODO: This optimization should be enabled with or without mips.
+ // For use with mips, we must set GR_GL_UNPACK_ROW_LENGTH once per
+ // mip level, before calling glTexImage2D.
+ const bool usesMips = texelsShallowCopy.count() > 1;
+ if (caps.unpackRowLengthSupport() && !swFlipY && !usesMips) {
// can't use this for flipping, only non-neg values allowed. :(
if (rowBytes != trimRowBytes) {
GrGLint rowLength = static_cast<GrGLint>(rowBytes / bpp);