Remove GrBackendFormat's textureType use from isFormatTexturable call.

The goal of this change was to remove the use of GrBackendFormat::textureType()
from GrCaps::isFormatTexturable call. Instead we will always pass in a
GrTextureType into this call.

To do this a lot of plumbing of GrTextureType was added to various call
sites. However, this CL halts the plubming up at the proxy level where we
get it from the GrBackendFormat still. Future CLs will continue removing
these call sites and others that use GrBackendFormat::textureType().

Bug: skia:12342
Change-Id: Ic0f02b9c7f7402405623b8aa31aa32a9a7c22297
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439277
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Greg Daniel 2021-08-13 14:06:38 -04:00 committed by SkCQ
parent 73339ada9d
commit 832c817bc8
42 changed files with 355 additions and 161 deletions

View File

@ -47,9 +47,16 @@ static GrSurfaceProxyView create_view(GrDirectContext* dContext,
GrMipLevel mipLevel = {src.getPixels(), src.rowBytes(), nullptr};
auto colorType = SkColorTypeToGrColorType(src.colorType());
return rp->createTexture(src.dimensions(), desc.fFormat, colorType,
desc.fRenderable, desc.fSampleCnt, desc.fBudgeted,
desc.fFit, desc.fProtected, mipLevel);
return rp->createTexture(src.dimensions(),
desc.fFormat,
desc.fFormat.textureType(),
colorType,
desc.fRenderable,
desc.fSampleCnt,
desc.fBudgeted,
desc.fFit,
desc.fProtected,
mipLevel);
},
format, GrRenderable::kNo, 1, GrProtected::kNo, *dContext->priv().caps(),
GrSurfaceProxy::UseAllocator::kYes);

View File

