[Mesa-dev] [PATCH] st/mesa: improve ARB_texture_stencil8 support

Marek Olšák maraeo at gmail.com
Sun Apr 5 04:42:22 PDT 2015


From: Marek Olšák <marek.olsak at amd.com>

1) Try selecting X24S8 and S8X24 first.
2) Make sure depth-stencil formats are always renderable.

r600g and radeonsi don't support S8 for rendering. Actually, they don't even
support X24S8 and S8X24, but we can fix that later.
---
 src/mesa/state_tracker/st_format.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 72dbf3b..26c7da4 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -1167,8 +1167,8 @@ static const struct format_mapping format_map[] = {
       { GL_STENCIL_INDEX, GL_STENCIL_INDEX1_EXT, GL_STENCIL_INDEX4_EXT,
         GL_STENCIL_INDEX8_EXT, GL_STENCIL_INDEX16_EXT, 0 },
       {
-         PIPE_FORMAT_S8_UINT, PIPE_FORMAT_Z24_UNORM_S8_UINT,
-         PIPE_FORMAT_S8_UINT_Z24_UNORM, 0
+         PIPE_FORMAT_S8_UINT, PIPE_FORMAT_X24S8_UINT, PIPE_FORMAT_S8X24_UINT,
+         PIPE_FORMAT_Z24_UNORM_S8_UINT, PIPE_FORMAT_S8_UINT_Z24_UNORM, 0
       }
    },
 
@@ -1942,11 +1942,6 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
                        GLint internalFormat,
                        GLenum format, GLenum type)
 {
-   const boolean want_renderable =
-      internalFormat == 3 || internalFormat == 4 ||
-      internalFormat == GL_RGB || internalFormat == GL_RGBA ||
-      internalFormat == GL_RGB8 || internalFormat == GL_RGBA8 ||
-      internalFormat == GL_BGRA;
    struct st_context *st = st_context(ctx);
    enum pipe_format pFormat;
    unsigned bindings;
@@ -1962,15 +1957,17 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
    }
 
    /* GL textures may wind up being render targets, but we don't know
-    * that in advance.  Specify potential render target flags now.
+    * that in advance.  Specify potential render target flags for formats
+    * that we know should always be renderable.
     */
    bindings = PIPE_BIND_SAMPLER_VIEW;
-   if (want_renderable) {
-      if (_mesa_is_depth_or_stencil_format(internalFormat))
-	 bindings |= PIPE_BIND_DEPTH_STENCIL;
-      else
-	 bindings |= PIPE_BIND_RENDER_TARGET;
-   }
+   if (_mesa_is_depth_or_stencil_format(internalFormat))
+      bindings |= PIPE_BIND_DEPTH_STENCIL;
+   else if (internalFormat == 3 || internalFormat == 4 ||
+            internalFormat == GL_RGB || internalFormat == GL_RGBA ||
+            internalFormat == GL_RGB8 || internalFormat == GL_RGBA8 ||
+            internalFormat == GL_BGRA)
+      bindings |= PIPE_BIND_RENDER_TARGET;
 
    /* GLES allows the driver to choose any format which matches
     * the format+type combo, because GLES only supports unsized internal
-- 
2.1.0



More information about the mesa-dev mailing list