summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-08-29 18:03:36 -0700
committerEric Anholt <[email protected]>2014-09-02 13:55:15 -0700
commit2da91188527d0878460eca5110867c6c1e665b64 (patch)
treeceebda4dce4194324bb9dd1313ac414ce08c8f99 /src/gallium
parent6720d1573a71684b7a032fe6f371056b0818f3a6 (diff)
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 <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/indices/u_primconvert.c20
1 files 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);