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 <robclark@freedesktop.org>
This commit is contained in:
parent
6720d1573a
commit
2da9118852
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue