Revert of Move config texturability/renderability to config table (patchset #8 id:140001 of https://codereview.chromium.org/1563443002/ )

Reason for revert:
speculative revert for breaking iOS writePixels tests

Original issue's description:
> Move config texturability/renderability to config table.
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1563443002
>
> Committed: https://skia.googlesource.com/skia/+/32a3cd2f2860b15a842a6aa49e4e6a3bed04f949

TBR=jvanverth@google.com,bsalomon@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/1569103003
This commit is contained in:
egdaniel 2016-01-07 17:06:04 -08:00 committed by Commit bot
parent 3061af4a5f
commit 4999df8ca2
5 changed files with 423 additions and 337 deletions

View File

@ -194,8 +194,15 @@ public:
// Will be 0 if MSAA is not supported
int maxSampleCount() const { return fMaxSampleCount; }
virtual bool isConfigTexturable(GrPixelConfig config) const = 0;
virtual bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const = 0;
bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const {
SkASSERT(kGrPixelConfigCnt > config);
return fConfigRenderSupport[config][withMSAA];
}
bool isConfigTexturable(GrPixelConfig config) const {
SkASSERT(kGrPixelConfigCnt > config);
return fConfigTextureSupport[config];
}
bool suppressPrints() const { return fSuppressPrints; }
@ -263,6 +270,10 @@ protected:
int fMaxTileSize;
int fMaxSampleCount;
// The first entry for each config is without msaa and the second is with.
bool fConfigRenderSupport[kGrPixelConfigCnt][2];
bool fConfigTextureSupport[kGrPixelConfigCnt];
private:
virtual void onApplyOptionsOverrides(const GrContextOptions&) {};

View File

@ -106,6 +106,9 @@ GrCaps::GrCaps(const GrContextOptions& options) {
fMaxTextureSize = 1;
fMaxSampleCount = 0;
memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport));
memset(fConfigTextureSupport, 0, sizeof(fConfigTextureSupport));
fSuppressPrints = options.fSuppressPrints;
fImmediateFlush = options.fImmediateMode;
fDrawPathMasksToCompressedTextureSupport = options.fDrawPathToCompressedTexture;
@ -226,24 +229,22 @@ SkString GrCaps::dump() const {
GR_STATIC_ASSERT(14 == kRGBA_half_GrPixelConfig);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kConfigNames) == kGrPixelConfigCnt);
SkASSERT(!this->isConfigRenderable(kUnknown_GrPixelConfig, false));
SkASSERT(!this->isConfigRenderable(kUnknown_GrPixelConfig, true));
SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][0]);
SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][1]);
for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) {
GrPixelConfig config = static_cast<GrPixelConfig>(i);
r.appendf("%s is renderable: %s, with MSAA: %s\n",
kConfigNames[i],
gNY[this->isConfigRenderable(config, false)],
gNY[this->isConfigRenderable(config, true)]);
gNY[fConfigRenderSupport[i][0]],
gNY[fConfigRenderSupport[i][1]]);
}
SkASSERT(!this->isConfigTexturable(kUnknown_GrPixelConfig));
SkASSERT(!fConfigTextureSupport[kUnknown_GrPixelConfig]);
for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) {
GrPixelConfig config = static_cast<GrPixelConfig>(i);
r.appendf("%s is uploadable to a texture: %s\n",
kConfigNames[i],
gNY[this->isConfigTexturable(config)]);
gNY[fConfigTextureSupport[i]]);
}
return r;

View File

