Remove compressed (ETC1) texture support from Ganesh (take 2)

Reland of https://skia-review.googlesource.com/c/17456/ (Remove compressed (ETC1) texture support from Ganesh) but w/o removing third_part\etc1 files

TBR=bsalomon@google.com
Change-Id: I8ec4b7e3ddf47d213cb24c382731c050ffb8847f
Reviewed-on: https://skia-review.googlesource.com/17700
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2017-05-23 07:43:48 -04:00 committed by Skia Commit-Bot
parent 8ca3356290
commit 92de631edd
27 changed files with 68 additions and 712 deletions

View File

@ -136,7 +136,6 @@ config("skia_private") {
"src/utils",
"src/utils/win",
"src/xml",
"third_party/etc1",
"third_party/gif",
]
@ -632,7 +631,6 @@ component("skia") {
"src/sfnt/SkOTTable_name.cpp",
"src/sfnt/SkOTUtils.cpp",
"src/utils/mac/SkStream_mac.cpp",
"third_party/etc1/etc1.cpp",
"third_party/gif/SkGifImageReader.cpp",
]

View File

@ -1,118 +0,0 @@
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
#include "sk_tool_utils.h"
#include "SkRandom.h"
#if SK_SUPPORT_GPU
#include "etc1.h"
#include "GrContext.h"
#include "GrRenderTargetContext.h"
#include "GrRenderTargetContextPriv.h"
#include "GrTextureProxy.h"
#include "effects/GrSimpleTextureEffect.h"
#include "ops/GrNonAAFillRectOp.h"
// Basic test of Ganesh's ETC1 support
class ETC1GM : public skiagm::GM {
public:
ETC1GM() {
this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC));
}
protected:
SkString onShortName() override {
return SkString("etc1");
}
SkISize onISize() override {
return SkISize::Make(kTexWidth + 2*kPad, kTexHeight + 2*kPad);
}
void onOnceBeforeDraw() override {
SkBitmap bm;
SkImageInfo ii = SkImageInfo::Make(kTexWidth, kTexHeight, kRGB_565_SkColorType,
kOpaque_SkAlphaType);
bm.allocPixels(ii);
bm.erase(SK_ColorBLUE, SkIRect::MakeWH(kTexWidth, kTexHeight));
for (int y = 0; y < kTexHeight; y += 4) {
for (int x = 0; x < kTexWidth; x += 4) {
bm.erase((x+y) % 8 ? SK_ColorRED : SK_ColorGREEN, SkIRect::MakeXYWH(x, y, 4, 4));
}
}
int size = etc1_get_encoded_data_size(bm.width(), bm.height());
fETC1Data.reset(size);
unsigned char* pixels = (unsigned char*) fETC1Data.get();
if (etc1_encode_image((unsigned char*) bm.getAddr16(0, 0),
bm.width(), bm.height(), 2, bm.rowBytes(), pixels)) {
fETC1Data.reset();
}
}
void onDraw(SkCanvas* canvas) override {
GrRenderTargetContext* renderTargetContext =
canvas->internal_private_accessTopLayerRenderTargetContext();
if (!renderTargetContext) {
skiagm::GM::DrawGpuOnlyMessage(canvas);
return;
}
GrContext* context = canvas->getGrContext();
if (!context) {
return;
}
GrSurfaceDesc desc;
desc.fConfig = kETC1_GrPixelConfig;
desc.fWidth = kTexWidth;
desc.fHeight = kTexHeight;
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(context->resourceProvider(),
desc, SkBudgeted::kYes,
fETC1Data.get(), 0);
if (!proxy) {
return;
}
const SkMatrix trans = SkMatrix::MakeTrans(-kPad, -kPad);
sk_sp<GrFragmentProcessor> fp = GrSimpleTextureEffect::Make(context->resourceProvider(),
std::move(proxy),
nullptr, trans);
GrPaint grPaint;
grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
grPaint.addColorFragmentProcessor(std::move(fp));
SkRect rect = SkRect::MakeXYWH(kPad, kPad, kTexWidth, kTexHeight);
renderTargetContext->priv().testingOnly_addDrawOp(GrNonAAFillRectOp::Make(
std::move(grPaint), SkMatrix::I(), rect, nullptr, nullptr, GrAAType::kNone));
}
private:
static const int kPad = 8;
static const int kTexWidth = 16;
static const int kTexHeight = 20;
SkAutoTMalloc<char> fETC1Data;
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
DEF_GM(return new ETC1GM;)
#endif

View File

@ -117,7 +117,6 @@ gm_sources = [
"$_gm/encode-alpha-jpeg.cpp",
"$_gm/encode-platform.cpp",
"$_gm/encode-srgb.cpp",
"$_gm/etc1.cpp",
"$_gm/extractbitmap.cpp",
"$_gm/fadefilter.cpp",
"$_gm/fatpathfill.cpp",

View File

@ -45,7 +45,6 @@ public:
bool srgbWriteControl() const { return fSRGBWriteControl; }
bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport; }
bool gpuTracingSupport() const { return fGpuTracingSupport; }
bool compressedTexSubImageSupport() const { return fCompressedTexSubImageSupport; }
bool oversizedStencilSupport() const { return fOversizedStencilSupport; }
bool textureBarrierSupport() const { return fTextureBarrierSupport; }
bool sampleLocationsSupport() const { return fSampleLocationsSupport; }
@ -212,7 +211,6 @@ protected:
bool fReuseScratchTextures : 1;
bool fReuseScratchBuffers : 1;
bool fGpuTracingSupport : 1;
bool fCompressedTexSubImageSupport : 1;
bool fOversizedStencilSupport : 1;
bool fTextureBarrierSupport : 1;
bool fSampleLocationsSupport : 1;

View File

