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>
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index ed64590..b3401e1 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -368,7 +368,7 @@
} 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 @@
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 @@
regions.count(),
regions.begin());
transferBuffer->unref();
+ if (1 == texelsShallowCopy.count()) {
+ tex->texturePriv().dirtyMipMaps(true);
+ }
return true;
}