@ -258,19 +258,10 @@ void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newT
class GrPipeline;
class MockCaps : public GrCaps {
public:
explicit MockCaps(const GrContextOptions& options) : INHERITED(options) {}
bool isConfigTexturable(GrPixelConfig config) const override { return false; }
bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { return false; }
private:
typedef GrCaps INHERITED;
};
class MockGpu : public GrGpu {
public:
MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(context) {
fCaps.reset(new MockCaps(options));
fCaps.reset(new GrCaps(options));
}
~MockGpu() override {}

View File

@ -20,11 +20,14 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
fStencilFormats.reset();
fMSFBOType = kNone_MSFBOType;
fInvalidateFBType = kNone_InvalidateFBType;
fLATCAlias = kLATC_LATCAlias;
fMapBufferType = kNone_MapBufferType;
fTransferBufferType = kNone_TransferBufferType;
fMaxFragmentUniformVectors = 0;
fMaxVertexAttributes = 0;
fMaxFragmentTextureUnits = 0;
fRGBA8RenderbufferSupport = false;
fBGRAIsInternalFormat = false;
fUnpackRowLengthSupport = false;
fUnpackFlipYSupport = false;
fPackRowLengthSupport = false;
@ -78,6 +81,14 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes);
GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUnits);
if (kGL_GrGLStandard == standard) {
fRGBA8RenderbufferSupport = true;
} else {
fRGBA8RenderbufferSupport = version >= GR_GL_VER(3,0) ||
ctxInfo.hasExtension("GL_OES_rgb8_rgba8") ||
ctxInfo.hasExtension("GL_ARM_rgba8");
}
if (kGL_GrGLStandard == standard) {
fUnpackRowLengthSupport = true;
fUnpackFlipYSupport = false;
@ -130,6 +141,28 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
fImagingSupport = kGL_GrGLStandard == standard &&
ctxInfo.hasExtension("GL_ARB_imaging");
// We only enable srgb support if both textures and FBOs support srgb.
bool srgbSupport = false;
if (kGL_GrGLStandard == standard) {
if (ctxInfo.version() >= GR_GL_VER(3,0)) {
srgbSupport = true;
} else if (ctxInfo.hasExtension("GL_EXT_texture_sRGB")) {
if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") ||
ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) {
srgbSupport = true;
}
}
// All the above srgb extensions support toggling srgb writes
fSRGBWriteControl = srgbSupport;
} else {
// See https://bug.skia.org/4148 for PowerVR issue.
srgbSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() &&
(ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_sRGB"));
// ES through 3.1 requires EXT_srgb_write_control to support toggling
// sRGB writing for destinations.
fSRGBWriteControl = ctxInfo.hasExtension("GL_EXT_sRGB_write_control");
}
// SGX and Mali GPUs that are based on a tiled-deferred architecture that have trouble with
// frequently changing VBOs. We've measured a performance increase using non-VBO vertex
// data for dynamic content on these GPUs. Perhaps we should read the renderer string and
@ -436,12 +469,13 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
ctxInfo.hasExtension("GL_EXT_instanced_arrays"));
}
this->initConfigTexturableTable(ctxInfo, gli, srgbSupport);
this->initConfigRenderableTable(ctxInfo, srgbSupport);
this->initShaderPrecisionTable(ctxInfo, gli, glslCaps);
// Requires fTexutreSwizzleSupport and fTextureRedSupport to be set before this point.
this->initConfigSwizzleTable(ctxInfo, glslCaps);
// Requires various members are already correctly initialized (e.g. fTextureRedSupport,
// msaa support).
this->initConfigTable(ctxInfo, gli);
// Requires various members are already correctly initialized (e.g. fTextureRedSupport).
this->initConfigTable(ctxInfo);
this->applyOptionsOverrides(contextOptions);
glslCaps->applyOptionsOverrides(contextOptions);
@ -611,6 +645,313 @@ bool GrGLCaps::hasPathRenderingSupport(const GrGLContextInfo& ctxInfo, const GrG
}
return true;
}
void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo, bool srgbSupport) {
// OpenGL < 3.0
// no support for render targets unless the GL_ARB_framebuffer_object
// extension is supported (in which case we get ALPHA, RED, RG, RGB,
// RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we
// probably don't get R8 in this case.
// OpenGL 3.0
// base color renderable: ALPHA, RED, RG, RGB, and RGBA
// sized derivatives: ALPHA8, R8, RGBA4, RGBA8
// >= OpenGL 3.1
// base color renderable: RED, RG, RGB, and RGBA
// sized derivatives: R8, RGBA4, RGBA8
// if the GL_ARB_compatibility extension is supported then we get back
// support for GL_ALPHA and ALPHA8
// GL_EXT_bgra adds BGRA render targets to any version
// ES 2.0
// color renderable: RGBA4, RGB5_A1, RGB565
// GL_EXT_texture_rg adds support for R8 as a color render target
// GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8
// GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 added BGRA support
// ES 3.0
// Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called
// below already account for this).
GrGLStandard standard = ctxInfo.standard();
enum {
kNo_MSAA = 0,
kYes_MSAA = 1,
};
if (kGL_GrGLStandard == standard) {
// Post 3.0 we will get R8
// Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object)
if (ctxInfo.version() >= GR_GL_VER(3,0) ||
ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = true;
fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = true;
}
} else {
// On ES we can only hope for R8
fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = fTextureRedSupport;
fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = fTextureRedSupport;
}
if (kGL_GrGLStandard != standard) {
// only available in ES
fConfigRenderSupport[kRGB_565_GrPixelConfig][kNo_MSAA] = true;
fConfigRenderSupport[kRGB_565_GrPixelConfig][kYes_MSAA] = true;
}
// we no longer support 444 as a render target
fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kNo_MSAA] = false;
fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kYes_MSAA] = false;
if (this->fRGBA8RenderbufferSupport) {
fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
}
if (this->isConfigTexturable(kBGRA_8888_GrPixelConfig)) {
// On iOS, BGRA is not supported as a renderable target on ES 3.0+
if (!ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888") ||
ctxInfo.version() < GR_GL_VER(3,0)) {
fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kNo_MSAA] = true;
// The GL_EXT_texture_format_BGRA8888 extension does not add BGRA to the list of
// configs that are color-renderable and can be passed to
// glRenderBufferStorageMultisample. Chromium may have an extension to allow BGRA
// renderbuffers to work on desktop platforms.
if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888")) {
fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = true;
} else {
fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] =
!fBGRAIsInternalFormat || !this->usesMSAARenderBuffers();
}
}
}
if (this->fRGBA8RenderbufferSupport && srgbSupport) {
fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
}
if (this->isConfigTexturable(kRGBA_float_GrPixelConfig)) {
if (kGL_GrGLStandard == standard) {
fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = true;
} else {
// for now we only enable this on desktop, because on ES we'd have to solve many
// precision issues and no clients actually want this yet
/*
if (ctxInfo.hasExtension("GL_EXT_color_buffer_float")) {
fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
} else {
fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = false;
}
// for now we don't support floating point MSAA on ES
fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = false;*/
fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = false;
fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = false;
}
}
if (this->isConfigTexturable(kAlpha_half_GrPixelConfig)) {
if (kGL_GrGLStandard == standard) {
fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = true;
} else if (ctxInfo.version() >= GR_GL_VER(3,0)) {
fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
// for now we don't support floating point MSAA on ES
fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
} else {
if (ctxInfo.hasExtension("GL_EXT_color_buffer_half_float") && fTextureRedSupport) {
fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
} else {
fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = false;
}
// for now we don't support floating point MSAA on ES
fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
}
}
if (this->isConfigTexturable(kRGBA_half_GrPixelConfig)) {
if (kGL_GrGLStandard == standard) {
fConfigRenderSupport[kRGBA_half_GrPixelConfig][kNo_MSAA] = true;
fConfigRenderSupport[kRGBA_half_GrPixelConfig][kYes_MSAA] = true;
} else if (ctxInfo.version() >= GR_GL_VER(3, 0)) {
fConfigRenderSupport[kRGBA_half_GrPixelConfig][kNo_MSAA] = true;
// for now we don't support floating point MSAA on ES
fConfigRenderSupport[kRGBA_half_GrPixelConfig][kYes_MSAA] = false;
} else {
if (ctxInfo.hasExtension("GL_EXT_color_buffer_half_float")) {
fConfigRenderSupport[kRGBA_half_GrPixelConfig][kNo_MSAA] = true;
} else {
fConfigRenderSupport[kRGBA_half_GrPixelConfig][kNo_MSAA] = false;
}
// for now we don't support floating point MSAA on ES
fConfigRenderSupport[kRGBA_half_GrPixelConfig][kYes_MSAA] = false;
}
}
// If we don't support MSAA then undo any places above where we set a config as renderable with
// msaa.
if (kNone_MSFBOType == fMSFBOType) {
for (int i = 0; i < kGrPixelConfigCnt; ++i) {
fConfigRenderSupport[i][kYes_MSAA] = false;
}
}
}
void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli,
bool srgbSupport) {
GrGLStandard standard = ctxInfo.standard();
GrGLVersion version = ctxInfo.version();
// Base texture support
fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true;
fConfigTextureSupport[kRGB_565_GrPixelConfig] = true;
fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true;
fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true;
// 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]) {
fConfigTextureSupport[kIndex_8_GrPixelConfig] = true;
break;
}
}
}
}
// Check for BGRA
if (kGL_GrGLStandard == standard) {
fConfigTextureSupport[kBGRA_8888_GrPixelConfig] =
version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra");
} else {
if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
if (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_texture_storage")) {
fBGRAIsInternalFormat = true;
}
} else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
fBGRAIsInternalFormat = true;
}
SkASSERT(fConfigTextureSupport[kBGRA_8888_GrPixelConfig] ||
kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig);
}
fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] = srgbSupport;
// Compressed texture support
// glCompressedTexImage2D is available on all OpenGL ES devices...
// however, it is only available on standard OpenGL after version 1.3
bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VER(1, 3));
fCompressedTexSubImageSupport =
hasCompressTex2D && (gli->fFunctions.fCompressedTexSubImage2D);
// Check for ETC1
bool hasETC1 = false;
// First check version for support
if (kGL_GrGLStandard == standard) {
hasETC1 = hasCompressTex2D &&
(version >= GR_GL_VER(4, 3) ||
ctxInfo.hasExtension("GL_ARB_ES3_compatibility"));
} else {
hasETC1 = hasCompressTex2D &&
(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")));
}
fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1;
// Check for LATC under its various forms
LATCAlias alias = kLATC_LATCAlias;
bool hasLATC = hasCompressTex2D &&
(ctxInfo.hasExtension("GL_EXT_texture_compression_latc") ||
ctxInfo.hasExtension("GL_NV_texture_compression_latc"));
// Check for RGTC
if (!hasLATC) {
// If we're using OpenGL 3.0 or later, then we have RGTC, an identical compression format.
if (kGL_GrGLStandard == standard) {
hasLATC = version >= GR_GL_VER(3, 0);
}
if (!hasLATC) {
hasLATC =
ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") ||
ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc");
}
if (hasLATC) {
alias = kRGTC_LATCAlias;
}
}
// Check for 3DC
if (!hasLATC) {
hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture");
if (hasLATC) {
alias = k3DC_LATCAlias;
}
}
fConfigTextureSupport[kLATC_GrPixelConfig] = hasLATC;
fLATCAlias = alias;
// Check for R11_EAC ... We don't support R11_EAC on desktop, as most
// cards default to decompressing the textures in the driver, and is
// generally slower.
if (kGL_GrGLStandard != standard) {
fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3, 0);
}
// Check for ASTC
fConfigTextureSupport[kASTC_12x12_GrPixelConfig] =
ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") ||
ctxInfo.hasExtension("GL_OES_texture_compression_astc");
// Check for floating point texture support
// NOTE: We disallow floating point textures on ES devices if linear
// filtering modes are not supported. This is for simplicity, but a more
// granular approach is possible. Coincidentally, floating point textures became part of
// the standard in ES3.1 / OGL 3.1, hence the shorthand
bool hasFPTextures = version >= GR_GL_VER(3, 1);
if (!hasFPTextures) {
hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
(ctxInfo.hasExtension("GL_OES_texture_float_linear") &&
ctxInfo.hasExtension("GL_OES_texture_float"));
}
fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures;
// Check for fp16 texture support
// NOTE: We disallow floating point textures on ES devices if linear
// filtering modes are not supported. This is for simplicity, but a more
// granular approach is possible. Coincidentally, 16-bit floating point textures became part of
// the standard in ES3.1 / OGL 3.1, hence the shorthand
bool hasHalfFPTextures = version >= GR_GL_VER(3, 1);
if (!hasHalfFPTextures) {
hasHalfFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
(ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
ctxInfo.hasExtension("GL_OES_texture_half_float"));
}
fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures;
fConfigTextureSupport[kRGBA_half_GrPixelConfig] = hasHalfFPTextures;
}
bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
GrPixelConfig readConfig,
GrPixelConfig currFBOConfig) const {
@ -847,6 +1188,8 @@ SkString GrGLCaps::dump() const {
r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors);
r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits);
r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes);
r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO"));
r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO"));
r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO"));
r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO"));
r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO"));
@ -991,88 +1334,7 @@ void GrGLCaps::initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps
}
bool GrGLCaps::bgraIsInternalFormat() const {
return fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat == GR_GL_BGRA;
}
void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
/*
Comments on renderability of configs on various GL versions.
OpenGL < 3.0:
no built in support for render targets.
GL_EXT_framebuffer_object adds possible support for any sized format with base internal
format RGB, RGBA and NV float formats we don't use.
This is the following:
R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16, RGBA2, RGBA4, RGB5_A1, RGBA8
RGB10_A2, RGBA12,RGBA16
Though, it is hard to believe the more obscure formats such as RGBA12 would work
since they aren't required by later standards and the driver can simply return
FRAMEBUFFER_UNSUPPORTED for anything it doesn't allow.
GL_ARB_framebuffer_object adds everything added by the EXT extension and additionally
any sized internal format with a base internal format of ALPHA, LUMINANCE,
LUMINANCE_ALPHA, INTENSITY, RED, and RG.
This adds a lot of additional renderable sized formats, including ALPHA8.
The GL_ARB_texture_rg brings in the RED and RG formats (8, 8I, 8UI, 16, 16I, 16UI,
16F, 32I, 32UI, and 32F variants).
Again, the driver has an escape hatch via FRAMEBUFFER_UNSUPPORTED.
For both the above extensions we limit ourselves to those that are also required by
OpenGL 3.0.
OpenGL 3.0:
Any format with base internal format ALPHA, RED, RG, RGB or RGBA is "color-renderable"
but are not required to be supported as renderable textures/renderbuffer.
Required renderable color formats:
- RGBA32F, RGBA32I, RGBA32UI, RGBA16, RGBA16F, RGBA16I,
RGBA16UI, RGBA8, RGBA8I, RGBA8UI, SRGB8_ALPHA8, and
RGB10_A2.
- R11F_G11F_B10F.
- RG32F, RG32I, RG32UI, RG16, RG16F, RG16I, RG16UI, RG8, RG8I,
and RG8UI.
- R32F, R32I, R32UI, R16F, R16I, R16UI, R16, R8, R8I, and R8UI.
- ALPHA8
OpenGL 3.1, 3.2, 3.3
Same as 3.0 except ALPHA8 requires GL_ARB_compatibility/compatibility profile.
OpengGL 3.3, 4.0, 4.1
Adds RGB10_A2UI.
OpengGL 4.2
Adds
- RGB5_A1, RGBA4
- RGB565
OpenGL 4.4
Does away with the separate list and adds a column to the sized internal color format
table. However, no new formats become required color renderable.
ES 2.0
color renderable: RGBA4, RGB5_A1, RGB565
GL_EXT_texture_rg adds support for R8, RG5 as a color render target
GL_OES_rgb8_rgba8 adds support for RGB8 and RGBA8
GL_ARM_rgba8 adds support for RGBA8 (but not RGB8)
GL_EXT_texture_format_BGRA8888 does not add renderbuffer support
GL_CHROMIUM_renderbuffer_format_BGRA8888 adds BGRA8 as color-renderable
GL_APPLE_texture_format_BGRA8888 does not add renderbuffer support
ES 3.0
- RGBA32I, RGBA32UI, RGBA16I, RGBA16UI, RGBA8, RGBA8I,
RGBA8UI, SRGB8_ALPHA8, RGB10_A2, RGB10_A2UI, RGBA4, and
RGB5_A1.
- RGB8 and RGB565.
- RG32I, RG32UI, RG16I, RG16UI, RG8, RG8I, and RG8UI.
- R32I, R32UI, R16I, R16UI, R8, R8I, and R8UI
ES 3.1
Adds RGB10_A2, RGB10_A2UI,
ES 3.2
Adds R16F, RG16F, RGBA16F, R32F, RG32F, RGBA32F, R11F_G11F_B10F.
*/
uint32_t allRenderFlags = ConfigInfo::kRenderable_Flag;
if (kNone_MSFBOType != fMSFBOType) {
allRenderFlags |= ConfigInfo::kRenderableWithMSAA_Flag;
}
GrGLStandard standard = ctxInfo.standard();
GrGLVersion version = ctxInfo.version();
void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo) {
fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0;
fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0;
fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat = 0;
@ -1084,67 +1346,19 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA;
fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
fConfigTable[kRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
if (kGL_GrGLStandard != standard || version > GR_GL_VER(2, 0)) {
fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags;
} else if (ctxInfo.hasExtension("GL_OES_rgb8_rgba8") || ctxInfo.hasExtension("GL_ARM_rgba8")) {
fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags;
}
if (this->bgraIsInternalFormat()) {
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_BGRA;
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_BGRA8;
} else {
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA8;
}
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat= GR_GL_BGRA;
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
if (kGL_GrGLStandard == standard) {
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA8;
if (version >= GR_GL_VER(1, 2) || ctxInfo.hasExtension("GL_EXT_bgra")) {
// Since the internal format is RGBA8, it is also renderable.
fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag |
allRenderFlags;
}
} else {
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_BGRA;
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_BGRA8;
if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
// The APPLE extension doesn't make this renderable.
fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
if (version < GR_GL_VER(3,0)) {
// On ES2 the internal format of a BGRA texture is RGBA with the APPLE extension.
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA8;
}
} else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag |
ConfigInfo::kRenderable_Flag;
if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888") &&
this->usesMSAARenderBuffers()) {
fConfigTable[kBGRA_8888_GrPixelConfig].fFlags |=
ConfigInfo::kRenderableWithMSAA_Flag;
}
}
}
// We only enable srgb support if both textures and FBOs support srgb.
bool srgbSupport = false;
if (kGL_GrGLStandard == standard) {
if (ctxInfo.version() >= GR_GL_VER(3,0)) {
srgbSupport = true;
} else if (ctxInfo.hasExtension("GL_EXT_texture_sRGB")) {
if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") ||
ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) {
srgbSupport = true;
}
}
// All the above srgb extensions support toggling srgb writes
fSRGBWriteControl = srgbSupport;
} else {
// See https://bug.skia.org/4148 for PowerVR issue.
srgbSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() &&
(ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_sRGB"));
// ES through 3.1 requires EXT_srgb_write_control to support toggling
// sRGB writing for destinations.
fSRGBWriteControl = ctxInfo.hasExtension("GL_EXT_sRGB_write_control");
}
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_SRGB_ALPHA;
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_SRGB8_ALPHA8;
// GL does not do srgb<->rgb conversions when transferring between cpu and gpu. Thus, the
@ -1152,10 +1366,6 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA;
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
if (srgbSupport) {
fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag |
allRenderFlags;
}
fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGB;
if (this->ES2CompatibilitySupport()) {
@ -1166,28 +1376,13 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB;
fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_SHORT_5_6_5;
fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
fConfigTable[kRGB_565_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
if (kGL_GrGLStandard == standard) {
if (version >= GR_GL_VER(4, 2) || ctxInfo.hasExtension("GL_ES2_compatibility")) {
fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags;
}
} else {
fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags;
}
fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA4;
fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA;
fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_SHORT_4_4_4_4;
fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
fConfigTable[kRGBA_4444_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
if (kGL_GrGLStandard == standard) {
if (version >= GR_GL_VER(4, 2)) {
fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags;
}
} else {
fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags;
}
if (this->textureRedSupport()) {
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RED;
@ -1200,58 +1395,12 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
}
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
fConfigTable[kAlpha_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
if (this->textureRedSupport() || kDesktop_ARB_MSFBOType == this->msFBOType()) {
// desktop ARB extension/3.0+ supports ALPHA8 as renderable.
// Core profile removes ALPHA8 support, but we should have chosen R8 in that case.
fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags;
}
// Check for [half] floating point texture support
// NOTE: We disallow floating point textures on ES devices if linear filtering modes are not
// supported. This is for simplicity, but a more granular approach is possible. Coincidentally,
// [half] floating point textures became part of the standard in ES3.1 / OGL 3.0.
bool hasFPTextures = false;
bool hasHalfFPTextures = false;
// for now we don't support floating point MSAA on ES
uint32_t fpRenderFlags = (kGL_GrGLStandard == standard) ?
allRenderFlags : (uint32_t)ConfigInfo::kRenderable_Flag;
if (kGL_GrGLStandard == standard) {
if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_texture_float")) {
hasFPTextures = true;
hasHalfFPTextures = true;
}
} else {
if (version >= GR_GL_VER(3, 1)) {
hasFPTextures = true;
hasHalfFPTextures = true;
} else {
if (ctxInfo.hasExtension("GL_OES_texture_float_linear") &&
ctxInfo.hasExtension("GL_OES_texture_float")) {
hasFPTextures = true;
}
if (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
ctxInfo.hasExtension("GL_OES_texture_half_float")) {
hasHalfFPTextures = true;
}
}
}
fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA32F;
fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA;
fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalType = GR_GL_FLOAT;
fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType;
if (hasFPTextures) {
fConfigTable[kRGBA_float_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
// For now we only enable rendering to float on desktop, because on ES we'd have to solve
// many precision issues and no clients actually want this yet.
if (kGL_GrGLStandard == standard /* || version >= GR_GL_VER(3,2) ||
ctxInfo.hasExtension("GL_EXT_color_buffer_float")*/) {
fConfigTable[kRGBA_float_GrPixelConfig].fFlags |= fpRenderFlags;
}
}
if (this->textureRedSupport()) {
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RED;
@ -1268,16 +1417,6 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HALF_FLOAT_OES;
}
fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType;
if (hasHalfFPTextures) {
fConfigTable[kAlpha_half_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
// ES requires either 3.2 or the combination of EXT_color_buffer_half_float and support for
// GL_RED internal format.
if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) ||
(this->textureRedSupport() &&
ctxInfo.hasExtension("GL_EXT_color_buffer_half_float"))) {
fConfigTable[kAlpha_half_GrPixelConfig].fFlags |= fpRenderFlags;
}
}
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA16F;
@ -1288,71 +1427,33 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HALF_FLOAT_OES;
}
fConfigTable[kRGBA_half_GrPixelConfig].fFormatType = kFloat_FormatType;
if (hasHalfFPTextures) {
fConfigTable[kRGBA_half_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
// ES requires 3.2 or EXT_color_buffer_half_float.
if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) ||
ctxInfo.hasExtension("GL_EXT_color_buffer_half_float")) {
fConfigTable[kRGBA_half_GrPixelConfig].fFlags |= fpRenderFlags;
}
}
// 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[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 = 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;
}
}
}
}
// May change the internal format based on extensions.
fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat =
GR_GL_COMPRESSED_LUMINANCE_LATC1;
fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_COMPRESSED_LUMINANCE_LATC1;
if (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") ||
ctxInfo.hasExtension("GL_NV_texture_compression_latc")) {
fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
} else if ((kGL_GrGLStandard == standard && version >= GR_GL_VER(3, 0)) ||
ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") ||
ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc")) {
// RGTC is identical and available on OpenGL 3.0+ as well as with extensions
fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat =
GR_GL_COMPRESSED_RED_RGTC1;
fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_COMPRESSED_RED_RGTC1;
} else if (ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture")) {
fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPRESSED_3DC_X;
fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_COMPRESSED_3DC_X;
switch(this->latcAlias()) {
case GrGLCaps::kLATC_LATCAlias:
fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat =
GR_GL_COMPRESSED_LUMINANCE_LATC1;
fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_COMPRESSED_LUMINANCE_LATC1;
break;
case GrGLCaps::kRGTC_LATCAlias:
fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat =
GR_GL_COMPRESSED_RED_RGTC1;
fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_COMPRESSED_RED_RGTC1;
break;
case GrGLCaps::k3DC_LATCAlias:
fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPRESSED_3DC_X;
fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_COMPRESSED_3DC_X;
break;
}
fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat = 0;
fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0;
@ -1363,30 +1464,12 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat = 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[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPRESSED_R11_EAC;
fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMPRESSED_R11_EAC;
fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat = 0;
fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0;
fConfigTable[kR11_EAC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
// Check for R11_EAC. We don't support R11_EAC on desktop, as most cards default to
// decompressing the textures in the driver, and is generally slower.
if (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) {
fConfigTable[kR11_EAC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
}
fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fBaseInternalFormat =
GR_GL_COMPRESSED_RGBA_ASTC_12x12;
@ -1395,11 +1478,6 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat = 0;
fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0;
fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
if (ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") ||
ctxInfo.hasExtension("GL_OES_texture_compression_astc")) {
fConfigTable[kASTC_12x12_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
}
// Bulk populate the texture internal/external formats here and then deal with exceptions below.

View File

@ -123,25 +123,12 @@ public:
GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo,
const GrGLInterface* glInterface);
bool isConfigTexturable(GrPixelConfig config) const override {
SkASSERT(kGrPixelConfigCnt > config);
return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kTextureable_Flag);
}
bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override {
SkASSERT(kGrPixelConfigCnt > config) ;
if (withMSAA) {
return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderableWithMSAA_Flag);
} else {
return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderable_Flag);
}
}
/** Returns conversions to various GL format parameters for a GrPixelCfonig. */
const ConfigFormats& configGLFormats(GrPixelConfig config) const {
return fConfigTable[config].fFormats;
}
/**
* Gets an array of legal stencil formats. These formats are not guaranteed
* to be supported by the driver but are legal GLenum names given the GL
@ -240,12 +227,15 @@ public:
/// maximum number of texture units accessible in the fragment shader.
int maxFragmentTextureUnits() const { return fMaxFragmentTextureUnits; }
/// ES requires an extension to support RGBA8 in RenderBufferStorage
bool rgba8RenderbufferSupport() const { return fRGBA8RenderbufferSupport; }
/**
* Depending on the ES extensions present the BGRA external format may
* correspond to either a BGRA or RGBA internalFormat. On desktop GL it is
* correspond either a BGRA or RGBA internalFormat. On desktop GL it is
* RGBA.
*/
bool bgraIsInternalFormat() const;
bool bgraIsInternalFormat() const { return fBGRAIsInternalFormat; }
/// Is there support for GL_UNPACK_ROW_LENGTH
bool unpackRowLengthSupport() const { return fUnpackRowLengthSupport; }
@ -319,6 +309,19 @@ public:
*/
SkString dump() const override;
/**
* LATC can appear under one of three possible names. In order to know
* which GL internal format to use, we need to keep track of which name
* we found LATC under. The default is LATC.
*/
enum LATCAlias {
kLATC_LATCAlias,
kRGTC_LATCAlias,
k3DC_LATCAlias
};
LATCAlias latcAlias() const { return fLATCAlias; }
bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; }
bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; }
@ -335,7 +338,8 @@ private:
void initBlendEqationSupport(const GrGLContextInfo&);
void initStencilFormats(const GrGLContextInfo&);
// This must be called after initFSAASupport().
void initConfigTable(const GrGLContextInfo&, const GrGLInterface* gli);
void initConfigRenderableTable(const GrGLContextInfo&, bool srgbSupport);
void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*, bool srgbSupport);
void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
const GrGLInterface* intf,
@ -343,6 +347,7 @@ private:
void initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps* glslCaps);
void initConfigTable(const GrGLContextInfo&);
SkTArray<StencilFormat, true> fStencilFormats;
@ -354,7 +359,10 @@ private:
InvalidateFBType fInvalidateFBType;
MapBufferType fMapBufferType;
TransferBufferType fTransferBufferType;
LATCAlias fLATCAlias;
bool fRGBA8RenderbufferSupport : 1;
bool fBGRAIsInternalFormat : 1;
bool fUnpackRowLengthSupport : 1;
bool fUnpackFlipYSupport : 1;
bool fPackRowLengthSupport : 1;
@ -412,10 +420,7 @@ private:
int fStencilFormatIndex;
enum {
kVerifiedColorAttachment_Flag = 0x1,
kTextureable_Flag = 0x2,
kRenderable_Flag = 0x4,
kRenderableWithMSAA_Flag = 0x8,
kVerifiedColorAttachment_Flag = 0x1
};
uint32_t fFlags;
};