Remove GrPixelConfig from GrSurface and GrSurfaceProxy.

This also requires us to compute a scratch key from backend format instead of config.

Bug: skia:6718
Change-Id: I6bf4c5ba8188e354ddc5307ebf2ca10080df27cd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265768
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Greg Daniel 2020-01-22 16:53:38 -05:00 committed by Skia Commit-Bot
parent ba16336168
commit d51fa2f1e3
45 changed files with 238 additions and 257 deletions

View File

@ -40,14 +40,6 @@ public:
*/
SkRect getBoundsRect() const { return SkRect::Make(this->dimensions()); }
/**
* Retrieves the pixel config specified when the surface was created.
* For render targets this can be kUnknown_GrPixelConfig
* if client asked us to render to a target that has a pixel
* config that isn't equivalent with one of our configs.
*/
GrPixelConfig config() const { return fConfig; }
virtual GrBackendFormat backendFormat() const = 0;
SK_API void setRelease(sk_sp<GrRefCntedCallback> releaseHelper) {
@ -120,9 +112,8 @@ protected:
// Provides access to methods that should be public within Skia code.
friend class GrSurfacePriv;
GrSurface(GrGpu* gpu, const SkISize& dimensions, GrPixelConfig config, GrProtected isProtected)
GrSurface(GrGpu* gpu, const SkISize& dimensions, GrProtected isProtected)
: INHERITED(gpu)
, fConfig(config)
, fDimensions(dimensions)
, fSurfaceFlags(GrInternalSurfaceFlags::kNone)
, fIsProtected(isProtected) {}
@ -148,7 +139,6 @@ private:
fReleaseHelper.reset();
}
GrPixelConfig fConfig;
SkISize fDimensions;
GrInternalSurfaceFlags fSurfaceFlags;
GrProtected fIsProtected;

View File

@ -74,7 +74,7 @@ public:
inline const GrTexturePriv texturePriv() const;
protected:
GrTexture(GrGpu*, const SkISize&, GrPixelConfig, GrProtected, GrTextureType, GrMipMapsStatus);
GrTexture(GrGpu*, const SkISize&, GrProtected, GrTextureType, GrMipMapsStatus);
virtual bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) = 0;

View File

