Module: Mesa
Branch: staging/23.0
Commit: 0bb13b2df23412222e90a4be5886f5bb7ff92d16
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0bb13b2df23412222e90a4be5886f5bb7ff92d16

Author: Marek Olšák <[email protected]>
Date:   Fri Feb  3 10:34:09 2023 -0500

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

Cc: mesa-stable

Reviewed-by: Mike Blumenkrantz <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21039>
(cherry picked from commit e2ad086f485b82e59b37dd87e7e6e6393bb62257)

---

 .pick_status.json    |  2 +-
 src/mesa/main/draw.c | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 5772baeadc4..4eaf8338535 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -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
     },
diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c
index 0fbf3063ed2..464d6bb5911 100644
--- a/src/mesa/main/draw.c
+++ b/src/mesa/main/draw.c
@@ -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;

Reply via email to