r300: make sure indexed rendering doesn't try to use more than the num of vertices
authorJerome Glisse <jglisse@redhat.com>
Wed, 10 Jun 2009 12:59:33 +0000 (14:59 +0200)
committerJerome Glisse <jglisse@redhat.com>
Wed, 10 Jun 2009 12:59:33 +0000 (14:59 +0200)
When with memory manager we need to make sure the GPU won't try to access
beyond vertex buffer size, do so by enforcing that the maximun index is the
last vertex of the buffer.

src/mesa/drivers/dri/r300/r300_render.c

index dfbd79a..c2c532a 100644 (file)
@@ -351,6 +351,7 @@ static void r300FireAOS(r300ContextPtr rmesa, int vertex_count, int type)
 void r300RunRenderPrimitive(GLcontext * ctx, int start, int end, int prim)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&rmesa->radeon);
        int type, num_verts;
 
        type = r300PrimitiveType(rmesa, prim);
@@ -384,6 +385,12 @@ void r300RunRenderPrimitive(GLcontext * ctx, int start, int end, int prim)
                 */
                r300EmitElts(ctx, num_verts);
                r300EmitAOS(rmesa, rmesa->radeon.tcl.aos_count, start);
+               if (rmesa->radeon.radeonScreen->kernel_mm) {
+                       BEGIN_BATCH_NO_AUTOSTATE(2);
+                       OUT_BATCH_REGSEQ(R300_VAP_VF_MAX_VTX_INDX, 1);
+                       OUT_BATCH(num_verts);
+                       END_BATCH();
+               }
                r300FireEB(rmesa, num_verts, type);
        } else {
                r300EmitAOS(rmesa, rmesa->radeon.tcl.aos_count, start);