diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/r300/r300_context.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_render.c | 39 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_screen_buffer.c | 18 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state.c | 4 |
4 files changed, 23 insertions, 43 deletions
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index b58f514c358..6a064420603 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -389,8 +389,9 @@ struct r300_resource struct radeon_winsys_cs_handle *cs_buf; enum radeon_bo_domain domain; - /* Constant buffers are in user memory. */ - uint8_t *constant_buffer; + /* Constant buffers and SWTCL vertex and index buffers are in user + * memory. */ + uint8_t *malloced_buffer; /* Texture description (addressing, layout, special features). */ struct r300_texture_desc tex; diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 56f480d3358..d98b28896be 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -855,10 +855,7 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe, const struct pipe_draw_info *info) { struct r300_context* r300 = r300_context(pipe); - struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS]; - struct pipe_transfer *ib_transfer = NULL; int i; - const void *indices = NULL; boolean indexed = info->indexed; if (r300->skip_rendering) { @@ -877,46 +874,26 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe, draw_set_mapped_vertex_buffer(r300->draw, i, r300->vertex_buffer[i].user_buffer); } else if (r300->vertex_buffer[i].buffer) { - void *buf = pipe_buffer_map(pipe, - r300->vertex_buffer[i].buffer, - PIPE_TRANSFER_READ | - PIPE_TRANSFER_UNSYNCHRONIZED, - &vb_transfer[i]); - draw_set_mapped_vertex_buffer(r300->draw, i, buf); + draw_set_mapped_vertex_buffer(r300->draw, i, + r300_resource(r300->vertex_buffer[i].buffer)->malloced_buffer); } } if (indexed) { if (r300->index_buffer.user_buffer) { - indices = r300->index_buffer.user_buffer; - } else { - indices = pipe_buffer_map(pipe, r300->index_buffer.buffer, - PIPE_TRANSFER_READ | - PIPE_TRANSFER_UNSYNCHRONIZED, &ib_transfer); + draw_set_mapped_index_buffer(r300->draw, + r300->index_buffer.user_buffer); + } else if (r300->index_buffer.buffer) { + draw_set_mapped_index_buffer(r300->draw, + r300_resource(r300->index_buffer.buffer)->malloced_buffer); } } - draw_set_mapped_index_buffer(r300->draw, indices); - r300->draw_vbo_locked = TRUE; r300->draw_first_emitted = FALSE; draw_vbo(r300->draw, info); draw_flush(r300->draw); r300->draw_vbo_locked = FALSE; - - for (i = 0; i < r300->nr_vertex_buffers; i++) { - if (r300->vertex_buffer[i].buffer) { - if (vb_transfer[i]) - pipe_buffer_unmap(pipe, vb_transfer[i]); - draw_set_mapped_vertex_buffer(r300->draw, i, NULL); - } - } - - if (indexed) { - if (ib_transfer) - pipe_buffer_unmap(pipe, ib_transfer); - draw_set_mapped_index_buffer(r300->draw, NULL); - } } /* Object for rendering using Draw. */ @@ -969,7 +946,7 @@ static boolean r300_render_allocate_vertices(struct vbuf_render* render, { pipe_resource_reference(&r300->vbo, NULL); r300->vbo = pipe_buffer_create(screen, - PIPE_BIND_VERTEX_BUFFER, + PIPE_BIND_CUSTOM, PIPE_USAGE_STREAM, R300_MAX_DRAW_VBO_SIZE); r300->draw_vbo_offset = 0; diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c index 9ab2acd671f..7cb8cd60d3e 100644 --- a/src/gallium/drivers/r300/r300_screen_buffer.c +++ b/src/gallium/drivers/r300/r300_screen_buffer.c @@ -55,8 +55,8 @@ static void r300_buffer_destroy(struct pipe_screen *screen, { struct r300_resource *rbuf = r300_resource(buf); - if (rbuf->constant_buffer) - FREE(rbuf->constant_buffer); + if (rbuf->malloced_buffer) + FREE(rbuf->malloced_buffer); if (rbuf->buf) pb_reference(&rbuf->buf, NULL); @@ -107,8 +107,8 @@ r300_buffer_transfer_map( struct pipe_context *pipe, uint8_t *map; enum pipe_transfer_usage usage; - if (rbuf->constant_buffer) - return (uint8_t *) rbuf->constant_buffer + transfer->box.x; + if (rbuf->malloced_buffer) + return (uint8_t *) rbuf->malloced_buffer + transfer->box.x; /* Buffers are never used for write, therefore mapping for read can be * unsynchronized. */ @@ -158,11 +158,13 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen, rbuf->b.b.screen = screen; rbuf->domain = RADEON_DOMAIN_GTT; rbuf->buf = NULL; - rbuf->constant_buffer = NULL; + rbuf->malloced_buffer = NULL; - /* Alloc constant buffers in RAM. */ - if (templ->bind & PIPE_BIND_CONSTANT_BUFFER) { - rbuf->constant_buffer = MALLOC(templ->width0); + /* Alloc constant buffers and SWTCL buffers in RAM. */ + if (templ->bind & PIPE_BIND_CONSTANT_BUFFER || + (!r300screen->caps.has_tcl && + (templ->bind & (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER)))) { + rbuf->malloced_buffer = MALLOC(templ->width0); return &rbuf->b.b; } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 5b02cfd90cd..758fb40fea4 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1848,8 +1848,8 @@ static void r300_set_constant_buffer(struct pipe_context *pipe, else { struct r300_resource *rbuf = r300_resource(cb->buffer); - if (rbuf && rbuf->constant_buffer) - mapped = (uint32_t*)rbuf->constant_buffer; + if (rbuf && rbuf->malloced_buffer) + mapped = (uint32_t*)rbuf->malloced_buffer; else return; } |