Mesa (master): mesa: always set valid index bounds for non-indexed draws for classic drivers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jan 14 20:36:19 UTC 2021
Module: Mesa
Branch: master
Commit: 39c415d5fd496b64f8fda2ea47b6adb88b9bd51e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=39c415d5fd496b64f8fda2ea47b6adb88b9bd51e
Author: Marek Olšák <marek.olsak at amd.com>
Date: Tue Jan 12 14:45:03 2021 -0500
mesa: always set valid index bounds for non-indexed draws for classic drivers
This should fix crashing piglit tests on the i915 classic driver.
Fixes: 2358da81d26 - mesa: switch (Multi)DrawArrays to DrawGallium
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8453>
---
src/mesa/main/draw.c | 35 +++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c
index eedf9c41167..669f0c5375e 100644
--- a/src/mesa/main/draw.c
+++ b/src/mesa/main/draw.c
@@ -91,12 +91,26 @@ _mesa_draw_gallium_fallback(struct gl_context *ctx,
{
struct _mesa_index_buffer ib;
unsigned index_size = info->index_size;
- unsigned min_index = info->index_bounds_valid ? info->min_index : 0;
- unsigned max_index = info->index_bounds_valid ? info->max_index : ~0;
+ unsigned min_index = 0, max_index = ~0u;
+ bool index_bounds_valid = false;
if (!info->instance_count)
return;
+ if (index_size) {
+ if (info->index_bounds_valid) {
+ min_index = info->min_index;
+ max_index = info->max_index;
+ index_bounds_valid = true;
+ }
+ } else {
+ /* The index_bounds_valid field and min/max_index are not used for
+ * non-indexed draw calls (they are undefined), but classic drivers
+ * need the index bounds. They will be computed manually.
+ */
+ index_bounds_valid = true;
+ }
+
ib.index_size_shift = util_logbase2(index_size);
/* Single draw or a fallback for user indices. */
@@ -132,8 +146,13 @@ _mesa_draw_gallium_fallback(struct gl_context *ctx,
prim.basevertex = index_size ? info->index_bias : 0;
prim.draw_id = info->drawid + (info->increment_draw_id ? i : 0);
+ if (!index_size) {
+ min_index = draws[i].start;
+ max_index = draws[i].start + draws[i].count - 1;
+ }
+
ctx->Driver.Draw(ctx, &prim, 1, index_size ? &ib : NULL,
- info->index_bounds_valid, info->primitive_restart,
+ index_bounds_valid, info->primitive_restart,
info->restart_index, min_index, max_index,
info->instance_count, info->start_instance);
}
@@ -146,6 +165,9 @@ _mesa_draw_gallium_fallback(struct gl_context *ctx,
ALLOC_PRIMS(prim, num_draws, "DrawGallium");
+ min_index = ~0u;
+ max_index = 0;
+
for (unsigned i = 0; i < num_draws; i++) {
if (!draws[i].count)
continue;
@@ -158,6 +180,11 @@ _mesa_draw_gallium_fallback(struct gl_context *ctx,
prim[num_prims].basevertex = info->index_size ? info->index_bias : 0;
prim[num_prims].draw_id = info->drawid + (info->increment_draw_id ? i : 0);
+ if (!index_size) {
+ min_index = MIN2(min_index, draws[i].start);
+ max_index = MAX2(max_index, draws[i].start + draws[i].count - 1);
+ }
+
max_count = MAX2(max_count, prim[num_prims].count);
num_prims++;
}
@@ -176,7 +203,7 @@ _mesa_draw_gallium_fallback(struct gl_context *ctx,
}
ctx->Driver.Draw(ctx, prim, num_prims, index_size ? &ib : NULL,
- info->index_bounds_valid, info->primitive_restart,
+ index_bounds_valid, info->primitive_restart,
info->restart_index, min_index, max_index,
info->instance_count, info->start_instance);
FREE_PRIMS(prim, num_draws);
More information about the mesa-commit
mailing list