mesa: Add and use _mesa_has_depth_float_channel

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7410>
(cherry picked from commit fda015023af5d0d2d844d5fde07a8c19e4d8f453)
diff --git a/.pick_status.json b/.pick_status.json
index 449b05e..db02c68 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1102,7 +1102,7 @@
         "description": "mesa: Add and use _mesa_has_depth_float_channel",
         "nominated": false,
         "nomination_type": null,
-        "resolution": 4,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 1d528f4..f98d189 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1335,6 +1335,15 @@
    }
 }
 
+/**
+ * Test if the given image format has a floating-point depth component.
+ */
+GLboolean
+_mesa_has_depth_float_channel(GLenum internalFormat)
+{
+   return internalFormat == GL_DEPTH32F_STENCIL8 ||
+          internalFormat == GL_DEPTH_COMPONENT32F;
+}
 
 /**
  * Test if an image format is a supported compressed format.
diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h
index 0a65ef6..90438ff 100644
--- a/src/mesa/main/glformats.h
+++ b/src/mesa/main/glformats.h
@@ -105,6 +105,9 @@
 _mesa_is_depth_or_stencil_format(GLenum format);
 
 extern GLboolean
+_mesa_has_depth_float_channel(GLenum internalFormat);
+
+extern GLboolean
 _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format);
 
 extern GLboolean
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index bca9c0c..5f9b4b9 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -910,8 +910,7 @@
    const GLenum data_type = _mesa_get_format_datatype(rb->Format);
    GLboolean is_unsigned_int = GL_FALSE;
    GLboolean is_signed_int = GL_FALSE;
-   GLboolean is_float_depth = (internalFormat == GL_DEPTH_COMPONENT32F) ||
-         (internalFormat == GL_DEPTH32F_STENCIL8);
+   GLboolean is_float_depth = _mesa_has_depth_float_channel(internalFormat);
 
    is_unsigned_int = _mesa_is_enum_format_unsigned_int(internalFormat);
    if (!is_unsigned_int) {