Add flag on GrBackendTexture to say whether texture is mipped or not
Bug: skia:
Change-Id: Ia684e3daf779ec2feaaec64c04dabf5cb03cd07a
Reviewed-on: https://skia-review.googlesource.com/57821
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 2119199..1a9bd2f 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -1175,7 +1175,8 @@
GrBackendObject GrVkGpu::createTestingOnlyBackendTexture(void* srcData, int w, int h,
GrPixelConfig config,
- bool isRenderTarget) {
+ bool isRenderTarget,
+ GrMipMapped mipMapped) {
VkFormat pixelFormat;
if (!GrPixelConfigToVkFormat(config, &pixelFormat)) {
@@ -1191,8 +1192,14 @@
return 0;
}
+ // Currently we don't support uploading pixel data when mipped.
+ if (srcData && GrMipMapped::kYes == mipMapped) {
+ return 0;
+ }
+
if (fVkCaps->isConfigTexturableLinearly(config) &&
- (!isRenderTarget || fVkCaps->isConfigRenderableLinearly(config, false))) {
+ (!isRenderTarget || fVkCaps->isConfigRenderableLinearly(config, false)) &&
+ GrMipMapped::kNo == mipMapped) {
linearTiling = true;
}
@@ -1217,6 +1224,12 @@
return 0;
}
+ // Figure out the number of mip levels.
+ uint32_t mipLevels = 1;
+ if (GrMipMapped::kYes == mipMapped) {
+ mipLevels = SkMipMap::ComputeLevelCount(w, h) + 1;
+ }
+
const VkImageCreateInfo imageCreateInfo = {
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
nullptr, // pNext
@@ -1224,7 +1237,7 @@
VK_IMAGE_TYPE_2D, // VkImageType
pixelFormat, // VkFormat
{ (uint32_t) w, (uint32_t) h, 1 }, // VkExtent3D
- 1, // mipLevels
+ mipLevels, // mipLevels
1, // arrayLayers
vkSamples, // samples
imageTiling, // VkImageTiling
@@ -1414,7 +1427,7 @@
info->fImageTiling = imageTiling;
info->fImageLayout = initialLayout;
info->fFormat = pixelFormat;
- info->fLevelCount = 1;
+ info->fLevelCount = mipLevels;
return (GrBackendObject)info;
}