Remove kIndex_8_GrPixelConfig

It's been disabled for a long time (GPUs don't support it, and it actually
caused performance regression in testing).

BUG=skia:4333

Change-Id: I6e2bf755f765168fd616de6c9c023c6fbd5abd20
Reviewed-on: https://skia-review.googlesource.com/6897
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2017-01-11 16:57:15 -05:00 committed by Skia Commit-Bot
parent 5de544b3ca
commit d0be1ef36c
11 changed files with 59 additions and 167 deletions

View File

@ -289,7 +289,6 @@ static inline uint32_t GrPixelConfigComponentMask(GrPixelConfig config) {
0, // kUnknown_GrPixelConfig
kA_GrColorComponentFlag, // kAlpha_8_GrPixelConfig
kRGB_GrColorComponentFlags, // kGray_8_GrPixelConfig
kRGBA_GrColorComponentFlags, // kIndex_8_GrPixelConfig
kRGB_GrColorComponentFlags, // kRGB_565_GrPixelConfig
kRGBA_GrColorComponentFlags, // kRGBA_4444_GrPixelConfig
kRGBA_GrColorComponentFlags, // kRGBA_8888_GrPixelConfig
@ -310,21 +309,20 @@ static inline uint32_t GrPixelConfigComponentMask(GrPixelConfig config) {
GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig);
GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig);
GR_STATIC_ASSERT(2 == kGray_8_GrPixelConfig);
GR_STATIC_ASSERT(3 == kIndex_8_GrPixelConfig);
GR_STATIC_ASSERT(4 == kRGB_565_GrPixelConfig);
GR_STATIC_ASSERT(5 == kRGBA_4444_GrPixelConfig);
GR_STATIC_ASSERT(6 == kRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(7 == kBGRA_8888_GrPixelConfig);
GR_STATIC_ASSERT(8 == kSRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(9 == kSBGRA_8888_GrPixelConfig);
GR_STATIC_ASSERT(10 == kRGBA_8888_sint_GrPixelConfig);
GR_STATIC_ASSERT(11 == kETC1_GrPixelConfig);
GR_STATIC_ASSERT(12 == kLATC_GrPixelConfig);
GR_STATIC_ASSERT(13 == kR11_EAC_GrPixelConfig);
GR_STATIC_ASSERT(14 == kASTC_12x12_GrPixelConfig);
GR_STATIC_ASSERT(15 == kRGBA_float_GrPixelConfig);
GR_STATIC_ASSERT(16 == kAlpha_half_GrPixelConfig);
GR_STATIC_ASSERT(17 == kRGBA_half_GrPixelConfig);
GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig);
GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
GR_STATIC_ASSERT(7 == kSRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(8 == kSBGRA_8888_GrPixelConfig);
GR_STATIC_ASSERT(9 == kRGBA_8888_sint_GrPixelConfig);
GR_STATIC_ASSERT(10 == kETC1_GrPixelConfig);
GR_STATIC_ASSERT(11 == kLATC_GrPixelConfig);
GR_STATIC_ASSERT(12 == kR11_EAC_GrPixelConfig);
GR_STATIC_ASSERT(13 == kASTC_12x12_GrPixelConfig);
GR_STATIC_ASSERT(14 == kRGBA_float_GrPixelConfig);
GR_STATIC_ASSERT(15 == kAlpha_half_GrPixelConfig);
GR_STATIC_ASSERT(16 == kRGBA_half_GrPixelConfig);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFlags) == kGrPixelConfigCnt);
}

View File

