[Mesa-dev] [PATCH 2/2] llvmpipe: Don't advertise S8_UNORM (with feeble attempt at supporting it).

jfonseca at vmware.com jfonseca at vmware.com
Tue Jan 29 05:28:29 PST 2013


From: José Fonseca <jfonseca at vmware.com>

S8_UNORM was inadvertedly supported together with Z16_UNORM.

I tried to update the code to accomodate stencil-only -- it seemed a simple
thing to do -- but "fbo-stencil clear GL_STENCIL_INDEX8" still fails,
and it's not worth debugging.

Therefore although this change tries to update for S8_UNORM, it also
disables it completely.
---
 src/gallium/drivers/llvmpipe/lp_bld_depth.c |   75 ++++++++++++++-------------
 src/gallium/drivers/llvmpipe/lp_screen.c    |    7 ++-
 2 files changed, 46 insertions(+), 36 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
index 24c997d..b9dbdc5 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
@@ -306,35 +306,35 @@ lp_depth_type(const struct util_format_description *format_desc,
               unsigned length)
 {
    struct lp_type type;
-   unsigned swizzle;
+   unsigned z_swizzle;
 
    assert(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS);
    assert(format_desc->block.width == 1);
    assert(format_desc->block.height == 1);
 
-   swizzle = format_desc->swizzle[0];
-   assert(swizzle < 4);
-
    memset(&type, 0, sizeof type);
    type.width = format_desc->block.bits;
 
-   if(format_desc->channel[swizzle].type == UTIL_FORMAT_TYPE_FLOAT) {
-      type.floating = TRUE;
-      assert(swizzle == 0);
-      assert(format_desc->channel[swizzle].size == format_desc->block.bits);
-   }
-   else if(format_desc->channel[swizzle].type == UTIL_FORMAT_TYPE_UNSIGNED) {
-      assert(format_desc->block.bits <= 32);
-      assert(format_desc->channel[swizzle].normalized);
-      if (format_desc->channel[swizzle].size < format_desc->block.bits) {
-         /* Prefer signed integers when possible, as SSE has less support
-          * for unsigned comparison;
-          */
-         type.sign = TRUE;
+   z_swizzle = format_desc->swizzle[0];
+   if (z_swizzle < 4) {
+      if (format_desc->channel[z_swizzle].type == UTIL_FORMAT_TYPE_FLOAT) {
+         type.floating = TRUE;
+         assert(z_swizzle == 0);
+         assert(format_desc->channel[z_swizzle].size == format_desc->block.bits);
+      }
+      else if(format_desc->channel[z_swizzle].type == UTIL_FORMAT_TYPE_UNSIGNED) {
+         assert(format_desc->block.bits <= 32);
+         assert(format_desc->channel[z_swizzle].normalized);
+         if (format_desc->channel[z_swizzle].size < format_desc->block.bits) {
+            /* Prefer signed integers when possible, as SSE has less support
+             * for unsigned comparison;
+             */
+            type.sign = TRUE;
+         }
       }
+      else
+         assert(0);
    }
-   else
-      assert(0);
 
    type.length = length;
 
@@ -604,24 +604,29 @@ lp_build_depth_stencil_test(struct gallivm_state *gallivm,
       assert(format_desc->block.height == 1);
 
       if (stencil[0].enabled) {
-         assert(format_desc->format == PIPE_FORMAT_Z24_UNORM_S8_UINT ||
-                format_desc->format == PIPE_FORMAT_S8_UINT_Z24_UNORM);
+         assert(s_swizzle < 4);
+         assert(format_desc->channel[s_swizzle].type == UTIL_FORMAT_TYPE_UNSIGNED);
+         assert(format_desc->channel[s_swizzle].pure_integer);
+         assert(!format_desc->channel[s_swizzle].normalized);
+         assert(format_desc->channel[s_swizzle].size == 8);
       }
 
-      assert(z_swizzle < 4);
-      assert(format_desc->block.bits <= z_type.width);
-      if (z_type.floating) {
-         assert(z_swizzle == 0);
-         assert(format_desc->channel[z_swizzle].type ==
-                UTIL_FORMAT_TYPE_FLOAT);
-         assert(format_desc->channel[z_swizzle].size ==
-                format_desc->block.bits);
-      }
-      else {
-         assert(format_desc->channel[z_swizzle].type ==
-                UTIL_FORMAT_TYPE_UNSIGNED);
-         assert(format_desc->channel[z_swizzle].normalized);
-         assert(!z_type.fixed);
+      if (depth->enabled) {
+         assert(z_swizzle < 4);
+         assert(format_desc->block.bits <= z_type.width);
+         if (z_type.floating) {
+            assert(z_swizzle == 0);
+            assert(format_desc->channel[z_swizzle].type ==
+                   UTIL_FORMAT_TYPE_FLOAT);
+            assert(format_desc->channel[z_swizzle].size ==
+                   format_desc->block.bits);
+         }
+         else {
+            assert(format_desc->channel[z_swizzle].type ==
+                   UTIL_FORMAT_TYPE_UNSIGNED);
+            assert(format_desc->channel[z_swizzle].normalized);
+            assert(!z_type.fixed);
+         }
       }
    }
 
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
index de80c6f..3769428 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -356,9 +356,14 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
       if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
          return FALSE;
 
-      /* FIXME: Temporary restriction. See lp_bld_depth.c. */
+      /* TODO: Support Z32_FLOAT_S8X24_UINT. See lp_bld_depth.c. */
       if (format_desc->block.bits > 32)
          return FALSE;
+
+      /* TODO: Support stencil-only formats */
+      if (format_desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_NONE) {
+         return FALSE;
+      }
    }
 
    if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
-- 
1.7.9.5



More information about the mesa-dev mailing list