#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"
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;
};
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;
&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);
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);