Mesa (master): iris: Stop quantizing the depth clear value

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 18 23:25:42 UTC 2020


Module: Mesa
Branch: master
Commit: 0d3b61dd7e8ce80f5ec0cbe27e901747e9e0e61d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0d3b61dd7e8ce80f5ec0cbe27e901747e9e0e61d

Author: Nanley Chery <nanley.g.chery at intel.com>
Date:   Mon Nov 16 16:33:39 2020 -0800

iris: Stop quantizing the depth clear value

This function has a number of problems:

 1. It performs 24-bit quantization on a format which shouldn't be
    quantized at all (PIPE_FORMAT_Z32_FLOAT_S8X24_UINT).
 2. The algorithm seems to create a different pixel than HW would in the
    absence of this SW conversion. This can cause issues with depth
    testing.

Instead of adding more code to deal with these issues, delete the
quantization code.

This code originated from i965
(0ae9ce0f29ea1973b850a4e6c6cae8606973036e) and helped to avoid a
regression in Lightsmark 2008. This change continues to avoid that
regression because any new clear value is now casted from double to
float before checking if the resource's clear value has changed.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3783
Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7665>

---

 src/gallium/drivers/iris/iris_clear.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_clear.c b/src/gallium/drivers/iris/iris_clear.c
index eaffcb87fe6..cf7dff74aa8 100644
--- a/src/gallium/drivers/iris/iris_clear.c
+++ b/src/gallium/drivers/iris/iris_clear.c
@@ -440,23 +440,6 @@ can_fast_clear_depth(struct iris_context *ice,
                                     box->y + box->height);
 }
 
-static float
-convert_depth_value(enum pipe_format format, double depth)
-{
-   /* Quantize the clear value to what can be stored in the actual depth
-    * buffer. This makes checking for changes more accurate because the actual
-    * depth bits are compared. It also prevents us from getting a too-accurate
-    * depth value during depth testing or when sampling with HiZ enabled.
-    */
-   if (format == PIPE_FORMAT_Z32_FLOAT) {
-      return depth;
-   } else {
-      const unsigned nbits = format == PIPE_FORMAT_Z16_UNORM ? 16 : 24;
-      const uint32_t depth_max = (1 << nbits) - 1;
-      return (unsigned)(depth * depth_max) / (float)depth_max;
-   }
-}
-
 static void
 fast_clear_depth(struct iris_context *ice,
                  struct iris_resource *res,
@@ -687,7 +670,7 @@ iris_clear(struct pipe_context *ctx,
       clear_depth_stencil(ice, psurf->texture, psurf->u.tex.level, &box, true,
                           buffers & PIPE_CLEAR_DEPTH,
                           buffers & PIPE_CLEAR_STENCIL,
-                          convert_depth_value(psurf->format, depth), stencil);
+                          depth, stencil);
    }
 
    if (buffers & PIPE_CLEAR_COLOR) {
@@ -834,7 +817,7 @@ iris_clear_depth_stencil(struct pipe_context *ctx,
    clear_depth_stencil(ice, psurf->texture, psurf->u.tex.level, &box,
                        render_condition_enabled,
                        flags & PIPE_CLEAR_DEPTH, flags & PIPE_CLEAR_STENCIL,
-                       convert_depth_value(psurf->format, depth), stencil);
+                       depth, stencil);
 }
 
 void



More information about the mesa-commit mailing list