dri/nouveau: Try to keep client buffers smaller than the scratch VBO length.
authorFrancisco Jerez <currojerez@riseup.net>
Thu, 4 Mar 2010 20:32:07 +0000 (21:32 +0100)
committerFrancisco Jerez <currojerez@riseup.net>
Thu, 4 Mar 2010 22:07:11 +0000 (23:07 +0100)
src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c

index 8a2caff63e3e5777cceb8b5404268a3d2dc96b47..69a9b96f0ca360c7e7e2844c6cc1e3d4a3a0dad1 100644 (file)
@@ -243,6 +243,23 @@ vbo_choose_attrs(GLcontext *ctx, const struct gl_client_array **arrays)
        vbo_emit_attr(ctx, arrays, VERT_ATTRIB_POS);
 }
 
+static unsigned
+get_max_client_stride(GLcontext *ctx)
+{
+       struct nouveau_render_state *render = to_render_state(ctx);
+       int i, s = 0;
+
+       for (i = 0; i < render->attr_count; i++) {
+               int attr = render->map[i];
+               struct nouveau_array_state *a = &render->attrs[attr];
+
+               if (attr >= 0 && !a->bo)
+                       s = MAX2(a->stride, s);
+       }
+
+       return s;
+}
+
 static void
 TAG(vbo_render_prims)(GLcontext *ctx, const struct gl_client_array **arrays,
                      const struct _mesa_prim *prims, GLuint nr_prims,
@@ -257,9 +274,18 @@ vbo_maybe_split(GLcontext *ctx, const struct gl_client_array **arrays,
            GLuint min_index, GLuint max_index)
 {
        struct nouveau_context *nctx = to_nouveau_context(ctx);
+       struct nouveau_render_state *render = to_render_state(ctx);
        unsigned pushbuf_avail = PUSHBUF_DWORDS - 2 * nctx->bo.count,
                vert_avail = get_max_vertices(ctx, NULL, pushbuf_avail),
                idx_avail = get_max_vertices(ctx, ib, pushbuf_avail);
+       int stride;
+
+       /* Try to keep client buffers smaller than the scratch BOs. */
+       if (!ib && render->mode == VBO &&
+           (stride = get_max_client_stride(ctx)))
+                   vert_avail = MIN2(vert_avail,
+                                     RENDER_SCRATCH_SIZE / stride);
+
 
        if ((ib && ib->count > idx_avail) ||
            (!ib && max_index - min_index > vert_avail)) {