From deb7fa10a2efe2edad1127e19df70442ce20a874 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Fri, 7 May 2021 14:31:08 +0200 Subject: [PATCH] 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 Reviewed-by: Dave Airlie Part-of: --- 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);