Remove use of GrColorType on GrCaps::getRenderTargetSampleCount.
Additionally this changes removes the version of the call that that takes
a GrPixelConfig.
As part of this change many call sites that were calling getRTSampleCount
to just check renderability have been changed to call
isFormat[AsColorType]Renderable instead. This change has also started to
move us to just checking format renderability (without GrCT) in classes
that are specifically dealing with GrSurface (GrResourceProvider, GrGpu, etc.).
Bug: skia:6718
Change-Id: Icf4a1a21a81a44e6863a7cd2059d21b9833d581f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/233039
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index 037d72b..2ccfdfd 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -280,9 +280,10 @@
return this->onCanCopySurface(dst, src, srcRect, dstPoint);
}
-bool GrCaps::validateSurfaceDesc(const GrSurfaceDesc& desc, GrRenderable renderable,
- int renderTargetSampleCnt, GrMipMapped mipped) const {
- if (!this->isConfigTexturable(desc.fConfig)) {
+bool GrCaps::validateSurfaceParams(const SkISize& size, const GrBackendFormat& format,
+ GrPixelConfig config, GrRenderable renderable,
+ int renderTargetSampleCnt, GrMipMapped mipped) const {
+ if (!this->isConfigTexturable(config)) {
return false;
}
@@ -290,16 +291,16 @@
return false;
}
- if (desc.fWidth < 1 || desc.fHeight < 1) {
+ if (size.width() < 1 || size.height() < 1) {
return false;
}
if (renderable == GrRenderable::kYes) {
- if (0 == this->getRenderTargetSampleCount(renderTargetSampleCnt, desc.fConfig)) {
+ if (!this->isFormatRenderable(format, renderTargetSampleCnt)) {
return false;
}
int maxRTSize = this->maxRenderTargetSize();
- if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) {
+ if (size.width() > maxRTSize || size.height() > maxRTSize) {
return false;
}
} else {
@@ -308,7 +309,7 @@
return false;
}
int maxSize = this->maxTextureSize();
- if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
+ if (size.width() > maxSize || size.height() > maxSize) {
return false;
}
}
diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h
index 1d974fe..5183a55 100644
--- a/src/gpu/GrCaps.h
+++ b/src/gpu/GrCaps.h
@@ -182,12 +182,10 @@
virtual bool isFormatRenderable(const GrBackendFormat& format, int sampleCount) const = 0;
// Find a sample count greater than or equal to the requested count which is supported for a
- // color buffer of the given config or 0 if no such sample count is supported. If the requested
+ // render target of the given format or 0 if no such sample count is supported. If the requested
// sample count is 1 then 1 will be returned if non-MSAA rendering is supported, otherwise 0.
// For historical reasons requestedCount==0 is handled identically to requestedCount==1.
- virtual int getRenderTargetSampleCount(int requestedCount,
- GrColorType, const GrBackendFormat&) const = 0;
- virtual int getRenderTargetSampleCount(int requestedCount, GrPixelConfig) const = 0;
+ virtual int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat&) const = 0;
/**
* Backends may have restrictions on what types of surfaces support GrGpu::writePixels().
@@ -362,8 +360,9 @@
return {};
}
- bool validateSurfaceDesc(const GrSurfaceDesc&, GrRenderable renderable,
- int renderTargetSampleCnt, GrMipMapped) const;
+ bool validateSurfaceParams(const SkISize&, const GrBackendFormat&, GrPixelConfig,
+ GrRenderable renderable, int renderTargetSampleCnt,
+ GrMipMapped) const;
bool areColorTypeAndFormatCompatible(GrColorType grCT,
const GrBackendFormat& format) const {
diff --git a/src/gpu/GrContextThreadSafeProxy.cpp b/src/gpu/GrContextThreadSafeProxy.cpp
index 5b00895..7ad6fb3 100644
--- a/src/gpu/GrContextThreadSafeProxy.cpp
+++ b/src/gpu/GrContextThreadSafeProxy.cpp
@@ -64,11 +64,13 @@
return SkSurfaceCharacterization(); // return an invalid characterization
}
- sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, grColorType, backendFormat);
- if (!sampleCnt) {
+ if (!this->caps()->isFormatAsColorTypeRenderable(grColorType, backendFormat, sampleCnt)) {
return SkSurfaceCharacterization(); // return an invalid characterization
}
+ sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, backendFormat);
+ SkASSERT(sampleCnt);
+
if (willUseGLFBO0 && isTextureable) {
return SkSurfaceCharacterization(); // return an invalid characterization
}
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 6130312..8c161fe 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -156,13 +156,14 @@
GrSurfaceDesc desc = origDesc;
GrMipMapped mipMapped = mipLevelCount > 1 ? GrMipMapped::kYes : GrMipMapped::kNo;
- if (!this->caps()->validateSurfaceDesc(desc, renderable, renderTargetSampleCnt, mipMapped)) {
+ if (!this->caps()->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, desc.fConfig,
+ renderable, renderTargetSampleCnt, mipMapped)) {
return nullptr;
}
if (renderable == GrRenderable::kYes) {
renderTargetSampleCnt =
- this->caps()->getRenderTargetSampleCount(renderTargetSampleCnt, desc.fConfig);
+ this->caps()->getRenderTargetSampleCount(renderTargetSampleCnt, format);
}
// Attempt to catch un- or wrongly initialized sample counts.
SkASSERT(renderTargetSampleCnt > 0 && renderTargetSampleCnt <= 64);
@@ -260,7 +261,7 @@
const GrCaps* caps = this->caps();
if (!caps->isFormatTexturable(colorType, backendTex.getBackendFormat()) ||
- !caps->getRenderTargetSampleCount(sampleCnt, colorType, backendTex.getBackendFormat())) {
+ !caps->isFormatRenderable(backendTex.getBackendFormat(), sampleCnt)) {
return nullptr;
}
@@ -280,8 +281,7 @@
const GrCaps* caps = this->caps();
- if (0 == caps->getRenderTargetSampleCount(backendRT.sampleCnt(), colorType,
- backendRT.getBackendFormat())) {
+ if (!caps->isFormatRenderable(backendRT.getBackendFormat(), backendRT.sampleCnt())) {
return nullptr;
}
@@ -300,8 +300,7 @@
return nullptr;
}
- if (0 == caps->getRenderTargetSampleCount(sampleCnt, colorType,
- backendTex.getBackendFormat())) {
+ if (!caps->isFormatRenderable(backendTex.getBackendFormat(), sampleCnt)) {
return nullptr;
}
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index f64b345..65d6ee2 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -277,7 +277,7 @@
}
if (renderable == GrRenderable::kYes) {
- sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, grCT, format);
+ sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, format);
if (!sampleCnt) {
return nullptr;
}
@@ -499,7 +499,8 @@
}
}
- if (!caps->validateSurfaceDesc(desc, renderable, renderTargetSampleCnt, mipMapped)) {
+ if (!caps->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, desc.fConfig, renderable,
+ renderTargetSampleCnt, mipMapped)) {
return nullptr;
}
GrSurfaceDesc copyDesc = desc;
@@ -509,7 +510,8 @@
GrSwizzle texSwizzle = caps->getTextureSwizzle(format, colorType);
if (renderable == GrRenderable::kYes) {
renderTargetSampleCnt =
- caps->getRenderTargetSampleCount(renderTargetSampleCnt, colorType, format);
+ caps->getRenderTargetSampleCount(renderTargetSampleCnt, format);
+ SkASSERT(renderTargetSampleCnt);
// We know anything we instantiate later from this deferred path will be
// both texturable and renderable
GrSwizzle outSwizzle = caps->getOutputSwizzle(format, colorType);
@@ -629,12 +631,14 @@
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
- sampleCnt = caps->getRenderTargetSampleCount(sampleCnt, colorType,
- backendTex.getBackendFormat());
- if (!sampleCnt) {
+ // TODO: This should have been checked and validated before getting into GrProxyProvider.
+ if (!caps->isFormatAsColorTypeRenderable(colorType, backendTex.getBackendFormat(), sampleCnt)) {
return nullptr;
}
+ sampleCnt = caps->getRenderTargetSampleCount(sampleCnt, backendTex.getBackendFormat());
+ SkASSERT(sampleCnt);
+
sk_sp<GrTexture> tex = resourceProvider->wrapRenderableBackendTexture(backendTex, sampleCnt,
colorType, ownership,
cacheable);
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 2413c64..cff3fcf 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -91,7 +91,8 @@
}
GrMipMapped mipMapped = mipLevelCount > 1 ? GrMipMapped::kYes : GrMipMapped::kNo;
- if (!fCaps->validateSurfaceDesc(desc, renderable, renderTargetSampleCnt, mipMapped)) {
+ if (!fCaps->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, desc.fConfig, renderable,
+ renderTargetSampleCnt, mipMapped)) {
return nullptr;
}
bool mustInitializeAllLevels = this->caps()->createTextureMustSpecifyAllLevels();
@@ -152,7 +153,8 @@
return nullptr;
}
- if (!fCaps->validateSurfaceDesc(desc, renderable, renderTargetSampleCnt, GrMipMapped::kNo)) {
+ if (!fCaps->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, desc.fConfig, renderable,
+ renderTargetSampleCnt, GrMipMapped::kNo)) {
return nullptr;
}
@@ -222,7 +224,8 @@
return nullptr;
}
- if (!fCaps->validateSurfaceDesc(desc, renderable, renderTargetSampleCnt, GrMipMapped::kNo)) {
+ if (!fCaps->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, desc.fConfig, renderable,
+ renderTargetSampleCnt, GrMipMapped::kNo)) {
return nullptr;
}
@@ -294,7 +297,8 @@
return nullptr;
}
- if (!fCaps->validateSurfaceDesc(desc, renderable, renderTargetSampleCnt, GrMipMapped::kNo)) {
+ if (!fCaps->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, desc.fConfig, renderable,
+ renderTargetSampleCnt, GrMipMapped::kNo)) {
return nullptr;
}
@@ -340,7 +344,8 @@
ASSERT_SINGLE_OWNER
SkASSERT(!this->isAbandoned());
SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
- SkASSERT(fCaps->validateSurfaceDesc(desc, renderable, renderTargetSampleCnt, GrMipMapped::kNo));
+ SkASSERT(fCaps->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, desc.fConfig,
+ renderable, renderTargetSampleCnt, GrMipMapped::kNo));
// We could make initial clears work with scratch textures but it is a rare case so we just opt
// to fall back to making a new texture.
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 1e1a95e..8c8bc55 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -3807,12 +3807,8 @@
return this->isFormatRenderable(glFormat, sampleCount);
}
-int GrGLCaps::getRenderTargetSampleCount(int requestedCount, GrColorType grCT,
- GrGLFormat format) const {
+int GrGLCaps::getRenderTargetSampleCount(int requestedCount, GrGLFormat format) const {
const FormatInfo& info = this->getFormatInfo(format);
- if (!SkToBool(info.colorTypeFlags(grCT) & ColorTypeInfo::kRenderable_Flag)) {
- return 0;
- }
int count = info.fColorSampleCounts.count();
if (!count) {
@@ -3834,7 +3830,6 @@
}
}
return 0;
-
}
int GrGLCaps::maxRenderTargetSampleCount(GrGLFormat format) const {
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 164a63a..5dc04c8 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -127,17 +127,12 @@
return sampleCount <= this->maxRenderTargetSampleCount(format);
}
- int getRenderTargetSampleCount(int requestedCount, GrColorType ct,
+ int getRenderTargetSampleCount(int requestedCount,
const GrBackendFormat& format) const override {
- return this->getRenderTargetSampleCount(requestedCount, ct,
+ return this->getRenderTargetSampleCount(requestedCount,
GrGLBackendFormatToGLFormat(format));
}
- int getRenderTargetSampleCount(int requestedCount, GrPixelConfig config) const override {
- GrColorType ct = GrPixelConfigToColorType(config);
- auto format = this->pixelConfigToFormat(config);
- return this->getRenderTargetSampleCount(requestedCount, ct, format);
-
- }
+ int getRenderTargetSampleCount(int requestedCount, GrGLFormat) const;
int maxRenderTargetSampleCount(const GrBackendFormat& format) const override {
return this->maxRenderTargetSampleCount(GrGLBackendFormatToGLFormat(format));
@@ -516,8 +511,6 @@
SupportedRead onSupportedReadPixelsColorType(GrColorType, const GrBackendFormat&,
GrColorType) const override;
- int getRenderTargetSampleCount(int requestedCount, GrColorType, GrGLFormat) const;
-
GrGLStandard fStandard;
SkTArray<StencilFormat, true> fStencilFormats;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index b22fde2..6e586ab 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -733,19 +733,21 @@
return nullptr;
}
+ const GrGLCaps& caps = this->glCaps();
+
+ if (!caps.isFormatRenderable(desc.fFormat, sampleCnt)) {
+ return nullptr;
+ }
+
if (kBorrow_GrWrapOwnership == ownership) {
desc.fOwnership = GrBackendObjectOwnership::kBorrowed;
} else {
desc.fOwnership = GrBackendObjectOwnership::kOwned;
}
- const GrCaps* caps = this->caps();
- sampleCnt =
- caps->getRenderTargetSampleCount(sampleCnt, colorType, backendTex.getBackendFormat());
- if (sampleCnt < 1) {
- return nullptr;
- }
+ sampleCnt = caps.getRenderTargetSampleCount(sampleCnt, desc.fFormat);
+ SkASSERT(sampleCnt);
GrGLRenderTarget::IDs rtIDs;
if (!this->createRenderTargetObjects(desc, sampleCnt, &rtIDs)) {
@@ -776,6 +778,11 @@
return nullptr;
}
+ GrGLFormat format = GrGLFormatFromGLEnum(info.fFormat);
+ if (!this->glCaps().isFormatRenderable(format, backendRT.sampleCnt())) {
+ return nullptr;
+ }
+
GrGLRenderTarget::IDs rtIDs;
rtIDs.fRTFBOID = info.fFBOID;
rtIDs.fMSColorRenderbufferID = 0;
@@ -784,14 +791,9 @@
GrPixelConfig config = this->caps()->getConfigFromBackendFormat(backendRT.getBackendFormat(),
grColorType);
- const auto format = GrGLBackendFormatToGLFormat(backendRT.getBackendFormat());
-
- SkASSERT(kUnknown_GrPixelConfig != config);
const auto size = SkISize::Make(backendRT.width(), backendRT.height());
- int sampleCount =
- this->caps()->getRenderTargetSampleCount(backendRT.sampleCnt(), grColorType,
- backendRT.getBackendFormat());
+ int sampleCount = this->glCaps().getRenderTargetSampleCount(backendRT.sampleCnt(), format);
return GrGLRenderTarget::MakeWrapped(this, size, format, config, sampleCount, rtIDs,
backendRT.stencilBits());
@@ -806,8 +808,12 @@
if (!check_backend_texture(tex, colorType, this->glCaps(), &desc, true)) {
return nullptr;
}
- const int sampleCount =
- this->caps()->getRenderTargetSampleCount(sampleCnt, colorType, tex.getBackendFormat());
+
+ if (!this->glCaps().isFormatRenderable(desc.fFormat, sampleCnt)) {
+ return nullptr;
+ }
+
+ const int sampleCount = this->glCaps().getRenderTargetSampleCount(sampleCnt, desc.fFormat);
GrGLRenderTarget::IDs rtIDs;
if (!this->createRenderTargetObjects(desc, sampleCount, &rtIDs)) {
return nullptr;
diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h
index 61971bc..a34cdb4 100644
--- a/src/gpu/mock/GrMockCaps.h
+++ b/src/gpu/mock/GrMockCaps.h
@@ -100,18 +100,13 @@
}
int getRenderTargetSampleCount(int requestCount,
- GrColorType, const GrBackendFormat& format) const override {
+ const GrBackendFormat& format) const override {
if (!format.getMockColorType()) {
return 0;
}
return this->getRenderTargetSampleCount(requestCount, *format.getMockColorType());
}
- int getRenderTargetSampleCount(int requestCount, GrPixelConfig config) const override {
- GrColorType ct = GrPixelConfigToColorType(config);
- return this->getRenderTargetSampleCount(requestCount, ct);
- }
-
int maxRenderTargetSampleCount(GrColorType ct) const {
switch (fOptions.fConfigOptions[(int)ct].fRenderability) {
case GrMockOptions::ConfigOptions::Renderability::kNo:
diff --git a/src/gpu/mtl/GrMtlCaps.h b/src/gpu/mtl/GrMtlCaps.h
index f5a5d32..c12c3c3 100644
--- a/src/gpu/mtl/GrMtlCaps.h
+++ b/src/gpu/mtl/GrMtlCaps.h
@@ -40,9 +40,7 @@
bool isFormatRenderable(const GrBackendFormat& format, int sampleCount) const override;
bool isFormatRenderable(MTLPixelFormat, int sampleCount) const;
- int getRenderTargetSampleCount(int requestedCount,
- GrColorType, const GrBackendFormat&) const override;
- int getRenderTargetSampleCount(int requestedCount, GrPixelConfig) const override;
+ int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat&) const override;
int getRenderTargetSampleCount(int requestedCount, MTLPixelFormat) const;
int maxRenderTargetSampleCount(const GrBackendFormat&) const override;
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index 3b2a496..8e145ab 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -368,40 +368,16 @@
return 0;
}
-int GrMtlCaps::getRenderTargetSampleCount(int requestedCount, GrColorType grColorType,
+int GrMtlCaps::getRenderTargetSampleCount(int requestedCount,
const GrBackendFormat& format) const {
if (!format.getMtlFormat()) {
return 0;
}
- // Currently we don't allow RGB_888X to be renderable because we don't have a way to
- // handle blends that reference dst alpha when the values in the dst alpha channel are
- // uninitialized. We also don't support rendering to Gray_8.
- if (GrColorType::kRGB_888x == grColorType || GrColorType::kGray_8 == grColorType) {
- return 0;
- }
-
MTLPixelFormat mtlFormat = static_cast<MTLPixelFormat>(*format.getMtlFormat());
return this->getRenderTargetSampleCount(requestedCount, mtlFormat);
}
-int GrMtlCaps::getRenderTargetSampleCount(int requestedCount, GrPixelConfig config) const {
- // Currently we don't allow RGB_888X to be renderable because we don't have a way to
- // handle blends that reference dst alpha when the values in the dst alpha channel are
- // uninitialized. We also don't support rendering to Gray_8.
- if (config == kRGB_888X_GrPixelConfig ||
- config == kGray_8_GrPixelConfig ||
- config == kGray_8_as_Red_GrPixelConfig) {
- return 0;
- }
-
- MTLPixelFormat format;
- if (!GrPixelConfigToMTLFormat(config, &format)) {
- return 0;
- }
- return this->getRenderTargetSampleCount(requestedCount, format);
-}
-
int GrMtlCaps::getRenderTargetSampleCount(int requestedCount, MTLPixelFormat format) const {
requestedCount = SkTMax(requestedCount, 1);
const FormatInfo& formatInfo = this->getFormatInfo(format);
diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm
index 2d567bd..f459c64 100644
--- a/src/gpu/mtl/GrMtlGpu.mm
+++ b/src/gpu/mtl/GrMtlGpu.mm
@@ -533,20 +533,22 @@
return nullptr;
}
- const GrCaps* caps = this->caps();
+ const GrMtlCaps& caps = this->mtlCaps();
- GrPixelConfig config = caps->getConfigFromBackendFormat(backendTex.getBackendFormat(),
- colorType);
+ MTLPixelFormat format = mtlTexture.pixelFormat;
+ if (!caps.isFormatRenderable(format, sampleCnt)) {
+ return nullptr;
+ }
+
+ GrPixelConfig config = caps.getConfigFromBackendFormat(backendTex.getBackendFormat(),
+ colorType);
SkASSERT(kUnknown_GrPixelConfig != config);
GrSurfaceDesc surfDesc;
init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kYes, config);
- sampleCnt = caps->getRenderTargetSampleCount(sampleCnt, colorType,
- backendTex.getBackendFormat());
- if (!sampleCnt) {
- return nullptr;
- }
+ sampleCnt = caps.getRenderTargetSampleCount(sampleCnt, format);
+ SkASSERT(sampleCnt);
return GrMtlTextureRenderTarget::MakeWrappedTextureRenderTarget(this, surfDesc, sampleCnt,
mtlTexture, cacheable);
@@ -581,14 +583,18 @@
return nullptr;
}
+ MTLPixelFormat format = mtlTexture.pixelFormat;
+ if (!this->mtlCaps().isFormatRenderable(format, sampleCnt)) {
+ return nullptr;
+ }
+
GrPixelConfig config = this->caps()->getConfigFromBackendFormat(backendTex.getBackendFormat(),
grColorType);
SkASSERT(kUnknown_GrPixelConfig != config);
GrSurfaceDesc surfDesc;
init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kYes, config);
- sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, grColorType,
- backendTex.getBackendFormat());
+ sampleCnt = this->mtlCaps().getRenderTargetSampleCount(sampleCnt, format);
if (!sampleCnt) {
return nullptr;
}
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index d37c046..3368c90 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -1130,7 +1130,6 @@
}
int GrVkCaps::getRenderTargetSampleCount(int requestedCount,
- GrColorType colorType,
const GrBackendFormat& format) const {
VkFormat vkFormat;
if (const auto* temp = format.getVkFormat()) {
@@ -1139,38 +1138,9 @@
return 0;
}
- // Currently we don't allow RGB_888X to be renderable with R8G8B8A8_UNORM because we don't have
- // a way to handle blends that reference dst alpha when the values in the dst alpha channel are
- // uninitialized.
- if (colorType == GrColorType::kRGB_888x && vkFormat == VK_FORMAT_R8G8B8A8_UNORM) {
- return 0;
- }
- // We also do not support rendering to kGray.
- if (GrColorTypeComponentFlags(colorType) & kGray_SkColorTypeComponentFlag) {
- return 0;
- }
-
return this->getRenderTargetSampleCount(requestedCount, *format.getVkFormat());
}
-int GrVkCaps::getRenderTargetSampleCount(int requestedCount, GrPixelConfig config) const {
- // Currently we don't allow RGB_888X to be renderable because we don't have a way to handle
- // blends that reference dst alpha when the values in the dst alpha channel are uninitialized.
- // We also do not support rendering to Gray_8.
- if (config == kRGB_888X_GrPixelConfig ||
- config == kGray_8_GrPixelConfig ||
- config == kGray_8_as_Red_GrPixelConfig) {
- return 0;
- }
-
- VkFormat format;
- if (!GrPixelConfigToVkFormat(config, &format)) {
- return 0;
- }
-
- return this->getRenderTargetSampleCount(requestedCount, format);
-}
-
int GrVkCaps::getRenderTargetSampleCount(int requestedCount, VkFormat format) const {
requestedCount = SkTMax(1, requestedCount);
diff --git a/src/gpu/vk/GrVkCaps.h b/src/gpu/vk/GrVkCaps.h
index b1d0cfd..938eff5 100644
--- a/src/gpu/vk/GrVkCaps.h
+++ b/src/gpu/vk/GrVkCaps.h
@@ -47,9 +47,7 @@
bool isFormatRenderable(const GrBackendFormat& format, int sampleCount) const override;
bool isFormatRenderable(VkFormat, int sampleCount) const;
- int getRenderTargetSampleCount(int requestedCount,
- GrColorType, const GrBackendFormat&) const override;
- int getRenderTargetSampleCount(int requestedCount, GrPixelConfig config) const override;
+ int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat&) const override;
int getRenderTargetSampleCount(int requestedCount, VkFormat) const;
int maxRenderTargetSampleCount(const GrBackendFormat&) const override;
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 4599fcf..f1c2ed9 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -1159,8 +1159,8 @@
return true;
}
-static bool check_rt_image_info(const GrVkCaps& caps, const GrVkImageInfo& info) {
- if (!caps.isFormatRenderable(info.fFormat, 1)) {
+static bool check_rt_image_info(const GrVkCaps& caps, const GrVkImageInfo& info, int sampleCnt) {
+ if (!caps.isFormatRenderable(info.fFormat, sampleCnt)) {
return false;
}
return true;
@@ -1218,7 +1218,7 @@
if (!check_tex_image_info(this->vkCaps(), imageInfo)) {
return nullptr;
}
- if (!check_rt_image_info(this->vkCaps(), imageInfo)) {
+ if (!check_rt_image_info(this->vkCaps(), imageInfo, sampleCnt)) {
return nullptr;
}
@@ -1235,8 +1235,7 @@
surfDesc.fWidth = backendTex.width();
surfDesc.fHeight = backendTex.height();
surfDesc.fConfig = config;
- sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, colorType,
- backendTex.getBackendFormat());
+ sampleCnt = this->vkCaps().getRenderTargetSampleCount(sampleCnt, imageInfo.fFormat);
sk_sp<GrVkImageLayout> layout = backendTex.getGrVkImageLayout();
SkASSERT(layout);
@@ -1267,7 +1266,7 @@
if (!check_image_info(this->vkCaps(), info, colorType, false)) {
return nullptr;
}
- if (!check_rt_image_info(this->vkCaps(), info)) {
+ if (!check_rt_image_info(this->vkCaps(), info, backendRT.sampleCnt())) {
return nullptr;
}
@@ -1305,7 +1304,7 @@
if (!check_image_info(this->vkCaps(), imageInfo, grColorType, false)) {
return nullptr;
}
- if (!check_rt_image_info(this->vkCaps(), imageInfo)) {
+ if (!check_rt_image_info(this->vkCaps(), imageInfo, sampleCnt)) {
return nullptr;
}
@@ -1322,8 +1321,7 @@
desc.fHeight = tex.height();
desc.fConfig = config;
- sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, grColorType,
- tex.getBackendFormat());
+ sampleCnt = this->vkCaps().getRenderTargetSampleCount(sampleCnt, imageInfo.fFormat);
if (!sampleCnt) {
return nullptr;
}
@@ -1346,12 +1344,12 @@
if (!backendFormat.isValid()) {
return nullptr;
}
- GrColorType grColorType = SkColorTypeToGrColorType(imageInfo.colorType());
- int sampleCnt = this->caps()->getRenderTargetSampleCount(1, grColorType, backendFormat);
+ int sampleCnt = this->vkCaps().getRenderTargetSampleCount(1, vkInfo.fFormat);
if (!sampleCnt) {
return nullptr;
}
+ GrColorType grColorType = SkColorTypeToGrColorType(imageInfo.colorType());
GrPixelConfig config = this->caps()->getConfigFromBackendFormat(backendFormat, grColorType);
if (config == kUnknown_GrPixelConfig) {
return nullptr;