[Mesa-dev] [PATCH 3/5] st/mesa: support EXT_texture_shared_exponent

Marek Olšák maraeo at gmail.com
Tue Apr 26 03:57:59 PDT 2011


---
 src/mesa/state_tracker/st_cb_drawpixels.c |    4 ++++
 src/mesa/state_tracker/st_extensions.c    |    6 ++++++
 src/mesa/state_tracker/st_format.c        |   13 +++++++++++++
 3 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 1707f82..be0cd61 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -372,6 +372,10 @@ internal_format(struct gl_context *ctx, GLenum format, GLenum type)
             return
                ctx->Extensions.ARB_texture_float ? GL_RGBA32F :
                ctx->Extensions.EXT_texture_snorm ? GL_RGBA16_SNORM : GL_RGBA16;
+
+         case GL_UNSIGNED_INT_5_9_9_9_REV:
+            assert(ctx->Extensions.EXT_texture_shared_exponent);
+            return GL_RGB9_E5;
          }
       }
    }
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index bdc0894..f280279 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -574,4 +574,10 @@ void st_init_extensions(struct st_context *st)
    if (st->pipe->texture_barrier) {
       ctx->Extensions.NV_texture_barrier = GL_TRUE;
    }
+
+   if (screen->is_format_supported(screen, PIPE_FORMAT_R9G9B9E5_FLOAT,
+                                   PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_SAMPLER_VIEW)) {
+      ctx->Extensions.EXT_texture_shared_exponent = GL_TRUE;
+   }
 }
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 8e50dbd..4b3a175 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -325,6 +325,9 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
    case MESA_FORMAT_SIGNED_I16:
       return PIPE_FORMAT_I16_SNORM;
 
+   case MESA_FORMAT_RGB9_E5_FLOAT:
+      return PIPE_FORMAT_R9G9B9E5_FLOAT;
+
    default:
       assert(0);
       return PIPE_FORMAT_NONE;
@@ -545,6 +548,9 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
    case PIPE_FORMAT_I16_SNORM:
       return MESA_FORMAT_SIGNED_I16;
 
+   case PIPE_FORMAT_R9G9B9E5_FLOAT:
+      return MESA_FORMAT_RGB9_E5_FLOAT;
+
    default:
       assert(0);
       return MESA_FORMAT_NONE;
@@ -1464,6 +1470,13 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
                target, sample_count, bindings);
       }
 
+   case GL_RGB9_E5:
+      if (screen->is_format_supported(screen, PIPE_FORMAT_R9G9B9E5_FLOAT, target,
+                                      sample_count, bindings)) {
+         return PIPE_FORMAT_R9G9B9E5_FLOAT;
+      }
+      return PIPE_FORMAT_NONE;
+
    default:
       return PIPE_FORMAT_NONE;
    }
-- 
1.7.4.1



More information about the mesa-dev mailing list