@ -442,6 +442,8 @@ public:
*/
virtual GrSwizzle getOutputSwizzle(const GrBackendFormat&, GrColorType) const = 0;
virtual uint64_t computeFormatKey(const GrBackendFormat&) const = 0;
const GrDriverBugWorkarounds& workarounds() const { return fDriverBugWorkarounds; }
/**

View File

@ -18,10 +18,9 @@
#include "src/gpu/GrStencilAttachment.h"
#include "src/gpu/GrStencilSettings.h"
GrRenderTarget::GrRenderTarget(GrGpu* gpu, const SkISize& dimensions, GrPixelConfig config,
int sampleCount, GrProtected isProtected,
GrStencilAttachment* stencil)
: INHERITED(gpu, dimensions, config, isProtected)
GrRenderTarget::GrRenderTarget(GrGpu* gpu, const SkISize& dimensions, int sampleCount,
GrProtected isProtected, GrStencilAttachment* stencil)
: INHERITED(gpu, dimensions, isProtected)
, fSampleCnt(sampleCount)
, fSamplePatternKey(GrSamplePatternDictionary::kInvalidSamplePatternKey)
, fStencilAttachment(stencil) {}

View File

@ -50,7 +50,7 @@ public:
const GrRenderTargetPriv renderTargetPriv() const;
protected:
GrRenderTarget(GrGpu*, const SkISize&, GrPixelConfig, int sampleCount, GrProtected,
GrRenderTarget(GrGpu*, const SkISize&, int sampleCount, GrProtected,
GrStencilAttachment* = nullptr);
~GrRenderTarget() override;

View File

@ -264,7 +264,7 @@ sk_sp<GrSurface> GrResourceAllocator::findSurfaceFor(const GrSurfaceProxy* proxy
// First look in the free pool
GrScratchKey key;
proxy->priv().computeScratchKey(&key);
proxy->priv().computeScratchKey(*fResourceProvider->caps(), &key);
auto filter = [] (const GrSurface* s) {
return true;

View File

@ -270,8 +270,9 @@ sk_sp<GrTexture> GrResourceProvider::refScratchTexture(const GrSurfaceDesc& desc
// to fall back to making a new texture.
if (fGpu->caps()->reuseScratchTextures() || renderable == GrRenderable::kYes) {
GrScratchKey key;
GrTexturePriv::ComputeScratchKey(desc.fConfig, {desc.fWidth, desc.fHeight}, renderable,
renderTargetSampleCnt, mipMapped, isProtected, &key);
GrTexturePriv::ComputeScratchKey(*this->caps(), format, {desc.fWidth, desc.fHeight},
renderable, renderTargetSampleCnt, mipMapped, isProtected,
&key);
GrGpuResource* resource = fCache->findAndRefScratchResource(key);
if (resource) {
fGpu->stats()->incNumScratchTexturesReused();

View File

@ -370,7 +370,9 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
format = rgbaDefaultFormat;
alphaType = kUnpremul_SkAlphaType;
} else {
desc.fConfig = dstProxy->config();
// This isn't actually used anywhere so just setting to unknown which should trigger
// asserts and failures if it is read.
desc.fConfig = kUnknown_GrPixelConfig;
colorType = this->colorInfo().colorType();
format = dstProxy->backendFormat().makeTexture2D();
if (!format.isValid()) {

View File

@ -34,13 +34,12 @@ static bool is_valid_lazy(const GrSurfaceDesc& desc, SkBackingFit fit) {
// So fully lazy proxies are created with width and height < 0. Regular lazy proxies must be
// created with positive widths and heights. The width and height are set to 0 only after a
// failed instantiation. The former must be "approximate" fit while the latter can be either.
return desc.fConfig != kUnknown_GrPixelConfig &&
((desc.fWidth < 0 && desc.fHeight < 0 && SkBackingFit::kApprox == fit) ||
return ((desc.fWidth < 0 && desc.fHeight < 0 && SkBackingFit::kApprox == fit) ||
(desc.fWidth > 0 && desc.fHeight > 0));
}
static bool is_valid_non_lazy(const GrSurfaceDesc& desc) {
return desc.fWidth > 0 && desc.fHeight > 0 && desc.fConfig != kUnknown_GrPixelConfig;
return desc.fWidth > 0 && desc.fHeight > 0;
}
#endif
@ -57,7 +56,6 @@ GrSurfaceProxy::GrSurfaceProxy(const GrBackendFormat& format,
UseAllocator useAllocator)
: fSurfaceFlags(surfaceFlags)
, fFormat(format)
, fConfig(desc.fConfig)
, fDimensions{desc.fWidth, desc.fHeight}
, fOrigin(origin)
, fTextureSwizzle(textureSwizzle)
@ -84,7 +82,6 @@ GrSurfaceProxy::GrSurfaceProxy(LazyInstantiateCallback&& callback,
UseAllocator useAllocator)
: fSurfaceFlags(surfaceFlags)
, fFormat(format)
, fConfig(desc.fConfig)
, fDimensions{desc.fWidth, desc.fHeight}
, fOrigin(origin)
, fTextureSwizzle(textureSwizzle)
@ -108,7 +105,6 @@ GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface,
: fTarget(std::move(surface))
, fSurfaceFlags(fTarget->surfacePriv().flags())
, fFormat(fTarget->backendFormat())
, fConfig(fTarget->config())
, fDimensions(fTarget->dimensions())
, fOrigin(origin)
, fTextureSwizzle(textureSwizzle)
@ -139,7 +135,6 @@ sk_sp<GrSurface> GrSurfaceProxy::createSurfaceImpl(GrResourceProvider* resourceP
GrSurfaceDesc desc;
desc.fWidth = fDimensions.width();
desc.fHeight = fDimensions.height();
desc.fConfig = fConfig;
sk_sp<GrSurface> surface;
if (SkBackingFit::kApprox == fFit) {
@ -222,7 +217,7 @@ void GrSurfaceProxy::deinstantiate() {
fTarget = nullptr;
}
void GrSurfaceProxy::computeScratchKey(GrScratchKey* key) const {
void GrSurfaceProxy::computeScratchKey(const GrCaps& caps, GrScratchKey* key) const {
SkASSERT(!this->isFullyLazy());
GrRenderable renderable = GrRenderable::kNo;
int sampleCount = 1;
@ -237,8 +232,8 @@ void GrSurfaceProxy::computeScratchKey(GrScratchKey* key) const {
mipMapped = tp->mipMapped();
}
GrTexturePriv::ComputeScratchKey(this->config(), this->backingStoreDimensions(), renderable,
sampleCount, mipMapped, fIsProtected, key);
GrTexturePriv::ComputeScratchKey(caps, this->backendFormat(), this->backingStoreDimensions(),
renderable, sampleCount, mipMapped, fIsProtected, key);
}
void GrSurfaceProxy::setLastRenderTask(GrRenderTask* renderTask) {
@ -318,10 +313,6 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrRecordingContext* context,
if (config == kUnknown_GrPixelConfig) {
return nullptr;
}
GrSurfaceDesc desc;
desc.fWidth = width;
desc.fHeight = height;
desc.fConfig = config;
GrSurfaceOrigin origin = src->origin();
if (src->backendFormat().textureType() != GrTextureType::kExternal) {
@ -467,7 +458,7 @@ bool GrSurfaceProxyPriv::doLazyInstantiation(GrResourceProvider* resourceProvide
#ifdef SK_DEBUG
void GrSurfaceProxy::validateSurface(const GrSurface* surface) {
SkASSERT(surface->config() == fConfig);
SkASSERT(surface->backendFormat() == fFormat);
this->onValidateSurface(surface);
}

View File

@ -108,8 +108,6 @@ public:
return result;
}
GrPixelConfig config() const { return fConfig; }
SkISize dimensions() const {
SkASSERT(!this->isFullyLazy());
return fDimensions;
@ -353,7 +351,7 @@ protected:
bool ignoredByResourceAllocator() const { return fIgnoredByResourceAllocator; }
void setIgnoredByResourceAllocator() { fIgnoredByResourceAllocator = true; }
void computeScratchKey(GrScratchKey*) const;
void computeScratchKey(const GrCaps&, GrScratchKey*) const;
virtual sk_sp<GrSurface> createSurface(GrResourceProvider*) const = 0;
void assign(sk_sp<GrSurface> surface);
@ -387,10 +385,9 @@ protected:
GrInternalSurfaceFlags fSurfaceFlags;
private:
// For wrapped resources, 'fFormat', 'fConfig', 'fWidth', 'fHeight', and 'fOrigin; will always
// For wrapped resources, 'fFormat', 'fWidth', 'fHeight', and 'fOrigin; will always
// be filled in from the wrapped resource.
const GrBackendFormat fFormat;
const GrPixelConfig fConfig;
SkISize fDimensions;
const GrSurfaceOrigin fOrigin;
const GrSwizzle fTextureSwizzle;

View File

@ -17,7 +17,9 @@
data members or virtual methods. */
class GrSurfaceProxyPriv {
public:
void computeScratchKey(GrScratchKey* key) const { return fProxy->computeScratchKey(key); }
void computeScratchKey(const GrCaps& caps, GrScratchKey* key) const {
return fProxy->computeScratchKey(caps, key);
}
// Create a GrSurface-derived class that meets the requirements (i.e, desc, renderability)
// of the GrSurfaceProxy.

View File

@ -39,11 +39,10 @@ size_t GrTexture::onGpuMemorySize() const {
/////////////////////////////////////////////////////////////////////////////
GrTexture::GrTexture(GrGpu* gpu,
const SkISize& dimensions,
GrPixelConfig config,
GrProtected isProtected,
GrTextureType textureType,
GrMipMapsStatus mipMapsStatus)
: INHERITED(gpu, dimensions, config, isProtected)
: INHERITED(gpu, dimensions, isProtected)
, fTextureType(textureType)
, fMipMapsStatus(mipMapsStatus) {
if (GrMipMapsStatus::kNotAllocated == fMipMapsStatus) {
@ -92,13 +91,14 @@ void GrTexture::computeScratchKey(GrScratchKey* key) const {
renderable = GrRenderable::kYes;
}
auto isProtected = this->isProtected() ? GrProtected::kYes : GrProtected::kNo;
GrTexturePriv::ComputeScratchKey(this->config(), this->dimensions(), renderable,
sampleCount, this->texturePriv().mipMapped(), isProtected,
key);
GrTexturePriv::ComputeScratchKey(*this->getGpu()->caps(), this->backendFormat(),
this->dimensions(), renderable, sampleCount,
this->texturePriv().mipMapped(), isProtected, key);
}
}
void GrTexturePriv::ComputeScratchKey(GrPixelConfig config,
void GrTexturePriv::ComputeScratchKey(const GrCaps& caps,
const GrBackendFormat& format,
SkISize dimensions,
GrRenderable renderable,
int sampleCnt,
@ -112,18 +112,20 @@ void GrTexturePriv::ComputeScratchKey(GrPixelConfig config,
// make sure desc.fConfig fits in 5 bits
SkASSERT(sk_float_log2(kLast_GrPixelConfig) <= 5);
SkASSERT(static_cast<uint32_t>(config) < (1 << 5));
SkASSERT(static_cast<uint32_t>(mipMapped) <= 1);
SkASSERT(static_cast<uint32_t>(isProtected) <= 1);
SkASSERT(static_cast<uint32_t>(renderable) <= 1);
SkASSERT(static_cast<uint32_t>(sampleCnt) < (1 << (32 - 8)));
SkASSERT(static_cast<uint32_t>(sampleCnt) < (1 << (32 - 3)));
GrScratchKey::Builder builder(key, kType, 3);
uint64_t formatKey = caps.computeFormatKey(format);
GrScratchKey::Builder builder(key, kType, 5);
builder[0] = dimensions.width();
builder[1] = dimensions.height();
builder[2] = (static_cast<uint32_t>(config) << 0)
| (static_cast<uint32_t>(mipMapped) << 5)
| (static_cast<uint32_t>(isProtected) << 6)
| (static_cast<uint32_t>(renderable) << 7)
| (static_cast<uint32_t>(sampleCnt) << 8);
builder[2] = formatKey & 0xFFFFFFFF;
builder[3] = (formatKey >> 32) & 0xFFFFFFFF;
builder[4] = (static_cast<uint32_t>(mipMapped) << 0)
| (static_cast<uint32_t>(isProtected) << 1)
| (static_cast<uint32_t>(renderable) << 2)
| (static_cast<uint32_t>(sampleCnt) << 3);
}

View File

@ -48,7 +48,8 @@ public:
return GrTextureTypeHasRestrictedSampling(this->textureType());
}
static void ComputeScratchKey(GrPixelConfig config,
static void ComputeScratchKey(const GrCaps& caps,
const GrBackendFormat& format,
SkISize dimensions,
GrRenderable,
int sampleCnt,

View File

@ -198,6 +198,15 @@ GrSwizzle GrDawnCaps::getOutputSwizzle(const GrBackendFormat& format, GrColorTyp
return get_swizzle(format, colorType, true);
}
uint64_t GrDawnCaps::computeFormatKey(const GrBackendFormat& format) const {
wgpu::TextureFormat dawnFormat;
SkAssertResult(format.asDawnFormat(&dawnFormat));
// Dawn max enum value should always fit in 32 bits.
SkASSERT(dawnFormat <= wgpu::WGPUTextureFormat_Force32);
return (uint64_t)dawnFormat;
}
bool GrDawnCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
const GrBackendFormat& format) const {
return true;

View File

@ -54,6 +54,8 @@ public:
GrSwizzle getOutputSwizzle(const GrBackendFormat&, GrColorType) const override;
uint64_t computeFormatKey(const GrBackendFormat&) const override;
GrColorType getYUVAColorTypeFromBackendFormat(const GrBackendFormat&,
bool isAlphaChannel) const override;

View File

@ -4393,6 +4393,11 @@ GrSwizzle GrGLCaps::getOutputSwizzle(const GrBackendFormat& format, GrColorType
return GrSwizzle::RGBA();
}
uint64_t GrGLCaps::computeFormatKey(const GrBackendFormat& format) const {
auto glFormat = format.asGLFormat();
return (uint64_t)(glFormat);
}
GrProgramDesc GrGLCaps::makeDesc(const GrRenderTarget* rt, const GrProgramInfo& programInfo) const {
GrProgramDesc desc;
SkDEBUGCODE(bool result =) GrProgramDesc::Build(&desc, rt, programInfo, *this);

View File

@ -423,6 +423,8 @@ public:
GrSwizzle getReadSwizzle(const GrBackendFormat&, GrColorType) const override;
GrSwizzle getOutputSwizzle(const GrBackendFormat&, GrColorType) const override;
uint64_t computeFormatKey(const GrBackendFormat&) const override;
GrProgramDesc makeDesc(const GrRenderTarget*, const GrProgramInfo&) const override;
#if GR_TEST_UTILS

View File

@ -683,9 +683,6 @@ static bool check_backend_texture(const GrBackendTexture& backendTex, const GrCo
return false;
}
desc->fConfig = caps.getConfigFromBackendFormat(backendTex.getBackendFormat(), colorType);
SkASSERT(desc->fConfig != kUnknown_GrPixelConfig);
return true;
}
@ -738,9 +735,6 @@ static bool check_compressed_backend_texture(const GrBackendTexture& backendTex,
return false;
}
desc->fConfig = caps.getConfigFromCompressedBackendFormat(backendTex.getBackendFormat());
SkASSERT(desc->fConfig != kUnknown_GrPixelConfig);
return true;
}
@ -838,14 +832,10 @@ sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTa
rtIDs.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID;
rtIDs.fRTFBOOwnership = GrBackendObjectOwnership::kBorrowed;
GrPixelConfig config = this->caps()->getConfigFromBackendFormat(backendRT.getBackendFormat(),
grColorType);
SkASSERT(kUnknown_GrPixelConfig != config);
const auto size = SkISize::Make(backendRT.width(), backendRT.height());
int sampleCount = this->glCaps().getRenderTargetSampleCount(backendRT.sampleCnt(), format);
return GrGLRenderTarget::MakeWrapped(this, size, format, config, sampleCount, rtIDs,
return GrGLRenderTarget::MakeWrapped(this, size, format, sampleCount, rtIDs,
backendRT.stencilBits());
}
@ -868,8 +858,7 @@ sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBacken
if (!this->createRenderTargetObjects(desc, sampleCount, &rtIDs)) {
return nullptr;
}
return GrGLRenderTarget::MakeWrapped(this, desc.fSize, desc.fFormat, desc.fConfig, sampleCount,
rtIDs, 0);
return GrGLRenderTarget::MakeWrapped(this, desc.fSize, desc.fFormat, sampleCount, rtIDs, 0);
}
static bool check_write_and_transfer_input(GrGLTexture* glTex) {
@ -1328,7 +1317,6 @@ sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
texDesc.fSize = {desc.fWidth, desc.fHeight};
texDesc.fTarget = GR_GL_TEXTURE_2D;
texDesc.fFormat = format.asGLFormat();
texDesc.fConfig = desc.fConfig;
texDesc.fOwnership = GrBackendObjectOwnership::kOwned;
SkASSERT(texDesc.fFormat != GrGLFormat::kUnknown);
SkASSERT(!GrGLFormatIsCompressed(texDesc.fFormat));
@ -1424,7 +1412,6 @@ sk_sp<GrTexture> GrGLGpu::onCreateCompressedTexture(SkISize dimensions,
GrGLTexture::Desc desc;
desc.fSize = dimensions;
desc.fTarget = GR_GL_TEXTURE_2D;
desc.fConfig = this->glCaps().getConfigFromCompressedBackendFormat(format);
desc.fOwnership = GrBackendObjectOwnership::kOwned;
desc.fFormat = format.asGLFormat();
desc.fID = this->createCompressedTexture2D(desc.fSize, desc.fFormat,
@ -3771,41 +3758,6 @@ void GrGLGpu::insertManualFramebufferBarrier() {
GL_CALL(MemoryBarrier(GR_GL_FRAMEBUFFER_BARRIER_BIT));
}
static GrPixelConfig gl_format_to_pixel_config(GrGLFormat format) {
switch (format) {
case GrGLFormat::kRGBA8: return kRGBA_8888_GrPixelConfig;
case GrGLFormat::kRGB8: return kRGB_888_GrPixelConfig;
case GrGLFormat::kRG8: return kRG_88_GrPixelConfig;
case GrGLFormat::kBGRA8: return kBGRA_8888_GrPixelConfig;
case GrGLFormat::kLUMINANCE8: return kGray_8_GrPixelConfig;
case GrGLFormat::kSRGB8_ALPHA8: return kSRGBA_8888_GrPixelConfig;
case GrGLFormat::kRGB10_A2: return kRGBA_1010102_GrPixelConfig;
case GrGLFormat::kRGB565: return kRGB_565_GrPixelConfig;
case GrGLFormat::kRGBA4: return kRGBA_4444_GrPixelConfig;
case GrGLFormat::kRGBA16F: return kRGBA_half_GrPixelConfig;
case GrGLFormat::kR16: return kAlpha_16_GrPixelConfig;
case GrGLFormat::kRG16: return kRG_1616_GrPixelConfig;
case GrGLFormat::kRGBA16: return kRGBA_16161616_GrPixelConfig;
case GrGLFormat::kRG16F: return kRG_half_GrPixelConfig;
case GrGLFormat::kUnknown: return kUnknown_GrPixelConfig;
// Configs with multiple equivalent formats.
case GrGLFormat::kR16F: return kAlpha_half_GrPixelConfig;
case GrGLFormat::kLUMINANCE16F: return kAlpha_half_GrPixelConfig;
case GrGLFormat::kALPHA8: return kAlpha_8_GrPixelConfig;
case GrGLFormat::kR8: return kAlpha_8_GrPixelConfig;
case GrGLFormat::kCOMPRESSED_ETC1_RGB8: return kRGB_ETC1_GrPixelConfig;
case GrGLFormat::kCOMPRESSED_RGB8_ETC2: return kRGB_ETC1_GrPixelConfig;
case GrGLFormat::kCOMPRESSED_RGB8_BC1: return kBC1_RGB8_UNORM_GrPixelConfig;
case GrGLFormat::kCOMPRESSED_RGBA8_BC1: return kBC1_RGBA8_UNORM_GrPixelConfig;
}
SkUNREACHABLE;
}
GrBackendTexture GrGLGpu::onCreateBackendTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
@ -3835,11 +3787,7 @@ GrBackendTexture GrGLGpu::onCreateBackendTexture(SkISize dimensions,
GrGLTextureInfo info;
GrGLTextureParameters::SamplerOverriddenState initialState;
GrSurfaceDesc desc;
desc.fWidth = dimensions.width();
desc.fHeight = dimensions.height();
desc.fConfig = gl_format_to_pixel_config(glFormat);
if (desc.fConfig == kUnknown_GrPixelConfig) {
if (glFormat == GrGLFormat::kUnknown) {
return {};
}
@ -3854,16 +3802,13 @@ GrBackendTexture GrGLGpu::onCreateBackendTexture(SkISize dimensions,
if (data && data->type() == BackendTextureData::Type::kPixmaps) {
SkTDArray<GrMipLevel> texels;
GrColorType colorType = SkColorTypeToGrColorType(data->pixmap(0).colorType());
// Incorporate the color type into the config to make it "specific" if applicable.
desc.fConfig = this->caps()->getConfigFromBackendFormat(format, colorType);
SkASSERT(desc.fConfig != kUnknown_GrPixelConfig);
texels.append(numMipLevels);
for (int i = 0; i < numMipLevels; ++i) {
texels[i] = {data->pixmap(i).addr(), data->pixmap(i).rowBytes()};
}
if (!this->uploadTexData(glFormat, colorType, desc.fWidth, desc.fHeight, GR_GL_TEXTURE_2D,
0, 0, desc.fWidth, desc.fHeight, colorType, texels.begin(),
texels.count())) {
if (!this->uploadTexData(glFormat, colorType, dimensions.width(), dimensions.height(),
GR_GL_TEXTURE_2D, 0, 0, dimensions.width(), dimensions.height(),
colorType, texels.begin(), texels.count())) {
GL_CALL(DeleteTextures(1, &info.fID));
return {};
}

View File

@ -22,12 +22,11 @@
GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu,
const SkISize& dimensions,
GrGLFormat format,
GrPixelConfig config,
int sampleCount,
const IDs& ids,
GrGLStencilAttachment* stencil)
: GrSurface(gpu, dimensions, config, GrProtected::kNo)
, INHERITED(gpu, dimensions, config, sampleCount, GrProtected::kNo, stencil) {
: GrSurface(gpu, dimensions, GrProtected::kNo)
, INHERITED(gpu, dimensions, sampleCount, GrProtected::kNo, stencil) {
this->setFlags(gpu->glCaps(), ids);
this->init(format, ids);
this->registerWithCacheWrapped(GrWrapCacheable::kNo);
@ -36,11 +35,10 @@ GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu,
GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu,
const SkISize& dimensions,
GrGLFormat format,
GrPixelConfig config,
int sampleCount,
const IDs& ids)
: GrSurface(gpu, dimensions, config, GrProtected::kNo)
, INHERITED(gpu, dimensions, config, sampleCount, GrProtected::kNo) {
: GrSurface(gpu, dimensions, GrProtected::kNo)
, INHERITED(gpu, dimensions, sampleCount, GrProtected::kNo) {
this->setFlags(gpu->glCaps(), ids);
this->init(format, ids);
}
@ -63,7 +61,6 @@ void GrGLRenderTarget::init(GrGLFormat format, const IDs& idDesc) {
sk_sp<GrGLRenderTarget> GrGLRenderTarget::MakeWrapped(GrGLGpu* gpu,
const SkISize& dimensions,
GrGLFormat format,
GrPixelConfig config,
int sampleCount,
const IDs& idDesc,
int stencilBits) {
@ -80,7 +77,7 @@ sk_sp<GrGLRenderTarget> GrGLRenderTarget::MakeWrapped(GrGLGpu* gpu,
sampleCount, format);
}
return sk_sp<GrGLRenderTarget>(
new GrGLRenderTarget(gpu, dimensions, format, config, sampleCount, idDesc, sb));
new GrGLRenderTarget(gpu, dimensions, format, sampleCount, idDesc, sb));
}
GrBackendRenderTarget GrGLRenderTarget::getBackendRenderTarget() const {

View File

@ -35,7 +35,6 @@ public:
static sk_sp<GrGLRenderTarget> MakeWrapped(GrGLGpu*,
const SkISize&,
GrGLFormat,
GrPixelConfig,
int sampleCount,
const IDs&,
int stencilBits);
@ -64,7 +63,6 @@ protected:
GrGLRenderTarget(GrGLGpu*,
const SkISize&,
GrGLFormat,
GrPixelConfig,
int sampleCount,
const IDs&);
@ -80,7 +78,6 @@ private:
GrGLRenderTarget(GrGLGpu*,
const SkISize&,
GrGLFormat,
GrPixelConfig,
int sampleCount,
const IDs&,
GrGLStencilAttachment*);

View File

@ -44,8 +44,8 @@ static inline GrGLenum target_from_texture_type(GrTextureType type) {
// Because this class is virtually derived from GrSurface we must explicitly call its constructor.
GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const Desc& desc,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, desc.fSize, desc.fConfig, GrProtected::kNo)
, INHERITED(gpu, desc.fSize, desc.fConfig, GrProtected::kNo,
: GrSurface(gpu, desc.fSize, GrProtected::kNo)
, INHERITED(gpu, desc.fSize, GrProtected::kNo,
TextureTypeFromTarget(desc.fTarget), mipMapsStatus)
, fParameters(sk_make_sp<GrGLTextureParameters>()) {
this->init(desc);
@ -58,8 +58,8 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const Desc& desc,
GrGLTexture::GrGLTexture(GrGLGpu* gpu, const Desc& desc, GrMipMapsStatus mipMapsStatus,
sk_sp<GrGLTextureParameters> parameters, GrWrapCacheable cacheable,
GrIOType ioType)
: GrSurface(gpu, desc.fSize, desc.fConfig, GrProtected::kNo)
, INHERITED(gpu, desc.fSize, desc.fConfig, GrProtected::kNo,
: GrSurface(gpu, desc.fSize, GrProtected::kNo)
, INHERITED(gpu, desc.fSize, GrProtected::kNo,
TextureTypeFromTarget(desc.fTarget), mipMapsStatus)
, fParameters(std::move(parameters)) {
SkASSERT(fParameters);
@ -72,8 +72,8 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, const Desc& desc, GrMipMapsStatus mipMaps
GrGLTexture::GrGLTexture(GrGLGpu* gpu, const Desc& desc, sk_sp<GrGLTextureParameters> parameters,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, desc.fSize, desc.fConfig, GrProtected::kNo)
, INHERITED(gpu, desc.fSize, desc.fConfig, GrProtected::kNo,
: GrSurface(gpu, desc.fSize, GrProtected::kNo)
, INHERITED(gpu, desc.fSize, GrProtected::kNo,
TextureTypeFromTarget(desc.fTarget), mipMapsStatus) {
SkASSERT(parameters || desc.fOwnership == GrBackendObjectOwnership::kOwned);
fParameters = parameters ? std::move(parameters) : sk_make_sp<GrGLTextureParameters>();

View File

@ -23,7 +23,6 @@ public:
GrGLenum fTarget = 0;
GrGLuint fID = 0;
GrGLFormat fFormat = GrGLFormat::kUnknown;
GrPixelConfig fConfig = kUnknown_GrPixelConfig;
GrBackendObjectOwnership fOwnership = GrBackendObjectOwnership::kOwned;
};

View File

@ -18,10 +18,9 @@ GrGLTextureRenderTarget::GrGLTextureRenderTarget(GrGLGpu* gpu,
const GrGLTexture::Desc& texDesc,
const GrGLRenderTarget::IDs& rtIDs,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, texDesc.fSize, texDesc.fConfig, GrProtected::kNo)
: GrSurface(gpu, texDesc.fSize, GrProtected::kNo)
, GrGLTexture(gpu, texDesc, nullptr, mipMapsStatus)
, GrGLRenderTarget(gpu, texDesc.fSize, texDesc.fFormat, texDesc.fConfig, sampleCount,
rtIDs) {
, GrGLRenderTarget(gpu, texDesc.fSize, texDesc.fFormat, sampleCount, rtIDs) {
this->registerWithCache(budgeted);
}
@ -32,9 +31,9 @@ GrGLTextureRenderTarget::GrGLTextureRenderTarget(GrGLGpu* gpu,
const GrGLRenderTarget::IDs& rtIDs,
GrWrapCacheable cacheable,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, texDesc.fSize, texDesc.fConfig, GrProtected::kNo)
: GrSurface(gpu, texDesc.fSize, GrProtected::kNo)
, GrGLTexture(gpu, texDesc, std::move(parameters), mipMapsStatus)
, GrGLRenderTarget(gpu, texDesc.fSize, texDesc.fFormat, texDesc.fConfig, sampleCount,
, GrGLRenderTarget(gpu, texDesc.fSize, texDesc.fFormat, sampleCount,
rtIDs) {
this->registerWithCacheWrapped(cacheable);
}

View File

@ -17,6 +17,15 @@ GrProgramDesc GrMockCaps::makeDesc(const GrRenderTarget* rt,
return desc;
}
uint64_t GrMockCaps::computeFormatKey(const GrBackendFormat& format) const {
#ifdef SK_DEBUG
SkImage::CompressionType compression = format.asMockCompressionType();
SkASSERT(compression == SkImage::CompressionType::kNone);
#endif
auto ct = format.asMockColorType();
return (uint64_t)ct;
}
#if GR_TEST_UTILS
std::vector<GrCaps::TestFormatColorTypeCombination> GrMockCaps::getTestingCombinations() const {
// TODO: need to add compressed formats to this list
@ -72,4 +81,5 @@ std::vector<GrCaps::TestFormatColorTypeCombination> GrMockCaps::getTestingCombin
return combos;
}
#endif

View File

@ -176,6 +176,8 @@ public:
return GrSwizzle();
}
uint64_t computeFormatKey(const GrBackendFormat&) const override;
GrProgramDesc makeDesc(const GrRenderTarget*, const GrProgramInfo&) const override;
#if GR_TEST_UTILS

View File

@ -51,9 +51,9 @@ protected:
// constructor for subclasses
GrMockTexture(GrMockGpu* gpu, const GrSurfaceDesc& desc, GrProtected isProtected,
GrMipMapsStatus mipMapsStatus, const GrMockTextureInfo& info)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, isProtected)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, isProtected,
GrTextureType::k2D, mipMapsStatus)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, isProtected)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, isProtected, GrTextureType::k2D,
mipMapsStatus)
, fInfo(info) {}
void onRelease() override {
@ -78,8 +78,8 @@ class GrMockRenderTarget : public GrRenderTarget {
public:
GrMockRenderTarget(GrMockGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc,
int sampleCnt, GrProtected isProtected, const GrMockRenderTargetInfo& info)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, isProtected)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, sampleCnt, isProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, isProtected)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, sampleCnt, isProtected)
, fInfo(info) {
this->registerWithCache(budgeted);
}
@ -87,8 +87,8 @@ public:
enum Wrapped { kWrapped };
GrMockRenderTarget(GrMockGpu* gpu, Wrapped, const GrSurfaceDesc& desc, int sampleCnt,
GrProtected isProtected, const GrMockRenderTargetInfo& info)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, isProtected)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, sampleCnt, isProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, isProtected)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, sampleCnt, isProtected)
, fInfo(info) {
this->registerWithCacheWrapped(GrWrapCacheable::kNo);
}
@ -123,8 +123,8 @@ protected:
// constructor for subclasses
GrMockRenderTarget(GrMockGpu* gpu, const GrSurfaceDesc& desc, int sampleCnt,
GrProtected isProtected, const GrMockRenderTargetInfo& info)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, isProtected)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, sampleCnt, isProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, isProtected)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, sampleCnt, isProtected)
, fInfo(info) {}
private:
@ -140,7 +140,7 @@ public:
int sampleCnt, GrProtected isProtected, GrMipMapsStatus mipMapsStatus,
const GrMockTextureInfo& texInfo,
const GrMockRenderTargetInfo& rtInfo)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, isProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, isProtected)
, GrMockTexture(gpu, desc, isProtected, mipMapsStatus, texInfo)
, GrMockRenderTarget(gpu, desc, sampleCnt, isProtected, rtInfo) {
this->registerWithCache(budgeted);
@ -151,7 +151,7 @@ public:
GrProtected isProtected, GrMipMapsStatus mipMapsStatus,
const GrMockTextureInfo& texInfo,
const GrMockRenderTargetInfo& rtInfo, GrWrapCacheable cacheble)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, isProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, isProtected)
, GrMockTexture(gpu, desc, isProtected, mipMapsStatus, texInfo)
, GrMockRenderTarget(gpu, desc, sampleCnt, isProtected, rtInfo) {
this->registerWithCacheWrapped(cacheble);

View File

@ -89,6 +89,8 @@ public:
GrSwizzle getReadSwizzle(const GrBackendFormat&, GrColorType) const override;
GrSwizzle getOutputSwizzle(const GrBackendFormat&, GrColorType) const override;
uint64_t computeFormatKey(const GrBackendFormat&) const override;
GrProgramDesc makeDesc(const GrRenderTarget*, const GrProgramInfo&) const override;
#if GR_TEST_UTILS

View File

@ -1101,6 +1101,16 @@ GrSwizzle GrMtlCaps::getOutputSwizzle(const GrBackendFormat& format, GrColorType
return GrSwizzle::RGBA();
}
uint64_t GrMtlCaps::computeFormatKey(const GrBackendFormat& format) const {
MTLPixelFormat mtlFormat = GrBackendFormatAsMTLPixelFormat(format);
SkASSERT(mtlFormat != MTLPixelFormatInvalid);
// A MTLPixelFormat is an NSUInteger type which is documented to be 32 bits in 32 bit
// applications and 64 bits in 64 bit applications. So it should fit in an uint64_t, but adding
// the assert heere to make sure.
static_assert(sizeof(MTLPixelFormat) <= sizeof(uint64_t));
return (uint64_t)mtlFormat;
}
GrCaps::SupportedWrite GrMtlCaps::supportedWritePixelsColorType(
GrColorType surfaceColorType, const GrBackendFormat& surfaceFormat,
GrColorType srcColorType) const {

View File

@ -203,7 +203,7 @@ private:
bool uploadToTexture(GrMtlTexture* tex, int left, int top, int width, int height,
GrColorType dataColorType, const GrMipLevel texels[], int mipLevels);
// Function that fills texture levels with transparent black based on levelMask.
bool clearTexture(GrMtlTexture*, GrColorType, uint32_t levelMask);
bool clearTexture(GrMtlTexture*, size_t bbp, uint32_t levelMask);
bool readOrTransferPixels(GrSurface* surface, int left, int top, int width, int height,
GrColorType dstColorType, id<MTLBuffer> transferBuffer, size_t offset,
size_t imageBytes, size_t rowBytes);

View File

@ -255,7 +255,7 @@ bool GrMtlGpu::uploadToTexture(GrMtlTexture* tex, int left, int top, int width,
if (width == 0 || height == 0) {
return false;
}
if (GrPixelConfigToColorType(tex->config()) != dataColorType) {
if (!this->mtlCaps().isFormatTexturableAndUploadable(dataColorType, tex->backendFormat())) {
return false;
}
@ -332,8 +332,8 @@ bool GrMtlGpu::uploadToTexture(GrMtlTexture* tex, int left, int top, int width,
return true;
}
bool GrMtlGpu::clearTexture(GrMtlTexture* tex, GrColorType dataColorType, uint32_t levelMask) {
SkASSERT(this->caps()->isFormatTexturableAndUploadable(dataColorType, tex->backendFormat()));
bool GrMtlGpu::clearTexture(GrMtlTexture* tex, size_t bpp, uint32_t levelMask) {
SkASSERT(this->mtlCaps().isFormatTexturable(tex->backendFormat()));
if (!levelMask) {
return true;
@ -344,9 +344,6 @@ bool GrMtlGpu::clearTexture(GrMtlTexture* tex, GrColorType dataColorType, uint32
// Either upload only the first miplevel or all miplevels
int mipLevelCount = (int)mtlTexture.mipmapLevelCount;
// TODO: implement some way of reusing transfer buffers?
size_t bpp = GrColorTypeBytesPerPixel(dataColorType);
SkTArray<size_t> individualMipOffsets(mipLevelCount);
size_t combinedBufferSize = 0;
int currentWidth = tex->width();
@ -495,8 +492,8 @@ sk_sp<GrTexture> GrMtlGpu::onCreateTexture(const GrSurfaceDesc& desc,
}
if (levelClearMask) {
auto colorType = GrPixelConfigToColorType(desc.fConfig);
this->clearTexture(tex.get(), colorType, levelClearMask);
this->clearTexture(tex.get(), this->mtlCaps().bytesPerPixel(mtlPixelFormat),
levelClearMask);
}
return tex;
@ -1004,10 +1001,8 @@ GrBackendRenderTarget GrMtlGpu::createTestingOnlyBackendRenderTarget(int w, int
return GrBackendRenderTarget();
}
GrPixelConfig config = GrColorTypeToPixelConfig(ct);
MTLPixelFormat format;
if (!GrPixelConfigToMTLFormat(config, &format)) {
MTLPixelFormat format = this->mtlCaps().getFormatFromColorType(ct);
if (format == MTLPixelFormatInvalid) {
return GrBackendRenderTarget();
}
@ -1175,8 +1170,7 @@ bool GrMtlGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int wid
GrGpuBuffer* transferBuffer, size_t offset, size_t rowBytes) {
SkASSERT(texture);
SkASSERT(transferBuffer);
if (textureColorType != bufferColorType ||
GrPixelConfigToColorType(texture->config()) != bufferColorType) {
if (textureColorType != bufferColorType) {
return false;
}
@ -1192,6 +1186,10 @@ bool GrMtlGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int wid
if (offset % bpp) {
return false;
}
if (this->mtlCaps().bytesPerPixel(texture->backendFormat()) != bpp) {
return false;
}
MTLOrigin origin = MTLOriginMake(left, top, 0);
id<MTLBlitCommandEncoder> blitCmdEncoder = this->commandBuffer()->getBlitCommandEncoder();
@ -1219,10 +1217,13 @@ bool GrMtlGpu::onTransferPixelsFrom(GrSurface* surface, int left, int top, int w
}
// Metal only supports offsets that are aligned to a pixel.
int bpp = GrColorTypeBytesPerPixel(bufferColorType);
size_t bpp = GrColorTypeBytesPerPixel(bufferColorType);
if (offset % bpp) {
return false;
}
if (this->mtlCaps().bytesPerPixel(surface->backendFormat()) != bpp) {
return false;
}
GrMtlBuffer* grMtlBuffer = static_cast<GrMtlBuffer*>(transferBuffer);
grMtlBuffer->bind();
@ -1241,9 +1242,6 @@ bool GrMtlGpu::readOrTransferPixels(GrSurface* surface, int left, int top, int w
if (!check_max_blit_width(width)) {
return false;
}
if (GrPixelConfigToColorType(surface->config()) != dstColorType) {
return false;
}
id<MTLTexture> mtlTexture;
if (GrMtlRenderTarget* rt = static_cast<GrMtlRenderTarget*>(surface->asRenderTarget())) {

View File

@ -21,9 +21,9 @@ GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu,
id<MTLTexture> colorTexture,
id<MTLTexture> resolveTexture,
Wrapped)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
, GrRenderTarget(
gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, sampleCnt, GrProtected::kNo)
gpu, {desc.fWidth, desc.fHeight}, sampleCnt, GrProtected::kNo)
, fColorTexture(colorTexture)
, fResolveTexture(resolveTexture) {
SkASSERT(sampleCnt > 1);
@ -34,8 +34,8 @@ GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu,
const GrSurfaceDesc& desc,
id<MTLTexture> colorTexture,
Wrapped)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo)
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, 1, GrProtected::kNo)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, 1, GrProtected::kNo)
, fColorTexture(colorTexture)
, fResolveTexture(nil) {
this->registerWithCacheWrapped(GrWrapCacheable::kNo);
@ -47,9 +47,9 @@ GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu,
int sampleCnt,
id<MTLTexture> colorTexture,
id<MTLTexture> resolveTexture)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
, GrRenderTarget(
gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, sampleCnt, GrProtected::kNo)
gpu, {desc.fWidth, desc.fHeight}, sampleCnt, GrProtected::kNo)
, fColorTexture(colorTexture)
, fResolveTexture(resolveTexture) {
SkASSERT(sampleCnt > 1);
@ -58,8 +58,8 @@ GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu,
GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu,
const GrSurfaceDesc& desc,
id<MTLTexture> colorTexture)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo)
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, 1, GrProtected::kNo)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, 1, GrProtected::kNo)
, fColorTexture(colorTexture)
, fResolveTexture(nil) {}
@ -75,8 +75,8 @@ sk_sp<GrMtlRenderTarget> GrMtlRenderTarget::MakeWrappedRenderTarget(GrMtlGpu* gp
GrMtlRenderTarget* mtlRT;
if (sampleCnt > 1) {
MTLPixelFormat format;
if (!GrPixelConfigToMTLFormat(desc.fConfig, &format)) {
MTLPixelFormat format = texture.pixelFormat;
if (!gpu->mtlCaps().isFormatRenderable(format, sampleCnt)) {
return nullptr;
}
MTLTextureDescriptor* texDesc = [[MTLTextureDescriptor alloc] init];

View File

@ -20,8 +20,8 @@ GrMtlTexture::GrMtlTexture(GrMtlGpu* gpu,
const GrSurfaceDesc& desc,
id<MTLTexture> texture,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo,
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo,
GrTextureType::k2D, mipMapsStatus)
, fTexture(texture) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == texture.mipmapLevelCount));
@ -42,8 +42,8 @@ GrMtlTexture::GrMtlTexture(GrMtlGpu* gpu,
GrMipMapsStatus mipMapsStatus,
GrWrapCacheable cacheable,
GrIOType ioType)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo,
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo,
GrTextureType::k2D, mipMapsStatus)
, fTexture(texture) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == texture.mipmapLevelCount));
@ -61,8 +61,8 @@ GrMtlTexture::GrMtlTexture(GrMtlGpu* gpu,
const GrSurfaceDesc& desc,
id<MTLTexture> texture,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo,
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo,
GrTextureType::k2D, mipMapsStatus)
, fTexture(texture) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == texture.mipmapLevelCount));

View File

@ -20,7 +20,7 @@ GrMtlTextureRenderTarget::GrMtlTextureRenderTarget(GrMtlGpu* gpu,
id<MTLTexture> colorTexture,
id<MTLTexture> resolveTexture,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
, GrMtlTexture(gpu, desc, resolveTexture, mipMapsStatus)
, GrMtlRenderTarget(gpu, desc, sampleCnt, colorTexture, resolveTexture) {
this->registerWithCache(budgeted);
@ -31,7 +31,7 @@ GrMtlTextureRenderTarget::GrMtlTextureRenderTarget(GrMtlGpu* gpu,
const GrSurfaceDesc& desc,
id<MTLTexture> colorTexture,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
, GrMtlTexture(gpu, desc, colorTexture, mipMapsStatus)
, GrMtlRenderTarget(gpu, desc, colorTexture) {
this->registerWithCache(budgeted);
@ -44,7 +44,7 @@ GrMtlTextureRenderTarget::GrMtlTextureRenderTarget(GrMtlGpu* gpu,
id<MTLTexture> resolveTexture,
GrMipMapsStatus mipMapsStatus,
GrWrapCacheable cacheable)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
, GrMtlTexture(gpu, desc, resolveTexture, mipMapsStatus)
, GrMtlRenderTarget(gpu, desc, sampleCnt, colorTexture, resolveTexture) {
this->registerWithCacheWrapped(cacheable);
@ -55,15 +55,15 @@ GrMtlTextureRenderTarget::GrMtlTextureRenderTarget(GrMtlGpu* gpu,
id<MTLTexture> colorTexture,
GrMipMapsStatus mipMapsStatus,
GrWrapCacheable cacheable)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
, GrMtlTexture(gpu, desc, colorTexture, mipMapsStatus)
, GrMtlRenderTarget(gpu, desc, colorTexture) {
this->registerWithCacheWrapped(cacheable);
}
id<MTLTexture> create_msaa_texture(GrMtlGpu* gpu, const GrSurfaceDesc& desc, int sampleCnt) {
MTLPixelFormat format;
if (!GrPixelConfigToMTLFormat(desc.fConfig, &format)) {
id<MTLTexture> create_msaa_texture(GrMtlGpu* gpu, const GrSurfaceDesc& desc, MTLPixelFormat format,
int sampleCnt) {
if (!gpu->mtlCaps().isFormatRenderable(format, sampleCnt)) {
return nullptr;
}
MTLTextureDescriptor* texDesc = [[MTLTextureDescriptor alloc] init];
@ -99,7 +99,8 @@ sk_sp<GrMtlTextureRenderTarget> GrMtlTextureRenderTarget::MakeNewTextureRenderTa
}
if (sampleCnt > 1) {
id<MTLTexture> colorTexture = create_msaa_texture(gpu, desc, sampleCnt);
id<MTLTexture> colorTexture = create_msaa_texture(gpu, desc, texture.pixelFormat,
sampleCnt);
if (!colorTexture) {
return nullptr;
}
@ -128,7 +129,8 @@ sk_sp<GrMtlTextureRenderTarget> GrMtlTextureRenderTarget::MakeWrappedTextureRend
? GrMipMapsStatus::kDirty
: GrMipMapsStatus::kNotAllocated;
if (sampleCnt > 1) {
id<MTLTexture> colorTexture = create_msaa_texture(gpu, desc, sampleCnt);
id<MTLTexture> colorTexture = create_msaa_texture(gpu, desc, texture.pixelFormat,
sampleCnt);
if (!colorTexture) {
return nullptr;
}

View File

@ -1775,6 +1775,21 @@ GrSwizzle GrVkCaps::getOutputSwizzle(const GrBackendFormat& format, GrColorType
return GrSwizzle::RGBA();
}
uint64_t GrVkCaps::computeFormatKey(const GrBackendFormat& format) const {
VkFormat vkFormat;
SkAssertResult(format.asVkFormat(&vkFormat));
#ifdef SK_DEBUG
// We should never be trying to compute a key for an external format
const GrVkYcbcrConversionInfo* ycbcrInfo = format.getVkYcbcrConversionInfo();
SkASSERT(ycbcrInfo);
SkASSERT(!ycbcrInfo->isValid() || ycbcrInfo->fExternalFormat == 0);
#endif
// A VkFormat has a size of 64 bits.
return (uint64_t)vkFormat;
}
GrCaps::SupportedRead GrVkCaps::onSupportedReadPixelsColorType(
GrColorType srcColorType, const GrBackendFormat& srcBackendFormat,
GrColorType dstColorType) const {

View File

@ -180,6 +180,8 @@ public:
GrSwizzle getReadSwizzle(const GrBackendFormat&, GrColorType) const override;
GrSwizzle getOutputSwizzle(const GrBackendFormat&, GrColorType) const override;
uint64_t computeFormatKey(const GrBackendFormat&) const override;
int getFragmentUniformBinding() const;
int getFragmentUniformSet() const;

View File

@ -465,8 +465,17 @@ bool GrVkGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int widt
GrColorType surfaceColorType, GrColorType bufferColorType,
GrGpuBuffer* transferBuffer, size_t bufferOffset,
size_t rowBytes) {
if (surfaceColorType != bufferColorType) {
return false;
}
size_t bpp = GrColorTypeBytesPerPixel(bufferColorType);
if (this->vkCaps().bytesPerPixel(texture->backendFormat()) != bpp) {
return false;
}
// Vulkan only supports offsets that are both 4-byte aligned and aligned to a pixel.
if ((bufferOffset & 0x3) || (bufferOffset % GrColorTypeBytesPerPixel(bufferColorType))) {
if ((bufferOffset & 0x3) || (bufferOffset % bpp)) {
return false;
}
GrVkTexture* vkTex = static_cast<GrVkTexture*>(texture);
@ -487,7 +496,6 @@ bool GrVkGpu::onTransferPixelsTo(GrTexture* texture, int left, int top, int widt
SkIRect bounds = SkIRect::MakeWH(texture->width(), texture->height());
SkASSERT(bounds.contains(subRect));
)
size_t bpp = GrColorTypeBytesPerPixel(bufferColorType);
// Set up copy region
VkBufferImageCopy region;
@ -526,6 +534,9 @@ bool GrVkGpu::onTransferPixelsFrom(GrSurface* surface, int left, int top, int wi
if (fProtectedContext == GrProtected::kYes) {
return false;
}
if (surfaceColorType != bufferColorType) {
return false;
}
GrVkTransferBuffer* vkBuffer = static_cast<GrVkTransferBuffer*>(transferBuffer);
@ -542,6 +553,11 @@ bool GrVkGpu::onTransferPixelsFrom(GrSurface* surface, int left, int top, int wi
srcImage = static_cast<GrVkTexture*>(surface->asTexture());
}
if (this->vkCaps().bytesPerPixel(srcImage->imageFormat()) !=
GrColorTypeBytesPerPixel(surfaceColorType)) {
return false;
}
// Set up copy region
VkBufferImageCopy region;
memset(&region, 0, sizeof(VkBufferImageCopy));
@ -741,14 +757,13 @@ bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex, int left, int top, int widt
return false;
}
if (GrPixelConfigToColorType(tex->config()) != dataColorType) {
if (!this->vkCaps().isFormatTexturableAndUploadable(dataColorType, tex->backendFormat())) {
return false;
}
// For RGB_888x src data we are uploading it first to an RGBA texture and then copying it to the
// dst RGB texture. Thus we do not upload mip levels for that.
if (dataColorType == GrColorType::kRGB_888x && tex->imageFormat() == VK_FORMAT_R8G8B8_UNORM) {
SkASSERT(tex->config() == kRGB_888_GrPixelConfig);
// First check that we'll be able to do the copy to the to the R8G8B8 image in the end via a
// blit or draw.
if (!this->vkCaps().formatCanBeDstofBlit(VK_FORMAT_R8G8B8_UNORM, tex->isLinearTiled()) &&
@ -2527,6 +2542,9 @@ bool GrVkGpu::onReadPixels(GrSurface* surface, int left, int top, int width, int
false);
size_t bpp = GrColorTypeBytesPerPixel(dstColorType);
if (this->vkCaps().bytesPerPixel(image->imageFormat()) != bpp) {
return false;
}
size_t tightRowBytes = bpp * width;
VkBufferImageCopy region;

View File

@ -31,10 +31,10 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
sk_sp<GrVkImageLayout> msaaLayout,
const GrVkImageView* colorAttachmentView,
const GrVkImageView* resolveAttachmentView)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
, GrVkImage(info, std::move(layout), GrBackendObjectOwnership::kBorrowed)
// for the moment we only support 1:1 color to stencil
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, sampleCnt, info.fProtected)
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, sampleCnt, info.fProtected)
, fColorAttachmentView(colorAttachmentView)
, fMSAAImage(new GrVkImage(msaaInfo, std::move(msaaLayout),
GrBackendObjectOwnership::kOwned))
@ -58,10 +58,10 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
const GrVkImageView* colorAttachmentView,
const GrVkImageView* resolveAttachmentView,
GrBackendObjectOwnership ownership)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
, GrVkImage(info, std::move(layout), ownership)
// for the moment we only support 1:1 color to stencil
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, sampleCnt, info.fProtected)
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, sampleCnt, info.fProtected)
, fColorAttachmentView(colorAttachmentView)
, fMSAAImage(
new GrVkImage(msaaInfo, std::move(msaaLayout), GrBackendObjectOwnership::kOwned))
@ -79,9 +79,9 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* colorAttachmentView)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
, GrVkImage(info, std::move(layout), GrBackendObjectOwnership::kBorrowed)
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, 1, info.fProtected)
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, 1, info.fProtected)
, fColorAttachmentView(colorAttachmentView)
, fMSAAImage(nullptr)
, fResolveAttachmentView(nullptr)
@ -98,9 +98,9 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* colorAttachmentView,
GrBackendObjectOwnership ownership)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
, GrVkImage(info, std::move(layout), ownership)
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, 1, info.fProtected)
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, 1, info.fProtected)
, fColorAttachmentView(colorAttachmentView)
, fMSAAImage(nullptr)
, fResolveAttachmentView(nullptr)
@ -114,9 +114,9 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
sk_sp<GrVkImageLayout> layout,
const GrVkRenderPass* renderPass,
VkCommandBuffer secondaryCommandBuffer)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
, GrVkImage(info, std::move(layout), GrBackendObjectOwnership::kBorrowed, true)
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, 1, info.fProtected)
, GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, 1, info.fProtected)
, fColorAttachmentView(nullptr)
, fMSAAImage(nullptr)
, fResolveAttachmentView(nullptr)

View File

@ -26,9 +26,9 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* view,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
, GrVkImage(info, std::move(layout), GrBackendObjectOwnership::kOwned)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected,
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, info.fProtected,
GrTextureType::k2D, mipMapsStatus)
, fTextureView(view)
, fDescSetCache(kMaxCachedDescSets) {
@ -45,9 +45,9 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu, const GrSurfaceDesc& desc, const GrVkImag
sk_sp<GrVkImageLayout> layout, const GrVkImageView* view,
GrMipMapsStatus mipMapsStatus, GrBackendObjectOwnership ownership,
GrWrapCacheable cacheable, GrIOType ioType, bool isExternal)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
, GrVkImage(info, std::move(layout), ownership)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected,
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, info.fProtected,
isExternal ? GrTextureType::kExternal : GrTextureType::k2D, mipMapsStatus)
, fTextureView(view)
, fDescSetCache(kMaxCachedDescSets) {
@ -66,10 +66,10 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
const GrVkImageView* view,
GrMipMapsStatus mipMapsStatus,
GrBackendObjectOwnership ownership)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
, GrVkImage(info, layout, ownership)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected,
GrTextureType::k2D, mipMapsStatus)
, INHERITED(gpu, {desc.fWidth, desc.fHeight}, info.fProtected, GrTextureType::k2D,
mipMapsStatus)
, fTextureView(view)
, fDescSetCache(kMaxCachedDescSets) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == info.fLevelCount));

