Dest color space no longer impacts mipmaps or texture sampling
PS5: Removes SkDestinationSurfaceColorMode, tracking of mipmap
mode on GrTexture, sRGB decode state per-texture. Because we
were often choosing sRGB configs for RGB color types, legacy
rendering would then be incorrect (too dark). So...
PS7: Stops ever using sRGB pixel configs when translating
image info or color type. Also removes a bunch of GrCaps bits
and a GrContextOption that are no longer relevant.
PS9: Adjusts surface creation unit test expectations, and
changes the raster rules accordingly.
At this point, sRGB configs are (obviously) going to be broken.
Locally, I ran 8888, gl, and the gbr- versions of both. Across
all GMs x configs, there are 13 diffs. 12 are GMs that create
surfaces with a color-space attached (and thus, the offscreen
is no longer getting sRGB pixel config). The only remainder
constructs an SkPictureImageGenerator, (with an attached color
space) and renders it to the gbr-gl canvas, which triggers a
a tagged surface inside the generator.
Bug: skia:
Change-Id: Ie5edfa157dd799f3121e8173fc4f97f6c8ed6789
Reviewed-on: https://skia-review.googlesource.com/131282
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 76a1417..602e9e1 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -29,7 +29,6 @@
**************************************************************************/
fMipMapSupport = true; // always available in Vulkan
fSRGBSupport = true; // always available in Vulkan
- fSRGBDecodeDisableSupport = true; // always available in Vulkan
fNPOTTextureTileSupport = true; // always available in Vulkan
fDiscardRenderTargetSupport = true;
fReuseScratchTextures = true; //TODO: figure this out
@@ -477,15 +476,13 @@
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
VK_IMAGE_USAGE_SAMPLED_BIT |
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
- VkImageCreateFlags createFlags = GrVkFormatIsSRGB(format, nullptr)
- ? VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT : 0;
VkImageFormatProperties properties;
GR_VK_CALL(interface, GetPhysicalDeviceImageFormatProperties(physDev,
format,
VK_IMAGE_TYPE_2D,
VK_IMAGE_TILING_OPTIMAL,
usage,
- createFlags,
+ 0, // createFlags
&properties));
VkSampleCountFlags flags = properties.sampleCounts;
if (flags & VK_SAMPLE_COUNT_1_BIT) {
diff --git a/src/gpu/vk/GrVkCopyManager.cpp b/src/gpu/vk/GrVkCopyManager.cpp
index c105922..28ca8b4 100644
--- a/src/gpu/vk/GrVkCopyManager.cpp
+++ b/src/gpu/vk/GrVkCopyManager.cpp
@@ -262,7 +262,7 @@
VkDescriptorImageInfo imageInfo;
memset(&imageInfo, 0, sizeof(VkDescriptorImageInfo));
imageInfo.sampler = sampler->sampler();
- imageInfo.imageView = srcTex->textureView(true)->imageView();
+ imageInfo.imageView = srcTex->textureView()->imageView();
imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
VkWriteDescriptorSet writeInfo;
@@ -353,7 +353,7 @@
// One sampler, texture view, and texture
SkSTArray<3, const GrVkResource*> descriptorResources;
descriptorResources.push_back(sampler);
- descriptorResources.push_back(srcTex->textureView(true));
+ descriptorResources.push_back(srcTex->textureView());
descriptorResources.push_back(srcTex->resource());
cmdBuffer->bindDescriptorSets(gpu,
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 2525c5c..772a92f 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -1213,14 +1213,10 @@
mipLevels = SkMipMap::ComputeLevelCount(w, h) + 1;
}
- // sRGB format images may need to be aliased to linear for various reasons (legacy mode):
- VkImageCreateFlags createFlags = GrVkFormatIsSRGB(pixelFormat, nullptr)
- ? VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT : 0;
-
const VkImageCreateInfo imageCreateInfo = {
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
nullptr, // pNext
- createFlags, // VkImageCreateFlags
+ 0, // VkImageCreateFlags
VK_IMAGE_TYPE_2D, // VkImageType
pixelFormat, // VkFormat
{(uint32_t)w, (uint32_t)h, 1}, // VkExtent3D
diff --git a/src/gpu/vk/GrVkImage.cpp b/src/gpu/vk/GrVkImage.cpp
index 9480a7b..a99134b 100644
--- a/src/gpu/vk/GrVkImage.cpp
+++ b/src/gpu/vk/GrVkImage.cpp
@@ -136,14 +136,10 @@
SkASSERT(VK_IMAGE_TILING_OPTIMAL == imageDesc.fImageTiling ||
VK_SAMPLE_COUNT_1_BIT == vkSamples);
- // sRGB format images may need to be aliased to linear for various reasons (legacy mode):
- VkImageCreateFlags createFlags = GrVkFormatIsSRGB(imageDesc.fFormat, nullptr)
- ? VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT : 0;
-
const VkImageCreateInfo imageCreateInfo = {
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
nullptr, // pNext
- createFlags, // VkImageCreateFlags
+ 0, // VkImageCreateFlags
imageDesc.fImageType, // VkImageType
imageDesc.fFormat, // VkFormat
{ imageDesc.fWidth, imageDesc.fHeight, 1 }, // VkExtent3D
diff --git a/src/gpu/vk/GrVkPipelineState.cpp b/src/gpu/vk/GrVkPipelineState.cpp
index 10e757e..5d4189f 100644
--- a/src/gpu/vk/GrVkPipelineState.cpp
+++ b/src/gpu/vk/GrVkPipelineState.cpp
@@ -281,7 +281,7 @@
fSamplerDescriptorSet = gpu->resourceProvider().getSamplerDescriptorSet(fSamplerDSHandle);
int samplerDSIdx = GrVkUniformHandler::kSamplerDescSet;
fDescriptorSets[samplerDSIdx] = fSamplerDescriptorSet->descriptorSet();
- this->writeSamplers(gpu, textureBindings, pipeline.getAllowSRGBInputs());
+ this->writeSamplers(gpu, textureBindings);
}
if (fNumTexelBuffers) {
@@ -372,8 +372,7 @@
void GrVkPipelineState::writeSamplers(
GrVkGpu* gpu,
- const SkTArray<const GrResourceIOProcessor::TextureSampler*>& textureBindings,
- bool allowSRGBInputs) {
+ const SkTArray<const GrResourceIOProcessor::TextureSampler*>& textureBindings) {
SkASSERT(fNumSamplers == textureBindings.count());
for (int i = 0; i < textureBindings.count(); ++i) {
@@ -388,7 +387,7 @@
textureResource->ref();
fTextures.push(textureResource);
- const GrVkImageView* textureView = texture->textureView(allowSRGBInputs);
+ const GrVkImageView* textureView = texture->textureView();
textureView->ref();
fTextureViews.push(textureView);
diff --git a/src/gpu/vk/GrVkPipelineState.h b/src/gpu/vk/GrVkPipelineState.h
index 2794b99..4ccd1d6 100644
--- a/src/gpu/vk/GrVkPipelineState.h
+++ b/src/gpu/vk/GrVkPipelineState.h
@@ -108,8 +108,7 @@
void writeSamplers(
GrVkGpu* gpu,
- const SkTArray<const GrResourceIOProcessor::TextureSampler*>& textureBindings,
- bool allowSRGBInputs);
+ const SkTArray<const GrResourceIOProcessor::TextureSampler*>& textureBindings);
void writeTexelBuffers(
GrVkGpu* gpu,
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index 116b37e..c4c7a8f 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -34,8 +34,7 @@
, GrVkImage(info, std::move(layout), GrBackendObjectOwnership::kOwned)
, INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig),
mipMapsStatus)
- , fTextureView(view)
- , fLinearTextureView(nullptr) {
+ , fTextureView(view) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == info.fLevelCount));
this->registerWithCache(budgeted);
}
@@ -52,8 +51,7 @@
, GrVkImage(info, std::move(layout), ownership)
, INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig),
mipMapsStatus)
- , fTextureView(view)
- , fLinearTextureView(nullptr) {
+ , fTextureView(view) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == info.fLevelCount));
this->registerWithCacheWrapped();
}
@@ -70,8 +68,7 @@
, GrVkImage(info, layout, ownership)
, INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig),
mipMapsStatus)
- , fTextureView(view)
- , fLinearTextureView(nullptr) {
+ , fTextureView(view) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == info.fLevelCount));
}
@@ -126,7 +123,6 @@
GrVkTexture::~GrVkTexture() {
// either release or abandon should have been called by the owner of this object.
SkASSERT(!fTextureView);
- SkASSERT(!fLinearTextureView);
}
void GrVkTexture::onRelease() {
@@ -136,11 +132,6 @@
fTextureView = nullptr;
}
- if (fLinearTextureView) {
- fLinearTextureView->unref(this->getVkGpu());
- fLinearTextureView = nullptr;
- }
-
this->releaseImage(this->getVkGpu());
INHERITED::onRelease();
@@ -152,11 +143,6 @@
fTextureView = nullptr;
}
- if (fLinearTextureView) {
- fLinearTextureView->unrefAndAbandon();
- fLinearTextureView = nullptr;
- }
-
this->abandonImage();
INHERITED::onAbandon();
}
@@ -170,20 +156,8 @@
return static_cast<GrVkGpu*>(this->getGpu());
}
-const GrVkImageView* GrVkTexture::textureView(bool allowSRGB) {
- VkFormat linearFormat;
- if (allowSRGB || !GrVkFormatIsSRGB(fInfo.fFormat, &linearFormat)) {
- return fTextureView;
- }
-
- if (!fLinearTextureView) {
- fLinearTextureView = GrVkImageView::Create(this->getVkGpu(), fInfo.fImage,
- linearFormat, GrVkImageView::kColor_Type,
- fInfo.fLevelCount);
- SkASSERT(fLinearTextureView);
- }
-
- return fLinearTextureView;
+const GrVkImageView* GrVkTexture::textureView() {
+ return fTextureView;
}
bool GrVkTexture::reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels) {
@@ -243,10 +217,6 @@
oldResource->unref(gpu);
oldView->unref(gpu);
- if (fLinearTextureView) {
- fLinearTextureView->unref(gpu);
- fLinearTextureView = nullptr;
- }
this->setNewResource(info.fImage, info.fAlloc, info.fImageTiling);
fTextureView = textureView;
diff --git a/src/gpu/vk/GrVkTexture.h b/src/gpu/vk/GrVkTexture.h
index 55239e3..91ed671 100644
--- a/src/gpu/vk/GrVkTexture.h
+++ b/src/gpu/vk/GrVkTexture.h
@@ -33,7 +33,7 @@
void textureParamsModified() override {}
- const GrVkImageView* textureView(bool allowSRGB);
+ const GrVkImageView* textureView();
bool reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels);
@@ -67,7 +67,6 @@
GrBackendObjectOwnership);
const GrVkImageView* fTextureView;
- const GrVkImageView* fLinearTextureView;
typedef GrTexture INHERITED;
};
diff --git a/src/gpu/vk/GrVkUtil.cpp b/src/gpu/vk/GrVkUtil.cpp
index e61d7bc..2b0bba7 100644
--- a/src/gpu/vk/GrVkUtil.cpp
+++ b/src/gpu/vk/GrVkUtil.cpp
@@ -167,105 +167,6 @@
}
}
-bool GrVkFormatIsSRGB(VkFormat format, VkFormat* linearFormat) {
- VkFormat linearFmt = format;
- switch (format) {
- case VK_FORMAT_R8_SRGB:
- linearFmt = VK_FORMAT_R8_UNORM;
- break;
- case VK_FORMAT_R8G8_SRGB:
- linearFmt = VK_FORMAT_R8G8_UNORM;
- break;
- case VK_FORMAT_R8G8B8_SRGB:
- linearFmt = VK_FORMAT_R8G8B8_UNORM;
- break;
- case VK_FORMAT_B8G8R8_SRGB:
- linearFmt = VK_FORMAT_B8G8R8_UNORM;
- break;
- case VK_FORMAT_R8G8B8A8_SRGB:
- linearFmt = VK_FORMAT_R8G8B8A8_UNORM;
- break;
- case VK_FORMAT_B8G8R8A8_SRGB:
- linearFmt = VK_FORMAT_B8G8R8A8_UNORM;
- break;
- case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
- linearFmt = VK_FORMAT_A8B8G8R8_UNORM_PACK32;
- break;
- case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
- linearFmt = VK_FORMAT_BC1_RGB_UNORM_BLOCK;
- break;
- case VK_FORMAT_BC1_RGBA_SRGB_BLOCK:
- linearFmt = VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
- break;
- case VK_FORMAT_BC2_SRGB_BLOCK:
- linearFmt = VK_FORMAT_BC2_UNORM_BLOCK;
- break;
- case VK_FORMAT_BC3_SRGB_BLOCK:
- linearFmt = VK_FORMAT_BC3_UNORM_BLOCK;
- break;
- case VK_FORMAT_BC7_SRGB_BLOCK:
- linearFmt = VK_FORMAT_BC7_UNORM_BLOCK;
- break;
- case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
- break;
- case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK;
- break;
- case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_4x4_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_4x4_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_5x4_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_5x4_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_5x5_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_5x5_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_6x5_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_6x5_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_6x6_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_6x6_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_8x5_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_8x5_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_8x6_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_8x6_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_8x8_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_8x8_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_10x5_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_10x5_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_10x6_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_10x6_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_10x8_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_10x8_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_10x10_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_10x10_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_12x10_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_12x10_UNORM_BLOCK;
- break;
- case VK_FORMAT_ASTC_12x12_SRGB_BLOCK:
- linearFmt = VK_FORMAT_ASTC_12x12_UNORM_BLOCK;
- break;
- default:
- break;
- }
- if (linearFormat) {
- *linearFormat = linearFmt;
- }
- return (linearFmt != format);
-}
-
bool GrSampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits* vkSamples) {
SkASSERT(samples >= 1);
switch (samples) {
diff --git a/src/gpu/vk/GrVkUtil.h b/src/gpu/vk/GrVkUtil.h
index 01688c8..08eef1a 100644
--- a/src/gpu/vk/GrVkUtil.h
+++ b/src/gpu/vk/GrVkUtil.h
@@ -44,12 +44,6 @@
*/
bool GrVkFormatPixelConfigPairIsValid(VkFormat, GrPixelConfig);
-/**
- * Returns true if the given vulkan texture format is sRGB encoded.
- * Also provides the non-sRGB version, if there is one.
- */
-bool GrVkFormatIsSRGB(VkFormat format, VkFormat* linearFormat);
-
bool GrSampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits* vkSamples);
bool GrCompileVkShaderModule(const GrVkGpu* gpu,