[Mesa-dev] [PATCH 09/13] st/mesa: initial ARB_depth_buffer_float support

Marek Olšák maraeo at gmail.com
Thu Jun 30 17:29:41 PDT 2011


---
 src/mesa/state_tracker/st_cb_clear.c   |    6 ++++--
 src/mesa/state_tracker/st_extensions.c |   11 +++++++++++
 src/mesa/state_tracker/st_format.c     |   19 +++++++++++++++++++
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 181fedd..117000b 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -381,7 +381,8 @@ check_clear_depth_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuff
 
    assert(rb->Format == MESA_FORMAT_S8 ||
           rb->Format == MESA_FORMAT_Z24_S8 ||
-          rb->Format == MESA_FORMAT_S8_Z24);
+          rb->Format == MESA_FORMAT_S8_Z24 ||
+          rb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
 
    if (ctx->Scissor.Enabled &&
        (ctx->Scissor.X != 0 ||
@@ -436,7 +437,8 @@ check_clear_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb
 
    assert(rb->Format == MESA_FORMAT_S8 ||
           rb->Format == MESA_FORMAT_Z24_S8 ||
-          rb->Format == MESA_FORMAT_S8_Z24);
+          rb->Format == MESA_FORMAT_S8_Z24 ||
+          rb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
 
    if (maskStencil) 
       return GL_TRUE;
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index d3aebe5..99b231d 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -607,4 +607,15 @@ void st_init_extensions(struct st_context *st)
    if (screen->get_param(screen, PIPE_CAP_SM3)) {
       ctx->Extensions.ARB_shader_texture_lod = GL_TRUE;
    }
+
+   if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_FLOAT,
+                                   PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_DEPTH_STENCIL |
+                                   PIPE_BIND_SAMPLER_VIEW) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED,
+                                   PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_DEPTH_STENCIL |
+                                   PIPE_BIND_SAMPLER_VIEW)) {
+      ctx->Extensions.ARB_depth_buffer_float = GL_TRUE;
+   }
 }
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index d1995f1..bd4f086 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -95,6 +95,9 @@ st_format_datatype(enum pipe_format format)
                format == PIPE_FORMAT_X8Z24_UNORM) {
          return GL_UNSIGNED_INT_24_8;
       }
+      else if (format == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED) {
+         return GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
+      }
       else {
          const GLuint size = format_max_bits(format);
 
@@ -205,6 +208,10 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
       return PIPE_FORMAT_Z24X8_UNORM;
    case MESA_FORMAT_S8:
       return PIPE_FORMAT_S8_USCALED;
+   case MESA_FORMAT_Z32_FLOAT:
+      return PIPE_FORMAT_Z32_FLOAT;
+   case MESA_FORMAT_Z32_FLOAT_X24S8:
+      return PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED;
    case MESA_FORMAT_YCBCR:
       return PIPE_FORMAT_UYVY;
 #if FEATURE_texture_s3tc
@@ -427,6 +434,10 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
       return MESA_FORMAT_X8_Z24;
    case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
       return MESA_FORMAT_S8_Z24;
+   case PIPE_FORMAT_Z32_FLOAT:
+      return MESA_FORMAT_Z32_FLOAT;
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      return MESA_FORMAT_Z32_FLOAT_X24S8;
 
    case PIPE_FORMAT_UYVY:
       return MESA_FORMAT_YCBCR;
@@ -784,6 +795,10 @@ static const struct format_mapping format_map[] = {
       { GL_DEPTH_COMPONENT, 0 },
       { DEFAULT_DEPTH_FORMATS }
    },
+   {
+      { GL_DEPTH_COMPONENT32F, 0 },
+      { PIPE_FORMAT_Z32_FLOAT, 0 }
+   },
 
    /* stencil formats */
    {
@@ -800,6 +815,10 @@ static const struct format_mapping format_map[] = {
       { GL_DEPTH_STENCIL_EXT, GL_DEPTH24_STENCIL8_EXT, 0 },
       { PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_FORMAT_S8_USCALED_Z24_UNORM, 0 }
    },
+   {
+      { GL_DEPTH32F_STENCIL8, 0 },
+      { PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, 0 }
+   },
 
    /* sRGB formats */
    {
-- 
1.7.4.1



More information about the mesa-dev mailing list