@ -298,10 +298,7 @@ enum GrPixelConfig {
* 8 bit signed integers per-channel. Byte order is b,g,r,a.
*/
kRGBA_8888_sint_GrPixelConfig,
/**
* ETC1 Compressed Data
*/
kETC1_GrPixelConfig,
/**
* Byte order is r, g, b, a. This color format is 32 bits per channel
*/
@ -337,58 +334,6 @@ static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1;
#error "SK_*32_SHIFT values must correspond to GL_BGRA or GL_RGBA format."
#endif
// Returns true if the pixel config is a GPU-specific compressed format
// representation.
static inline bool GrPixelConfigIsCompressed(GrPixelConfig config) {
switch (config) {
case kETC1_GrPixelConfig:
return true;
case kUnknown_GrPixelConfig:
case kAlpha_8_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_8888_sint_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
return false;
}
SkFAIL("Invalid pixel config");
return false;
}
/** If the pixel config is compressed, return an equivalent uncompressed format. */
static inline GrPixelConfig GrMakePixelConfigUncompressed(GrPixelConfig config) {
switch (config) {
case kETC1_GrPixelConfig:
return kRGBA_8888_GrPixelConfig;
case kUnknown_GrPixelConfig:
case kAlpha_8_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_8888_sint_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
SkASSERT(!GrPixelConfigIsCompressed(config));
return config;
}
SkFAIL("Invalid pixel config");
return config;
}
// Returns true if the pixel config is 32 bits per pixel
static inline bool GrPixelConfigIs8888Unorm(GrPixelConfig config) {
switch (config) {
@ -403,7 +348,6 @@ static inline bool GrPixelConfigIs8888Unorm(GrPixelConfig config) {
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGBA_8888_sint_GrPixelConfig:
case kETC1_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
@ -429,7 +373,6 @@ static inline bool GrPixelConfigIsSRGB(GrPixelConfig config) {
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kRGBA_8888_sint_GrPixelConfig:
case kETC1_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
@ -458,7 +401,6 @@ static inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) {
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGBA_8888_sint_GrPixelConfig:
case kETC1_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
@ -470,7 +412,6 @@ static inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) {
}
static inline size_t GrBytesPerPixel(GrPixelConfig config) {
SkASSERT(!GrPixelConfigIsCompressed(config));
switch (config) {
case kAlpha_8_GrPixelConfig:
case kGray_8_GrPixelConfig:
@ -492,7 +433,6 @@ static inline size_t GrBytesPerPixel(GrPixelConfig config) {
case kRG_float_GrPixelConfig:
return 8;
case kUnknown_GrPixelConfig:
case kETC1_GrPixelConfig:
return 0;
}
SkFAIL("Invalid pixel config");
@ -501,7 +441,6 @@ static inline size_t GrBytesPerPixel(GrPixelConfig config) {
static inline bool GrPixelConfigIsOpaque(GrPixelConfig config) {
switch (config) {
case kETC1_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kGray_8_GrPixelConfig:
return true;
@ -537,7 +476,6 @@ static inline bool GrPixelConfigIsAlphaOnly(GrPixelConfig config) {
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_8888_sint_GrPixelConfig:
case kETC1_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
@ -564,7 +502,6 @@ static inline bool GrPixelConfigIsFloatingPoint(GrPixelConfig config) {
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_8888_sint_GrPixelConfig:
case kETC1_GrPixelConfig:
return false;
}
SkFAIL("Invalid pixel config");
@ -779,41 +716,6 @@ enum GrGLBackendState {
kALL_GrGLBackendState = 0xffff
};
/**
* Returns the data size for the given compressed pixel config
*/
static inline size_t GrCompressedFormatDataSize(GrPixelConfig config,
int width, int height) {
SkASSERT(GrPixelConfigIsCompressed(config));
switch (config) {
case kETC1_GrPixelConfig:
SkASSERT((width & 3) == 0);
SkASSERT((height & 3) == 0);
return (width >> 2) * (height >> 2) * 8;
case kUnknown_GrPixelConfig:
case kAlpha_8_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_8888_sint_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
SkFAIL("Unknown compressed pixel config");
return 4 * width * height;
}
SkFAIL("Invalid pixel config");
return 4 * width * height;
}
/**
* This value translates to reseting all the context state for any backend.
*/

View File

@ -21,7 +21,6 @@ static const char* pixel_config_name(GrPixelConfig config) {
case kSRGBA_8888_GrPixelConfig: return "SRGBA8888";
case kSBGRA_8888_GrPixelConfig: return "SBGRA8888";
case kRGBA_8888_sint_GrPixelConfig: return "RGBA8888_sint";
case kETC1_GrPixelConfig: return "ETC1";
case kRGBA_float_GrPixelConfig: return "RGBAFloat";
case kRG_float_GrPixelConfig: return "RGFloat";
case kAlpha_half_GrPixelConfig: return "AlphaHalf";
@ -40,7 +39,6 @@ GrCaps::GrCaps(const GrContextOptions& options) {
fReuseScratchTextures = true;
fReuseScratchBuffers = true;
fGpuTracingSupport = false;
fCompressedTexSubImageSupport = false;
fOversizedStencilSupport = false;
fTextureBarrierSupport = false;
fSampleLocationsSupport = false;
@ -130,7 +128,6 @@ SkString GrCaps::dump() const {
r.appendf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]);
r.appendf("Reuse Scratch Buffers : %s\n", gNY[fReuseScratchBuffers]);
r.appendf("Gpu Tracing Support : %s\n", gNY[fGpuTracingSupport]);
r.appendf("Compressed Update Support : %s\n", gNY[fCompressedTexSubImageSupport]);
r.appendf("Oversized Stencil Support : %s\n", gNY[fOversizedStencilSupport]);
r.appendf("Texture Barrier Support : %s\n", gNY[fTextureBarrierSupport]);
r.appendf("Sample Locations Support : %s\n", gNY[fSampleLocationsSupport]);

View File

@ -172,9 +172,6 @@ GrDrawOpAtlas::GrDrawOpAtlas(GrContext* context, sk_sp<GrTextureProxy> proxy,
SkDEBUGCODE(fNumPlots = numPlotsX * numPlotsY;)
// We currently do not support compressed atlases...
SkASSERT(!GrPixelConfigIsCompressed(fProxy->config()));
// set up allocated plots
fPlotArray.reset(new sk_sp<Plot>[ numPlotsX * numPlotsY ]);

View File

@ -143,24 +143,8 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budget
desc.fOrigin = resolve_origin(desc.fOrigin, isRT);
GrTexture* tex = nullptr;
if (GrPixelConfigIsCompressed(desc.fConfig)) {
// We shouldn't be rendering into this
SkASSERT(!isRT);
SkASSERT(0 == desc.fSampleCnt);
if (!caps->npotTextureTileSupport() &&
(!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) {
return nullptr;
}
this->handleDirtyContext();
tex = this->onCreateCompressedTexture(desc, budgeted, texels);
} else {
this->handleDirtyContext();
tex = this->onCreateTexture(desc, budgeted, texels);
}
this->handleDirtyContext();
GrTexture* tex = this->onCreateTexture(desc, budgeted, texels);
if (tex) {
if (!caps->reuseScratchTextures() && !isRT) {
tex->resourcePriv().removeScratchKey();
@ -261,9 +245,6 @@ bool GrGpu::copySurface(GrSurface* dst,
if (GrPixelConfigIsSint(dst->config()) != GrPixelConfigIsSint(src->config())) {
return false;
}
if (GrPixelConfigIsCompressed(dst->config())) {
return false;
}
return this->onCopySurface(dst, src, srcRect, dstPoint);
}
@ -275,11 +256,6 @@ bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, size
SkASSERT(srcSurface);
SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference);
// We currently do not support reading into a compressed buffer
if (GrPixelConfigIsCompressed(readConfig)) {
return false;
}
// We currently do not support reading into the packed formats 565 or 4444 as they are not
// required to have read back support on all devices and backends.
if (kRGB_565_GrPixelConfig == readConfig || kRGBA_4444_GrPixelConfig == readConfig) {
@ -311,10 +287,6 @@ bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, int width, int height,
SkASSERT(dstSurface);
SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference);
if (GrPixelConfigIsCompressed(dstSurface->config()) && dstSurface->config() != srcConfig) {
return false;
}
if (SkToBool(dstSurface->asRenderTarget())) {
if (this->caps()->useDrawInsteadOfAllRenderTargetWrites()) {
ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
@ -353,11 +325,6 @@ bool GrGpu::readPixels(GrSurface* surface,
return false;
}
// We cannot read pixels into a compressed buffer
if (GrPixelConfigIsCompressed(config)) {
return false;
}
size_t bpp = GrBytesPerPixel(config);
if (!GrSurfacePriv::AdjustReadPixelParams(surface->width(), surface->height(), bpp,
&left, &top, &width, &height,

View File

@ -100,8 +100,7 @@ public:
* @param budgeted does this texture count against the resource cache budget?
* @param texels array of mipmap levels containing texel data to load.
* Each level begins with full-size palette data for paletted textures.
* For compressed formats the level contains the compressed pixel data.
* Otherwise, it contains width*height texels. If there is only one
* It contains width*height texels. If there is only one
* element and it contains nullptr fPixels, texture data is
* uninitialized.
* @return The texture object if successful, otherwise nullptr.
@ -546,13 +545,10 @@ private:
// overridden by backend-specific derived class to create objects.
// Texture size and sample size will have already been validated in base class before
// onCreateTexture/CompressedTexture are called.
// onCreateTexture is called.
virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc,
SkBudgeted budgeted,
const SkTArray<GrMipLevel>& texels) = 0;
virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc,
SkBudgeted budgeted,
const SkTArray<GrMipLevel>& texels) = 0;
virtual sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&,
GrSurfaceOrigin,

View File

@ -157,17 +157,15 @@ sk_sp<GrTextureProxy> GrResourceProvider::createTextureProxy(const GrSurfaceDesc
GrContext* context = fGpu->getContext();
if (!GrPixelConfigIsCompressed(desc.fConfig)) {
SkImageInfo srcInfo;
SkImageInfo srcInfo;
if (make_info(desc.fWidth, desc.fHeight, desc.fConfig, &srcInfo)) {
sk_sp<GrTexture> tex = this->getExactScratch(desc, budgeted, 0);
sk_sp<GrSurfaceContext> sContext =
context->contextPriv().makeWrappedSurfaceContext(std::move(tex));
if (sContext) {
if (sContext->writePixels(srcInfo, mipLevel.fPixels, mipLevel.fRowBytes, 0, 0)) {
return sContext->asTextureProxyRef();
}
if (make_info(desc.fWidth, desc.fHeight, desc.fConfig, &srcInfo)) {
sk_sp<GrTexture> tex = this->getExactScratch(desc, budgeted, 0);
sk_sp<GrSurfaceContext> sContext =
context->contextPriv().makeWrappedSurfaceContext(std::move(tex));
if (sContext) {
if (sContext->writePixels(srcInfo, mipLevel.fPixels, mipLevel.fRowBytes, 0, 0)) {
return sContext->asTextureProxyRef();
}
}
}
@ -192,14 +190,12 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, Sk
return nullptr;
}
if (!GrPixelConfigIsCompressed(desc.fConfig)) {
sk_sp<GrTexture> tex = this->getExactScratch(desc, budgeted, flags);
if (tex) {
return tex;
}
sk_sp<GrTexture> tex = this->getExactScratch(desc, budgeted, flags);
if (tex) {
return tex;
}
sk_sp<GrTexture> tex(fGpu->createTexture(desc, budgeted));
tex.reset(fGpu->createTexture(desc, budgeted));
return tex;
}
@ -211,11 +207,6 @@ GrTexture* GrResourceProvider::createApproxTexture(const GrSurfaceDesc& desc, ui
return nullptr;
}
// Currently we don't recycle compressed textures as scratch.
if (GrPixelConfigIsCompressed(desc.fConfig)) {
return nullptr;
}
if (!validate_desc(desc, *fCaps)) {
return nullptr;
}
@ -226,7 +217,6 @@ GrTexture* GrResourceProvider::createApproxTexture(const GrSurfaceDesc& desc, ui
GrTexture* GrResourceProvider::refScratchTexture(const GrSurfaceDesc& inDesc, uint32_t flags) {
ASSERT_SINGLE_OWNER
SkASSERT(!this->isAbandoned());
SkASSERT(!GrPixelConfigIsCompressed(inDesc.fConfig));
SkASSERT(validate_desc(inDesc, *fCaps));
SkTCopyOnFirstWrite<GrSurfaceDesc> desc(inDesc);

View File

@ -213,13 +213,12 @@ void GrShaderCaps::initSamplerPrecisionTable() {
table[kSRGBA_8888_GrPixelConfig] = lowp;
table[kSBGRA_8888_GrPixelConfig] = lowp;
table[kRGBA_8888_sint_GrPixelConfig] = lowp;
table[kETC1_GrPixelConfig] = lowp;
table[kRGBA_float_GrPixelConfig] = kHigh_GrSLPrecision;
table[kRG_float_GrPixelConfig] = kHigh_GrSLPrecision;
table[kAlpha_half_GrPixelConfig] = mediump;
table[kRGBA_half_GrPixelConfig] = mediump;
GR_STATIC_ASSERT(15 == kGrPixelConfigCnt);
GR_STATIC_ASSERT(14 == kGrPixelConfigCnt);
}
}

View File

@ -29,7 +29,6 @@ size_t GrSurface::WorstCaseSize(const GrSurfaceDesc& desc, bool useNextPow2) {
colorValuesPerPixel += 1;
}
SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
size_t colorBytes = (size_t) width * height * GrBytesPerPixel(desc.fConfig);
// This would be a nice assert to have (i.e., we aren't creating 0 width/height surfaces).
@ -39,11 +38,7 @@ size_t GrSurface::WorstCaseSize(const GrSurfaceDesc& desc, bool useNextPow2) {
size = colorValuesPerPixel * colorBytes;
size += colorBytes/3; // in case we have to mipmap
} else {
if (GrPixelConfigIsCompressed(desc.fConfig)) {
size = GrCompressedFormatDataSize(desc.fConfig, width, height);
} else {
size = (size_t) width * height * GrBytesPerPixel(desc.fConfig);
}
size = (size_t) width * height * GrBytesPerPixel(desc.fConfig);
size += size/3; // in case we have to mipmap
}
@ -57,17 +52,11 @@ size_t GrSurface::ComputeSize(GrPixelConfig config,
int colorSamplesPerPixel,
bool hasMIPMaps,
bool useNextPow2) {
size_t colorSize;
width = useNextPow2 ? GrNextPow2(width) : width;
height = useNextPow2 ? GrNextPow2(height) : height;
SkASSERT(kUnknown_GrPixelConfig != config);
if (GrPixelConfigIsCompressed(config)) {
colorSize = GrCompressedFormatDataSize(config, width, height);
} else {
colorSize = (size_t)width * height * GrBytesPerPixel(config);
}
size_t colorSize = (size_t)width * height * GrBytesPerPixel(config);
SkASSERT(colorSize > 0);
size_t finalSize = colorSamplesPerPixel * colorSize;

View File

@ -136,18 +136,6 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrResourceProvider* resourceP
// TODO: move this logic into GrResourceProvider!
// TODO: share this testing code with check_texture_creation_params
if (GrPixelConfigIsCompressed(desc.fConfig)) {
if (SkBackingFit::kApprox == fit || kBottomLeft_GrSurfaceOrigin == desc.fOrigin) {
// We don't allow scratch compressed textures and, apparently can't Y-flip compressed
// textures
return nullptr;
}
if (!caps->npotTextureTileSupport() && (!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) {
return nullptr;
}
}
if (!caps->isConfigTexturable(desc.fConfig)) {
return nullptr;
}

View File

@ -76,16 +76,14 @@ GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType
}
void GrTexture::computeScratchKey(GrScratchKey* key) const {
if (!GrPixelConfigIsCompressed(this->config())) {
const GrRenderTarget* rt = this->asRenderTarget();
int sampleCount = 0;
if (rt) {
sampleCount = rt->numStencilSamples();
}
GrTexturePriv::ComputeScratchKey(this->config(), this->width(), this->height(),
this->origin(), SkToBool(rt), sampleCount,
this->texturePriv().hasMipMaps(), key);
const GrRenderTarget* rt = this->asRenderTarget();
int sampleCount = 0;
if (rt) {
sampleCount = rt->numStencilSamples();
}
GrTexturePriv::ComputeScratchKey(this->config(), this->width(), this->height(),
this->origin(), SkToBool(rt), sampleCount,
this->texturePriv().hasMipMaps(), key);
}
void GrTexturePriv::ComputeScratchKey(GrPixelConfig config, int width, int height,

View File

@ -23,12 +23,10 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
SkASSERT(!subset || !subset->isEmpty());
SkASSERT(context);
GrPixelConfig config = GrMakePixelConfigUncompressed(inputProxy->config());
const SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
sk_sp<GrRenderTargetContext> copyRTC = context->makeDeferredRenderTargetContextWithFallback(
SkBackingFit::kExact, dstRect.width(), dstRect.height(), config, nullptr);
SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(), nullptr);
if (!copyRTC) {
return nullptr;
}

View File

@ -209,7 +209,7 @@ sk_sp<GrTextureProxy> GrRefCachedBitmapTextureProxy(GrContext*,
/**
* Creates a new texture for the bitmap. Does not concern itself with cache keys or texture params.
* The bitmap must have CPU-accessible pixels. Attempts to take advantage of faster paths for
* compressed textures and yuv planes.
* yuv planes.
*/
sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrResourceProvider*, const SkBitmap&,
SkColorSpace* dstColorSpace);

View File

@ -1344,15 +1344,6 @@ bool GrGLCaps::getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig ext
return true;
}
bool GrGLCaps::getCompressedTexImageFormats(GrPixelConfig surfaceConfig,
GrGLenum* internalFormat) const {
if (!GrPixelConfigIsCompressed(surfaceConfig)) {
return false;
}
*internalFormat = fConfigTable[surfaceConfig].fFormats.fInternalFormatTexImage;
return true;
}
bool GrGLCaps::getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
GrGLenum* externalFormat, GrGLenum* externalType) const {
if (!this->getExternalFormat(surfaceConfig, externalConfig, kOther_ExternalFormatUsage,
@ -1363,9 +1354,6 @@ bool GrGLCaps::getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig ex
}
bool GrGLCaps::getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) const {
if (GrPixelConfigIsCompressed(config)) {
return false;
}
*internalFormat = fConfigTable[config].fFormats.fInternalFormatRenderbuffer;
return true;
}
@ -1374,9 +1362,6 @@ bool GrGLCaps::getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memo
ExternalFormatUsage usage, GrGLenum* externalFormat,
GrGLenum* externalType) const {
SkASSERT(externalFormat && externalType);
if (GrPixelConfigIsCompressed(memoryConfig)) {
return false;
}
bool surfaceIsAlphaOnly = GrPixelConfigIsAlphaOnly(surfaceConfig);
bool memoryIsAlphaOnly = GrPixelConfigIsAlphaOnly(memoryConfig);
@ -1926,39 +1911,6 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
}
fConfigTable[kRGBA_half_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
// Compressed texture support
// glCompressedTexImage2D is available on all OpenGL ES devices. It is available on standard
// OpenGL after version 1.3. We'll assume at least that level of OpenGL support.
// TODO: Fix command buffer bindings and remove this.
fCompressedTexSubImageSupport = SkToBool(gli->fFunctions.fCompressedTexSubImage2D);
// No sized/unsized internal format distinction for compressed formats, no external format.
// Below we set the external formats and types to 0.
{
fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPRESSED_ETC1_RGB8;
fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_COMPRESSED_ETC1_RGB8;
fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = 0;
fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0;
fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
if (kGL_GrGLStandard == standard) {
if (version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compatibility")) {
fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
}
} else {
if (version >= GR_GL_VER(3, 0) ||
ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
// ETC2 is a superset of ETC1, so we can just check for that, too.
(ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))) {
fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
}
}
fConfigTable[kETC1_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
}
// Bulk populate the texture internal/external formats here and then deal with exceptions below.
// ES 2.0 requires that the internal/external formats match.

View File

@ -153,8 +153,6 @@ public:
GrGLenum* internalFormat, GrGLenum* externalFormat,
GrGLenum* externalType) const;
bool getCompressedTexImageFormats(GrPixelConfig surfaceConfig, GrGLenum* internalFormat) const;
bool getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
GrGLenum* externalFormat, GrGLenum* externalType) const;

View File

@ -662,10 +662,6 @@ bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height,
GrPixelConfig srcConfig,
DrawPreference* drawPreference,
WritePixelTempDrawInfo* tempDrawInfo) {
if (GrPixelConfigIsCompressed(dstSurface->config())) {
return false;
}
// This subclass only allows writes to textures. If the dst is not a texture we have to draw
// into it. We could use glDrawPixels on GLs that have it, but we don't today.
if (!dstSurface->asTexture()) {
@ -765,20 +761,9 @@ bool GrGLGpu::onWritePixels(GrSurface* surface,
this->setScratchTextureUnit();
GL_CALL(BindTexture(glTex->target(), glTex->textureID()));
bool success = false;
if (GrPixelConfigIsCompressed(glTex->config())) {
// We check that config == desc.fConfig in GrGLGpu::canWriteTexturePixels()
SkASSERT(config == glTex->config());
success = this->uploadCompressedTexData(glTex->config(), glTex->width(), glTex->height(),
glTex->origin(), glTex->target(), texels,
kWrite_UploadType, left, top, width, height);
} else {
success = this->uploadTexData(glTex->config(), glTex->width(), glTex->height(),
glTex->origin(), glTex->target(), kWrite_UploadType,
left, top, width, height, config, texels);
}
return success;
return this->uploadTexData(glTex->config(), glTex->width(), glTex->height(),
glTex->origin(), glTex->target(), kWrite_UploadType,
left, top, width, height, config, texels);
}
bool GrGLGpu::onTransferPixels(GrSurface* surface,
@ -791,11 +776,6 @@ bool GrGLGpu::onTransferPixels(GrSurface* surface,
return false;
}
// For the moment, can't transfer compressed data
if (GrPixelConfigIsCompressed(glTex->config())) {
return false;
}
this->setScratchTextureUnit();
GL_CALL(BindTexture(glTex->target(), glTex->textureID()));
@ -818,7 +798,6 @@ bool GrGLGpu::onTransferPixels(GrSurface* surface,
// For GL_[UN]PACK_ALIGNMENT.
static inline GrGLint config_alignment(GrPixelConfig config) {
SkASSERT(!GrPixelConfigIsCompressed(config));
switch (config) {
case kAlpha_8_GrPixelConfig:
case kGray_8_GrPixelConfig:
@ -837,7 +816,6 @@ static inline GrGLint config_alignment(GrPixelConfig config) {
case kRG_float_GrPixelConfig:
return 4;
case kUnknown_GrPixelConfig:
case kETC1_GrPixelConfig:
return 0;
}
SkFAIL("Invalid pixel config");
@ -858,16 +836,16 @@ static inline GrGLint config_alignment(GrPixelConfig config) {
* @param baseWidth The width of the texture's base mipmap level
* @param baseHeight The height of the texture's base mipmap level
*/
static bool allocate_and_populate_uncompressed_texture(GrPixelConfig config,
const GrGLInterface& interface,
const GrGLCaps& caps,
GrGLenum target,
GrGLenum internalFormat,
GrGLenum internalFormatForTexStorage,
GrGLenum externalFormat,
GrGLenum externalType,
const SkTArray<GrMipLevel>& texels,
int baseWidth, int baseHeight) {
static bool allocate_and_populate_texture(GrPixelConfig config,
const GrGLInterface& interface,
const GrGLCaps& caps,
GrGLenum target,
GrGLenum internalFormat,
GrGLenum internalFormatForTexStorage,
GrGLenum externalFormat,
GrGLenum externalType,
const SkTArray<GrMipLevel>& texels,
int baseWidth, int baseHeight) {
CLEAR_ERROR_BEFORE_ALLOC(&interface);
bool useTexStorage = caps.isConfigTexSupportEnabled(config);
@ -950,97 +928,6 @@ static bool allocate_and_populate_uncompressed_texture(GrPixelConfig config,
return true;
}
/**
* Creates storage space for the texture and fills it with texels.
*
* @param config Compressed pixel config of the texture.
* @param desc The surface descriptor for the texture being created.
* @param interface The GL interface in use.
* @param caps The capabilities of the GL device.
* @param internalFormat The data format used for the internal storage of the texture.
* @param texels The texel data of the texture being created.
*/
static bool allocate_and_populate_compressed_texture(GrPixelConfig config,
const GrGLInterface& interface,
const GrGLCaps& caps,
GrGLenum target, GrGLenum internalFormat,
const SkTArray<GrMipLevel>& texels,
int baseWidth, int baseHeight) {
CLEAR_ERROR_BEFORE_ALLOC(&interface);
bool useTexStorage = caps.isConfigTexSupportEnabled(config);
// We can only use TexStorage if we know we will not later change the storage requirements.
// This means if we may later want to add mipmaps, we cannot use TexStorage.
// Right now, we cannot know if we will later add mipmaps or not.
// The only time we can use TexStorage is when we already have the
// mipmaps.
useTexStorage &= texels.count() > 1;
if (useTexStorage) {
// We never resize or change formats of textures.
GL_ALLOC_CALL(&interface,
TexStorage2D(target,
texels.count(),
internalFormat,
baseWidth, baseHeight));
GrGLenum error = CHECK_ALLOC_ERROR(&interface);
if (error != GR_GL_NO_ERROR) {
return false;
} else {
for (int currentMipLevel = 0; currentMipLevel < texels.count(); currentMipLevel++) {
const void* currentMipData = texels[currentMipLevel].fPixels;
if (currentMipData == nullptr) {
continue;
}
int twoToTheMipLevel = 1 << currentMipLevel;
int currentWidth = SkTMax(1, baseWidth / twoToTheMipLevel);
int currentHeight = SkTMax(1, baseHeight / twoToTheMipLevel);
// Make sure that the width and height that we pass to OpenGL
// is a multiple of the block size.
size_t dataSize = GrCompressedFormatDataSize(config, currentWidth, currentHeight);
GR_GL_CALL(&interface, CompressedTexSubImage2D(target,
currentMipLevel,
0, // left
0, // top
currentWidth,
currentHeight,
internalFormat,
SkToInt(dataSize),
currentMipData));
}
}
} else {
for (int currentMipLevel = 0; currentMipLevel < texels.count(); currentMipLevel++) {
int twoToTheMipLevel = 1 << currentMipLevel;
int currentWidth = SkTMax(1, baseWidth / twoToTheMipLevel);
int currentHeight = SkTMax(1, baseHeight / twoToTheMipLevel);
// Make sure that the width and height that we pass to OpenGL
// is a multiple of the block size.
size_t dataSize = GrCompressedFormatDataSize(config, baseWidth, baseHeight);
GL_ALLOC_CALL(&interface,
CompressedTexImage2D(target,
currentMipLevel,
internalFormat,
currentWidth,
currentHeight,
0, // border
SkToInt(dataSize),
texels[currentMipLevel].fPixels));
GrGLenum error = CHECK_ALLOC_ERROR(&interface);
if (error != GR_GL_NO_ERROR) {
return false;
}
}
}
return true;
}
/**
* After a texture is created, any state which was altered during its creation
* needs to be restored.
@ -1065,9 +952,6 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
GrSurfaceOrigin texOrigin, GrGLenum target, UploadType uploadType,
int left, int top, int width, int height, GrPixelConfig dataConfig,
const SkTArray<GrMipLevel>& texels) {
// If we're uploading compressed data then we should be using uploadCompressedTexData
SkASSERT(!GrPixelConfigIsCompressed(dataConfig));
SkASSERT(this->caps()->isConfigTexturable(texConfig));
// texels is const.
@ -1222,7 +1106,7 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
bool succeeded = true;
if (kNewTexture_UploadType == uploadType) {
if (0 == left && 0 == top && texWidth == width && texHeight == height) {
succeeded = allocate_and_populate_uncompressed_texture(
succeeded = allocate_and_populate_texture(
texConfig, *interface, caps, target, internalFormat,
internalFormatForTexStorage, externalFormat, externalType, texelsShallowCopy,
width, height);
@ -1254,75 +1138,6 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
return succeeded;
}
// TODO: This function is using a lot of wonky semantics like, if width == -1
// then set width = desc.fWdith ... blah. A better way to do it might be to
// create a CompressedTexData struct that takes a desc/ptr and figures out
// the proper upload semantics. Then users can construct this function how they
// see fit if they want to go against the "standard" way to do it.
bool GrGLGpu::uploadCompressedTexData(GrPixelConfig config, int texWidth, int texHeight,
GrSurfaceOrigin texOrigin, GrGLenum target,
const SkTArray<GrMipLevel>& texels, UploadType uploadType,
int left, int top, int width, int height) {
SkASSERT(this->caps()->isConfigTexturable(config));
// No support for software flip y, yet...
SkASSERT(kBottomLeft_GrSurfaceOrigin != texOrigin);
const GrGLInterface* interface = this->glInterface();
const GrGLCaps& caps = this->glCaps();
if (-1 == width) {
width = texWidth;
}
#ifdef SK_DEBUG
else {
SkASSERT(width <= texWidth);
}
#endif
if (-1 == height) {
height = texHeight;
}
#ifdef SK_DEBUG
else {
SkASSERT(height <= texHeight);
}
#endif
// We only need the internal format for compressed 2D textures.
GrGLenum internalFormat;
if (!caps.getCompressedTexImageFormats(config, &internalFormat)) {
return false;
}
if (kNewTexture_UploadType == uploadType) {
return allocate_and_populate_compressed_texture(config, *interface, caps, target,
internalFormat, texels, width, height);
} else {
for (int currentMipLevel = 0; currentMipLevel < texels.count(); currentMipLevel++) {
SkASSERT(texels[currentMipLevel].fPixels || kTransfer_UploadType == uploadType);
int twoToTheMipLevel = 1 << currentMipLevel;
int currentWidth = SkTMax(1, width / twoToTheMipLevel);
int currentHeight = SkTMax(1, height / twoToTheMipLevel);
// Make sure that the width and height that we pass to OpenGL
// is a multiple of the block size.
size_t dataSize = GrCompressedFormatDataSize(config, currentWidth, currentHeight);
GL_CALL(CompressedTexSubImage2D(target,
currentMipLevel,
left, top,
currentWidth,
currentHeight,
internalFormat,
SkToInt(dataSize),
texels[currentMipLevel].fPixels));
}
}
return true;
}
static bool renderbuffer_storage_msaa(const GrGLContext& ctx,
int sampleCount,
GrGLenum format,
@ -1477,18 +1292,6 @@ static size_t as_size_t(int x) {
}
#endif
static GrGLTexture::IDDesc generate_gl_texture(const GrGLInterface* interface) {
GrGLTexture::IDDesc idDesc;
idDesc.fInfo.fID = 0;
GR_GL_CALL(interface, GenTextures(1, &idDesc.fInfo.fID));
idDesc.fOwnership = GrBackendObjectOwnership::kOwned;
// When we create the texture, we only
// create GL_TEXTURE_2D at the moment.
// External clients can do something different.
idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D;
return idDesc;
}
static void set_initial_texture_params(const GrGLInterface* interface,
const GrGLTextureInfo& info,
GrGLTexture::TexParams* initialTexParams) {
@ -1561,41 +1364,6 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
return tex;
}
GrTexture* GrGLGpu::onCreateCompressedTexture(const GrSurfaceDesc& desc,
SkBudgeted budgeted,
const SkTArray<GrMipLevel>& texels) {
// Make sure that we're not flipping Y.
if (kBottomLeft_GrSurfaceOrigin == desc.fOrigin) {
return return_null_texture();
}
GrGLTexture::IDDesc idDesc = generate_gl_texture(this->glInterface());
if (!idDesc.fInfo.fID) {
return return_null_texture();
}
this->setScratchTextureUnit();
GL_CALL(BindTexture(idDesc.fInfo.fTarget, idDesc.fInfo.fID));
GrGLTexture::TexParams initialTexParams;
set_initial_texture_params(this->glInterface(), idDesc.fInfo, &initialTexParams);
if (!this->uploadCompressedTexData(desc.fConfig, desc.fWidth, desc.fHeight, desc.fOrigin,
idDesc.fInfo.fTarget, texels)) {
GL_CALL(DeleteTextures(1, &idDesc.fInfo.fID));
return return_null_texture();
}
GrGLTexture* tex;
tex = new GrGLTexture(this, budgeted, desc, idDesc);
tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
#ifdef TRACE_TEXTURE_CREATION
SkDebugf("--- new compressed texture [%d] size=(%d %d) config=%d\n",
idDesc.fInfo.fID, desc.fWidth, desc.fHeight, desc.fConfig);
#endif
return tex;
}
namespace {
const GrGLuint kUnknownBitCount = GrGLStencilAttachment::kUnknownBitCount;
@ -3027,7 +2795,7 @@ void GrGLGpu::bindTexture(int unitIdx, const GrSamplerParams& params, bool allow
GrSamplerParams::FilterMode filterMode = params.filterMode();
if (GrSamplerParams::kMipMap_FilterMode == filterMode) {
if (!this->caps()->mipMapSupport() || GrPixelConfigIsCompressed(texture->config())) {
if (!this->caps()->mipMapSupport()) {
filterMode = GrSamplerParams::kBilerp_FilterMode;
}
}
@ -3173,7 +2941,7 @@ void GrGLGpu::generateMipmaps(const GrSamplerParams& params, bool allowSRGBInput
GrSamplerParams::FilterMode filterMode = params.filterMode();
if (GrSamplerParams::kMipMap_FilterMode == filterMode) {
if (!this->caps()->mipMapSupport() || GrPixelConfigIsCompressed(texture->config())) {
if (!this->caps()->mipMapSupport()) {
filterMode = GrSamplerParams::kBilerp_FilterMode;
}
}
@ -3395,7 +3163,6 @@ static inline bool can_copy_texsubimage(const GrSurface* dst,
// Check that we could wrap the source in an FBO, that the dst is TEXTURE_2D, that no mirroring
// is required.
if (gpu->glCaps().canConfigBeFBOColorAttachment(src->config()) &&
!GrPixelConfigIsCompressed(src->config()) &&
(!srcTex || srcTex->target() == GR_GL_TEXTURE_2D) && dstTex->target() == GR_GL_TEXTURE_2D &&
dst->origin() == src->origin()) {
return true;

View File

@ -163,9 +163,6 @@ private:
GrTexture* onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
const SkTArray<GrMipLevel>& texels) override;
GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc,
SkBudgeted budgeted,
const SkTArray<GrMipLevel>& texels) override;
GrBuffer* onCreateBuffer(size_t size, GrBufferType intendedType, GrAccessPattern,
const void* data) override;
@ -366,18 +363,6 @@ private:
int top, int width, int height, GrPixelConfig dataConfig,
const SkTArray<GrMipLevel>& texels);
// helper for onCreateCompressedTexture. If width and height are
// set to -1, then this function will use desc.fWidth and desc.fHeight
// for the size of the data. The isNewTexture flag should be set to true
// whenever a new texture needs to be created. Otherwise, we assume that
// the texture is already in GPU memory and that it's going to be updated
// with new data.
bool uploadCompressedTexData(GrPixelConfig texAndDataConfig, int texWidth, int texHeight,
GrSurfaceOrigin texOrigin, GrGLenum target,
const SkTArray<GrMipLevel>& texels,
UploadType uploadType = kNewTexture_UploadType, int left = 0,
int top = 0, int width = -1, int height = -1);
bool createRenderTargetObjects(const GrSurfaceDesc&, const GrGLTextureInfo& texInfo,
GrGLRenderTarget::IDDesc*);

View File

@ -67,9 +67,6 @@ std::unique_ptr<GrOp> GrCopySurfaceOp::Make(GrResourceProvider* resourceProvider
if (GrPixelConfigIsSint(dstProxy->config()) != GrPixelConfigIsSint(srcProxy->config())) {
return nullptr;
}
if (GrPixelConfigIsCompressed(dstProxy->config())) {
return nullptr;
}
SkIRect clippedSrcRect;
SkIPoint clippedDstPoint;
// If the rect is outside the srcProxy or dstProxy then we've already succeeded.

View File

@ -31,7 +31,6 @@ GrVkCaps::GrVkCaps(const GrContextOptions& contextOptions, const GrVkInterface*
fDiscardRenderTargetSupport = true;
fReuseScratchTextures = true; //TODO: figure this out
fGpuTracingSupport = false; //TODO: figure this out
fCompressedTexSubImageSupport = false; //TODO: figure this out
fOversizedStencilSupport = false; //TODO: figure this out
fUseDrawInsteadOfClear = false;
@ -307,11 +306,6 @@ void GrVkCaps::initConfigTable(const GrVkInterface* interface, VkPhysicalDevice
fConfigTable[i].init(interface, physDev, format);
}
}
// We currently do not support compressed textures in Vulkan
const uint16_t kFlagsToRemove = ConfigInfo::kTextureable_Flag|ConfigInfo::kRenderable_Flag;
fConfigTable[kETC1_GrPixelConfig].fOptimalFlags &= ~kFlagsToRemove;
fConfigTable[kETC1_GrPixelConfig].fLinearFlags &= ~kFlagsToRemove;
}
void GrVkCaps::ConfigInfo::InitConfigFlags(VkFormatFeatureFlags vkFlags, uint16_t* flags) {

View File

@ -315,10 +315,6 @@ 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 (GrPixelConfigIsCompressed(dstSurface->config())) {
return false;
}
GrRenderTarget* renderTarget = dstSurface->asRenderTarget();
// Start off assuming no swizzling
@ -379,43 +375,32 @@ bool GrVkGpu::onWritePixels(GrSurface* surface,
}
bool success = false;
if (GrPixelConfigIsCompressed(vkTex->config())) {
// We check that config == desc.fConfig in GrGpu::getWritePixelsInfo()
SkASSERT(config == vkTex->config());
// TODO: add compressed texture support
// delete the following two lines and uncomment the two after that when ready
vkTex->unref();
return false;
//success = this->uploadCompressedTexData(vkTex->desc(), buffer, false, left, top, width,
// height);
bool linearTiling = vkTex->isLinearTiled();
if (linearTiling) {
if (texels.count() > 1) {
SkDebugf("Can't upload mipmap data to linear tiled texture");
return false;
}
if (VK_IMAGE_LAYOUT_PREINITIALIZED != vkTex->currentLayout()) {
// Need to change the layout to general in order to perform a host write
vkTex->setImageLayout(this,
VK_IMAGE_LAYOUT_GENERAL,
VK_ACCESS_HOST_WRITE_BIT,
VK_PIPELINE_STAGE_HOST_BIT,
false);
this->submitCommandBuffer(kForce_SyncQueue);
}
success = this->uploadTexDataLinear(vkTex, left, top, width, height, config,
texels.begin()->fPixels, texels.begin()->fRowBytes);
} else {
bool linearTiling = vkTex->isLinearTiled();
if (linearTiling) {
if (texels.count() > 1) {
SkDebugf("Can't upload mipmap data to linear tiled texture");
int newMipLevels = texels.count();
int currentMipLevels = vkTex->texturePriv().maxMipMapLevel() + 1;
if (newMipLevels > currentMipLevels) {
if (!vkTex->reallocForMipmap(this, newMipLevels)) {
return false;
}
if (VK_IMAGE_LAYOUT_PREINITIALIZED != vkTex->currentLayout()) {
// Need to change the layout to general in order to perform a host write
vkTex->setImageLayout(this,
VK_IMAGE_LAYOUT_GENERAL,
VK_ACCESS_HOST_WRITE_BIT,
VK_PIPELINE_STAGE_HOST_BIT,
false);
this->submitCommandBuffer(kForce_SyncQueue);
}
success = this->uploadTexDataLinear(vkTex, left, top, width, height, config,
texels.begin()->fPixels, texels.begin()->fRowBytes);
} else {
int newMipLevels = texels.count();
int currentMipLevels = vkTex->texturePriv().maxMipMapLevel() + 1;
if (newMipLevels > currentMipLevels) {
if (!vkTex->reallocForMipmap(this, newMipLevels)) {
return false;
}
}
success = this->uploadTexDataOptimal(vkTex, left, top, width, height, config, texels);
}
success = this->uploadTexDataOptimal(vkTex, left, top, width, height, config, texels);
}
return success;
@ -498,9 +483,6 @@ bool GrVkGpu::uploadTexDataLinear(GrVkTexture* tex,
SkASSERT(data);
SkASSERT(tex->isLinearTiled());
// If we're uploading compressed data then we should be using uploadCompressedTexData
SkASSERT(!GrPixelConfigIsCompressed(dataConfig));
size_t bpp = GrBytesPerPixel(dataConfig);
if (!GrSurfacePriv::AdjustWritePixelParams(tex->width(), tex->height(), bpp, &left, &top,
@ -569,9 +551,6 @@ bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex,
// first.
SkASSERT(1 == texels.count() || texels.count() == (tex->texturePriv().maxMipMapLevel() + 1));
// If we're uploading compressed data then we should be using uploadCompressedTexData
SkASSERT(!GrPixelConfigIsCompressed(dataConfig));
if (width == 0 || height == 0) {
return false;
}

View File

@ -176,9 +176,6 @@ private:
GrTexture* onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
const SkTArray<GrMipLevel>&) override;
GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, SkBudgeted,
const SkTArray<GrMipLevel>&) override { return NULL; }
sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&,
GrSurfaceOrigin,
GrBackendTextureFlags,

View File

@ -48,10 +48,6 @@ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) {
case kGray_8_GrPixelConfig:
*format = VK_FORMAT_R8_UNORM;
return true;
case kETC1_GrPixelConfig:
// converting to ETC2 which is a superset of ETC1
*format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
return true;
case kRGBA_float_GrPixelConfig:
*format = VK_FORMAT_R32G32B32A32_SFLOAT;
return true;
@ -90,8 +86,6 @@ GrPixelConfig GrVkFormatToPixelConfig(VkFormat format) {
return kRGBA_4444_GrPixelConfig;
case VK_FORMAT_R8_UNORM:
return kAlpha_8_GrPixelConfig;
case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
return kETC1_GrPixelConfig; // this conversion seems a bit sketchy
case VK_FORMAT_R32G32B32A32_SFLOAT:
return kRGBA_float_GrPixelConfig;
case VK_FORMAT_R32G32_SFLOAT:

View File

@ -118,7 +118,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
for (auto widthHeight : { 100, 128, 1048576 }) {
for (auto config : { kAlpha_8_GrPixelConfig, kRGB_565_GrPixelConfig,
kETC1_GrPixelConfig, kRGBA_8888_GrPixelConfig }) {
kRGBA_8888_GrPixelConfig }) {
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
for (auto numSamples : { 0, 4, 16, 128 }) {

View File

@ -360,11 +360,6 @@ private:
return nullptr;
}
GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
const SkTArray<GrMipLevel>& texels) override {
return nullptr;
}
sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&,
GrSurfaceOrigin,
GrBackendTextureFlags,