From 48268e0f2a5e65b63586398db3a58523a8c7a7a0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 3 Aug 2010 16:32:32 -0600 Subject: draw: check for instance divisors in vcache_check_run() When we have instance divisors we don't really know which vertex elements we'll be fetching ahead of time. This fixes a bug in instanced drawing which was exposed by the new draw_vbo() code because of max_index not being ~0 as often as it used to be. The test for max_index >= DRAW_PIPE_MAX_VERTICES often hid this problem before. --- src/gallium/auxiliary/draw/draw_pt_vcache.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c index 8ef94c3163..d2fa1c6d4e 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache.c +++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c @@ -339,6 +339,25 @@ format_from_get_elt( pt_elt_func get_elt ) #endif +/** + * Check if any vertex attributes use instance divisors. + * Note that instance divisors complicate vertex fetching so we need + * to take the vcache path when they're in use. + */ +static boolean +any_instance_divisors(const struct draw_context *draw) +{ + uint i; + + for (i = 0; i < draw->pt.nr_vertex_elements; i++) { + uint div = draw->pt.vertex_element[i].instance_divisor; + if (div) + return TRUE; + } + return FALSE; +} + + static INLINE void vcache_check_run( struct draw_pt_front_end *frontend, pt_elt_func get_elt, @@ -382,6 +401,9 @@ vcache_check_run( struct draw_pt_front_end *frontend, if (max_index >= (unsigned) DRAW_PIPE_MAX_VERTICES) goto fail; + if (any_instance_divisors(draw)) + goto fail; + fetch_count = max_index + 1 - min_index; if (0) -- cgit v1.2.3