View File

@ -30,7 +30,7 @@ GrVkTextureRenderTarget::GrVkTextureRenderTarget(GrVkGpu* gpu,
const GrVkImageView* colorAttachmentView,
const GrVkImageView* resolveAttachmentView,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
, GrVkImage(info, layout, GrBackendObjectOwnership::kOwned)
, GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus,
GrBackendObjectOwnership::kOwned)
@ -49,7 +49,7 @@ GrVkTextureRenderTarget::GrVkTextureRenderTarget(GrVkGpu* gpu,
const GrVkImageView* texView,
const GrVkImageView* colorAttachmentView,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
, GrVkImage(info, layout, GrBackendObjectOwnership::kOwned)
, GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus,
GrBackendObjectOwnership::kOwned)
@ -71,7 +71,7 @@ GrVkTextureRenderTarget::GrVkTextureRenderTarget(GrVkGpu* gpu,
GrMipMapsStatus mipMapsStatus,
GrBackendObjectOwnership ownership,
GrWrapCacheable cacheable)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
, GrVkImage(info, layout, ownership)
, GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus, ownership)
, GrVkRenderTarget(gpu, desc, sampleCnt, info, layout, msaaInfo, std::move(msaaLayout),
@ -89,7 +89,7 @@ GrVkTextureRenderTarget::GrVkTextureRenderTarget(GrVkGpu* gpu,
GrMipMapsStatus mipMapsStatus,
GrBackendObjectOwnership ownership,
GrWrapCacheable cacheable)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, info.fProtected)
: GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
, GrVkImage(info, layout, ownership)
, GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus, ownership)
, GrVkRenderTarget(gpu, desc, info, layout, colorAttachmentView, ownership) {

View File

@ -345,7 +345,8 @@ static std::unique_ptr<GrRenderTargetContext> draw_mipmap_into_new_render_target
GrSurfaceDesc desc;
desc.fWidth = 1;
desc.fHeight = 1;
desc.fConfig = mipmapProxy->config();
// We don't read this config so setting kUnknown
desc.fConfig = kUnknown_GrPixelConfig;
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(mipmapProxy->backendFormat(),
colorType);
sk_sp<GrSurfaceProxy> renderTarget = proxyProvider->createProxy(

View File

@ -301,11 +301,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTextureReuseDifferentConfig, repo
// The backend texture should be shared between the two uses
REPORTER_ASSERT(reporter, GrBackendTexture::TestingOnly_Equals(
grayBackendTex, texture->getBackendTexture()));
// but the view of them from the GrTexture should've been transmuted into the
// specific pixel configs
REPORTER_ASSERT(reporter, texture->config() == kAlpha_8_as_Red_GrPixelConfig ||
texture->config() == kGray_8_as_Red_GrPixelConfig);
}
}

