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@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10689>
This commit is contained in:
Erik Faye-Lund 2021-05-07 14:31:08 +02:00 committed by Marge Bot
parent 8ad7a7c7b3
commit deb7fa10a2
1 changed files with 1 additions and 1 deletions

View File

@ -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);