Mesa (main): st/mesa: do not take util_logbase2 of a negative size

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 10 17:00:43 UTC 2021


Module: Mesa
Branch: main
Commit: deb7fa10a2efe2edad1127e19df70442ce20a874
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=deb7fa10a2efe2edad1127e19df70442ce20a874

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Fri May  7 14:31:08 2021 +0200

st/mesa: do not take util_logbase2 of a negative size

It's possible to get all width, height and depth as negative here, and
if we take the util_logbase2 of that, we get a nonsense value that might
be outside of the range the driver supports. So let's clamp to zero here
to avoid having to make the drivers overly pessimistic about what the
state-tracker demands.

Reviewed-by: Adam Jackson <ajax at redhat.com>
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10689>

---

 src/mesa/state_tracker/st_cb_texture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index bf98d21b554..d220f1e3d08 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -3162,7 +3162,7 @@ st_TestProxyTexImage(struct gl_context *ctx, GLenum target,
       }
       else {
          /* assume a full set of mipmaps */
-         pt.last_level = util_logbase2(MAX3(width, height, depth));
+         pt.last_level = util_logbase2(MAX4(width, height, depth, 0));
       }
 
       return st->screen->can_create_resource(st->screen, &pt);



More information about the mesa-commit mailing list