Add SkImage::CompressionType::kBC1_RGBA8_UNORM support
This is mainly so we can test the compression code on macOS. Bug: skia:9680 Change-Id: Ie0a2eacfe9100ee4ce4cc94c878d3032d6985832 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/264480 Reviewed-by: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
b53bdf16aa
commit
b0855273ab
@ -8,6 +8,8 @@ Milestone 81
|
||||
|
||||
<Insert new notes here- top is most recent.>
|
||||
|
||||
* Added support for BC1 RGBA compressed textures
|
||||
|
||||
* Added CachingHint to SkImage::makeRasterImage
|
||||
|
||||
* Added SkAnimatedImage::getCurrentFrame()
|
||||
|
@ -173,6 +173,10 @@ protected:
|
||||
fOpaqueBC1Data = make_compressed_data({ kTexWidth, kTexHeight },
|
||||
kRGBA_8888_SkColorType, true,
|
||||
SkImage::CompressionType::kBC1_RGB8_UNORM);
|
||||
|
||||
fTransparentBC1Data = make_compressed_data({ kTexWidth, kTexHeight },
|
||||
kRGBA_8888_SkColorType, false,
|
||||
SkImage::CompressionType::kBC1_RGBA8_UNORM);
|
||||
}
|
||||
|
||||
void onDraw(GrContext* context, GrRenderTargetContext*, SkCanvas* canvas) override {
|
||||
@ -181,6 +185,10 @@ protected:
|
||||
|
||||
this->drawCell(context, canvas, fOpaqueBC1Data,
|
||||
SkImage::CompressionType::kBC1_RGB8_UNORM, { 2*kPad + kCellWidth, kPad });
|
||||
|
||||
this->drawCell(context, canvas, fTransparentBC1Data,
|
||||
SkImage::CompressionType::kBC1_RGBA8_UNORM,
|
||||
{ 2*kPad + kCellWidth, 2*kPad + kTexHeight });
|
||||
}
|
||||
|
||||
private:
|
||||
@ -220,6 +228,7 @@ private:
|
||||
|
||||
sk_sp<SkData> fOpaqueETC2Data;
|
||||
sk_sp<SkData> fOpaqueBC1Data;
|
||||
sk_sp<SkData> fTransparentBC1Data;
|
||||
|
||||
typedef GM INHERITED;
|
||||
};
|
||||
|
@ -233,18 +233,22 @@ public:
|
||||
|
||||
/*
|
||||
* Experimental:
|
||||
* Skia | GL_COMPRESSED_* | MTLPixelFormat* | VK_FORMAT_*_BLOCK
|
||||
* -------------------------------------------------------------------------------------
|
||||
* kETC2_RGB8_UNORM | ETC1_RGB8 | ETC2_RGB8 (iOS-only)| ETC2_R8G8B8_UNORM
|
||||
* | RGB8_ETC2 | |
|
||||
* -------------------------------------------------------------------------------------
|
||||
* kBC1_RGB8_UNORM | RGB_S3TC_DXT1_EXT | N/A | BC1_RGB_UNORM
|
||||
* Skia | GL_COMPRESSED_* | MTLPixelFormat* | VK_FORMAT_*_BLOCK
|
||||
* --------------------------------------------------------------------------------------
|
||||
* kETC2_RGB8_UNORM | ETC1_RGB8 | ETC2_RGB8 (iOS-only) | ETC2_R8G8B8_UNORM
|
||||
* | RGB8_ETC2 | |
|
||||
* --------------------------------------------------------------------------------------
|
||||
* kBC1_RGB8_UNORM | RGB_S3TC_DXT1_EXT | N/A | BC1_RGB_UNORM
|
||||
* --------------------------------------------------------------------------------------
|
||||
* kBC1_RGBA8_UNORM | RGBA_S3TC_DXT1_EXT | BC1_RGBA (macOS-only)| BC1_RGBA_UNORM
|
||||
*/
|
||||
enum class CompressionType {
|
||||
kNone,
|
||||
kETC2_RGB8_UNORM, // the same as ETC1
|
||||
|
||||
kBC1_RGB8_UNORM,
|
||||
kLast = kBC1_RGB8_UNORM,
|
||||
kBC1_RGBA8_UNORM,
|
||||
kLast = kBC1_RGBA8_UNORM,
|
||||
};
|
||||
|
||||
static constexpr int kCompressionTypeCount = static_cast<int>(CompressionType::kLast) + 1;
|
||||
|
@ -71,9 +71,10 @@ enum class GrGLFormat {
|
||||
kRGB10_A2,
|
||||
kRGBA4,
|
||||
kSRGB8_ALPHA8,
|
||||
kCOMPRESSED_RGB8_ETC2,
|
||||
kCOMPRESSED_ETC1_RGB8,
|
||||
kCOMPRESSED_RGB8_ETC2,
|
||||
kCOMPRESSED_RGB8_BC1,
|
||||
kCOMPRESSED_RGBA8_BC1,
|
||||
kR16,
|
||||
kRG16,
|
||||
kRGBA16,
|
||||
|
@ -110,6 +110,7 @@ struct GrMockOptions {
|
||||
|
||||
fCompressedOptions[(int)SkImage::CompressionType::kETC2_RGB8_UNORM].fTexturable = true;
|
||||
fCompressedOptions[(int)SkImage::CompressionType::kBC1_RGB8_UNORM].fTexturable = true;
|
||||
fCompressedOptions[(int)SkImage::CompressionType::kBC1_RGBA8_UNORM].fTexturable = true;
|
||||
}
|
||||
|
||||
struct ConfigOptions {
|
||||
|
@ -74,7 +74,8 @@ enum GrPixelConfig {
|
||||
kRGBA_half_GrPixelConfig,
|
||||
kRGBA_half_Clamped_GrPixelConfig,
|
||||
kRGB_ETC1_GrPixelConfig,
|
||||
kRGB_BC1_GrPixelConfig,
|
||||
kBC1_RGB8_UNORM_GrPixelConfig,
|
||||
kBC1_RGBA8_UNORM_GrPixelConfig,
|
||||
kAlpha_16_GrPixelConfig,
|
||||
kRG_1616_GrPixelConfig,
|
||||
kRGBA_16161616_GrPixelConfig,
|
||||
@ -1221,11 +1222,14 @@ static constexpr GrColorType GrPixelConfigToColorType(GrPixelConfig config) {
|
||||
return GrColorType::kRGBA_F16;
|
||||
case kRGBA_half_Clamped_GrPixelConfig:
|
||||
return GrColorType::kRGBA_F16_Clamped;
|
||||
|
||||
// We may need a roughly equivalent color type for a compressed textures. This should be
|
||||
// the logical format for decompressing the data into.
|
||||
case kRGB_ETC1_GrPixelConfig:
|
||||
case kRGB_BC1_GrPixelConfig:
|
||||
// We may need a roughly equivalent color type for a compressed texture. This should be
|
||||
// the logical format for decompressing the data into.
|
||||
case kBC1_RGB8_UNORM_GrPixelConfig:
|
||||
return GrColorType::kRGB_888x;
|
||||
case kBC1_RGBA8_UNORM_GrPixelConfig:
|
||||
return GrColorType::kRGBA_8888;
|
||||
case kAlpha_8_as_Alpha_GrPixelConfig:
|
||||
return GrColorType::kAlpha_8;
|
||||
case kAlpha_8_as_Red_GrPixelConfig:
|
||||
@ -1286,7 +1290,19 @@ static constexpr GrPixelConfig GrCompressionTypeToPixelConfig(SkImage::Compressi
|
||||
switch (compression) {
|
||||
case SkImage::CompressionType::kNone: return kUnknown_GrPixelConfig;
|
||||
case SkImage::CompressionType::kETC2_RGB8_UNORM: return kRGB_ETC1_GrPixelConfig;
|
||||
case SkImage::CompressionType::kBC1_RGB8_UNORM: return kRGB_BC1_GrPixelConfig;
|
||||
case SkImage::CompressionType::kBC1_RGB8_UNORM: return kBC1_RGB8_UNORM_GrPixelConfig;
|
||||
case SkImage::CompressionType::kBC1_RGBA8_UNORM: return kBC1_RGBA8_UNORM_GrPixelConfig;
|
||||
}
|
||||
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
|
||||
static constexpr bool GrCompressionTypeIsOpaque(SkImage::CompressionType compression) {
|
||||
switch (compression) {
|
||||
case SkImage::CompressionType::kNone: return true;
|
||||
case SkImage::CompressionType::kETC2_RGB8_UNORM: return true;
|
||||
case SkImage::CompressionType::kBC1_RGB8_UNORM: return true;
|
||||
case SkImage::CompressionType::kBC1_RGBA8_UNORM: return false;
|
||||
}
|
||||
|
||||
SkUNREACHABLE;
|
||||
@ -1362,6 +1378,7 @@ static constexpr const char* GrCompressionTypeToStr(SkImage::CompressionType com
|
||||
case SkImage::CompressionType::kNone: return "kNone";
|
||||
case SkImage::CompressionType::kETC2_RGB8_UNORM: return "kETC2_RGB8_UNORM";
|
||||
case SkImage::CompressionType::kBC1_RGB8_UNORM: return "kBC1_RGB8_UNORM";
|
||||
case SkImage::CompressionType::kBC1_RGBA8_UNORM: return "kBC1_RGBA8_UNORM";
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
|
@ -146,8 +146,15 @@ static uint16_t to565(SkColor col) {
|
||||
static void create_BC1_block(SkColor col0, SkColor col1, BC1Block* block) {
|
||||
block->fColor0 = to565(col0);
|
||||
block->fColor1 = to565(col1);
|
||||
// This sets all 16 pixels to just use 'fColor0'
|
||||
block->fIndices = 0;
|
||||
if (col0 == SK_ColorTRANSPARENT) {
|
||||
// This sets all 16 pixels to just use color3 (under the assumption
|
||||
// that this is a kBC1_RGBA8_UNORM texture. Note that in this case
|
||||
// fColor0 will be opaque black.
|
||||
block->fIndices = 0xFFFFFFFF;
|
||||
} else {
|
||||
// This sets all 16 pixels to just use 'fColor0'
|
||||
block->fIndices = 0;
|
||||
}
|
||||
}
|
||||
|
||||
size_t GrCompressedDataSize(SkImage::CompressionType type, SkISize dimensions,
|
||||
@ -164,7 +171,8 @@ size_t GrCompressedDataSize(SkImage::CompressionType type, SkISize dimensions,
|
||||
case SkImage::CompressionType::kNone:
|
||||
break;
|
||||
case SkImage::CompressionType::kETC2_RGB8_UNORM:
|
||||
case SkImage::CompressionType::kBC1_RGB8_UNORM: {
|
||||
case SkImage::CompressionType::kBC1_RGB8_UNORM:
|
||||
case SkImage::CompressionType::kBC1_RGBA8_UNORM: {
|
||||
for (int i = 0; i < numMipLevels; ++i) {
|
||||
int numBlocks = num_ETC1_blocks(dimensions.width(), dimensions.height());
|
||||
|
||||
@ -177,6 +185,7 @@ size_t GrCompressedDataSize(SkImage::CompressionType type, SkISize dimensions,
|
||||
|
||||
dimensions = {SkTMax(1, dimensions.width()/2), SkTMax(1, dimensions.height()/2)};
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,12 +201,14 @@ size_t GrCompressedRowBytes(SkImage::CompressionType type, int width) {
|
||||
switch (type) {
|
||||
case SkImage::CompressionType::kNone:
|
||||
return 0;
|
||||
case SkImage::CompressionType::kBC1_RGB8_UNORM:
|
||||
case SkImage::CompressionType::kETC2_RGB8_UNORM:
|
||||
case SkImage::CompressionType::kBC1_RGB8_UNORM:
|
||||
case SkImage::CompressionType::kBC1_RGBA8_UNORM: {
|
||||
int numBlocksWidth = num_ETC1_blocks_w(width);
|
||||
|
||||
static_assert(sizeof(ETC1Block) == sizeof(BC1Block));
|
||||
return numBlocksWidth * sizeof(ETC1Block);
|
||||
}
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
@ -206,13 +217,15 @@ SkISize GrCompressedDimensions(SkImage::CompressionType type, SkISize baseDimens
|
||||
switch (type) {
|
||||
case SkImage::CompressionType::kNone:
|
||||
return baseDimensions;
|
||||
case SkImage::CompressionType::kBC1_RGB8_UNORM:
|
||||
case SkImage::CompressionType::kETC2_RGB8_UNORM:
|
||||
case SkImage::CompressionType::kBC1_RGB8_UNORM:
|
||||
case SkImage::CompressionType::kBC1_RGBA8_UNORM: {
|
||||
int numBlocksWidth = num_ETC1_blocks_w(baseDimensions.width());
|
||||
int numBlocksHeight = num_ETC1_blocks_w(baseDimensions.height());
|
||||
|
||||
// Each BC1_RGB8_UNORM and ETC1 block has 16 pixels
|
||||
return { 4 * numBlocksWidth, 4 * numBlocksHeight };
|
||||
}
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
@ -341,7 +354,8 @@ void GrFillInCompressedData(SkImage::CompressionType type, SkISize dimensions,
|
||||
if (SkImage::CompressionType::kETC2_RGB8_UNORM == type) {
|
||||
fillin_ETC1_with_color(dimensions, colorf, &dstPixels[offset]);
|
||||
} else {
|
||||
SkASSERT(type == SkImage::CompressionType::kBC1_RGB8_UNORM);
|
||||
SkASSERT(type == SkImage::CompressionType::kBC1_RGB8_UNORM ||
|
||||
type == SkImage::CompressionType::kBC1_RGBA8_UNORM);
|
||||
fillin_BC1_with_color(dimensions, colorf, &dstPixels[offset]);
|
||||
}
|
||||
|
||||
|
@ -603,6 +603,8 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapCompressedBackendTexture(const GrBack
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const GrCaps* caps = this->caps();
|
||||
|
||||
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
|
||||
|
||||
sk_sp<GrTexture> tex = resourceProvider->wrapCompressedBackendTexture(beTex, ownership,
|
||||
@ -619,8 +621,10 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapCompressedBackendTexture(const GrBack
|
||||
// Make sure we match how we created the proxy with SkBudgeted::kNo
|
||||
SkASSERT(GrBudgetedType::kBudgeted != tex->resourcePriv().budgetedType());
|
||||
|
||||
// TODO: this will need to be changed for compressed RGBA formats
|
||||
GrSwizzle texSwizzle = GrSwizzle::RGB1();
|
||||
SkImage::CompressionType compressionType = caps->compressionType(beTex.getBackendFormat());
|
||||
|
||||
GrSwizzle texSwizzle = GrCompressionTypeIsOpaque(compressionType) ? GrSwizzle::RGB1()
|
||||
: GrSwizzle::RGBA();
|
||||
|
||||
return sk_sp<GrTextureProxy>(
|
||||
new GrTextureProxy(std::move(tex), origin, texSwizzle, UseAllocator::kNo));
|
||||
|
@ -2651,6 +2651,20 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
||||
// There are no support GrColorTypes for this format
|
||||
}
|
||||
|
||||
// Format: COMPRESSED_RGBA8_BC1
|
||||
{
|
||||
FormatInfo& info = this->getFormatInfo(GrGLFormat::kCOMPRESSED_RGBA8_BC1);
|
||||
info.fFormatType = FormatType::kNormalizedFixedPoint;
|
||||
info.fInternalFormatForTexImageOrStorage = GR_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
if (GR_IS_GR_GL(standard) || GR_IS_GR_GL_ES(standard)) {
|
||||
if (ctxInfo.hasExtension("GL_EXT_texture_compression_s3tc")) {
|
||||
info.fFlags = FormatInfo::kTexturable_Flag;
|
||||
}
|
||||
} // No WebGL support
|
||||
|
||||
// There are no support GrColorTypes for this format
|
||||
}
|
||||
|
||||
// Format: COMPRESSED_RGB8_ETC2
|
||||
{
|
||||
FormatInfo& info = this->getFormatInfo(GrGLFormat::kCOMPRESSED_RGB8_ETC2);
|
||||
@ -4003,6 +4017,8 @@ SkImage::CompressionType GrGLCaps::compressionType(const GrBackendFormat& format
|
||||
return SkImage::CompressionType::kETC2_RGB8_UNORM;
|
||||
case GrGLFormat::kCOMPRESSED_RGB8_BC1:
|
||||
return SkImage::CompressionType::kBC1_RGB8_UNORM;
|
||||
case GrGLFormat::kCOMPRESSED_RGBA8_BC1:
|
||||
return SkImage::CompressionType::kBC1_RGBA8_UNORM;
|
||||
default:
|
||||
return SkImage::CompressionType::kNone;
|
||||
}
|
||||
@ -4132,6 +4148,8 @@ static GrPixelConfig validate_sized_format(GrGLFormat format,
|
||||
case GrColorType::kRGBA_8888:
|
||||
if (format == GrGLFormat::kRGBA8) {
|
||||
return kRGBA_8888_GrPixelConfig;
|
||||
} else if (format == GrGLFormat::kCOMPRESSED_RGBA8_BC1) {
|
||||
return kBC1_RGBA8_UNORM_GrPixelConfig;
|
||||
}
|
||||
break;
|
||||
case GrColorType::kRGBA_8888_SRGB:
|
||||
@ -4148,7 +4166,7 @@ static GrPixelConfig validate_sized_format(GrGLFormat format,
|
||||
format == GrGLFormat::kCOMPRESSED_ETC1_RGB8) {
|
||||
return kRGB_ETC1_GrPixelConfig;
|
||||
} else if (format == GrGLFormat::kCOMPRESSED_RGB8_BC1) {
|
||||
return kRGB_BC1_GrPixelConfig;
|
||||
return kBC1_RGB8_UNORM_GrPixelConfig;
|
||||
}
|
||||
break;
|
||||
case GrColorType::kRG_88:
|
||||
@ -4259,7 +4277,9 @@ GrPixelConfig GrGLCaps::onGetConfigFromCompressedBackendFormat(const GrBackendFo
|
||||
glFormat == GrGLFormat::kCOMPRESSED_ETC1_RGB8) {
|
||||
return kRGB_ETC1_GrPixelConfig;
|
||||
} else if (glFormat == GrGLFormat::kCOMPRESSED_RGB8_BC1) {
|
||||
return kRGB_BC1_GrPixelConfig;
|
||||
return kBC1_RGB8_UNORM_GrPixelConfig;
|
||||
} else if (glFormat == GrGLFormat::kCOMPRESSED_RGBA8_BC1) {
|
||||
return kBC1_RGBA8_UNORM_GrPixelConfig;
|
||||
}
|
||||
|
||||
return kUnknown_GrPixelConfig;
|
||||
@ -4320,6 +4340,12 @@ GrBackendFormat GrGLCaps::getBackendFormatFromCompressionType(
|
||||
GR_GL_TEXTURE_2D);
|
||||
}
|
||||
return {};
|
||||
case SkImage::CompressionType::kBC1_RGBA8_UNORM:
|
||||
if (this->isFormatTexturable(GrGLFormat::kCOMPRESSED_RGBA8_BC1)) {
|
||||
return GrBackendFormat::MakeGL(GR_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
||||
GR_GL_TEXTURE_2D);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
SkUNREACHABLE;
|
||||
@ -4376,6 +4402,10 @@ std::vector<GrCaps::TestFormatColorTypeCombination> GrGLCaps::getTestingCombinat
|
||||
GrBackendFormat::MakeGL(GR_GL_COMPRESSED_RGB8_ETC2, GR_GL_TEXTURE_2D) },
|
||||
{ GrColorType::kRGB_888x,
|
||||
GrBackendFormat::MakeGL(GR_GL_COMPRESSED_ETC1_RGB8, GR_GL_TEXTURE_2D) },
|
||||
{ GrColorType::kRGB_888x,
|
||||
GrBackendFormat::MakeGL(GR_GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GR_GL_TEXTURE_2D) },
|
||||
{ GrColorType::kRGBA_8888,
|
||||
GrBackendFormat::MakeGL(GR_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GR_GL_TEXTURE_2D) },
|
||||
{ GrColorType::kRG_88,
|
||||
GrBackendFormat::MakeGL(GR_GL_RG8, GR_GL_TEXTURE_2D) },
|
||||
{ GrColorType::kRGBA_1010102,
|
||||
|
@ -3791,10 +3791,11 @@ static GrPixelConfig gl_format_to_pixel_config(GrGLFormat format) {
|
||||
case GrGLFormat::kALPHA8: return kAlpha_8_GrPixelConfig;
|
||||
case GrGLFormat::kR8: return kAlpha_8_GrPixelConfig;
|
||||
|
||||
case GrGLFormat::kCOMPRESSED_RGB8_ETC2: return kRGB_ETC1_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 kRGB_BC1_GrPixelConfig;
|
||||
case GrGLFormat::kCOMPRESSED_RGB8_BC1: return kBC1_RGB8_UNORM_GrPixelConfig;
|
||||
case GrGLFormat::kCOMPRESSED_RGBA8_BC1: return kBC1_RGBA8_UNORM_GrPixelConfig;
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
|
@ -634,9 +634,10 @@ GrGLenum GrToGLStencilFunc(GrStencilTest test) {
|
||||
|
||||
bool GrGLFormatIsCompressed(GrGLFormat format) {
|
||||
switch (format) {
|
||||
case GrGLFormat::kCOMPRESSED_RGB8_ETC2:
|
||||
case GrGLFormat::kCOMPRESSED_ETC1_RGB8:
|
||||
case GrGLFormat::kCOMPRESSED_RGB8_ETC2:
|
||||
case GrGLFormat::kCOMPRESSED_RGB8_BC1:
|
||||
case GrGLFormat::kCOMPRESSED_RGBA8_BC1:
|
||||
return true;
|
||||
|
||||
case GrGLFormat::kRGBA8:
|
||||
@ -665,11 +666,13 @@ bool GrGLFormatIsCompressed(GrGLFormat format) {
|
||||
|
||||
SkImage::CompressionType GrGLFormatToCompressionType(GrGLFormat format) {
|
||||
switch (format) {
|
||||
case GrGLFormat::kCOMPRESSED_RGB8_ETC2:
|
||||
case GrGLFormat::kCOMPRESSED_ETC1_RGB8:
|
||||
case GrGLFormat::kCOMPRESSED_RGB8_ETC2:
|
||||
return SkImage::CompressionType::kETC2_RGB8_UNORM;
|
||||
case GrGLFormat::kCOMPRESSED_RGB8_BC1:
|
||||
return SkImage::CompressionType::kBC1_RGB8_UNORM;
|
||||
case GrGLFormat::kCOMPRESSED_RGBA8_BC1:
|
||||
return SkImage::CompressionType::kBC1_RGBA8_UNORM;
|
||||
|
||||
case GrGLFormat::kRGBA8:
|
||||
case GrGLFormat::kR8:
|
||||
|
@ -298,9 +298,10 @@ static constexpr GrGLFormat GrGLFormatFromGLEnum(GrGLenum glFormat) {
|
||||
case GR_GL_RGB10_A2: return GrGLFormat::kRGB10_A2;
|
||||
case GR_GL_RGBA4: return GrGLFormat::kRGBA4;
|
||||
case GR_GL_SRGB8_ALPHA8: return GrGLFormat::kSRGB8_ALPHA8;
|
||||
case GR_GL_COMPRESSED_RGB8_ETC2: return GrGLFormat::kCOMPRESSED_RGB8_ETC2;
|
||||
case GR_GL_COMPRESSED_ETC1_RGB8: return GrGLFormat::kCOMPRESSED_ETC1_RGB8;
|
||||
case GR_GL_COMPRESSED_RGB8_ETC2: return GrGLFormat::kCOMPRESSED_RGB8_ETC2;
|
||||
case GR_GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return GrGLFormat::kCOMPRESSED_RGB8_BC1;
|
||||
case GR_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return GrGLFormat::kCOMPRESSED_RGBA8_BC1;
|
||||
case GR_GL_R16: return GrGLFormat::kR16;
|
||||
case GR_GL_RG16: return GrGLFormat::kRG16;
|
||||
case GR_GL_RGBA16: return GrGLFormat::kRGBA16;
|
||||
@ -327,9 +328,10 @@ static constexpr GrGLenum GrGLFormatToEnum(GrGLFormat format) {
|
||||
case GrGLFormat::kRGB10_A2: return GR_GL_RGB10_A2;
|
||||
case GrGLFormat::kRGBA4: return GR_GL_RGBA4;
|
||||
case GrGLFormat::kSRGB8_ALPHA8: return GR_GL_SRGB8_ALPHA8;
|
||||
case GrGLFormat::kCOMPRESSED_RGB8_ETC2: return GR_GL_COMPRESSED_RGB8_ETC2;
|
||||
case GrGLFormat::kCOMPRESSED_ETC1_RGB8: return GR_GL_COMPRESSED_ETC1_RGB8;
|
||||
case GrGLFormat::kCOMPRESSED_RGB8_ETC2: return GR_GL_COMPRESSED_RGB8_ETC2;
|
||||
case GrGLFormat::kCOMPRESSED_RGB8_BC1: return GR_GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
||||
case GrGLFormat::kCOMPRESSED_RGBA8_BC1: return GR_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
case GrGLFormat::kR16: return GR_GL_R16;
|
||||
case GrGLFormat::kRG16: return GR_GL_RG16;
|
||||
case GrGLFormat::kRGBA16: return GR_GL_RGBA16;
|
||||
@ -357,8 +359,10 @@ static constexpr const char* GrGLFormatToStr(GrGLenum glFormat) {
|
||||
case GR_GL_RGBA4: return "RGBA4";
|
||||
case GR_GL_RGBA32F: return "RGBA32F";
|
||||
case GR_GL_SRGB8_ALPHA8: return "SRGB8_ALPHA8";
|
||||
case GR_GL_COMPRESSED_RGB8_ETC2: return "ETC2";
|
||||
case GR_GL_COMPRESSED_ETC1_RGB8: return "ETC1";
|
||||
case GR_GL_COMPRESSED_RGB8_ETC2: return "ETC2";
|
||||
case GR_GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return "RGB8_BC1";
|
||||
case GR_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return "RGBA8_BC1";
|
||||
case GR_GL_R16: return "R16";
|
||||
case GR_GL_RG16: return "RG16";
|
||||
case GR_GL_RGBA16: return "RGBA16";
|
||||
|
@ -60,7 +60,8 @@ std::vector<GrCaps::TestFormatColorTypeCombination> GrMockCaps::getTestingCombin
|
||||
SkImage::CompressionType::kETC2_RGB8_UNORM)},
|
||||
{ GrColorType::kRGB_888x, GrBackendFormat::MakeMock(GrColorType::kUnknown,
|
||||
SkImage::CompressionType::kBC1_RGB8_UNORM)},
|
||||
|
||||
{ GrColorType::kRGBA_8888, GrBackendFormat::MakeMock(GrColorType::kUnknown,
|
||||
SkImage::CompressionType::kBC1_RGBA8_UNORM)},
|
||||
};
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
|
@ -225,6 +225,9 @@ private:
|
||||
compression == SkImage::CompressionType::kBC1_RGB8_UNORM) {
|
||||
return ct == GrColorType::kRGB_888x; // TODO: this may be too restrictive
|
||||
}
|
||||
if (compression == SkImage::CompressionType::kBC1_RGBA8_UNORM) {
|
||||
return ct == GrColorType::kRGBA_8888;
|
||||
}
|
||||
|
||||
return ct == format.asMockColorType();
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ private:
|
||||
#ifdef SK_BUILD_FOR_IOS
|
||||
static constexpr size_t kNumMtlFormats = 17;
|
||||
#else
|
||||
static constexpr size_t kNumMtlFormats = 14;
|
||||
static constexpr size_t kNumMtlFormats = 15;
|
||||
#endif
|
||||
static size_t GetFormatIndex(MTLPixelFormat);
|
||||
FormatInfo fFormatTable[kNumMtlFormats];
|
||||
|
@ -313,19 +313,21 @@ bool GrMtlCaps::isFormatSRGB(const GrBackendFormat& format) const {
|
||||
}
|
||||
|
||||
SkImage::CompressionType GrMtlCaps::compressionType(const GrBackendFormat& format) const {
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
return SkImage::CompressionType::kNone;
|
||||
#else
|
||||
|
||||
switch (GrBackendFormatAsMTLPixelFormat(format)) {
|
||||
#ifdef SK_BUILD_FOR_IOS
|
||||
case MTLPixelFormatETC2_RGB8:
|
||||
// ETC2 uses the same compression layout as ETC1
|
||||
return SkImage::CompressionType::kETC2_RGB8_UNORM;
|
||||
#else
|
||||
case MTLPixelFormatBC1_RGBA:
|
||||
return SkImage::CompressionType::kBC1_RGBA8_UNORM;
|
||||
#endif
|
||||
default:
|
||||
return SkImage::CompressionType::kNone;
|
||||
}
|
||||
|
||||
SkUNREACHABLE;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GrMtlCaps::isFormatTexturableAndUploadable(GrColorType ct,
|
||||
@ -478,6 +480,8 @@ static constexpr MTLPixelFormat kMtlFormats[] = {
|
||||
MTLPixelFormatRG16Unorm,
|
||||
#ifdef SK_BUILD_FOR_IOS
|
||||
MTLPixelFormatETC2_RGB8,
|
||||
#else
|
||||
MTLPixelFormatBC1_RGBA,
|
||||
#endif
|
||||
MTLPixelFormatRGBA16Unorm,
|
||||
MTLPixelFormatRG16Float,
|
||||
@ -783,6 +787,11 @@ void GrMtlCaps::initFormatTable() {
|
||||
info = &fFormatTable[GetFormatIndex(MTLPixelFormatETC2_RGB8)];
|
||||
info->fFlags = FormatInfo::kTexturable_Flag;
|
||||
// NO supported colorTypes
|
||||
#else
|
||||
// BC1_RGBA
|
||||
info = &fFormatTable[GetFormatIndex(MTLPixelFormatBC1_RGBA)];
|
||||
info->fFlags = FormatInfo::kTexturable_Flag;
|
||||
// NO supported colorTypes
|
||||
#endif
|
||||
|
||||
// Format: RGBA16Unorm
|
||||
@ -893,6 +902,11 @@ static constexpr GrPixelConfig validate_sized_format(GrMTLPixelFormat grFormat,
|
||||
if (MTLPixelFormatRGBA8Unorm == format) {
|
||||
return kRGBA_8888_GrPixelConfig;
|
||||
}
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
else if (MTLPixelFormatBC1_RGBA == format) {
|
||||
return kBC1_RGBA8_UNORM_GrPixelConfig;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case GrColorType::kRGBA_8888_SRGB:
|
||||
if (MTLPixelFormatRGBA8Unorm_sRGB == format) {
|
||||
@ -1000,6 +1014,8 @@ GrPixelConfig GrMtlCaps::onGetConfigFromCompressedBackendFormat(const GrBackendF
|
||||
switch (GrBackendFormatAsMTLPixelFormat(f)) {
|
||||
#ifdef SK_BUILD_FOR_IOS
|
||||
case MTLPixelFormatETC2_RGB8: return kRGB_ETC1_GrPixelConfig;
|
||||
#else
|
||||
case MTLPixelFormatBC1_RGBA: return kBC1_RGBA8_UNORM_GrPixelConfig;
|
||||
#endif
|
||||
default: return kUnknown_GrPixelConfig;
|
||||
}
|
||||
@ -1047,8 +1063,15 @@ GrBackendFormat GrMtlCaps::getBackendFormatFromCompressionType(
|
||||
return GrBackendFormat::MakeMtl(MTLPixelFormatETC2_RGB8);
|
||||
#endif
|
||||
case SkImage::CompressionType::kBC1_RGB8_UNORM:
|
||||
// Metal only supports the RGBA BC1 variants
|
||||
// Metal only supports the RGBA BC1 variant (see following)
|
||||
return {};
|
||||
case SkImage::CompressionType::kBC1_RGBA8_UNORM:
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
return GrBackendFormat::MakeMtl(MTLPixelFormatBC1_RGBA);
|
||||
#else
|
||||
return {};
|
||||
#endif
|
||||
|
||||
}
|
||||
SK_ABORT("Invalid compression type");
|
||||
}
|
||||
@ -1174,6 +1197,8 @@ std::vector<GrCaps::TestFormatColorTypeCombination> GrMtlCaps::getTestingCombina
|
||||
{ GrColorType::kRGB_888x, GrBackendFormat::MakeMtl(MTLPixelFormatRGBA8Unorm) },
|
||||
#ifdef SK_BUILD_FOR_IOS
|
||||
{ GrColorType::kRGB_888x, GrBackendFormat::MakeMtl(MTLPixelFormatETC2_RGB8) },
|
||||
#else
|
||||
{ GrColorType::kRGBA_8888, GrBackendFormat::MakeMtl(MTLPixelFormatBC1_RGBA) },
|
||||
#endif
|
||||
{ GrColorType::kRG_88, GrBackendFormat::MakeMtl(MTLPixelFormatRG8Unorm) },
|
||||
{ GrColorType::kBGRA_8888, GrBackendFormat::MakeMtl(MTLPixelFormatBGRA8Unorm) },
|
||||
|
@ -584,17 +584,16 @@ sk_sp<GrTexture> GrMtlGpu::onCreateCompressedTexture(SkISize dimensions,
|
||||
// copy data into the buffer, skipping any trailing bytes
|
||||
memcpy(buffer, data, dataSize);
|
||||
|
||||
size_t bytesPerPixel = fMtlCaps->bytesPerPixel(mtlPixelFormat);
|
||||
|
||||
SkISize levelDimensions = dimensions;
|
||||
for (int currentMipLevel = 0; currentMipLevel < numMipLevels; currentMipLevel++) {
|
||||
size_t trimRowBytes = levelDimensions.width() * bytesPerPixel;
|
||||
size_t levelSize = trimRowBytes * levelDimensions.height();
|
||||
const size_t levelRowBytes = GrCompressedRowBytes(compressionType, levelDimensions.width());
|
||||
size_t levelSize = GrCompressedDataSize(compressionType, levelDimensions, nullptr,
|
||||
GrMipMapped::kNo);
|
||||
|
||||
// TODO: can this all be done in one go?
|
||||
[blitCmdEncoder copyFromBuffer: transferBuffer
|
||||
sourceOffset: individualMipOffsets[currentMipLevel]
|
||||
sourceBytesPerRow: trimRowBytes
|
||||
sourceBytesPerRow: levelRowBytes
|
||||
sourceBytesPerImage: levelSize
|
||||
sourceSize: MTLSizeMake(levelDimensions.width(),
|
||||
levelDimensions.height(), 1)
|
||||
|
@ -98,9 +98,16 @@ bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format) {
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
case kRGB_BC1_GrPixelConfig:
|
||||
// Even Mac desktops only support the RGBA variants
|
||||
case kBC1_RGB8_UNORM_GrPixelConfig:
|
||||
// Even Mac desktops only support the RGBA variant
|
||||
return false;
|
||||
case kBC1_RGBA8_UNORM_GrPixelConfig:
|
||||
#ifdef SK_BUILD_FOR_IOS
|
||||
return false;
|
||||
#else
|
||||
*format = MTLPixelFormatBC1_RGBA;
|
||||
return true;
|
||||
#endif
|
||||
case kAlpha_16_GrPixelConfig:
|
||||
*format = MTLPixelFormatR16Unorm;
|
||||
return true;
|
||||
@ -300,6 +307,9 @@ bool GrMtlFormatIsCompressed(MTLPixelFormat mtlFormat) {
|
||||
#ifdef SK_BUILD_FOR_IOS
|
||||
case MTLPixelFormatETC2_RGB8:
|
||||
return true;
|
||||
#else
|
||||
case MTLPixelFormatBC1_RGBA:
|
||||
return true;
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
@ -310,6 +320,8 @@ SkImage::CompressionType GrMtlFormatToCompressionType(MTLPixelFormat mtlFormat)
|
||||
switch (mtlFormat) {
|
||||
#ifdef SK_BUILD_FOR_IOS
|
||||
case MTLPixelFormatETC2_RGB8: return SkImage::CompressionType::kETC2_RGB8_UNORM;
|
||||
#else
|
||||
case MTLPixelFormatBC1_RGBA: return SkImage::CompressionType::kBC1_RGBA8_UNORM;
|
||||
#endif
|
||||
default: return SkImage::CompressionType::kNone;
|
||||
}
|
||||
@ -343,12 +355,14 @@ const char* GrMtlFormatToStr(GrMTLPixelFormat mtlFormat) {
|
||||
case MTLPixelFormatR16Unorm: return "R16Unorm";
|
||||
case MTLPixelFormatRG16Unorm: return "RG16Unorm";
|
||||
#ifdef SK_BUILD_FOR_IOS
|
||||
case MTLPixelFormatETC2_RGB8: return "ETC2_RGB8";
|
||||
case MTLPixelFormatETC2_RGB8: return "ETC2_RGB8";
|
||||
#else
|
||||
case MTLPixelFormatBC1_RGBA: return "BC1_RGBA";
|
||||
#endif
|
||||
case MTLPixelFormatRGBA16Unorm: return "RGBA16Unorm";
|
||||
case MTLPixelFormatRG16Float: return "RG16Float";
|
||||
case MTLPixelFormatRGBA16Unorm: return "RGBA16Unorm";
|
||||
case MTLPixelFormatRG16Float: return "RG16Float";
|
||||
|
||||
default: return "Unknown";
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,8 @@ enum class FormatCompatibilityClass {
|
||||
k24_3_1,
|
||||
k32_4_1,
|
||||
k64_8_1,
|
||||
kBC1_RGB_8_16,
|
||||
kBC1_RGB_8_16_1,
|
||||
kBC1_RGBA_8_16,
|
||||
kETC2_RGB_8_16,
|
||||
};
|
||||
} // anonymous namespace
|
||||
@ -113,7 +114,10 @@ static FormatCompatibilityClass format_compatibility_class(VkFormat format) {
|
||||
return FormatCompatibilityClass::kETC2_RGB_8_16;
|
||||
|
||||
case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
|
||||
return FormatCompatibilityClass::kBC1_RGB_8_16;
|
||||
return FormatCompatibilityClass::kBC1_RGB_8_16_1;
|
||||
|
||||
case VK_FORMAT_BC1_RGBA_UNORM_BLOCK:
|
||||
return FormatCompatibilityClass::kBC1_RGBA_8_16;
|
||||
|
||||
default:
|
||||
SK_ABORT("Unsupported VkFormat");
|
||||
@ -673,6 +677,7 @@ static constexpr VkFormat kVkFormats[] = {
|
||||
VK_FORMAT_R8G8B8A8_SRGB,
|
||||
VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
|
||||
VK_FORMAT_BC1_RGB_UNORM_BLOCK,
|
||||
VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
|
||||
VK_FORMAT_R16_UNORM,
|
||||
VK_FORMAT_R16G16_UNORM,
|
||||
VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM,
|
||||
@ -1139,6 +1144,15 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
|
||||
// No supported GrColorTypes.
|
||||
}
|
||||
|
||||
// Format: VK_FORMAT_BC1_RGBA_UNORM_BLOCK
|
||||
{
|
||||
constexpr VkFormat format = VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
|
||||
auto& info = this->getFormatInfo(format);
|
||||
info.init(interface, physDev, properties, format);
|
||||
info.fBytesPerPixel = 0;
|
||||
// No supported GrColorTypes.
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Map GrColorTypes (used for creating GrSurfaces) to VkFormats. The order in which the formats
|
||||
// are passed into the setColorType function indicates the priority in selecting which format
|
||||
@ -1283,6 +1297,7 @@ SkImage::CompressionType GrVkCaps::compressionType(const GrBackendFormat& format
|
||||
switch (vkFormat) {
|
||||
case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: return SkImage::CompressionType::kETC2_RGB8_UNORM;
|
||||
case VK_FORMAT_BC1_RGB_UNORM_BLOCK: return SkImage::CompressionType::kBC1_RGB8_UNORM;
|
||||
case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: return SkImage::CompressionType::kBC1_RGBA8_UNORM;
|
||||
default: return SkImage::CompressionType::kNone;
|
||||
}
|
||||
|
||||
@ -1550,6 +1565,8 @@ static GrPixelConfig validate_image_info(VkFormat format, GrColorType ct, bool h
|
||||
case GrColorType::kRGBA_8888:
|
||||
if (VK_FORMAT_R8G8B8A8_UNORM == format) {
|
||||
return kRGBA_8888_GrPixelConfig;
|
||||
} else if (VK_FORMAT_BC1_RGBA_UNORM_BLOCK == format) {
|
||||
return kBC1_RGBA8_UNORM_GrPixelConfig;
|
||||
}
|
||||
break;
|
||||
case GrColorType::kRGBA_8888_SRGB:
|
||||
@ -1565,7 +1582,7 @@ static GrPixelConfig validate_image_info(VkFormat format, GrColorType ct, bool h
|
||||
} else if (VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK == format) {
|
||||
return kRGB_ETC1_GrPixelConfig;
|
||||
} else if (VK_FORMAT_BC1_RGB_UNORM_BLOCK == format) {
|
||||
return kRGB_BC1_GrPixelConfig;
|
||||
return kBC1_RGB8_UNORM_GrPixelConfig;
|
||||
}
|
||||
break;
|
||||
case GrColorType::kRG_88:
|
||||
@ -1659,7 +1676,9 @@ GrPixelConfig GrVkCaps::onGetConfigFromCompressedBackendFormat(const GrBackendFo
|
||||
if (vkFormat == VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK) {
|
||||
return kRGB_ETC1_GrPixelConfig;
|
||||
} else if (vkFormat == VK_FORMAT_BC1_RGB_UNORM_BLOCK) {
|
||||
return kRGB_BC1_GrPixelConfig;
|
||||
return kBC1_RGB8_UNORM_GrPixelConfig;
|
||||
} else if (vkFormat == VK_FORMAT_BC1_RGBA_UNORM_BLOCK) {
|
||||
return kBC1_RGBA8_UNORM_GrPixelConfig;
|
||||
}
|
||||
return kUnknown_GrPixelConfig;
|
||||
}
|
||||
@ -1714,6 +1733,11 @@ GrBackendFormat GrVkCaps::getBackendFormatFromCompressionType(
|
||||
return GrBackendFormat::MakeVk(VK_FORMAT_BC1_RGB_UNORM_BLOCK);
|
||||
}
|
||||
return {};
|
||||
case SkImage::CompressionType::kBC1_RGBA8_UNORM:
|
||||
if (this->isVkFormatTexturable(VK_FORMAT_BC1_RGBA_UNORM_BLOCK)) {
|
||||
return GrBackendFormat::MakeVk(VK_FORMAT_BC1_RGBA_UNORM_BLOCK);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
SkUNREACHABLE;
|
||||
@ -1873,6 +1897,7 @@ std::vector<GrCaps::TestFormatColorTypeCombination> GrVkCaps::getTestingCombinat
|
||||
// These two compressed formats both have an effective colorType of kRGB_888x
|
||||
{ GrColorType::kRGB_888x, GrBackendFormat::MakeVk(VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK)},
|
||||
{ GrColorType::kRGB_888x, GrBackendFormat::MakeVk(VK_FORMAT_BC1_RGB_UNORM_BLOCK) },
|
||||
{ GrColorType::kRGBA_8888, GrBackendFormat::MakeVk(VK_FORMAT_BC1_RGBA_UNORM_BLOCK) },
|
||||
};
|
||||
|
||||
return combos;
|
||||
|
@ -283,7 +283,7 @@ private:
|
||||
std::unique_ptr<ColorTypeInfo[]> fColorTypeInfos;
|
||||
int fColorTypeInfoCount = 0;
|
||||
};
|
||||
static const size_t kNumVkFormats = 20;
|
||||
static const size_t kNumVkFormats = 21;
|
||||
FormatInfo fFormatTable[kNumVkFormats];
|
||||
|
||||
FormatInfo& getFormatInfo(VkFormat);
|
||||
|
@ -40,6 +40,7 @@ bool GrVkFormatColorTypePairIsValid(VkFormat format, GrColorType colorType) {
|
||||
case VK_FORMAT_R16G16_SFLOAT: return GrColorType::kRG_F16 == colorType;
|
||||
case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: return GrColorType::kRGB_888x == colorType;
|
||||
case VK_FORMAT_BC1_RGB_UNORM_BLOCK: return GrColorType::kRGB_888x == colorType;
|
||||
case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: return GrColorType::kRGBA_8888 == colorType;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
@ -61,6 +62,7 @@ bool GrVkFormatIsSupported(VkFormat format) {
|
||||
case VK_FORMAT_R8_UNORM:
|
||||
case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
|
||||
case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
|
||||
case VK_FORMAT_BC1_RGBA_UNORM_BLOCK:
|
||||
case VK_FORMAT_R16G16B16A16_SFLOAT:
|
||||
case VK_FORMAT_R16_SFLOAT:
|
||||
case VK_FORMAT_R16_UNORM:
|
||||
@ -176,6 +178,7 @@ bool GrVkFormatIsCompressed(VkFormat vkFormat) {
|
||||
switch (vkFormat) {
|
||||
case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
|
||||
case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
|
||||
case VK_FORMAT_BC1_RGBA_UNORM_BLOCK:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -187,6 +190,7 @@ SkImage::CompressionType GrVkFormatToCompressionType(VkFormat vkFormat) {
|
||||
switch (vkFormat) {
|
||||
case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: return SkImage::CompressionType::kETC2_RGB8_UNORM;
|
||||
case VK_FORMAT_BC1_RGB_UNORM_BLOCK: return SkImage::CompressionType::kBC1_RGB8_UNORM;
|
||||
case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: return SkImage::CompressionType::kBC1_RGBA8_UNORM;
|
||||
default: return SkImage::CompressionType::kNone;
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
|
@ -103,6 +103,7 @@ static constexpr const char* GrVkFormatToStr(VkFormat vkFormat) {
|
||||
case VK_FORMAT_R8G8B8A8_SRGB: return "R8G8B8A8_SRGB";
|
||||
case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: return "ETC2_R8G8B8_UNORM_BLOCK";
|
||||
case VK_FORMAT_BC1_RGB_UNORM_BLOCK: return "BC1_RGB_UNORM_BLOCK";
|
||||
case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: return "BC1_RGBA_UNORM_BLOCK";
|
||||
case VK_FORMAT_R16_UNORM: return "R16_UNORM";
|
||||
case VK_FORMAT_R16G16_UNORM: return "R16G16_UNORM";
|
||||
case VK_FORMAT_R16G16B16A16_UNORM: return "R16G16B16A16_UNORM";
|
||||
|
@ -40,7 +40,8 @@ static void check_compressed_mipmaps(GrContext* context, const GrBackendTexture&
|
||||
|
||||
SkImage::CompressionType compression = caps->compressionType(backendTex.getBackendFormat());
|
||||
|
||||
SkAlphaType at = kOpaque_SkAlphaType;
|
||||
SkAlphaType at = GrCompressionTypeIsOpaque(compression) ? kOpaque_SkAlphaType
|
||||
: kPremul_SkAlphaType;
|
||||
|
||||
sk_sp<SkImage> img = SkImage::MakeFromCompressedTexture(context,
|
||||
backendTex,
|
||||
@ -66,7 +67,8 @@ static void check_compressed_mipmaps(GrContext* context, const GrBackendTexture&
|
||||
SkCanvas* canvas = surf->getCanvas();
|
||||
|
||||
SkPaint p;
|
||||
p.setFilterQuality(kHigh_SkFilterQuality);
|
||||
p.setFilterQuality(kHigh_SkFilterQuality); // to force mipMapping
|
||||
p.setBlendMode(SkBlendMode::kSrc);
|
||||
|
||||
int numMipLevels = 1;
|
||||
if (mipMapped == GrMipMapped::kYes) {
|
||||
@ -154,7 +156,6 @@ static void test_compressed_data_init(GrContext* context,
|
||||
SkImage::CompressionType compression,
|
||||
GrMipMapped mipMapped) {
|
||||
|
||||
// TODO: make these transparent for RGBA compressed formats
|
||||
SkColor4f expectedColors[6] = {
|
||||
{ 1.0f, 0.0f, 0.0f, 1.0f }, // R
|
||||
{ 0.0f, 1.0f, 0.0f, 1.0f }, // G
|
||||
@ -187,7 +188,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CompressedBackendAllocationTest, reporter, ct
|
||||
SkColor4f fColor;
|
||||
} combinations[] = {
|
||||
{ SkImage::CompressionType::kETC2_RGB8_UNORM, SkColors::kRed },
|
||||
{ SkImage::CompressionType::kBC1_RGB8_UNORM, SkColors::kBlue },
|
||||
{ SkImage::CompressionType::kBC1_RGB8_UNORM, SkColors::kBlue },
|
||||
{ SkImage::CompressionType::kBC1_RGBA8_UNORM, SkColors::kTransparent },
|
||||
};
|
||||
|
||||
for (auto combo : combinations) {
|
||||
|
Loading…
Reference in New Issue
Block a user