Mesa (master): iris: Add and use convert_depth_value

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Nov 13 19:01:49 UTC 2020


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

Author: Nanley Chery <nanley.g.chery at intel.com>
Date:   Mon Oct 19 15:31:24 2020 -0700

iris: Add and use convert_depth_value

Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7410>

---

 src/gallium/drivers/iris/iris_clear.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_clear.c b/src/gallium/drivers/iris/iris_clear.c
index 9be44e460a0..dbb808de75e 100644
--- a/src/gallium/drivers/iris/iris_clear.c
+++ b/src/gallium/drivers/iris/iris_clear.c
@@ -440,6 +440,23 @@ 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,
@@ -450,16 +467,7 @@ fast_clear_depth(struct iris_context *ice,
    struct pipe_resource *p_res = (void *) res;
    struct iris_batch *batch = &ice->batches[IRIS_BATCH_RENDER];
 
-   /* Quantize the clear value to what can be stored in the actual depth
-    * buffer.  This makes the following check more accurate because it now
-    * checks if the actual depth bits will match.  It also prevents us from
-    * getting a too-accurate depth value during depth testing or when sampling
-    * with HiZ enabled.
-    */
-   const unsigned nbits = p_res->format == PIPE_FORMAT_Z16_UNORM ? 16 : 24;
-   const uint32_t depth_max = (1 << nbits) - 1;
-   depth = p_res->format == PIPE_FORMAT_Z32_FLOAT ? depth :
-      (unsigned)(depth * depth_max) / (float)depth_max;
+   depth = convert_depth_value(p_res->format, depth);
 
    bool update_clear_depth = false;
 



More information about the mesa-commit mailing list