From fda015023af5d0d2d844d5fde07a8c19e4d8f453 Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Thu, 5 Nov 2020 15:45:44 -0800 Subject: [PATCH] mesa: Add and use _mesa_has_depth_float_channel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák Reviewed-by: Eric Anholt Part-of: --- src/mesa/main/glformats.c | 9 +++++++++ src/mesa/main/glformats.h | 3 +++ src/mesa/main/readpix.c | 3 +-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index 1d528f4bff5..f98d189c8e6 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -1335,6 +1335,15 @@ _mesa_is_depth_or_stencil_format(GLenum format) } } +/** + * 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 0a65ef6cace..90438ffba0d 100644 --- a/src/mesa/main/glformats.h +++ b/src/mesa/main/glformats.h @@ -104,6 +104,9 @@ _mesa_is_depthstencil_format(GLenum format); extern GLboolean _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); diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index bca9c0c90a4..5f9b4b9d159 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -910,8 +910,7 @@ read_pixels_es3_error_check(struct gl_context *ctx, GLenum format, GLenum type, 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) {