diff options
author | Greg Daniel <egdaniel@google.com> | 2017-04-07 14:42:23 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-07 19:27:14 +0000 |
commit | dd20e918bb3c92a7643a8cbd6760ac66c2694017 (patch) | |
tree | 264e01809dba8ccdb18ff206fa9bfedb5e38913c | |
parent | 149e42ed194e09ed273a131cd25d0d4a4a1fe64b (diff) |
Allow Vulkan to upload to main mip level without uploading to all levels.
It should be allowed for the client to upload original data to a texture via
writePixels and then we just regenerate the mipmaps. I think it also resonable
to limit this to either writting to all levels or just the top level.
Bug: skia:
Change-Id: I66943cca54c2a7187a781788653948fb69c17c68
Reviewed-on: https://skia-review.googlesource.com/11798
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index ed64590c74..b3401e12b6 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -368,7 +368,7 @@ bool GrVkGpu::onWritePixels(GrSurface* surface, } else { int newMipLevels = texels.count(); int currentMipLevels = vkTex->texturePriv().maxMipMapLevel() + 1; - if (newMipLevels != currentMipLevels) { + if (newMipLevels > currentMipLevels) { if (!vkTex->reallocForMipmap(this, newMipLevels)) { return false; } @@ -517,6 +517,10 @@ bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex, SkASSERT(1 == texels.count() || (0 == left && 0 == top && width == tex->width() && height == tex->height())); + // We assume that if the texture has mip levels, we either upload to all the levels or just the + // first. + SkASSERT(1 == texels.count() || texels.count() == (tex->texturePriv().maxMipMapLevel() + 1)); + // If we're uploading compressed data then we should be using uploadCompressedTexData SkASSERT(!GrPixelConfigIsCompressed(dataConfig)); @@ -642,6 +646,9 @@ bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex, regions.count(), regions.begin()); transferBuffer->unref(); + if (1 == texelsShallowCopy.count()) { + tex->texturePriv().dirtyMipMaps(true); + } return true; } |