One more pass at getting half float texture configs correct.
authorjvanverth <jvanverth@google.com>
Thu, 18 Dec 2014 13:44:55 +0000 (05:44 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 18 Dec 2014 13:44:55 +0000 (05:44 -0800)
Added in check for sized internal format.
Made choice between RED and ALPHA orthogonal to HALF_FLOAT and
HALF_FLOAT_OES.
Enabled rendertarget support on ES 2.0.

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

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

index c1eb6e10e254020ad96955596a169e59cd7e9910..cfb9558c76cdf41af061f12820e32490d09c3894 100644 (file)
@@ -497,10 +497,17 @@ void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
         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 {
-            // 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;
+            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;
         }
     }
@@ -649,10 +656,10 @@ 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("GL_OES_texture_half_float_linear") &&
-         ctxInfo.hasExtension("GL_OES_texture_half_float"));
+                            (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
+                             ctxInfo.hasExtension("GL_OES_texture_half_float"));
     }
-    fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures && fTextureRedSupport;
+    fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures;
 }
 
 bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf,
index 92b00c3f5c65c7df68b3abc5f08defef81dc9552..5987c7000f6e7a216d3f09afee549830da463a89 100644 (file)
@@ -2386,18 +2386,25 @@ bool GrGLGpu::configToGLFormats(GrPixelConfig config,
             break;
 
         case kAlpha_half_GrPixelConfig:
-            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;
+            if (this->glCaps().textureRedSupport()) {
+                if (getSizedInternalFormat) {
+                    *internalFormat = GR_GL_R16F;
+                } else {
+                    *internalFormat = GR_GL_RED;
+                }
                 *externalFormat = GR_GL_RED;
-                *externalType = GR_GL_HALF_FLOAT;
             } else {
-                *internalFormat = GR_GL_ALPHA16F;
+                if (getSizedInternalFormat) {
+                    *internalFormat = GR_GL_ALPHA16F;
+                } else {
+                    *internalFormat = GR_GL_ALPHA;
+                }
                 *externalFormat = GR_GL_ALPHA;
+            }
+            if (kGL_GrGLStandard == this->glStandard() || this->glVersion() >= GR_GL_VER(3, 0)) {
                 *externalType = GR_GL_HALF_FLOAT;
+            } else {
+                *externalType = GR_GL_HALF_FLOAT_OES;
             }
             break;
             
index 5cf1f0a449381387a88cd89e88ccdcadc153e461..346c7379929be483060ab118f0ae2c341f285f4e 100644 (file)
@@ -90,7 +90,7 @@ DEF_GPUTEST(HalfFloatTextureTest, reporter, factory) {
         controlPixelData[i + 2] = SK_HalfEpsilon;
         controlPixelData[i + 3] = 0x6800;   // 2^11
     }
-    
+
     for (int origin = 0; origin < 2; ++origin) {
         int glCtxTypeCnt = 1;
         glCtxTypeCnt = GrContextFactory::kGLContextTypeCnt;
@@ -102,7 +102,7 @@ DEF_GPUTEST(HalfFloatTextureTest, reporter, factory) {
             desc.fConfig = kAlpha_half_GrPixelConfig;
             desc.fOrigin = 0 == origin ?
             kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
-            
+
             GrContext* context = NULL;
             GrContextFactory::GLContextType type =
             static_cast<GrContextFactory::GLContextType>(glCtxType);
@@ -113,16 +113,16 @@ DEF_GPUTEST(HalfFloatTextureTest, reporter, factory) {
             if (NULL == context){
                 continue;
             }
-            
+
             SkAutoTUnref<GrTexture> fpTexture(context->createUncachedTexture(desc,
                                                                              NULL,
                                                                              0));
-            
+
             // 16-bit floating point textures are NOT supported everywhere
             if (NULL == fpTexture) {
                 continue;
             }
-            
+
             // write square
             fpTexture->writePixels(0, 0, DEV_W, DEV_H, desc.fConfig, controlPixelData, 0);
             fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer, 0);