View File

@ -30,14 +30,10 @@ static void check_surface(skiatest::Reporter* reporter,
GrSurfaceProxy* proxy,
GrSurfaceOrigin origin,
int width, int height,
GrPixelConfig config,
SkBudgeted budgeted) {
REPORTER_ASSERT(reporter, proxy->origin() == origin);
REPORTER_ASSERT(reporter, proxy->width() == width);
REPORTER_ASSERT(reporter, proxy->height() == height);
#ifdef SK_DEBUG
REPORTER_ASSERT(reporter, GrCaps::AreConfigsCompatible(config, proxy->config()));
#endif
REPORTER_ASSERT(reporter, !proxy->uniqueID().isInvalid());
REPORTER_ASSERT(reporter, proxy->isBudgeted() == budgeted);
}
@ -71,7 +67,7 @@ static void check_rendertarget(skiatest::Reporter* reporter,
REPORTER_ASSERT(reporter, rt->width() >= rtProxy->width());
REPORTER_ASSERT(reporter, rt->height() >= rtProxy->height());
}
REPORTER_ASSERT(reporter, rt->config() == rtProxy->config());
REPORTER_ASSERT(reporter, rt->backendFormat() == rtProxy->backendFormat());
REPORTER_ASSERT(reporter, rt->numSamples() == rtProxy->numSamples());
REPORTER_ASSERT(reporter, rt->surfacePriv().flags() == rtProxy->testingOnly_getFlags());
@ -108,7 +104,7 @@ static void check_texture(skiatest::Reporter* reporter,
REPORTER_ASSERT(reporter, tex->dimensions() == expectedSize);
REPORTER_ASSERT(reporter, tex->config() == texProxy->config());
REPORTER_ASSERT(reporter, tex->backendFormat() == texProxy->backendFormat());
}
@ -168,7 +164,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
proxy->gpuMemorySize(caps);
check_surface(reporter, proxy.get(), origin,
widthHeight, widthHeight, config, budgeted);
widthHeight, widthHeight, budgeted);
int supportedSamples =
caps.getRenderTargetSampleCount(numSamples, format);
check_rendertarget(reporter, caps, resourceProvider,
@ -204,7 +200,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
proxy->gpuMemorySize(caps);
check_surface(reporter, proxy.get(), origin,
widthHeight, widthHeight, config, budgeted);
widthHeight, widthHeight, budgeted);
check_texture(reporter, resourceProvider,
proxy->asTextureProxy(), fit);
}
@ -232,8 +228,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType,
kRGBA_1010102_SkColorType }) {
GrColorType grColorType = SkColorTypeToGrColorType(colorType);
GrPixelConfig config = GrColorTypeToPixelConfig(grColorType);
SkASSERT(kUnknown_GrPixelConfig != config);
// External on-screen render target.
// Tests wrapBackendRenderTarget with a GrBackendRenderTarget
@ -246,7 +240,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
proxyProvider->wrapBackendRenderTarget(backendRT, grColorType,
origin, nullptr, nullptr));
check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight,
config, SkBudgeted::kNo);
SkBudgeted::kNo);
static constexpr int kExpectedNumSamples = 1;
check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
kExpectedNumSamples, SkBackingFit::kExact,
@ -276,8 +270,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
proxyProvider->wrapBackendRenderTarget(backendRT, grColorType,
origin, nullptr, nullptr));
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
config, SkBudgeted::kNo);
kWidthHeight, kWidthHeight, SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact, 0);
@ -301,8 +294,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
}
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
config, SkBudgeted::kNo);
kWidthHeight, kWidthHeight, SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact,
@ -331,8 +323,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
}
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
config, SkBudgeted::kNo);
kWidthHeight, kWidthHeight, SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact,
@ -361,8 +352,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
}
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
config, SkBudgeted::kNo);
kWidthHeight, kWidthHeight, SkBudgeted::kNo);
check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
SkBackingFit::kExact);

