summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-05-18 11:34:44 -0700
committerJason Ekstrand <[email protected]>2016-05-23 19:12:34 -0700
commita01a1eb9e48196a5dde37675c51d294b31c32728 (patch)
treee9a6588ccb6541ec4e21be1a0027bb009c8ee894
parenta7011922f1d48357f18af4639fad008f6f33a984 (diff)
i965/draw: Stop relying on min_index == -1 for invalid index bounds
The vbo layer passes an index_bounds_valid flag that we should be using instead. This also fixes a bug when min_index == -1 and basevertex != 0 where we were actually comparing min_index + basevertex == -1 which was false and we were getting the wrong buffer-sizing path. Cc: "11.1 11.2" <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h1
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c7
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c2
3 files changed, 7 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 9a4dd31c4bb..c6fb8d277e1 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -963,6 +963,7 @@ struct brw_context
/* Summary of size and varying of active arrays, so we can check
* for changes to this state:
*/
+ bool index_bounds_valid;
unsigned int min_index, max_index;
/* Offset from start of vertex buffer so we can avoid redefining
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index bb963f467f9..7901972111f 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -424,6 +424,7 @@ brw_try_draw_prims(struct gl_context *ctx,
const struct _mesa_prim *prims,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
+ bool index_bounds_valid,
GLuint min_index,
GLuint max_index,
struct brw_transform_feedback_object *xfb_obj,
@@ -477,6 +478,7 @@ brw_try_draw_prims(struct gl_context *ctx,
brw->ib.ib = ib;
brw->ctx.NewDriverState |= BRW_NEW_INDICES;
+ brw->vb.index_bounds_valid = index_bounds_valid;
brw->vb.min_index = min_index;
brw->vb.max_index = max_index;
brw->ctx.NewDriverState |= BRW_NEW_VERTICES;
@@ -659,14 +661,15 @@ brw_draw_prims(struct gl_context *ctx,
perf_debug("Scanning index buffer to compute index buffer bounds. "
"Use glDrawRangeElements() to avoid this.\n");
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index, nr_prims);
+ index_bounds_valid = true;
}
/* Try drawing with the hardware, but don't do anything else if we can't
* manage it. swrast doesn't support our featureset, so we can't fall back
* to it.
*/
- brw_try_draw_prims(ctx, arrays, prims, nr_prims, ib, min_index, max_index,
- xfb_obj, stream, indirect);
+ brw_try_draw_prims(ctx, arrays, prims, nr_prims, ib, index_bounds_valid,
+ min_index, max_index, xfb_obj, stream, indirect);
}
void
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 5af458368c8..3ec37f805e3 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -493,7 +493,7 @@ brw_prepare_vertices(struct brw_context *brw)
glarray->InstanceDivisor) - 1) +
glarray->_ElementSize);
} else {
- if (min_index == -1) {
+ if (!brw->vb.index_bounds_valid) {
offset = 0;
size = intel_buffer->Base.Size;
} else {