@ -288,6 +288,7 @@ public:
/** deprecated alias of hasMipmaps(). */
bool hasMipMaps() const { return this->hasMipmaps(); }
GrBackendApi backend() const {return fBackend; }
GrTextureType textureType() const { return fTextureType; }
// If the backend API is GL, copies a snapshot of the GrGLTextureInfo struct into the passed in
// pointer and returns true. Otherwise returns false if the backend API is not GL.
@ -397,6 +398,7 @@ private:
int fHeight; //<! height in pixels
GrMipmapped fMipmapped;
GrBackendApi fBackend;
GrTextureType fTextureType;
union {
#ifdef SK_GL

View File

@ -82,27 +82,27 @@ GrBackendFormat& GrBackendFormat::operator=(const GrBackendFormat& that) {
}
#ifdef SK_GL
static GrTextureType gl_target_to_gr_target(GrGLenum target) {
switch (target) {
case GR_GL_TEXTURE_NONE:
return GrTextureType::kNone;
case GR_GL_TEXTURE_2D:
return GrTextureType::k2D;
case GR_GL_TEXTURE_RECTANGLE:
return GrTextureType::kRectangle;
case GR_GL_TEXTURE_EXTERNAL:
return GrTextureType::kExternal;
default:
SkUNREACHABLE;
}
}
GrBackendFormat::GrBackendFormat(GrGLenum format, GrGLenum target)
: fBackend(GrBackendApi::kOpenGL)
, fValid(true)
, fGLFormat(format) {
switch (target) {
case GR_GL_TEXTURE_NONE:
fTextureType = GrTextureType::kNone;
break;
case GR_GL_TEXTURE_2D:
fTextureType = GrTextureType::k2D;
break;
case GR_GL_TEXTURE_RECTANGLE:
fTextureType = GrTextureType::kRectangle;
break;
case GR_GL_TEXTURE_EXTERNAL:
fTextureType = GrTextureType::kExternal;
break;
default:
SK_ABORT("Unexpected texture target");
}
}
, fGLFormat(format)
, fTextureType(gl_target_to_gr_target(target)) {}
#endif
GrGLFormat GrBackendFormat::asGLFormat() const {
@ -455,6 +455,7 @@ GrBackendTexture::GrBackendTexture(int width,
, fHeight(height)
, fMipmapped(GrMipmapped(dawnInfo.fLevelCount > 1))
, fBackend(GrBackendApi::kDawn)
, fTextureType(GrTextureType::k2D)
, fDawnInfo(dawnInfo) {}
#endif
@ -483,6 +484,13 @@ static GrVkImageInfo apply_default_usage_flags(const GrVkImageInfo& info,
return info;
}
static GrTextureType vk_image_info_to_texture_type(const GrVkImageInfo& info) {
if (info.fYcbcrConversionInfo.isValid() && info.fYcbcrConversionInfo.fExternalFormat != 0) {
return GrTextureType::kExternal;
}
return GrTextureType::k2D;
}
GrBackendTexture::GrBackendTexture(int width,
int height,
const GrVkImageInfo& vkInfo,
@ -492,6 +500,7 @@ GrBackendTexture::GrBackendTexture(int width,
, fHeight(height)
, fMipmapped(GrMipmapped(vkInfo.fLevelCount > 1))
, fBackend(GrBackendApi::kVulkan)
, fTextureType(vk_image_info_to_texture_type(vkInfo))
, fVkInfo(apply_default_usage_flags(vkInfo, kDefaultTexRTUsageFlags))
, fMutableState(std::move(mutableState)) {}
#endif
@ -507,6 +516,7 @@ GrBackendTexture::GrBackendTexture(int width,
, fHeight(height)
, fMipmapped(mipmapped)
, fBackend(GrBackendApi::kOpenGL)
, fTextureType(gl_target_to_gr_target(glInfo.fTarget))
, fGLInfo(glInfo, params.release()) {}
sk_sp<GrGLTextureParameters> GrBackendTexture::getGLTextureParams() const {
@ -527,6 +537,7 @@ GrBackendTexture::GrBackendTexture(int width,
, fHeight(height)
, fMipmapped(mipmapped)
, fBackend(GrBackendApi::kMetal)
, fTextureType(GrTextureType::k2D)
, fMtlInfo(mtlInfo) {}
#endif
@ -546,6 +557,7 @@ GrBackendTexture::GrBackendTexture(int width,
, fHeight(height)
, fMipmapped(GrMipmapped(d3dInfo.fLevelCount > 1))
, fBackend(GrBackendApi::kDirect3D)
, fTextureType(GrTextureType::k2D)
, fD3DInfo(d3dInfo, state.release()) {}
#endif
@ -569,6 +581,7 @@ GrBackendTexture::GrBackendTexture(int width,
, fHeight(height)
, fMipmapped(mipmapped)
, fBackend(GrBackendApi::kMock)
, fTextureType(GrTextureType::k2D)
, fMockInfo(mockInfo) {}
GrBackendTexture::~GrBackendTexture() {

View File

@ -309,9 +309,11 @@ bool GrCaps::canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src
bool GrCaps::validateSurfaceParams(const SkISize& dimensions, const GrBackendFormat& format,
GrRenderable renderable, int renderTargetSampleCnt,
GrMipmapped mipped) const {
if (!this->isFormatTexturable(format)) {
return false;
GrMipmapped mipped, GrTextureType textureType) const {
if (textureType != GrTextureType::kNone) {
if (!this->isFormatTexturable(format, textureType)) {
return false;
}
}
if (GrMipmapped::kYes == mipped && !this->mipmapSupport()) {
@ -386,7 +388,7 @@ GrBackendFormat GrCaps::getDefaultBackendFormat(GrColorType colorType,
}
auto format = this->onGetDefaultBackendFormat(colorType);
if (!this->isFormatTexturable(format)) {
if (!this->isFormatTexturable(format, GrTextureType::k2D)) {
return {};
}
if (!this->areColorTypeAndFormatCompatible(colorType, format)) {

View File

@ -221,8 +221,9 @@ public:
bool isFormatCompressed(const GrBackendFormat& format) const;
// Can a texture be made with the GrBackendFormat, and then be bound and sampled in a shader.
virtual bool isFormatTexturable(const GrBackendFormat&) const = 0;
// Can a texture be made with the GrBackendFormat and texture type, and then be bound and
// sampled in a shader.
virtual bool isFormatTexturable(const GrBackendFormat&, GrTextureType) const = 0;
// Returns whether a texture of the given format can be copied to a texture of the same format.
virtual bool isFormatCopyable(const GrBackendFormat&) const = 0;
@ -420,7 +421,7 @@ public:
}
bool validateSurfaceParams(const SkISize&, const GrBackendFormat&, GrRenderable renderable,
int renderTargetSampleCnt, GrMipmapped) const;
int renderTargetSampleCnt, GrMipmapped, GrTextureType) const;
bool areColorTypeAndFormatCompatible(GrColorType grCT, const GrBackendFormat& format) const;

View File

@ -99,7 +99,7 @@ SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(
return {};
}
if (isTextureable && !fCaps->isFormatTexturable(backendFormat)) {
if (isTextureable && !fCaps->isFormatTexturable(backendFormat, backendFormat.textureType())) {
// Skia doesn't agree that this is textureable.
return {};
}
@ -158,7 +158,7 @@ GrBackendFormat GrContextThreadSafeProxy::compressedBackendFormat(SkImage::Compr
GrBackendFormat format = fCaps->getBackendFormatFromCompressionType(c);
SkASSERT(!format.isValid() || fCaps->isFormatTexturable(format));
SkASSERT(!format.isValid() || fCaps->isFormatTexturable(format, GrTextureType::k2D));
return format;
}

View File

@ -94,8 +94,14 @@ void GrDynamicAtlas::reset(SkISize initialSize, const GrCaps& caps) {
[this](GrResourceProvider* resourceProvider, const LazyAtlasDesc& desc) {
if (!fBackingTexture) {
fBackingTexture = resourceProvider->createTexture(
fTextureProxy->backingStoreDimensions(), desc.fFormat, desc.fRenderable,
desc.fSampleCnt, desc.fMipmapped, desc.fBudgeted, desc.fProtected);
fTextureProxy->backingStoreDimensions(),
desc.fFormat,
desc.fFormat.textureType(),
desc.fRenderable,
desc.fSampleCnt,
desc.fMipmapped,
desc.fBudgeted,
desc.fProtected);
}
return GrSurfaceProxy::LazyCallbackResult(fBackingTexture);
},

View File

@ -98,6 +98,7 @@ static bool validate_texel_levels(SkISize dimensions, GrColorType texelColorType
sk_sp<GrTexture> GrGpu::createTextureCommon(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrRenderable renderable,
int renderTargetSampleCnt,
SkBudgeted budgeted,
@ -110,8 +111,12 @@ sk_sp<GrTexture> GrGpu::createTextureCommon(SkISize dimensions,
}
GrMipmapped mipMapped = mipLevelCount > 1 ? GrMipmapped::kYes : GrMipmapped::kNo;
if (!this->caps()->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
mipMapped)) {
if (!this->caps()->validateSurfaceParams(dimensions,
format,
renderable,
renderTargetSampleCnt,
mipMapped,
textureType)) {
return nullptr;
}
@ -147,6 +152,7 @@ sk_sp<GrTexture> GrGpu::createTextureCommon(SkISize dimensions,
sk_sp<GrTexture> GrGpu::createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrRenderable renderable,
int renderTargetSampleCnt,
GrMipmapped mipMapped,
@ -159,8 +165,15 @@ sk_sp<GrTexture> GrGpu::createTexture(SkISize dimensions,
}
uint32_t levelClearMask =
this->caps()->shouldInitializeTextures() ? (1 << mipLevelCount) - 1 : 0;
auto tex = this->createTextureCommon(dimensions, format, renderable, renderTargetSampleCnt,
budgeted, isProtected, mipLevelCount, levelClearMask);
auto tex = this->createTextureCommon(dimensions,
format,
textureType,
renderable,
renderTargetSampleCnt,
budgeted,
isProtected,
mipLevelCount,
levelClearMask);
if (tex && mipMapped == GrMipmapped::kYes && levelClearMask) {
tex->markMipmapsClean();
}
@ -169,6 +182,7 @@ sk_sp<GrTexture> GrGpu::createTexture(SkISize dimensions,
sk_sp<GrTexture> GrGpu::createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrRenderable renderable,
int renderTargetSampleCnt,
SkBudgeted budgeted,
@ -199,8 +213,15 @@ sk_sp<GrTexture> GrGpu::createTexture(SkISize dimensions,
}
}
auto tex = this->createTextureCommon(dimensions, format, renderable, renderTargetSampleCnt,
budgeted, isProtected, texelLevelCount, levelClearMask);
auto tex = this->createTextureCommon(dimensions,
format,
textureType,
renderable,
renderTargetSampleCnt,
budgeted,
isProtected,
texelLevelCount,
levelClearMask);
if (tex) {
bool markMipLevelsClean = false;
// Currently if level 0 does not have pixels then no other level may, as enforced by
@ -245,12 +266,16 @@ sk_sp<GrTexture> GrGpu::createCompressedTexture(SkISize dimensions,
if (!data) {
return nullptr;
}
if (!this->caps()->isFormatTexturable(format)) {
return nullptr;
}
// TODO: expand CompressedDataIsCorrect to work here too
SkImage::CompressionType compressionType = GrBackendFormatToCompressionType(format);
if (compressionType == SkImage::CompressionType::kNone) {
return nullptr;
}
if (!this->caps()->isFormatTexturable(format, GrTextureType::k2D)) {
return nullptr;
}
if (dataSize < SkCompressedDataSize(compressionType, dimensions, nullptr,
mipMapped == GrMipmapped::kYes)) {
@ -270,7 +295,7 @@ sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex,
const GrCaps* caps = this->caps();
SkASSERT(caps);
if (!caps->isFormatTexturable(backendTex.getBackendFormat())) {
if (!caps->isFormatTexturable(backendTex.getBackendFormat(), backendTex.textureType())) {
return nullptr;
}
if (backendTex.width() > caps->maxTextureSize() ||
@ -289,7 +314,7 @@ sk_sp<GrTexture> GrGpu::wrapCompressedBackendTexture(const GrBackendTexture& bac
const GrCaps* caps = this->caps();
SkASSERT(caps);
if (!caps->isFormatTexturable(backendTex.getBackendFormat())) {
if (!caps->isFormatTexturable(backendTex.getBackendFormat(), backendTex.textureType())) {
return nullptr;
}
if (backendTex.width() > caps->maxTextureSize() ||
@ -311,7 +336,7 @@ sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& bac
const GrCaps* caps = this->caps();
if (!caps->isFormatTexturable(backendTex.getBackendFormat()) ||
if (!caps->isFormatTexturable(backendTex.getBackendFormat(), backendTex.textureType()) ||
!caps->isFormatRenderable(backendTex.getBackendFormat(), sampleCnt)) {
return nullptr;
}
@ -391,7 +416,8 @@ bool GrGpu::readPixels(GrSurface* surface,
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
SkASSERT(surface);
SkASSERT(!surface->framebufferOnly());
SkASSERT(this->caps()->isFormatTexturable(surface->backendFormat()));
SkASSERT(this->caps()->areColorTypeAndFormatCompatible(surfaceColorType,
surface->backendFormat()));
if (!SkIRect::MakeSize(surface->dimensions()).contains(rect)) {
return false;
@ -523,7 +549,8 @@ bool GrGpu::transferPixelsFrom(GrSurface* surface,
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
SkASSERT(surface);
SkASSERT(transferBuffer);
SkASSERT(this->caps()->isFormatTexturable(surface->backendFormat()));
SkASSERT(this->caps()->areColorTypeAndFormatCompatible(surfaceColorType,
surface->backendFormat()));
#ifdef SK_DEBUG
auto supportedRead = this->caps()->supportedReadPixelsColorType(

View File

@ -130,6 +130,7 @@ public:
*/
sk_sp<GrTexture> createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrRenderable renderable,
int renderTargetSampleCnt,
SkBudgeted budgeted,
@ -144,6 +145,7 @@ public:
*/
sk_sp<GrTexture> createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrRenderable renderable,
int renderTargetSampleCnt,
GrMipmapped mipMapped,
@ -798,6 +800,7 @@ private:
sk_sp<GrTexture> createTextureCommon(SkISize,
const GrBackendFormat&,
GrTextureType textureType,
GrRenderable,
int renderTargetSampleCnt,
SkBudgeted,

View File

@ -142,11 +142,21 @@ sk_sp<GrTextureProxy> GrProxyProvider::testingOnly_createInstantiatedProxy(
sk_sp<GrTexture> tex;
if (SkBackingFit::kApprox == fit) {
tex = resourceProvider->createApproxTexture(dimensions, format, renderable,
renderTargetSampleCnt, isProtected);
tex = resourceProvider->createApproxTexture(dimensions,
format,
format.textureType(),
renderable,
renderTargetSampleCnt,
isProtected);
} else {
tex = resourceProvider->createTexture(dimensions, format, renderable, renderTargetSampleCnt,
GrMipmapped::kNo, budgeted, isProtected);
tex = resourceProvider->createTexture(dimensions,
format,
format.textureType(),
renderable,
renderTargetSampleCnt,
GrMipmapped::kNo,
budgeted,
isProtected);
}
if (!tex) {
return nullptr;
@ -327,8 +337,16 @@ sk_sp<GrTextureProxy> GrProxyProvider::createNonMippedProxyFromBitmap(const SkBi
GrMipLevel mipLevel = {bitmap.getPixels(), bitmap.rowBytes(), nullptr};
auto colorType = SkColorTypeToGrColorType(bitmap.colorType());
return LazyCallbackResult(resourceProvider->createTexture(
desc.fDimensions, desc.fFormat, colorType, desc.fRenderable,
desc.fSampleCnt, desc.fBudgeted, desc.fFit, desc.fProtected, mipLevel));
desc.fDimensions,
desc.fFormat,
desc.fFormat.textureType(),
colorType,
desc.fRenderable,
desc.fSampleCnt,
desc.fBudgeted,
desc.fFit,
desc.fProtected,
mipLevel));
},
format, dims, GrMipmapped::kNo, GrMipmapStatus::kNotAllocated,
GrInternalSurfaceFlags::kNone, fit, budgeted, GrProtected::kNo, UseAllocator::kYes);
@ -375,8 +393,16 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMippedProxyFromBitmap(const SkBitma
SkASSERT(generatedMipLevel.fPixmap.colorType() == bitmap.colorType());
}
return LazyCallbackResult(resourceProvider->createTexture(
desc.fDimensions, desc.fFormat, colorType, GrRenderable::kNo, 1,
desc.fBudgeted, GrMipMapped::kYes, GrProtected::kNo, texels.get()));
desc.fDimensions,
desc.fFormat,
desc.fFormat.textureType(),
colorType,
GrRenderable::kNo,
1,
desc.fBudgeted,
GrMipMapped::kYes,
GrProtected::kNo,
texels.get()));
},
format, dims, GrMipmapped::kYes, GrMipmapStatus::kValid, GrInternalSurfaceFlags::kNone,
SkBackingFit::kExact, budgeted, GrProtected::kNo, UseAllocator::kYes);
@ -420,8 +446,12 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrBackendFormat& format
}
}
if (!caps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
mipMapped)) {
if (!caps->validateSurfaceParams(dimensions,
format,
renderable,
renderTargetSampleCnt,
mipMapped,
GrTextureType::k2D)) {
return nullptr;
}
GrMipmapStatus mipmapStatus = (GrMipmapped::kYes == mipMapped)
@ -454,7 +484,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createCompressedTextureProxy(
GrBackendFormat format = this->caps()->getBackendFormatFromCompressionType(compressionType);
if (!this->caps()->isFormatTexturable(format)) {
if (!this->caps()->isFormatTexturable(format, GrTextureType::k2D)) {
return nullptr;
}

View File

@ -43,6 +43,7 @@ GrResourceProvider::GrResourceProvider(GrGpu* gpu, GrResourceCache* cache, GrSin
sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrColorType colorType,
GrRenderable renderable,
int renderTargetSampleCnt,
@ -61,14 +62,24 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.fWidth, dimensions.fHeight) + 1;
}
if (!fCaps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
mipmapped)) {
if (!fCaps->validateSurfaceParams(dimensions,
format,
renderable,
renderTargetSampleCnt,
mipmapped,
textureType)) {
return nullptr;
}
// Current rule is that you can provide no level data, just the base, or all the levels.
bool hasPixels = texels[0].fPixels;
auto scratch = this->getExactScratch(dimensions, format, renderable, renderTargetSampleCnt,
budgeted, mipmapped, isProtected);
auto scratch = this->getExactScratch(dimensions,
format,
textureType,
renderable,
renderTargetSampleCnt,
budgeted,
mipmapped,
isProtected);
if (scratch) {
if (!hasPixels) {
return scratch;
@ -85,20 +96,33 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
return nullptr;
}
}
return fGpu->createTexture(dimensions, format, renderable, renderTargetSampleCnt, budgeted,
isProtected, colorType, tempColorType, tmpTexels.get(),
return fGpu->createTexture(dimensions,
format,
textureType,
renderable,
renderTargetSampleCnt,
budgeted,
isProtected,
colorType,
tempColorType,
tmpTexels.get(),
numMipLevels);
}
sk_sp<GrTexture> GrResourceProvider::getExactScratch(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrRenderable renderable,
int renderTargetSampleCnt,
SkBudgeted budgeted,
GrMipmapped mipmapped,
GrProtected isProtected) {
sk_sp<GrTexture> tex(this->findAndRefScratchTexture(dimensions, format, renderable,
renderTargetSampleCnt, mipmapped,
sk_sp<GrTexture> tex(this->findAndRefScratchTexture(dimensions,
format,
textureType,
renderable,
renderTargetSampleCnt,
mipmapped,
isProtected));
if (tex && SkBudgeted::kNo == budgeted) {
tex->resourcePriv().makeUnbudgeted();
@ -109,6 +133,7 @@ sk_sp<GrTexture> GrResourceProvider::getExactScratch(SkISize dimensions,
sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrColorType colorType,
GrRenderable renderable,
int renderTargetSampleCnt,
@ -127,19 +152,27 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
return nullptr;
}
if (!fCaps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
GrMipmapped::kNo)) {
GrMipmapped::kNo, textureType)) {
return nullptr;
}
auto tex = this->createApproxTexture(dimensions, format, renderable, renderTargetSampleCnt,
isProtected);
auto tex = this->createApproxTexture(dimensions, format, textureType, renderable,
renderTargetSampleCnt, isProtected);
if (!tex) {
return nullptr;
}
return this->writePixels(std::move(tex), colorType, dimensions, &mipLevel, 1);
} else {
return this->createTexture(dimensions, format, colorType, renderable, renderTargetSampleCnt,
budgeted, GrMipmapped::kNo, isProtected, &mipLevel);
return this->createTexture(dimensions,
format,
textureType,
colorType,
renderable,
renderTargetSampleCnt,
budgeted,
GrMipmapped::kNo,
isProtected,
&mipLevel);
}
}
@ -159,6 +192,7 @@ sk_sp<GrTexture> GrResourceProvider::createCompressedTexture(SkISize dimensions,
sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrRenderable renderable,
int renderTargetSampleCnt,
GrMipmapped mipmapped,
@ -170,7 +204,7 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
}
if (!fCaps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
mipmapped)) {
mipmapped, textureType)) {
return nullptr;
}
@ -180,14 +214,26 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
// TODO: Support GrMipmapped::kYes in scratch texture lookup here.
sk_sp<GrTexture> tex =
this->getExactScratch(dimensions, format, renderable, renderTargetSampleCnt, budgeted,
mipmapped, isProtected);
this->getExactScratch(dimensions,
format,
textureType,
renderable,
renderTargetSampleCnt,
budgeted,
mipmapped,
isProtected);
if (tex) {
return tex;
}
return fGpu->createTexture(dimensions, format, renderable, renderTargetSampleCnt, mipmapped,
budgeted, isProtected);
return fGpu->createTexture(dimensions,
format,
textureType,
renderable,
renderTargetSampleCnt,
mipmapped,
budgeted,
isProtected);
}
// Map 'value' to a larger multiple of 2. Values <= 'kMagicTol' will pop up to
@ -221,6 +267,7 @@ SkISize GrResourceProvider::MakeApprox(SkISize dimensions) {
sk_sp<GrTexture> GrResourceProvider::createApproxTexture(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrRenderable renderable,
int renderTargetSampleCnt,
GrProtected isProtected) {
@ -235,20 +282,26 @@ sk_sp<GrTexture> GrResourceProvider::createApproxTexture(SkISize dimensions,
SkASSERT(!this->caps()->isFormatCompressed(format));
if (!fCaps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
GrMipmapped::kNo)) {
GrMipmapped::kNo, textureType)) {
return nullptr;
}
auto copyDimensions = MakeApprox(dimensions);
if (auto tex = this->findAndRefScratchTexture(copyDimensions, format, renderable,
if (auto tex = this->findAndRefScratchTexture(copyDimensions, format, textureType, renderable,
renderTargetSampleCnt, GrMipmapped::kNo,
isProtected)) {
return tex;
}
return fGpu->createTexture(copyDimensions, format, renderable, renderTargetSampleCnt,
GrMipmapped::kNo, SkBudgeted::kYes, isProtected);
return fGpu->createTexture(copyDimensions,
format,
textureType,
renderable,
renderTargetSampleCnt,
GrMipmapped::kNo,
SkBudgeted::kYes,
isProtected);
}
sk_sp<GrTexture> GrResourceProvider::findAndRefScratchTexture(const GrScratchKey& key) {
@ -266,6 +319,7 @@ sk_sp<GrTexture> GrResourceProvider::findAndRefScratchTexture(const GrScratchKey
sk_sp<GrTexture> GrResourceProvider::findAndRefScratchTexture(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrRenderable renderable,
int renderTargetSampleCnt,
GrMipmapped mipmapped,
@ -274,7 +328,7 @@ sk_sp<GrTexture> GrResourceProvider::findAndRefScratchTexture(SkISize dimensions
SkASSERT(!this->isAbandoned());
SkASSERT(!this->caps()->isFormatCompressed(format));
SkASSERT(fCaps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
GrMipmapped::kNo));
GrMipmapped::kNo, textureType));
// 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.
@ -596,8 +650,12 @@ sk_sp<GrAttachment> GrResourceProvider::getDiscardableMSAAAttachment(SkISize dim
return nullptr;
}
if (!fCaps->validateSurfaceParams(
dimensions, format, GrRenderable::kYes, sampleCnt, GrMipmapped::kNo)) {
if (!fCaps->validateSurfaceParams(dimensions,
format,
GrRenderable::kYes,
sampleCnt,
GrMipmapped::kNo,
GrTextureType::kNone)) {
return nullptr;
}
@ -633,8 +691,12 @@ sk_sp<GrAttachment> GrResourceProvider::makeMSAAAttachment(SkISize dimensions,
return nullptr;
}
if (!fCaps->validateSurfaceParams(dimensions, format, GrRenderable::kYes, sampleCnt,
GrMipmapped::kNo)) {
if (!fCaps->validateSurfaceParams(dimensions,
format,
GrRenderable::kYes,
sampleCnt,
GrMipmapped::kNo,
GrTextureType::kNone)) {
return nullptr;
}
@ -653,8 +715,12 @@ sk_sp<GrAttachment> GrResourceProvider::refScratchMSAAAttachment(SkISize dimensi
ASSERT_SINGLE_OWNER
SkASSERT(!this->isAbandoned());
SkASSERT(!this->caps()->isFormatCompressed(format));
SkASSERT(fCaps->validateSurfaceParams(dimensions, format, GrRenderable::kYes, sampleCnt,
GrMipmapped::kNo));
SkASSERT(fCaps->validateSurfaceParams(dimensions,
format,
GrRenderable::kYes,
sampleCnt,
GrMipmapped::kNo,
GrTextureType::kNone));
GrScratchKey key;
GrAttachment::ComputeScratchKey(*this->caps(), format, dimensions,

View File

@ -62,6 +62,7 @@ public:
*/
sk_sp<GrTexture> createApproxTexture(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrRenderable renderable,
int renderTargetSampleCnt,
GrProtected isProtected);
@ -69,6 +70,7 @@ public:
/** Create an exact fit texture with no initial data to upload. */
sk_sp<GrTexture> createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrRenderable renderable,
int renderTargetSampleCnt,
GrMipmapped mipMapped,
@ -82,6 +84,7 @@ public:
*/
sk_sp<GrTexture> createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrTextureType textureType,
GrColorType colorType,
GrRenderable renderable,
int renderTargetSampleCnt,
@ -97,6 +100,7 @@ public:
*/
sk_sp<GrTexture> createTexture(SkISize dimensions,
const GrBackendFormat&,
GrTextureType textureType,
GrColorType srcColorType,
GrRenderable,
int renderTargetSampleCnt,
@ -112,6 +116,7 @@ public:
sk_sp<GrTexture> findAndRefScratchTexture(const GrScratchKey&);
sk_sp<GrTexture> findAndRefScratchTexture(SkISize dimensions,
const GrBackendFormat&,
GrTextureType textureType,
GrRenderable,
int renderTargetSampleCnt,
GrMipmapped,
@ -338,6 +343,7 @@ private:
*/
sk_sp<GrTexture> getExactScratch(SkISize dimensions,
const GrBackendFormat&,
GrTextureType,
GrRenderable,
int renderTargetSampleCnt,
SkBudgeted,

View File

@ -112,11 +112,21 @@ sk_sp<GrSurface> GrSurfaceProxy::createSurfaceImpl(GrResourceProvider* resourceP
sk_sp<GrSurface> surface;
if (SkBackingFit::kApprox == fFit) {
surface = resourceProvider->createApproxTexture(fDimensions, fFormat, renderable, sampleCnt,
surface = resourceProvider->createApproxTexture(fDimensions,
fFormat,
fFormat.textureType(),
renderable,
sampleCnt,
fIsProtected);
} else {
surface = resourceProvider->createTexture(fDimensions, fFormat, renderable, sampleCnt,
mipMapped, fBudgeted, fIsProtected);
surface = resourceProvider->createTexture(fDimensions,
fFormat,
fFormat.textureType(),
renderable,
sampleCnt,
mipMapped,
fBudgeted,
fIsProtected);
}
if (!surface) {
return nullptr;

View File

@ -783,7 +783,7 @@ bool GrD3DCaps::isFormatSRGB(const GrBackendFormat& format) const {
}
}
bool GrD3DCaps::isFormatTexturable(const GrBackendFormat& format) const {
bool GrD3DCaps::isFormatTexturable(const GrBackendFormat& format, GrTextureType) const {
DXGI_FORMAT dxgiFormat;
if (!format.asDxgiFormat(&dxgiFormat)) {
return false;

View File

@ -28,7 +28,7 @@ public:
bool isFormatSRGB(const GrBackendFormat&) const override;
bool isFormatTexturable(const GrBackendFormat&) const override;
bool isFormatTexturable(const GrBackendFormat&, GrTextureType) const override;
bool isFormatTexturable(DXGI_FORMAT) const;
bool isFormatCopyable(const GrBackendFormat&) const override { return true; }

View File

@ -687,7 +687,7 @@ bool GrD3DGpu::uploadToTexture(GrD3DTexture* tex,
GrColorType colorType,
const GrMipLevel* texels,
int mipLevelCount) {
SkASSERT(this->caps()->isFormatTexturable(tex->backendFormat()));
SkASSERT(this->d3dCaps().isFormatTexturable(tex->dxgiFormat()));
// The assumption is either that we have no mipmaps, or that our rect is the entire texture
SkASSERT(mipLevelCount == 1 || rect == SkIRect::MakeSize(tex->dimensions()));

View File

@ -37,7 +37,7 @@ bool GrDawnCaps::isFormatSRGB(const GrBackendFormat& format) const {
return false;
}
bool GrDawnCaps::isFormatTexturable(const GrBackendFormat& format) const {
bool GrDawnCaps::isFormatTexturable(const GrBackendFormat& format, GrTextureType) const {
// Currently, all the formats in GrDawnFormatToPixelConfig are texturable.
wgpu::TextureFormat dawnFormat;
return format.asDawnFormat(&dawnFormat);

View File

@ -27,7 +27,7 @@ public:
bool isFormatCopyable(const GrBackendFormat& format) const override { return true; }
bool isFormatTexturable(const GrBackendFormat& format) const override;
bool isFormatTexturable(const GrBackendFormat& format, GrTextureType) const override;
SupportedWrite supportedWritePixelsColorType(GrColorType surfaceColorType,
const GrBackendFormat& surfaceFormat,

View File

@ -4450,8 +4450,8 @@ bool GrGLCaps::isFormatSRGB(const GrBackendFormat& format) const {
return format.asGLFormat() == GrGLFormat::kSRGB8_ALPHA8;
}
bool GrGLCaps::isFormatTexturable(const GrBackendFormat& format) const {
if (format.textureType() == GrTextureType::kRectangle && !this->rectangleTextureSupport()) {
bool GrGLCaps::isFormatTexturable(const GrBackendFormat& format, GrTextureType textureType) const {
if (textureType == GrTextureType::kRectangle && !this->rectangleTextureSupport()) {
return false;
}
return this->isFormatTexturable(format.asGLFormat());

View File

@ -120,7 +120,7 @@ public:
bool isFormatSRGB(const GrBackendFormat&) const override;
bool isFormatTexturable(const GrBackendFormat&) const override;
bool isFormatTexturable(const GrBackendFormat&, GrTextureType) const override;
bool isFormatTexturable(GrGLFormat) const;
bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat& format,

View File

@ -51,7 +51,7 @@ public:
return GrGetColorTypeDesc(ct).encoding() == GrColorTypeEncoding::kSRGBUnorm;
}
bool isFormatTexturable(const GrBackendFormat& format) const override {
bool isFormatTexturable(const GrBackendFormat& format, GrTextureType) const override {
SkImage::CompressionType compression = format.asMockCompressionType();
if (compression != SkImage::CompressionType::kNone) {
return fOptions.fCompressedOptions[(int)compression].fTexturable;

View File

@ -229,7 +229,7 @@ GrBackendTexture GrMockGpu::onCreateBackendTexture(SkISize dimensions,
}
auto colorType = format.asMockColorType();
if (!this->caps()->isFormatTexturable(format)) {
if (!this->caps()->isFormatTexturable(format, GrTextureType::k2D)) {
return GrBackendTexture(); // invalid
}
@ -247,7 +247,7 @@ GrBackendTexture GrMockGpu::onCreateCompressedBackendTexture(
return {}; // should go through onCreateBackendTexture
}
if (!this->caps()->isFormatTexturable(format)) {
if (!this->caps()->isFormatTexturable(format, GrTextureType::k2D)) {
return {};
}

View File

@ -26,7 +26,7 @@ public:
bool isFormatSRGB(const GrBackendFormat&) const override;
bool isFormatTexturable(const GrBackendFormat&) const override;
bool isFormatTexturable(const GrBackendFormat&, GrTextureType) const override;
bool isFormatTexturable(MTLPixelFormat) const;
bool isFormatCopyable(const GrBackendFormat&) const override { return true; }

View File

@ -373,7 +373,7 @@ bool GrMtlCaps::isFormatSRGB(const GrBackendFormat& format) const {
return format_is_srgb(GrBackendFormatAsMTLPixelFormat(format));
}
bool GrMtlCaps::isFormatTexturable(const GrBackendFormat& format) const {
bool GrMtlCaps::isFormatTexturable(const GrBackendFormat& format, GrTextureType) const {
MTLPixelFormat mtlFormat = GrBackendFormatAsMTLPixelFormat(format);
return this->isFormatTexturable(mtlFormat);
}

View File

@ -366,7 +366,7 @@ bool GrMtlGpu::uploadToTexture(GrMtlTexture* tex,
GrColorType dataColorType,
const GrMipLevel texels[],
int mipLevelCount) {
SkASSERT(this->caps()->isFormatTexturable(tex->backendFormat()));
SkASSERT(this->mtlCaps().isFormatTexturable(tex->mtlTexture().pixelFormat));
// The assumption is either that we have no mipmaps, or that our rect is the entire texture
SkASSERT(mipLevelCount == 1 || rect == SkIRect::MakeSize(tex->dimensions()));
@ -475,7 +475,7 @@ bool GrMtlGpu::uploadToTexture(GrMtlTexture* tex,
}
bool GrMtlGpu::clearTexture(GrMtlTexture* tex, size_t bpp, uint32_t levelMask) {
SkASSERT(this->mtlCaps().isFormatTexturable(tex->backendFormat()));
SkASSERT(this->mtlCaps().isFormatTexturable(tex->mtlTexture().pixelFormat));
if (!levelMask) {
return true;
@ -645,7 +645,7 @@ sk_sp<GrTexture> GrMtlGpu::onCreateCompressedTexture(SkISize dimensions,
return nullptr;
}
SkASSERT(this->caps()->isFormatTexturable(format));
SkASSERT(this->caps()->isFormatTexturable(format, GrTextureType::k2D));
SkASSERT(data);
if (!check_max_blit_width(dimensions.width())) {

View File

@ -1411,7 +1411,7 @@ bool GrVkCaps::isFormatSRGB(const GrBackendFormat& format) const {
return format_is_srgb(vkFormat);
}
bool GrVkCaps::isFormatTexturable(const GrBackendFormat& format) const {
bool GrVkCaps::isFormatTexturable(const GrBackendFormat& format, GrTextureType) const {
VkFormat vkFormat;
if (!format.asVkFormat(&vkFormat)) {
return false;

View File

@ -36,7 +36,7 @@ public:
bool isFormatSRGB(const GrBackendFormat&) const override;
bool isFormatTexturable(const GrBackendFormat&) const override;
bool isFormatTexturable(const GrBackendFormat&, GrTextureType) const override;
bool isVkFormatTexturable(VkFormat) const;
bool isFormatCopyable(const GrBackendFormat&) const override { return true; }

View File

@ -442,7 +442,7 @@ static bool validate_backend_texture(const GrCaps* caps, const GrBackendTexture&
return false;
}
if (texturable && !caps->isFormatTexturable(backendFormat)) {
if (texturable && !caps->isFormatTexturable(backendFormat, tex.textureType())) {
return false;
}

View File

@ -798,10 +798,11 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLBackendAllocationTest, reporter, ctxInfo) {
};
for (auto combo : combinations) {
for (GrGLenum target : {GR_GL_TEXTURE_2D, GR_GL_TEXTURE_RECTANGLE}) {
for (GrTextureType textureType : {GrTextureType::k2D, GrTextureType::kRectangle}) {
GrGLenum target = textureType == GrTextureType::k2D ? GR_GL_TEXTURE_2D
: GR_GL_TEXTURE_RECTANGLE;
GrBackendFormat format = GrBackendFormat::MakeGL(combo.fFormat, target);
if (!glCaps->isFormatTexturable(format)) {
if (!glCaps->isFormatTexturable(format, textureType)) {
continue;
}

View File

@ -295,7 +295,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CompressedBackendAllocationTest, reporter, ct
continue;
}
if (!caps->isFormatTexturable(format)) {
if (!caps->isFormatTexturable(format, GrTextureType::k2D)) {
continue;
}

View File

@ -36,8 +36,8 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(GrSurface, reporter, ctxInfo) {
auto format = context->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kYes);
sk_sp<GrSurface> texRT1 =
resourceProvider->createTexture(kDesc, format, GrRenderable::kYes, 1, GrMipmapped::kNo,
SkBudgeted::kNo, GrProtected::kNo);
resourceProvider->createTexture(kDesc, format, GrTextureType::k2D, GrRenderable::kYes,
1, GrMipmapped::kNo, SkBudgeted::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asRenderTarget());
REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asTexture());
@ -49,8 +49,8 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(GrSurface, reporter, ctxInfo) {
static_cast<GrSurface*>(texRT1->asTexture()));
sk_sp<GrTexture> tex1 =
resourceProvider->createTexture(kDesc, format, GrRenderable::kNo, 1, GrMipmapped::kNo,
SkBudgeted::kNo, GrProtected::kNo);
resourceProvider->createTexture(kDesc, format, GrTextureType::k2D, GrRenderable::kNo, 1,
GrMipmapped::kNo, SkBudgeted::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget());
REPORTER_ASSERT(reporter, tex1.get() == tex1->asTexture());
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1.get()) == tex1->asTexture());
@ -100,8 +100,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
return rp->createCompressedTexture(dimensions, format, SkBudgeted::kNo,
GrMipmapped::kNo, GrProtected::kNo, data.get());
} else {
return rp->createTexture(dimensions, format, renderable, 1, GrMipmapped::kNo,
SkBudgeted::kNo, GrProtected::kNo);
return rp->createTexture(dimensions, format, GrTextureType::k2D, renderable, 1,
GrMipmapped::kNo, SkBudgeted::kNo, GrProtected::kNo);
}
};
@ -126,7 +126,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
// support check is working
{
bool isCompressed = caps->isFormatCompressed(combo.fFormat);
bool isTexturable = caps->isFormatTexturable(combo.fFormat);
bool isTexturable = caps->isFormatTexturable(combo.fFormat, GrTextureType::k2D);
sk_sp<GrSurface> tex = createTexture(kDims, combo.fColorType, combo.fFormat,
GrRenderable::kNo, resourceProvider);
@ -153,8 +153,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
bool isRenderable = caps->isFormatRenderable(combo.fFormat, 1);
sk_sp<GrSurface> tex = resourceProvider->createTexture(
kDims, combo.fFormat, GrRenderable::kYes, 1, GrMipmapped::kNo, SkBudgeted::kNo,
GrProtected::kNo);
kDims, combo.fFormat, GrTextureType::k2D, GrRenderable::kYes, 1,
GrMipmapped::kNo, SkBudgeted::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, SkToBool(tex) == isRenderable,
"ct:%s format:%s, tex:%d, isRenderable:%d",
GrColorTypeToStr(combo.fColorType), combo.fFormat.toStr().c_str(),
@ -166,8 +166,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
bool isRenderable = caps->isFormatRenderable(combo.fFormat, 2);
sk_sp<GrSurface> tex = resourceProvider->createTexture(
kDims, combo.fFormat, GrRenderable::kYes, 2, GrMipmapped::kNo, SkBudgeted::kNo,
GrProtected::kNo);
kDims, combo.fFormat, GrTextureType::k2D, GrRenderable::kYes, 2,
GrMipmapped::kNo, SkBudgeted::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, SkToBool(tex) == isRenderable,
"ct:%s format:%s, tex:%d, isRenderable:%d",
GrColorTypeToStr(combo.fColorType), combo.fFormat.toStr().c_str(),
@ -219,7 +219,7 @@ DEF_GPUTEST(InitialTextureClear, reporter, baseOptions) {
SkASSERT(combo.fColorType != GrColorType::kUnknown);
SkASSERT(combo.fFormat.isValid());
if (!caps->isFormatTexturable(combo.fFormat)) {
if (!caps->isFormatTexturable(combo.fFormat, GrTextureType::k2D)) {
continue;
}

View File

@ -92,8 +92,14 @@ public:
} else {
static constexpr SkISize kDimensions = {1234, 567};
sk_sp<GrTexture> texture = rp->createTexture(
kDimensions, desc.fFormat, desc.fRenderable, desc.fSampleCnt,
desc.fMipmapped, desc.fBudgeted, desc.fProtected);
kDimensions,
desc.fFormat,
desc.fFormat.textureType(),
desc.fRenderable,
desc.fSampleCnt,
desc.fMipmapped,
desc.fBudgeted,
desc.fProtected);
REPORTER_ASSERT(fTest->fReporter, texture);
return texture;
}
@ -239,9 +245,14 @@ DEF_GPUTEST(LazyProxyReleaseTest, reporter, /* options */) {
GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kNo);
auto tex = ctx->priv().resourceProvider()->createTexture({kSize, kSize}, format,
GrRenderable::kNo, 1, GrMipmapped::kNo,
SkBudgeted::kNo, GrProtected::kNo);
auto tex = ctx->priv().resourceProvider()->createTexture({kSize, kSize},
format,
GrTextureType::k2D,
GrRenderable::kNo,
1,
GrMipmapped::kNo,
SkBudgeted::kNo,
GrProtected::kNo);
using LazyInstantiationResult = GrSurfaceProxy::LazyCallbackResult;
for (bool doInstantiate : {true, false}) {
for (bool releaseCallback : {false, true}) {
@ -346,8 +357,13 @@ private:
*testExecuteValue = 1;
return {};
}
return {rp->createTexture(desc.fDimensions, desc.fFormat, desc.fRenderable,
desc.fSampleCnt, desc.fMipmapped, desc.fBudgeted,
return {rp->createTexture(desc.fDimensions,
desc.fFormat,
desc.fFormat.textureType(),
desc.fRenderable,
desc.fSampleCnt,
desc.fMipmapped,
desc.fBudgeted,
desc.fProtected),
true, GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced};
},

View File

@ -61,8 +61,9 @@ DEF_GPUTEST_FOR_METAL_CONTEXT(MtlCopySurfaceTest, reporter, ctxInfo) {
GrBackendFormat backendFormat = GrBackendFormat::MakeMtl(drawable.texture.pixelFormat);
GrSurface* src = srcProxy->peekSurface();
sk_sp<GrTexture> dst =
gpu->createTexture({kWidth, kHeight}, backendFormat, GrRenderable::kNo, 1,
GrMipmapped::kNo, SkBudgeted::kNo, GrProtected::kNo);
gpu->createTexture({kWidth, kHeight}, backendFormat, GrTextureType::k2D,
GrRenderable::kNo, 1, GrMipmapped::kNo, SkBudgeted::kNo,
GrProtected::kNo);
bool result = gpu->copySurface(dst.get(), src, SkIRect::MakeXYWH(0, 0, kWidth, kHeight),
SkIPoint::Make(0, 0));

View File

@ -314,8 +314,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTextureFullCache, reporter, ctxIn
auto format = dContext->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kNo);
textures.emplace_back(dContext->priv().resourceProvider()->createTexture(
{100, 100}, format, GrRenderable::kNo, 1, GrMipmapped::kNo, SkBudgeted::kYes,
GrProtected::kNo));
{100, 100}, format, GrTextureType::k2D, GrRenderable::kNo, 1, GrMipmapped::kNo,
SkBudgeted::kYes, GrProtected::kNo));
REPORTER_ASSERT(reporter, textures[i]);
}

View File

@ -136,12 +136,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
sk_sp<GrTexture> tex;
if (SkBackingFit::kApprox == fit) {
tex = resourceProvider->createApproxTexture(
dims, format, GrRenderable::kYes, numSamples,
GrProtected::kNo);
dims, format, GrTextureType::k2D, GrRenderable::kYes,
numSamples, GrProtected::kNo);
} else {
tex = resourceProvider->createTexture(
dims, format, GrRenderable::kYes, numSamples,
GrMipmapped::kNo, budgeted, GrProtected::kNo);
dims, format, GrTextureType::k2D, GrRenderable::kYes,
numSamples, GrMipmapped::kNo, budgeted, GrProtected::kNo);
}
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
@ -172,12 +172,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
sk_sp<GrTexture> tex;
if (SkBackingFit::kApprox == fit) {
tex = resourceProvider->createApproxTexture(
dims, format, GrRenderable::kNo, numSamples,
GrProtected::kNo);
dims, format, GrTextureType::k2D, GrRenderable::kNo,
numSamples, GrProtected::kNo);
} else {
tex = resourceProvider->createTexture(
dims, format, GrRenderable::kNo, numSamples,
GrMipmapped::kNo, budgeted, GrProtected::kNo);
dims, format, GrTextureType::k2D, GrRenderable::kNo,
numSamples, GrMipmapped::kNo, budgeted, GrProtected::kNo);
}
sk_sp<GrTextureProxy> proxy(proxyProvider->createProxy(

View File

@ -91,6 +91,7 @@ static sk_sp<GrSurfaceProxy> make_fully_lazy(GrProxyProvider* proxyProvider, con
const GrBackendFormat format = caps->getDefaultBackendFormat(p.fColorType, p.fRenderable);
auto cb = [p](GrResourceProvider* provider, const GrSurfaceProxy::LazySurfaceDesc& desc) {
auto tex = provider->createTexture({p.fSize, p.fSize}, desc.fFormat,
desc.fFormat.textureType(),
desc.fRenderable, desc.fSampleCnt,
desc.fMipmapped, desc.fBudgeted,
desc.fProtected);
@ -106,6 +107,7 @@ static sk_sp<GrSurfaceProxy> make_lazy(GrProxyProvider* proxyProvider, const GrC
const GrBackendFormat format = caps->getDefaultBackendFormat(p.fColorType, p.fRenderable);
auto cb = [](GrResourceProvider* provider, const GrSurfaceProxy::LazySurfaceDesc& desc) {
auto tex = provider->createTexture(desc.fDimensions, desc.fFormat,
desc.fFormat.textureType(),
desc.fRenderable, desc.fSampleCnt,
desc.fMipmapped, desc.fBudgeted,
desc.fProtected);

View File

@ -89,9 +89,9 @@ static sk_sp<GrRenderTarget> create_RT_with_SB(GrResourceProvider* provider,
int size, int sampleCount, SkBudgeted budgeted) {
auto format =
provider->caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888, GrRenderable::kYes);
sk_sp<GrTexture> tex(provider->createTexture({size, size}, format, GrRenderable::kYes,
sampleCount, GrMipmapped::kNo, budgeted,
GrProtected::kNo));
sk_sp<GrTexture> tex(provider->createTexture({size, size}, format, GrTextureType::k2D,
GrRenderable::kYes, sampleCount, GrMipmapped::kNo,
budgeted, GrProtected::kNo));
if (!tex || !tex->asRenderTarget()) {
return nullptr;
}
@ -1687,8 +1687,8 @@ static sk_sp<GrTexture> make_normal_texture(GrResourceProvider* provider,
SkISize dims,
int sampleCnt) {
auto format = provider->caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888, renderable);
return provider->createTexture(dims, format, renderable, sampleCnt, GrMipmapped::kNo,
SkBudgeted::kYes, GrProtected::kNo);
return provider->createTexture(dims, format, GrTextureType::k2D, renderable, sampleCnt,
GrMipmapped::kNo, SkBudgeted::kYes, GrProtected::kNo);
}
static sk_sp<GrTextureProxy> make_mipmap_proxy(GrRecordingContext* rContext,

View File

@ -77,8 +77,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(TextureBindingsResetTest, reporter, ctxInf
static constexpr SkISize kDims = {10, 10};
GrBackendFormat format = gpu->caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kNo);
auto tex = gpu->createTexture(kDims, format, GrRenderable::kNo, 1, GrMipmapped::kNo,
SkBudgeted::kNo, GrProtected::kNo);
auto tex = gpu->createTexture(kDims, format, GrTextureType::k2D, GrRenderable::kNo, 1,
GrMipmapped::kNo, SkBudgeted::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, tex);
dContext->resetGLTextureBindings();
checkBindings();

View File

@ -127,8 +127,8 @@ void basic_transfer_to_test(skiatest::Reporter* reporter,
const int kBufferHeight = 16;
sk_sp<GrTexture> tex =
resourceProvider->createTexture(kTexDims, backendFormat, renderable, 1,
GrMipmapped::kNo, SkBudgeted::kNo, GrProtected::kNo);
resourceProvider->createTexture(kTexDims, backendFormat, GrTextureType::k2D, renderable,
1, GrMipmapped::kNo, SkBudgeted::kNo, GrProtected::kNo);
if (!tex) {
ERRORF(reporter, "Could not create texture");
return;
@ -313,8 +313,9 @@ void basic_transfer_from_test(skiatest::Reporter* reporter, const sk_gpu_test::C
GrMipLevel data;
data.fPixels = textureData.get();
data.fRowBytes = textureDataRowBytes;
sk_sp<GrTexture> tex = resourceProvider->createTexture(kTexDims, format, colorType, renderable,
1, SkBudgeted::kNo, GrMipMapped::kNo,
sk_sp<GrTexture> tex = resourceProvider->createTexture(kTexDims, format, GrTextureType::k2D,
colorType, renderable, 1,
SkBudgeted::kNo, GrMipMapped::kNo,
GrProtected::kNo, &data);
if (!tex) {
return;

View File

@ -245,7 +245,7 @@ void DDLPromiseImageHelper::createCallbackContexts(GrDirectContext* direct) {
GrBackendFormat backendFormat = direct->defaultBackendFormat(baseLevel.colorType(),
GrRenderable::kNo);
if (!caps->isFormatTexturable(backendFormat)) {
if (!caps->isFormatTexturable(backendFormat, GrTextureType::k2D)) {
continue;
}

View File

@ -32,12 +32,11 @@ void DDLTileHelper::TileData::init(int id,
this->paddedRectSize().height());
SkASSERT(fPlaybackChar.isValid());
GrBackendFormat backendFormat = direct->defaultBackendFormat(fPlaybackChar.colorType(),
GrRenderable::kYes);
SkDEBUGCODE(const GrCaps* caps = direct->priv().caps());
SkASSERT(caps->isFormatTexturable(backendFormat));
SkASSERT(caps->isFormatTexturable(fPlaybackChar.backendFormat(),
fPlaybackChar.backendFormat().textureType()));
fCallbackContext.reset(new PromiseImageCallbackContext(direct, backendFormat));
fCallbackContext.reset(new PromiseImageCallbackContext(direct, fPlaybackChar.backendFormat()));
}
DDLTileHelper::TileData::TileData() {}

View File

@ -176,8 +176,9 @@ static bool setup_backend_objects(GrDirectContext* dContext,
constexpr int kSampleCnt = 0;
sk_sp<GrTexture> tmp = resourceProvider->createTexture(
offscreenDims, renderableFormat, GrColorType::kRGBA_8888, GrRenderable::kYes,
kSampleCnt, SkBudgeted::kNo, GrMipMapped::kNo, GrProtected::kNo, &level0);
offscreenDims, renderableFormat, GrTextureType::k2D, GrColorType::kRGBA_8888,
GrRenderable::kYes, kSampleCnt, SkBudgeted::kNo, GrMipMapped::kNo, GrProtected::kNo,
&level0);
if (!tmp || !tmp->asRenderTarget()) {
fputs("GrTexture is invalid.\n", stderr);
return false;