From 2da91188527d0878460eca5110867c6c1e665b64 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 29 Aug 2014 18:03:36 -0700 Subject: [PATCH] u_primconvert: Use u_upload_mgr for our little IB allocations. tex-miplevel-selection was hammering my memory manager with primconverts on individual quads. This gets all those converted IBs packed into larger IBs. Reviewed-by: Rob Clark --- src/gallium/auxiliary/indices/u_primconvert.c | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/gallium/auxiliary/indices/u_primconvert.c b/src/gallium/auxiliary/indices/u_primconvert.c index c8d1d66a858..0b029c97f2c 100644 --- a/src/gallium/auxiliary/indices/u_primconvert.c +++ b/src/gallium/auxiliary/indices/u_primconvert.c @@ -45,6 +45,7 @@ #include "util/u_draw.h" #include "util/u_inlines.h" #include "util/u_memory.h" +#include "util/u_upload_mgr.h" #include "indices/u_indices.h" #include "indices/u_primconvert.h" @@ -55,7 +56,7 @@ struct primconvert_context struct pipe_index_buffer saved_ib; uint32_t primtypes_mask; unsigned api_pv; - // TODO we could cache/recycle the indexbuf created to translate prims.. + struct u_upload_mgr *upload; }; @@ -112,7 +113,7 @@ util_primconvert_draw_vbo(struct primconvert_context *pc, struct pipe_index_buffer *ib = &pc->saved_ib; struct pipe_index_buffer new_ib; struct pipe_draw_info new_info; - struct pipe_transfer *src_transfer = NULL, *dst_transfer = NULL; + struct pipe_transfer *src_transfer = NULL; u_translate_func trans_func; u_generate_func gen_func; const void *src = NULL; @@ -144,14 +145,12 @@ util_primconvert_draw_vbo(struct primconvert_context *pc, &gen_func); } + if (!pc->upload) { + pc->upload = u_upload_create(pc->pipe, 4096, 4, PIPE_BIND_INDEX_BUFFER); + } - new_ib.buffer = pipe_buffer_create(pc->pipe->screen, - PIPE_BIND_INDEX_BUFFER, - PIPE_USAGE_IMMUTABLE, - new_ib.index_size * new_info.count); - dst = - pipe_buffer_map(pc->pipe, new_ib.buffer, PIPE_TRANSFER_WRITE, - &dst_transfer); + u_upload_alloc(pc->upload, 0, new_ib.index_size * new_info.count, + &new_ib.offset, &new_ib.buffer, &dst); if (info->indexed) { trans_func(src, info->start, new_info.count, dst); @@ -163,8 +162,7 @@ util_primconvert_draw_vbo(struct primconvert_context *pc, if (src_transfer) pipe_buffer_unmap(pc->pipe, src_transfer); - if (dst_transfer) - pipe_buffer_unmap(pc->pipe, dst_transfer); + u_upload_unmap(pc->upload); /* bind new index buffer: */ pc->pipe->set_index_buffer(pc->pipe, &new_ib); -- 2.30.2