mesa: finish up ARB_texture_float
authorMarek Olšák <maraeo@gmail.com>
Tue, 15 Feb 2011 23:35:44 +0000 (00:35 +0100)
committerMarek Olšák <maraeo@gmail.com>
Fri, 15 Apr 2011 03:08:00 +0000 (05:08 +0200)
Squashed commit of the following:

Author: Marek Olšák <maraeo@gmail.com>

    mesa: handle floating-point formats in _mesa_base_fbo_format
    mesa: add ARB/ATI_texture_float, remove MESAX_texture_float

commit 123bb110852739dffadcc81ad80b005b1c4f586d
Author: Luca Barbieri <luca@luca-barbieri.com>
Date:   Wed Aug 25 01:35:42 2010 +0200

    mesa: compute floatMode for FBOs and return it on RGBA_FLOAT_MODE

src/mesa/drivers/dri/r300/r300_context.c
src/mesa/drivers/dri/r600/r600_context.c
src/mesa/main/extensions.c
src/mesa/main/fbobject.c
src/mesa/main/framebuffer.c

index 0d8bd4fc706d4cd29c60610aaad63098f5f950a4..213d3c060a689bfe980ed1e8a16534ec7e235e6a 100644 (file)
@@ -133,7 +133,6 @@ static const struct dri_extension card_extensions[] = {
   {"GL_ATI_texture_mirror_once",       NULL},
   {"GL_MESA_pack_invert",              NULL},
   {"GL_MESA_ycbcr_texture",            NULL},
-  {"GL_MESAX_texture_float",           NULL},
   {"GL_NV_blend_square",               NULL},
   {"GL_NV_vertex_program",             GL_NV_vertex_program_functions},
 #if FEATURE_OES_EGL_image
index 00708be19937dbcc667a49a89447f66df86a7c12..1b9676147ee005761138d644e7070082be702aba 100644 (file)
@@ -145,7 +145,6 @@ static const struct dri_extension card_extensions[] = {
   {"GL_ATI_texture_mirror_once",       NULL},
   {"GL_MESA_pack_invert",              NULL},
   {"GL_MESA_ycbcr_texture",            NULL},
-  {"GL_MESAX_texture_float",           NULL},
   {"GL_NV_blend_square",               NULL},
   {"GL_NV_vertex_program",             GL_NV_vertex_program_functions},
   {"GL_ARB_pixel_buffer_object",        NULL},
index c45265900ba2d1dd3a49b66c3f9dd2e6d28cc979..8a0ab9615235d1898e66bc95d3f27efad8eb8aa6 100644 (file)
@@ -124,6 +124,7 @@ static const struct extension extension_table[] = {
    { "GL_ARB_texture_env_combine",                 o(ARB_texture_env_combine),                 GL,             2001 },
    { "GL_ARB_texture_env_crossbar",                o(ARB_texture_env_crossbar),                GL,             2001 },
    { "GL_ARB_texture_env_dot3",                    o(ARB_texture_env_dot3),                    GL,             2001 },
+   { "GL_ARB_texture_float",                       o(ARB_texture_float),                       GL,             2004 },
    { "GL_ARB_texture_mirrored_repeat",             o(ARB_texture_mirrored_repeat),             GL,             2001 },
    { "GL_ARB_texture_multisample",                 o(ARB_texture_multisample),                 GL,             2009 },
    { "GL_ARB_texture_non_power_of_two",            o(ARB_texture_non_power_of_two),            GL,             2003 },
@@ -268,6 +269,7 @@ static const struct extension extension_table[] = {
    { "GL_ATI_separate_stencil",                    o(ATI_separate_stencil),                    GL,             2006 },
    { "GL_ATI_texture_compression_3dc",             o(ATI_texture_compression_3dc),             GL,             2004 },
    { "GL_ATI_texture_env_combine3",                o(ATI_texture_env_combine3),                GL,             2002 },
+   { "GL_ATI_texture_float",                       o(ARB_texture_float),                       GL,             2002 },
    { "GL_ATI_texture_mirror_once",                 o(ATI_texture_mirror_once),                 GL,             2006 },
    { "GL_IBM_multimode_draw_arrays",               o(IBM_multimode_draw_arrays),               GL,             1998 },
    { "GL_IBM_rasterpos_clip",                      o(IBM_rasterpos_clip),                      GL,             1996 },
@@ -278,7 +280,6 @@ static const struct extension extension_table[] = {
    { "GL_MESA_texture_array",                      o(MESA_texture_array),                      GL,             2007 },
    { "GL_MESA_texture_signed_rgba",                o(EXT_texture_snorm),                       GL,             2009 },
    { "GL_MESA_window_pos",                         o(ARB_window_pos),                          GL,             2000 },
-   { "GL_MESAX_texture_float",                     o(ARB_texture_float),                       GL,             2009 },
    { "GL_MESA_ycbcr_texture",                      o(MESA_ycbcr_texture),                      GL,             2002 },
    { "GL_NV_blend_square",                         o(NV_blend_square),                         GL,             1999 },
    { "GL_NV_conditional_render",                   o(NV_conditional_render),                   GL,             2008 },
index eb1fef51427d47c7007a12198de14e73d18e2397..1edb310ea13d650c138c9080b8f304f35db25c41 100644 (file)
@@ -1145,7 +1145,37 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat)
    case GL_INTENSITY16_SNORM:
       return ctx->Extensions.EXT_texture_snorm &&
              ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0;
-   /* XXX add floating point and integer formats eventually */
+   case GL_R16F:
+   case GL_R32F:
+      return ctx->Extensions.ARB_texture_rg &&
+             ctx->Extensions.ARB_texture_float ? GL_RED : 0;
+   case GL_RG16F:
+   case GL_RG32F:
+      return ctx->Extensions.ARB_texture_rg &&
+             ctx->Extensions.ARB_texture_float ? GL_RG : 0;
+   case GL_RGB16F:
+   case GL_RGB32F:
+      return ctx->Extensions.ARB_texture_float ? GL_RGB : 0;
+   case GL_RGBA16F:
+   case GL_RGBA32F:
+      return ctx->Extensions.ARB_texture_float ? GL_RGBA : 0;
+   case GL_ALPHA16F_ARB:
+   case GL_ALPHA32F_ARB:
+      return ctx->Extensions.ARB_texture_float &&
+             ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0;
+   case GL_LUMINANCE16F_ARB:
+   case GL_LUMINANCE32F_ARB:
+      return ctx->Extensions.ARB_texture_float &&
+             ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0;
+   case GL_LUMINANCE_ALPHA16F_ARB:
+   case GL_LUMINANCE_ALPHA32F_ARB:
+      return ctx->Extensions.ARB_texture_float &&
+             ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0;
+   case GL_INTENSITY16F_ARB:
+   case GL_INTENSITY32F_ARB:
+      return ctx->Extensions.ARB_texture_float &&
+             ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0;
+   /* XXX add integer formats eventually */
    default:
       return 0;
    }
index 4f0e6f57853932ae595dcf2a1df3f2b60f9e14d3..66c9bd91096260139b1f32ea2b7cb09c5def7e83 100644 (file)
@@ -551,7 +551,6 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx,
             fb->Visual.alphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS);
             fb->Visual.rgbBits = fb->Visual.redBits
                + fb->Visual.greenBits + fb->Visual.blueBits;
-            fb->Visual.floatMode = GL_FALSE;
             fb->Visual.samples = rb->NumSamples;
             if (_mesa_get_format_color_encoding(fmt) == GL_SRGB)
                 fb->Visual.sRGBCapable = ctx->Const.sRGBCapable;
@@ -560,6 +559,19 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx,
       }
    }
 
+   fb->Visual.floatMode = GL_FALSE;
+   for (i = 0; i < BUFFER_COUNT; i++) {
+      if (fb->Attachment[i].Renderbuffer) {
+         const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
+         const gl_format fmt = rb->Format;
+
+         if (_mesa_get_format_datatype(fmt) == GL_FLOAT) {
+            fb->Visual.floatMode = GL_TRUE;
+            break;
+         }
+      }
+   }
+
    if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) {
       const struct gl_renderbuffer *rb =
          fb->Attachment[BUFFER_DEPTH].Renderbuffer;