aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-03-17 13:01:26 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-17 13:01:26 -0700
commitc571c001cee4e0dfacd7bd17d5cd0a2900a853a9 (patch)
treeb677d3cb745b52dd7f74507de78709c8437b3ecd /src/gpu/gl
parentb893a4c569d0719a395abffb266d1d61af847e2f (diff)
Revert of sRGB support in Ganesh. Several pieces: (patchset #12 id:220001 of https://codereview.chromium.org/1789663002/ )
Reason for revert: We're getting sRGB non-8888 configs? Original issue's description: > sRGB support in Ganesh. Several pieces: > > sRGB support now also requires GL_EXT_texture_sRGB_decode, which allows > us to disable sRGB -> Linear conversion when reading textures. This gives > us an easy way to support "legacy" L32 mode. We disable decoding based on > the pixel config of the render target. Textures can override that behavior > (specifically for format-conversion draws where we want that behavior). > > Added sBGRA pixel config, which is not-really-a-format. It's just sRGBA > internally, and the external format is BGR order, so TexImage calls will > swizzle correctly. This lets us interact with sRGB raster surfaces on BGR > platforms. > > Devices without sRGB support behave like they always have: conversion from > color type and profile type ignores sRGB and always returns linear pixel > configs. > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1789663002 > > Committed: https://skia.googlesource.com/skia/+/9e3f1bf4e5cd8fc59554f986f36d6b034e99f9eb TBR=reed@google.com,bsalomon@google.com,robertphillips@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1814533003
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLCaps.cpp43
-rw-r--r--src/gpu/gl/GrGLCaps.h3
-rw-r--r--src/gpu/gl/GrGLDefines.h5
-rw-r--r--src/gpu/gl/GrGLGpu.cpp35
-rw-r--r--src/gpu/gl/GrGLGpu.h3
-rw-r--r--src/gpu/gl/GrGLTexture.h1
6 files changed, 15 insertions, 75 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index af31480ba7..40885359fb 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -1435,31 +1435,27 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
}
fConfigTable[kBGRA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
- // We only enable srgb support if both textures and FBOs support srgb,
- // *and* we can disable sRGB decode-on-read, to support "legacy" mode.
+ // 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)) {
- fSRGBSupport = true;
+ srgbSupport = true;
} else if (ctxInfo.hasExtension("GL_EXT_texture_sRGB")) {
if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") ||
ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) {
- fSRGBSupport = true;
+ srgbSupport = true;
}
}
// All the above srgb extensions support toggling srgb writes
- fSRGBWriteControl = fSRGBSupport;
+ fSRGBWriteControl = srgbSupport;
} else {
// See https://bug.skia.org/4148 for PowerVR issue.
- fSRGBSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() &&
+ 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");
}
- if (!ctxInfo.hasExtension("GL_EXT_texture_sRGB_decode")) {
- // To support "legacy" L32 mode, we require the ability to turn off sRGB decode:
- fSRGBSupport = false;
- }
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
@@ -1468,7 +1464,7 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
GR_GL_RGBA;
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
- if (fSRGBSupport) {
+ if (srgbSupport) {
fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag |
allRenderFlags;
}
@@ -1477,26 +1473,6 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
}
fConfigTable[kSRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
- // sBGRA is not a "real" thing in OpenGL, but GPUs support it, and on platforms where
- // kN32 == BGRA, we need some way to work with it. (The default framebuffer on Windows
- // is in this format, for example).
- fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_SRGB_ALPHA;
- fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_SRGB8_ALPHA8;
- // GL does not do srgb<->rgb conversions when transferring between cpu and gpu. Thus, the
- // external format is GL_BGRA.
- fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
- GR_GL_BGRA;
- fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
- fConfigTable[kSBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
- if (fSRGBSupport) {
- fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag |
- allRenderFlags;
- }
- if (texStorageSupported) {
- fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
- }
- fConfigTable[kSBGRA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
-
fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGB;
if (this->ES2CompatibilitySupport()) {
fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGB565;
@@ -1816,11 +1792,6 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
if (ctxInfo.standard() == kGLES_GrGLStandard && ctxInfo.version() == GR_GL_VER(2,0)) {
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kTexImage_ExternalFormatUsage] =
GR_GL_SRGB_ALPHA;
-
- // Additionally, because we had to "invent" sBGRA, there is no way to make it work
- // in ES 2.0, because there is no <internalFormat> we can use. So just make that format
- // unsupported. (If we have no sRGB support at all, this will get overwritten below).
- fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags = 0;
}
// If BGRA is supported as an internal format it must always be specified to glTex[Sub]Image
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index ed673e7ce7..376610d8b0 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -120,10 +120,12 @@ public:
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 {
@@ -132,6 +134,7 @@ public:
}
bool isConfigTexSupportEnabled(GrPixelConfig config) const {
+ SkASSERT(kGrPixelConfigCnt > config);
return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kCanUseTexStorage_Flag);
}
diff --git a/src/gpu/gl/GrGLDefines.h b/src/gpu/gl/GrGLDefines.h
index ff4c457250..cd73be401b 100644
--- a/src/gpu/gl/GrGLDefines.h
+++ b/src/gpu/gl/GrGLDefines.h
@@ -506,17 +506,12 @@
/* TextureUsage */
#define GR_GL_FRAMEBUFFER_ATTACHMENT 0x93A3
-/* TextureSRGBDecode */
-#define GR_GL_DECODE_EXT 0x8A49
-#define GR_GL_SKIP_DECODE_EXT 0x8A4A
-
/* TextureParameterName */
#define GR_GL_TEXTURE_MAG_FILTER 0x2800
#define GR_GL_TEXTURE_MIN_FILTER 0x2801
#define GR_GL_TEXTURE_WRAP_S 0x2802
#define GR_GL_TEXTURE_WRAP_T 0x2803
#define GR_GL_TEXTURE_USAGE 0x93A2
-#define GR_GL_TEXTURE_SRGB_DECODE_EXT 0x8A48
/* TextureTarget */
/* GL_TEXTURE_2D */
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 62baf79002..76cb1a068a 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -898,7 +898,6 @@ static inline GrGLint config_alignment(GrPixelConfig config) {
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
- case kSBGRA_8888_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
return 4;
default:
@@ -2101,15 +2100,13 @@ bool GrGLGpu::flushGLState(const GrPipeline& pipeline, const GrPrimitiveProcesso
SkSTArray<8, const GrTextureAccess*> textureAccesses;
program->setData(primProc, pipeline, &textureAccesses);
- GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget());
- bool allowSRGB = GrAllowSRGBForDestinationPixelConfig(glRT->config());
-
int numTextureAccesses = textureAccesses.count();
for (int i = 0; i < numTextureAccesses; i++) {
- this->bindTexture(i, textureAccesses[i]->getParams(), allowSRGB,
+ this->bindTexture(i, textureAccesses[i]->getParams(),
static_cast<GrGLTexture*>(textureAccesses[i]->getTexture()));
}
+ GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget());
this->flushStencil(pipeline.getStencil());
this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->origin());
this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStencil().isDisabled());
@@ -2610,16 +2607,6 @@ bool GrGLGpu::onGetReadPixelsInfo(GrSurface* srcSurface, int width, int height,
tempDrawInfo->fSwizzle = GrSwizzle::BGRA();
tempDrawInfo->fReadConfig = kRGBA_8888_GrPixelConfig;
ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
- } else if (readConfig == kSBGRA_8888_GrPixelConfig &&
- this->glCaps().isConfigRenderable(kSRGBA_8888_GrPixelConfig, false) &&
- this->readPixelsSupported(kSRGBA_8888_GrPixelConfig, kSRGBA_8888_GrPixelConfig)) {
- // We're trying to read sBGRA but it's not supported. If sRGBA is renderable and
- // we can read it back, then do a swizzling draw to a sRGBA and read it back (which
- // will effectively be sBGRA).
- tempDrawInfo->fTempSurfaceDesc.fConfig = kSRGBA_8888_GrPixelConfig;
- tempDrawInfo->fSwizzle = GrSwizzle::BGRA();
- tempDrawInfo->fReadConfig = kSRGBA_8888_GrPixelConfig;
- ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
} else if (readConfig == kAlpha_8_GrPixelConfig) {
// onReadPixels implements a fallback for cases where we are want to read kAlpha_8,
// it's unsupported, but 32bit RGBA reads are supported.
@@ -3324,8 +3311,7 @@ static void get_tex_param_swizzle(GrPixelConfig config,
}
}
-void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, bool dstConfigAllowsSRGB,
- GrGLTexture* texture) {
+void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture) {
SkASSERT(texture);
#ifdef SK_DEBUG
@@ -3361,19 +3347,6 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, bool dstCo
bool setAll = timestamp < this->getResetTimestamp();
GrGLTexture::TexParams newTexParams;
- if (this->caps()->srgbSupport()) {
- // By default, the decision to allow SRGB decode is based on the destination config.
- // A texture can override that by specifying a value in GrTextureParams.
- newTexParams.fSRGBDecode =
- (dstConfigAllowsSRGB || GrTextureParams::kForceAllowSRGB_SRGBMode == params.srgbMode())
- ? GR_GL_DECODE_EXT : GR_GL_SKIP_DECODE_EXT;
-
- if (setAll || newTexParams.fSRGBDecode != oldTexParams.fSRGBDecode) {
- this->setTextureUnit(unitIdx);
- GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SRGB_DECODE_EXT, newTexParams.fSRGBDecode));
- }
- }
-
static GrGLenum glMinFilterModes[] = {
GR_GL_NEAREST,
GR_GL_LINEAR,
@@ -4041,7 +4014,7 @@ void GrGLGpu::copySurfaceAsDraw(GrSurface* dst,
GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture());
GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode);
- this->bindTexture(0, params, true, srcTex);
+ this->bindTexture(0, params, srcTex);
GrGLIRect dstVP;
this->bindSurfaceFBOForCopy(dst, GR_GL_FRAMEBUFFER, &dstVP, kDst_TempFBOTarget);
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index a3582739e7..e365601e1f 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -59,8 +59,7 @@ public:
void discard(GrRenderTarget*) override;
// Used by GrGLProgram to configure OpenGL state.
- void bindTexture(int unitIdx, const GrTextureParams& params, bool dstConfigAllowsSRGB,
- GrGLTexture* texture);
+ void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture);
bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeight, size_t rowBytes,
GrPixelConfig readConfig, DrawPreference*,
diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h
index 6ee8dcfe2b..937b8be13e 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -25,7 +25,6 @@ public:
GrGLenum fWrapT;
GrGLenum fMaxMipMapLevel;
GrGLenum fSwizzleRGBA[4];
- GrGLenum fSRGBDecode;
void invalidate() { memset(this, 0xff, sizeof(TexParams)); }
};