View File

@ -148,7 +148,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceAllocatorTest, reporter, ctxInfo) {
bool kConditionallyShare = resourceProvider->caps()->reuseScratchTextures();
const GrColorType kRGBA = GrColorType::kRGBA_8888;
const GrColorType kBGRA = GrColorType::kBGRA_8888;
const GrColorType kAlpha = GrColorType::kAlpha_8;
const SkBackingFit kE = SkBackingFit::kExact;
const SkBackingFit kA = SkBackingFit::kApprox;
@ -199,7 +199,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceAllocatorTest, reporter, ctxInfo) {
// Two non-overlapping intervals w/ different MSAA sample counts should not share
{ { 64, kRT, kRGBA, kA, k2, kTL, kNotB },{ 64, kRT, kRGBA, kA, k4,kTL, kNotB}, k2 == k4 },
// Two non-overlapping intervals w/ different configs should not share
{ { 64, kRT, kRGBA, kA, 1, kTL, kNotB }, { 64, kRT, kBGRA, kA, 1, kTL, kNotB }, kDontShare },
{ { 64, kRT, kRGBA, kA, 1, kTL, kNotB }, { 64, kRT, kAlpha, kA, 1, kTL, kNotB }, kDontShare },
// Two non-overlapping intervals w/ different RT classifications should never share
{ { 64, kRT, kRGBA, kA, 1, kTL, kNotB }, { 64, kNotRT, kRGBA, kA, 1, kTL, kNotB }, kDontShare },
{ { 64, kNotRT, kRGBA, kA, 1, kTL, kNotB }, { 64, kRT, kRGBA, kA, 1, kTL, kNotB }, kDontShare },

View File

@ -93,7 +93,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_ownedGLTexture, reporter
desc.fID = 7; // Arbitrary, we don't actually use the texture.
desc.fFormat = GrGLFormat::kRGBA8;
desc.fOwnership = GrBackendObjectOwnership::kOwned;
desc.fConfig = kRGBA_8888_GrPixelConfig;
desc.fSize = SkISize::Make(64, 64);
auto texture =
@ -111,7 +110,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_unownedGLTexture, report
desc.fID = 7; // Arbitrary, we don't actually use the texture.
desc.fFormat = GrGLFormat::kRGBA8;
desc.fOwnership = GrBackendObjectOwnership::kBorrowed;
desc.fConfig = kRGBA_8888_GrPixelConfig;
desc.fSize = SkISize::Make(64, 64);
auto params = sk_make_sp<GrGLTextureParameters>();
@ -128,7 +126,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_ownedGLRenderTarget, rep
GrGLGpu* gpu = static_cast<GrGLGpu*>(context->priv().getGpu());
static constexpr auto kSize = SkISize::Make(64, 64);
static constexpr auto kConfig = kRGBA_8888_GrPixelConfig;
GrGLRenderTarget::IDs rtIDs;
rtIDs.fRTFBOID = 20;
@ -137,7 +134,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_ownedGLRenderTarget, rep
rtIDs.fMSColorRenderbufferID = 22;
sk_sp<GrGLRenderTarget> rt =
GrGLRenderTarget::MakeWrapped(gpu, kSize, GrGLFormat::kRGBA8, kConfig, 1, rtIDs, 0);
GrGLRenderTarget::MakeWrapped(gpu, kSize, GrGLFormat::kRGBA8, 1, rtIDs, 0);
ValidateMemoryDumps(reporter, context, rt->gpuMemorySize(), true /* isOwned */);
}
@ -147,7 +144,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_unownedGLRenderTarget, r
GrGLGpu* gpu = static_cast<GrGLGpu*>(context->priv().getGpu());
static constexpr auto kSize = SkISize::Make(64, 64);
static constexpr auto kConfig = kRGBA_8888_GrPixelConfig;
GrGLRenderTarget::IDs rtIDs;
rtIDs.fRTFBOID = 20;
@ -156,7 +152,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_unownedGLRenderTarget, r
rtIDs.fMSColorRenderbufferID = 22;
sk_sp<GrGLRenderTarget> rt =
GrGLRenderTarget::MakeWrapped(gpu, kSize, GrGLFormat::kRGBA8, kConfig, 1, rtIDs, 0);
GrGLRenderTarget::MakeWrapped(gpu, kSize, GrGLFormat::kRGBA8, 1, rtIDs, 0);
ValidateMemoryDumps(reporter, context, rt->gpuMemorySize(), false /* isOwned */);
}

View File

@ -74,10 +74,8 @@ bool read_pixels_from_texture(GrTexture* texture, GrColorType colorType, char* d
int h = texture->height();
size_t rowBytes = GrColorTypeBytesPerPixel(colorType) * w;
GrColorType srcCT = GrPixelConfigToColorType(texture->config());
GrCaps::SupportedRead supportedRead =
caps->supportedReadPixelsColorType(srcCT, texture->backendFormat(), colorType);
caps->supportedReadPixelsColorType(colorType, texture->backendFormat(), colorType);
std::fill_n(tolerances, 4, 0);
if (supportedRead.fColorType != colorType) {
size_t tmpRowBytes = GrColorTypeBytesPerPixel(supportedRead.fColorType) * w;