mesa: ignore indices[i] if count[i] == 0 for MultiDrawElements

Cc: mesa-stable

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21039>
(cherry picked from commit e2ad086f48)
This commit is contained in:
Marek Olšák 2023-02-03 10:34:09 -05:00 committed by Dylan Baker
parent a4e3154973
commit 0bb13b2df2
2 changed files with 8 additions and 5 deletions

View file

@ -1282,7 +1282,7 @@
"description": "mesa: ignore indices[i] if count[i] == 0 for MultiDrawElements",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -1974,9 +1974,11 @@ _mesa_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
min_index_ptr = (uintptr_t) indices[0];
max_index_ptr = 0;
for (i = 0; i < primcount; i++) {
min_index_ptr = MIN2(min_index_ptr, (uintptr_t) indices[i]);
max_index_ptr = MAX2(max_index_ptr, (uintptr_t) indices[i] +
(count[i] << index_size_shift));
if (count[i]) {
min_index_ptr = MIN2(min_index_ptr, (uintptr_t) indices[i]);
max_index_ptr = MAX2(max_index_ptr, (uintptr_t) indices[i] +
(count[i] << index_size_shift));
}
}
/* Check if we can handle this thing as a bunch of index offsets from the
@ -1987,7 +1989,8 @@ _mesa_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
*/
if (index_size_shift) {
for (i = 0; i < primcount; i++) {
if ((((uintptr_t) indices[i] - min_index_ptr) &
if (count[i] &&
(((uintptr_t)indices[i] - min_index_ptr) &
((1 << index_size_shift) - 1)) != 0) {
fallback = true;
break;