[Mesa-dev] [PATCH] gallium/u_vbuf: drop min/max-scanning for empty indirect draws

Erik Faye-Lund erik.faye-lund at collabora.com
Thu Jun 28 13:22:40 UTC 2018


When building with asserts enabled, we'll end up triggering an assert
in pipe_buffer_map_range down this code-path, due to trying to map
an empty range. Even if we avoid that, we'll trigger another assert
a bit later, because u_vbuf_get_minmax_index returns a min-index of
-1 here, which gets promoted to an unsigned value, and gives us an
out-of-bounds buffer-mapping offset.

Since we can't really have a well-defined min/max range here when
the range is empty anyway, we should just drop this dance in the
first place. After all, no rendering is going to be produced.

This fixes a crash in dEQP-GLES31.functional.draw_indirect.random.0
on VirGL for me.

Signed-off-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
---
I noticed this while debugging something else, so I thought I'd send
a patch upstream, as the problem doesn't seem unique to my usecase.

 src/gallium/auxiliary/util/u_vbuf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
index 42f37c7574..76a1d143d9 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -1183,6 +1183,9 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info)
       new_info.start = data[2];
       pipe_buffer_unmap(pipe, transfer);
       new_info.indirect = NULL;
+
+      if (!new_info.count)
+         return;
    }
 
    if (new_info.index_size) {
-- 
2.18.0.rc2



More information about the mesa-dev mailing list