Fix float and half float support on mobile.
authorjvanverth <jvanverth@google.com>
Fri, 12 Dec 2014 13:58:06 +0000 (05:58 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 12 Dec 2014 13:58:06 +0000 (05:58 -0800)
It's unclear what params should be used for half float alpha
rendertargets, so they are disabled for the moment.

Review URL: https://codereview.chromium.org/799593002

src/gpu/gl/GrGLCaps.cpp
src/gpu/gl/GrGpuGL.cpp
tests/FloatingPointTextureTest.cpp

index ea34a00..8b26282 100644 (file)
@@ -470,21 +470,28 @@ void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
     }
 
     if (this->isConfigTexturable(kRGBA_float_GrPixelConfig)) {
-        fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
         if (kGL_GrGLStandard == standard) {
+            fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
             fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = true;
         } else {
-            // for now we don't support float point MSAA on ES
+            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[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
         }
     }
 
     if (this->isConfigTexturable(kAlpha_half_GrPixelConfig)) {
-        fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
         if (kGL_GrGLStandard == standard) {
+            fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
             fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = true;
         } else {
-            // for now we don't support float point MSAA on ES
+            // in theory, check for "GL_EXT_color_buffer_half_float" 
+            // for now we don't support half float alpha render target on ES
+            fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = false;
             fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
         }
     }
@@ -620,7 +627,7 @@ void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const G
     bool hasFPTextures = version >= GR_GL_VER(3, 1);
     if (!hasFPTextures) {
         hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
-                        (ctxInfo.hasExtension("OES_texture_float_linear") &&
+                        (ctxInfo.hasExtension("GL_OES_texture_float_linear") &&
                          ctxInfo.hasExtension("GL_OES_texture_float"));
     }
     fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures;
@@ -633,7 +640,7 @@ void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const G
     bool hasHalfFPTextures = version >= GR_GL_VER(3, 1);
     if (!hasHalfFPTextures) {
         hasHalfFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
-        (ctxInfo.hasExtension("OES_texture_half_float_linear") &&
+        (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
          ctxInfo.hasExtension("GL_OES_texture_half_float"));
     }
     fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures && fTextureRedSupport;
index 7db6abd..c6cdbfa 100644 (file)
@@ -2246,16 +2246,18 @@ bool GrGpuGL::configToGLFormats(GrPixelConfig config,
             break;
 
         case kAlpha_half_GrPixelConfig:
-            if (this->glCaps().textureRedSupport()) {
+            if (kGLES_GrGLStandard == this->glStandard() && this->glVersion() < GR_GL_VER(3, 1)) {
+                *internalFormat = GR_GL_ALPHA;
+                *externalFormat = GR_GL_ALPHA;
+                *externalType = GR_GL_HALF_FLOAT_OES;
+            } else if (this->glCaps().textureRedSupport()) {
                 *internalFormat = GR_GL_R16F;
                 *externalFormat = GR_GL_RED;
-                *externalType = (kGLES_GrGLStandard == this->glStandard()) ? GR_GL_HALF_FLOAT
-                                                                           : GR_GL_HALF_FLOAT_OES;
+                *externalType = GR_GL_HALF_FLOAT;
             } else {
                 *internalFormat = GR_GL_ALPHA16F;
                 *externalFormat = GR_GL_ALPHA;
-                *externalType = (kGLES_GrGLStandard == this->glStandard()) ? GR_GL_HALF_FLOAT
-                                                                           : GR_GL_HALF_FLOAT_OES;
+                *externalType = GR_GL_HALF_FLOAT;
             }
             break;
             
index d6074b9..5cf1f0a 100644 (file)
@@ -127,7 +127,6 @@ DEF_GPUTEST(HalfFloatTextureTest, reporter, factory) {
             fpTexture->writePixels(0, 0, DEV_W, DEV_H, desc.fConfig, controlPixelData, 0);
             fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer, 0);
             for (int j = 0; j < HALF_CONTROL_ARRAY_SIZE; ++j) {
-                SkASSERT(readBuffer[j] == controlPixelData[j]);
                 REPORTER_ASSERT(reporter, readBuffer[j] == controlPixelData[j]);
             }
         }