From 3f801cbb67895fa9fa29498aa017a7666960a627 Mon Sep 17 00:00:00 2001 From: jvanverth Date: Tue, 16 Dec 2014 09:49:38 -0800 Subject: Change desktop and ES 3.0 to always use sized internal texture formats. Committed: https://skia.googlesource.com/skia/+/bc02bf0ee4221604796cd6d0394ca3af60c0a579 Review URL: https://codereview.chromium.org/806943002 --- src/gpu/gl/GrGLCaps.cpp | 9 +++++++++ src/gpu/gl/GrGLCaps.h | 4 ++++ src/gpu/gl/GrGLDefines.h | 1 + src/gpu/gl/GrGpuGL.cpp | 27 ++++++++++----------------- 4 files changed, 24 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 8b26282968..c1eb6e10e2 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -44,6 +44,7 @@ void GrGLCaps::reset() { fTwoFormatLimit = false; fFragCoordsConventionSupport = false; fVertexArrayObjectSupport = false; + fES2CompatibilitySupport = false; fUseNonVBOVertexAndIndexDynamicData = false; fIsCoreProfile = false; fFullClearIsFree = false; @@ -86,6 +87,7 @@ GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) { fTwoFormatLimit = caps.fTwoFormatLimit; fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport; fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport; + fES2CompatibilitySupport = caps.fES2CompatibilitySupport; fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicData; fIsCoreProfile = caps.fIsCoreProfile; fFullClearIsFree = caps.fFullClearIsFree; @@ -239,6 +241,13 @@ bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { ctxInfo.hasExtension("GL_OES_vertex_array_object"); } + if (kGL_GrGLStandard == standard) { + fES2CompatibilitySupport = ctxInfo.hasExtension("GL_ARB_ES2_compatibility"); + } + else { + fES2CompatibilitySupport = true; + } + if (kGLES_GrGLStandard == standard) { if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) { fFBFetchSupport = true; diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 19e9b878de..0018263b02 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -245,6 +245,9 @@ public: /// Is there support for Vertex Array Objects? bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; } + /// Is there support for ES2 compatability? + bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; } + /// Use indices or vertices in CPU arrays rather than VBOs for dynamic content. bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; @@ -364,6 +367,7 @@ private: bool fTwoFormatLimit : 1; bool fFragCoordsConventionSupport : 1; bool fVertexArrayObjectSupport : 1; + bool fES2CompatibilitySupport : 1; bool fUseNonVBOVertexAndIndexDynamicData : 1; bool fIsCoreProfile : 1; bool fFullClearIsFree : 1; diff --git a/src/gpu/gl/GrGLDefines.h b/src/gpu/gl/GrGLDefines.h index dc9468fd1e..0eb5149a8c 100644 --- a/src/gpu/gl/GrGLDefines.h +++ b/src/gpu/gl/GrGLDefines.h @@ -736,6 +736,7 @@ #define GR_GL_RGB565 0x8D62 #define GR_GL_RGBA8 0x8058 #define GR_GL_RGBA32F 0x8814 +#define GR_GL_RGB5 0x8050 #define GR_GL_RGB8 0x8051 #define GR_GL_BGRA8 0x93A1 #define GR_GL_SRGB 0x8C40 diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 2965cd4007..7d3920fad9 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -554,21 +554,14 @@ bool GrGLGpu::uploadTexData(const GrSurfaceDesc& desc, useTexStorage = desc.fConfig != kRGB_565_GrPixelConfig; } - GrGLenum internalFormat; - GrGLenum externalFormat = 0x0; // suprress warning - GrGLenum externalType = 0x0;// suprress warning - - // glTexStorage requires sized internal formats on both desktop and ES. ES2 requires an unsized - // format for glTexImage, unlike ES3 and desktop. However, we allow the driver to decide the - // size of the internal format whenever possible and so only use a sized internal format when - // using texture storage. - bool useSizedFormat = useTexStorage; - // Many versions of the ES3 drivers on various platforms will not accept GL_RED in - // glTexImage2D for the internal format but will accept GL_R8. - if (kGLES_GrGLStandard == this->glStandard() && this->glVersion() >= GR_GL_VER(3, 0) && - kAlpha_8_GrPixelConfig == dataConfig) { - useSizedFormat = true; - } + GrGLenum internalFormat = 0x0; // suppress warning + GrGLenum externalFormat = 0x0; // suppress warning + GrGLenum externalType = 0x0; // suppress warning + + // glTexStorage requires sized internal formats on both desktop and ES. + // ES2 requires an unsized format for glTexImage. On ES3 and desktop we default to sized. + bool useSizedFormat = useTexStorage || kGL_GrGLStandard == this->glStandard() || + this->glVersion() >= GR_GL_VER(3, 0); if (!this->configToGLFormats(dataConfig, useSizedFormat, &internalFormat, &externalFormat, &externalType)) { return false; @@ -2276,8 +2269,8 @@ bool GrGLGpu::configToGLFormats(GrPixelConfig config, *internalFormat = GR_GL_RGB; *externalFormat = GR_GL_RGB; if (getSizedInternalFormat) { - if (this->glStandard() == kGL_GrGLStandard) { - return false; + if (!this->glCaps().ES2CompatibilitySupport()) { + *internalFormat = GR_GL_RGB5; } else { *internalFormat = GR_GL_RGB565; } -- cgit v1.2.3