[Mesa-dev] [PATCH] u_primconvert: Copy min/max_index from the original primitive.

Eric Anholt eric at anholt.net
Tue Aug 5 11:43:51 PDT 2014


These values are supposed to be the minimum/maximum index values used to
read from the vertex buffers.  This code either copies index values out of
the old IB (so, same min/max as the original draw call), or generates a
new IB (using index values between the start and the start + count of the
old array draw info, which just happens to be what min/max_index are set
to by st_draw.c).

We were incorrectly setting the max_index in the
converting-from-glDrawArrays case to the start vertex plus the number of
vertices generated in the new IB, which broke QUADS primitive conversion
on VC4 (where max_index really has to be correct, or the kernel might
reject your draw call due to buffer overflow).

Reviewed-by: Rob Clark <robclark at freedesktop.org> (from verbal description
             of the patch)
---
 src/gallium/auxiliary/indices/u_primconvert.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/indices/u_primconvert.c b/src/gallium/auxiliary/indices/u_primconvert.c
index f2a77ce..abcf0d7 100644
--- a/src/gallium/auxiliary/indices/u_primconvert.c
+++ b/src/gallium/auxiliary/indices/u_primconvert.c
@@ -121,6 +121,8 @@ util_primconvert_draw_vbo(struct primconvert_context *pc,
    memset(&new_ib, 0, sizeof(new_ib));
    util_draw_init_info(&new_info);
    new_info.indexed = true;
+   new_info.min_index = info->min_index;
+   new_info.max_index = info->max_index;
 
    if (info->indexed) {
       u_index_translator(pc->primtypes_mask,
@@ -152,13 +154,9 @@ util_primconvert_draw_vbo(struct primconvert_context *pc,
                       &dst_transfer);
 
    if (info->indexed) {
-      new_info.min_index = 0;
-      new_info.max_index = ~0;
       trans_func(src, info->start, new_info.count, dst);
    }
    else {
-      new_info.min_index = info->start;
-      new_info.max_index = info->start + new_info.count;
       gen_func(info->start, new_info.count, dst);
    }
 
-- 
2.0.1



More information about the mesa-dev mailing list