[Mesa-dev] [PATCH 07/10] gallium/vbuf: use the common uploader
Marek Olšák
maraeo at gmail.com
Fri Jan 27 11:02:10 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/auxiliary/util/u_vbuf.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
index 532e7c0..c26a923 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -139,21 +139,20 @@ enum {
VB_CONST = 2,
VB_NUM = 3
};
struct u_vbuf {
struct u_vbuf_caps caps;
struct pipe_context *pipe;
struct translate_cache *translate_cache;
struct cso_cache *cso_cache;
- struct u_upload_mgr *uploader;
/* This is what was set in set_vertex_buffers.
* May contain user buffers. */
struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
uint32_t enabled_vb_mask;
/* Saved vertex buffer. */
unsigned aux_vertex_buffer_slot;
struct pipe_vertex_buffer aux_vertex_buffer_saved;
@@ -307,24 +306,20 @@ u_vbuf_create(struct pipe_context *pipe,
{
struct u_vbuf *mgr = CALLOC_STRUCT(u_vbuf);
mgr->caps = *caps;
mgr->aux_vertex_buffer_slot = aux_vertex_buffer_index;
mgr->pipe = pipe;
mgr->cso_cache = cso_cache_create();
mgr->translate_cache = translate_cache_create();
memset(mgr->fallback_vbs, ~0, sizeof(mgr->fallback_vbs));
- mgr->uploader = u_upload_create(pipe, 1024 * 1024,
- PIPE_BIND_VERTEX_BUFFER,
- PIPE_USAGE_STREAM);
-
return mgr;
}
/* u_vbuf uses its own caching for vertex elements, because it needs to keep
* its own preprocessed state per vertex element CSO. */
static struct u_vbuf_elements *
u_vbuf_set_vertex_elements_internal(struct u_vbuf *mgr, unsigned count,
const struct pipe_vertex_element *states)
{
struct pipe_context *pipe = mgr->pipe;
@@ -383,21 +378,20 @@ void u_vbuf_destroy(struct u_vbuf *mgr)
for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
pipe_resource_reference(&mgr->vertex_buffer[i].buffer, NULL);
}
for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, NULL);
}
pipe_resource_reference(&mgr->aux_vertex_buffer_saved.buffer, NULL);
translate_cache_destroy(mgr->translate_cache);
- u_upload_destroy(mgr->uploader);
cso_cache_delete(mgr->cso_cache);
FREE(mgr);
}
static enum pipe_error
u_vbuf_translate_buffers(struct u_vbuf *mgr, struct translate_key *key,
unsigned vb_mask, unsigned out_vb,
int start_vertex, unsigned num_vertices,
int start_index, unsigned num_indices, int min_index,
boolean unroll_indices)
@@ -447,21 +441,21 @@ u_vbuf_translate_buffers(struct u_vbuf *mgr, struct translate_key *key,
/* Translate. */
if (unroll_indices) {
struct pipe_index_buffer *ib = &mgr->index_buffer;
struct pipe_transfer *transfer = NULL;
unsigned offset = ib->offset + start_index * ib->index_size;
uint8_t *map;
assert((ib->buffer || ib->user_buffer) && ib->index_size);
/* Create and map the output buffer. */
- u_upload_alloc(mgr->uploader, 0,
+ u_upload_alloc(mgr->pipe->stream_uploader, 0,
key->output_stride * num_indices, 4,
&out_offset, &out_buffer,
(void**)&out_map);
if (!out_buffer)
return PIPE_ERROR_OUT_OF_MEMORY;
if (ib->user_buffer) {
map = (uint8_t*)ib->user_buffer + offset;
} else {
map = pipe_buffer_map_range(mgr->pipe, ib->buffer, offset,
@@ -479,21 +473,21 @@ u_vbuf_translate_buffers(struct u_vbuf *mgr, struct translate_key *key,
case 1:
tr->run_elts8(tr, map, num_indices, 0, 0, out_map);
break;
}
if (transfer) {
pipe_buffer_unmap(mgr->pipe, transfer);
}
} else {
/* Create and map the output buffer. */
- u_upload_alloc(mgr->uploader,
+ u_upload_alloc(mgr->pipe->stream_uploader,
key->output_stride * start_vertex,
key->output_stride * num_vertices, 4,
&out_offset, &out_buffer,
(void**)&out_map);
if (!out_buffer)
return PIPE_ERROR_OUT_OF_MEMORY;
out_offset -= key->output_stride * start_vertex;
tr->run(tr, 0, num_vertices, 0, 0, out_map);
@@ -983,21 +977,21 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr,
i = u_bit_scan(&buffer_mask);
start = start_offset[i];
end = end_offset[i];
assert(start < end);
real_vb = &mgr->real_vertex_buffer[i];
ptr = mgr->vertex_buffer[i].user_buffer;
- u_upload_data(mgr->uploader, start, end - start, 4, ptr + start,
+ u_upload_data(mgr->pipe->stream_uploader, start, end - start, 4, ptr + start,
&real_vb->buffer_offset, &real_vb->buffer);
if (!real_vb->buffer)
return PIPE_ERROR_OUT_OF_MEMORY;
real_vb->buffer_offset -= start;
}
return PIPE_OK;
}
@@ -1288,21 +1282,21 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info)
util_dump_vertex_buffer(stdout, mgr->vertex_buffer+i);
printf("\n");
}
for (i = 0; i < mgr->nr_real_vertex_buffers; i++) {
printf("real %i: ", i);
util_dump_vertex_buffer(stdout, mgr->real_vertex_buffer+i);
printf("\n");
}
*/
- u_upload_unmap(mgr->uploader);
+ u_upload_unmap(pipe->stream_uploader);
u_vbuf_set_driver_vertex_buffers(mgr);
pipe->draw_vbo(pipe, &new_info);
if (mgr->using_translate) {
u_vbuf_translate_end(mgr);
}
}
void u_vbuf_save_vertex_elements(struct u_vbuf *mgr)
--
2.7.4
More information about the mesa-dev
mailing list