@ -220,7 +220,6 @@ enum GrPixelConfig {
kUnknown_GrPixelConfig,
kAlpha_8_GrPixelConfig,
kGray_8_GrPixelConfig,
kIndex_8_GrPixelConfig,
kRGB_565_GrPixelConfig,
/**
* Premultiplied
@ -307,7 +306,6 @@ static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1;
// representation.
static inline bool GrPixelConfigIsCompressed(GrPixelConfig config) {
switch (config) {
case kIndex_8_GrPixelConfig:
case kETC1_GrPixelConfig:
case kLATC_GrPixelConfig:
case kR11_EAC_GrPixelConfig:
@ -321,7 +319,6 @@ static inline bool GrPixelConfigIsCompressed(GrPixelConfig config) {
/** If the pixel config is compressed, return an equivalent uncompressed format. */
static inline GrPixelConfig GrMakePixelConfigUncompressed(GrPixelConfig config) {
switch (config) {
case kIndex_8_GrPixelConfig:
case kETC1_GrPixelConfig:
case kASTC_12x12_GrPixelConfig:
return kRGBA_8888_GrPixelConfig;
@ -659,11 +656,8 @@ enum GrGLBackendState {
static inline size_t GrCompressedFormatDataSize(GrPixelConfig config,
int width, int height) {
SkASSERT(GrPixelConfigIsCompressed(config));
static const int kGrIndex8TableSize = 256 * 4; // 4 == sizeof(GrColor)
switch (config) {
case kIndex_8_GrPixelConfig:
return width * height + kGrIndex8TableSize;
case kR11_EAC_GrPixelConfig:
case kLATC_GrPixelConfig:
case kETC1_GrPixelConfig:

View File

@ -171,7 +171,6 @@ SkString GrCaps::dump() const {
"Unknown", // kUnknown_GrPixelConfig
"Alpha8", // kAlpha_8_GrPixelConfig,
"Gray8", // kGray_8_GrPixelConfig,
"Index8", // kIndex_8_GrPixelConfig,
"RGB565", // kRGB_565_GrPixelConfig,
"RGBA444", // kRGBA_4444_GrPixelConfig,
"RGBA8888", // kRGBA_8888_GrPixelConfig,
@ -190,21 +189,20 @@ SkString GrCaps::dump() const {
GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig);
GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig);
GR_STATIC_ASSERT(2 == kGray_8_GrPixelConfig);
GR_STATIC_ASSERT(3 == kIndex_8_GrPixelConfig);
GR_STATIC_ASSERT(4 == kRGB_565_GrPixelConfig);
GR_STATIC_ASSERT(5 == kRGBA_4444_GrPixelConfig);
GR_STATIC_ASSERT(6 == kRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(7 == kBGRA_8888_GrPixelConfig);
GR_STATIC_ASSERT(8 == kSRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(9 == kSBGRA_8888_GrPixelConfig);
GR_STATIC_ASSERT(10 == kRGBA_8888_sint_GrPixelConfig);
GR_STATIC_ASSERT(11 == kETC1_GrPixelConfig);
GR_STATIC_ASSERT(12 == kLATC_GrPixelConfig);
GR_STATIC_ASSERT(13 == kR11_EAC_GrPixelConfig);
GR_STATIC_ASSERT(14 == kASTC_12x12_GrPixelConfig);
GR_STATIC_ASSERT(15 == kRGBA_float_GrPixelConfig);
GR_STATIC_ASSERT(16 == kAlpha_half_GrPixelConfig);
GR_STATIC_ASSERT(17 == kRGBA_half_GrPixelConfig);
GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig);
GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
GR_STATIC_ASSERT(7 == kSRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(8 == kSBGRA_8888_GrPixelConfig);
GR_STATIC_ASSERT(9 == kRGBA_8888_sint_GrPixelConfig);
GR_STATIC_ASSERT(10 == kETC1_GrPixelConfig);
GR_STATIC_ASSERT(11 == kLATC_GrPixelConfig);
GR_STATIC_ASSERT(12 == kR11_EAC_GrPixelConfig);
GR_STATIC_ASSERT(13 == kASTC_12x12_GrPixelConfig);
GR_STATIC_ASSERT(14 == kRGBA_float_GrPixelConfig);
GR_STATIC_ASSERT(15 == kAlpha_half_GrPixelConfig);
GR_STATIC_ASSERT(16 == kRGBA_half_GrPixelConfig);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kConfigNames) == kGrPixelConfigCnt);
SkASSERT(!this->isConfigRenderable(kUnknown_GrPixelConfig, false));

View File

@ -683,7 +683,6 @@ static inline GrPixelConfig GrPixelConfigFallback(GrPixelConfig config) {
kUnknown_GrPixelConfig, // kUnknown_GrPixelConfig
kRGBA_8888_GrPixelConfig, // kAlpha_8_GrPixelConfig
kUnknown_GrPixelConfig, // kGray_8_GrPixelConfig
kUnknown_GrPixelConfig, // kIndex_8_GrPixelConfig
kRGBA_8888_GrPixelConfig, // kRGB_565_GrPixelConfig
kRGBA_8888_GrPixelConfig, // kRGBA_4444_GrPixelConfig
kUnknown_GrPixelConfig, // kRGBA_8888_GrPixelConfig
@ -704,21 +703,20 @@ static inline GrPixelConfig GrPixelConfigFallback(GrPixelConfig config) {
GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig);
GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig);
GR_STATIC_ASSERT(2 == kGray_8_GrPixelConfig);
GR_STATIC_ASSERT(3 == kIndex_8_GrPixelConfig);
GR_STATIC_ASSERT(4 == kRGB_565_GrPixelConfig);
GR_STATIC_ASSERT(5 == kRGBA_4444_GrPixelConfig);
GR_STATIC_ASSERT(6 == kRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(7 == kBGRA_8888_GrPixelConfig);
GR_STATIC_ASSERT(8 == kSRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(9 == kSBGRA_8888_GrPixelConfig);
GR_STATIC_ASSERT(10 == kRGBA_8888_sint_GrPixelConfig);
GR_STATIC_ASSERT(11 == kETC1_GrPixelConfig);
GR_STATIC_ASSERT(12 == kLATC_GrPixelConfig);
GR_STATIC_ASSERT(13 == kR11_EAC_GrPixelConfig);
GR_STATIC_ASSERT(14 == kASTC_12x12_GrPixelConfig);
GR_STATIC_ASSERT(15 == kRGBA_float_GrPixelConfig);
GR_STATIC_ASSERT(16 == kAlpha_half_GrPixelConfig);
GR_STATIC_ASSERT(17 == kRGBA_half_GrPixelConfig);
GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig);
GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
GR_STATIC_ASSERT(7 == kSRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(8 == kSBGRA_8888_GrPixelConfig);
GR_STATIC_ASSERT(9 == kRGBA_8888_sint_GrPixelConfig);
GR_STATIC_ASSERT(10 == kETC1_GrPixelConfig);
GR_STATIC_ASSERT(11 == kLATC_GrPixelConfig);
GR_STATIC_ASSERT(12 == kR11_EAC_GrPixelConfig);
GR_STATIC_ASSERT(13 == kASTC_12x12_GrPixelConfig);
GR_STATIC_ASSERT(14 == kRGBA_float_GrPixelConfig);
GR_STATIC_ASSERT(15 == kAlpha_half_GrPixelConfig);
GR_STATIC_ASSERT(16 == kRGBA_half_GrPixelConfig);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFallback) == kGrPixelConfigCnt);
}

View File

@ -203,7 +203,6 @@ void GrShaderCaps::initSamplerPrecisionTable() {
table[kUnknown_GrPixelConfig] = kDefault_GrSLPrecision;
table[kAlpha_8_GrPixelConfig] = lowp;
table[kGray_8_GrPixelConfig] = lowp;
table[kIndex_8_GrPixelConfig] = lowp;
table[kRGB_565_GrPixelConfig] = lowp;
table[kRGBA_4444_GrPixelConfig] = lowp;
table[kRGBA_8888_GrPixelConfig] = lowp;
@ -219,7 +218,7 @@ void GrShaderCaps::initSamplerPrecisionTable() {
table[kAlpha_half_GrPixelConfig] = mediump;
table[kRGBA_half_GrPixelConfig] = mediump;
GR_STATIC_ASSERT(18 == kGrPixelConfigCnt);
GR_STATIC_ASSERT(17 == kGrPixelConfigCnt);
}
}

View File

@ -111,58 +111,6 @@ GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data,
//////////////////////////////////////////////////////////////////////////////
/**
* Fill out buffer with the compressed format Ganesh expects from a colortable
* based bitmap. [palette (colortable) + indices].
*
* At the moment Ganesh only supports 8bit version. If Ganesh allowed we others
* we could detect that the colortable.count is <= 16, and then repack the
* indices as nibbles to save RAM, but it would take more time (i.e. a lot
* slower than memcpy), so skipping that for now.
*
* Ganesh wants a full 256 palette entry, even though Skia's ctable is only as big
* as the colortable.count says it is.
*/
static void build_index8_data(void* buffer, const SkPixmap& pixmap) {
SkASSERT(kIndex_8_SkColorType == pixmap.colorType());
const SkColorTable* ctable = pixmap.ctable();
char* dst = (char*)buffer;
const int count = ctable->count();
SkDstPixelInfo dstPI;
dstPI.fColorType = kRGBA_8888_SkColorType;
dstPI.fAlphaType = kPremul_SkAlphaType;
dstPI.fPixels = buffer;
dstPI.fRowBytes = count * sizeof(SkPMColor);
SkSrcPixelInfo srcPI;
srcPI.fColorType = kN32_SkColorType;
srcPI.fAlphaType = kPremul_SkAlphaType;
srcPI.fPixels = ctable->readColors();
srcPI.fRowBytes = count * sizeof(SkPMColor);
srcPI.convertPixelsTo(&dstPI, count, 1);
// always skip a full 256 number of entries, even if we memcpy'd fewer
dst += 256 * sizeof(GrColor);
if ((unsigned)pixmap.width() == pixmap.rowBytes()) {
memcpy(dst, pixmap.addr(), pixmap.getSafeSize());
} else {
// need to trim off the extra bytes per row
size_t width = pixmap.width();
size_t rowBytes = pixmap.rowBytes();
const uint8_t* src = pixmap.addr8();
for (int y = 0; y < pixmap.height(); y++) {
memcpy(dst, src, width);
src += rowBytes;
dst += width;
}
}
}
/**
* Once we have made SkImages handle all lazy/deferred/generated content, the YUV apis will
* be gone from SkPixelRef, and we can remove this subclass entirely.
@ -224,6 +172,9 @@ GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud
const GrCaps* caps = ctx->caps();
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info(), *caps);
// TODO: We're checking for srgbSupport, but we can then end up picking sBGRA as our pixel
// config (which may not be supported). We need better fallback management here.
if (caps->srgbSupport() &&
pixmap.info().colorSpace() && pixmap.info().colorSpace()->gammaCloseToSRGB() &&
!(GrPixelConfigIsSRGB(desc.fConfig) ||
@ -254,29 +205,17 @@ GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud
// must rebuild desc, since we've forced the info to be N32
desc = GrImageInfoToSurfaceDesc(pmap->info(), *caps);
} else if (kIndex_8_SkColorType == pixmap.colorType()) {
if (caps->isConfigTexturable(kIndex_8_GrPixelConfig)) {
size_t imageSize = GrCompressedFormatDataSize(kIndex_8_GrPixelConfig,
pixmap.width(), pixmap.height());
SkAutoMalloc storage(imageSize);
build_index8_data(storage.get(), pixmap);
// our compressed data will be trimmed, so pass width() for its
// "rowBytes", since they are the same now.
return ctx->textureProvider()->createTexture(desc, budgeted, storage.get(),
pixmap.width());
} else {
SkImageInfo info = SkImageInfo::MakeN32Premul(pixmap.width(), pixmap.height());
tmpBitmap.allocPixels(info);
if (!pixmap.readPixels(info, tmpBitmap.getPixels(), tmpBitmap.rowBytes())) {
return nullptr;
}
if (!tmpBitmap.peekPixels(&tmpPixmap)) {
return nullptr;
}
pmap = &tmpPixmap;
// must rebuild desc, since we've forced the info to be N32
desc = GrImageInfoToSurfaceDesc(pmap->info(), *caps);
SkImageInfo info = SkImageInfo::MakeN32Premul(pixmap.width(), pixmap.height());
tmpBitmap.allocPixels(info);
if (!pixmap.readPixels(info, tmpBitmap.getPixels(), tmpBitmap.rowBytes())) {
return nullptr;
}
if (!tmpBitmap.peekPixels(&tmpPixmap)) {
return nullptr;
}
pmap = &tmpPixmap;
// must rebuild desc, since we've forced the info to be N32
desc = GrImageInfoToSurfaceDesc(pmap->info(), *caps);
}
return ctx->textureProvider()->createTexture(desc, budgeted, pmap->addr(),
@ -461,7 +400,7 @@ GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, const SkCol
return (caps.srgbSupport() && cs && cs->gammaCloseToSRGB())
? kSBGRA_8888_GrPixelConfig : kBGRA_8888_GrPixelConfig;
case kIndex_8_SkColorType:
return kIndex_8_GrPixelConfig;
return kSkia8888_GrPixelConfig;
case kGray_8_SkColorType:
return kGray_8_GrPixelConfig;
case kRGBA_F16_SkColorType:
@ -480,9 +419,6 @@ bool GrPixelConfigToColorType(GrPixelConfig config, SkColorType* ctOut) {
case kGray_8_GrPixelConfig:
ct = kGray_8_SkColorType;
break;
case kIndex_8_GrPixelConfig:
ct = kIndex_8_SkColorType;
break;
case kRGB_565_GrPixelConfig:
ct = kRGB_565_SkColorType;
break;

View File

@ -1922,29 +1922,6 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
// No sized/unsized internal format distinction for compressed formats, no external format.
// Below we set the external formats and types to 0.
fConfigTable[kIndex_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_PALETTE8_RGBA8;
fConfigTable[kIndex_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_PALETTE8_RGBA8;
fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = 0;
fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalType = 0;
fConfigTable[kIndex_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
// Disable this for now, while we investigate https://bug.skia.org/4333
if ((false)) {
// Check for 8-bit palette..
GrGLint numFormats;
GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats);
if (numFormats) {
SkAutoSTMalloc<10, GrGLint> formats(numFormats);
GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
for (int i = 0; i < numFormats; ++i) {
if (GR_GL_PALETTE8_RGBA8 == formats[i]) {
fConfigTable[kIndex_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
break;
}
}
}
}
fConfigTable[kIndex_8_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
// May change the internal format based on extensions.
fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat =
GR_GL_COMPRESSED_LUMINANCE_LATC1;

View File

@ -509,7 +509,6 @@
/* RGBA sized formats */
#define GR_GL_RGBA4 0x8056
#define GR_GL_RGB5_A1 0x8057
#define GR_GL_PALETTE8_RGBA8 0x8B96
#define GR_GL_RGBA8 0x8058
#define GR_GL_SRGB8_ALPHA8 0x8C43
#define GR_GL_RGBA16F 0x881A

View File

@ -778,7 +778,7 @@ bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height,
GrPixelConfig srcConfig,
DrawPreference* drawPreference,
WritePixelTempDrawInfo* tempDrawInfo) {
if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurface->config())) {
if (GrPixelConfigIsCompressed(dstSurface->config())) {
return false;
}
@ -1420,10 +1420,6 @@ bool GrGLGpu::uploadCompressedTexData(const GrSurfaceDesc& desc,
return allocate_and_populate_compressed_texture(desc, *interface, caps, target,
internalFormat, texels, width, height);
} else {
// Paletted textures can't be updated.
if (GR_GL_PALETTE8_RGBA8 == internalFormat) {
return false;
}
for (int currentMipLevel = 0; currentMipLevel < texels.count(); currentMipLevel++) {
SkASSERT(texels[currentMipLevel].fPixels || kTransfer_UploadType == uploadType);

View File

@ -257,7 +257,7 @@ GrBuffer* GrVkGpu::onCreateBuffer(size_t size, GrBufferType type, GrAccessPatter
bool GrVkGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height,
GrPixelConfig srcConfig, DrawPreference* drawPreference,
WritePixelTempDrawInfo* tempDrawInfo) {
if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurface->config())) {
if (GrPixelConfigIsCompressed(dstSurface->config())) {
return false;
}

View File

@ -42,9 +42,6 @@ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) {
// store the data is if it was B4G4R4A4 and swizzle in shaders
*format = VK_FORMAT_B4G4R4A4_UNORM_PACK16;
return true;
case kIndex_8_GrPixelConfig:
// No current vulkan support for this config
return false;
case kAlpha_8_GrPixelConfig:
*format = VK_FORMAT_R8_UNORM;
return true;