diff options
author | Marek Olšák <[email protected]> | 2012-05-11 16:38:13 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-05-11 16:38:13 +0200 |
commit | bb4c5d72d7c7cb1d9e7016e2c07c36875f30011a (patch) | |
tree | 153444ff535900f82ae63b5af8ccd09fb2f063af /src/gallium/drivers/nv30 | |
parent | 96956dc5076fc03b9290368ca90e3f3b870ee613 (diff) | |
parent | 8dd3e341b337ca2d22bcc0e7548a78a6c36ca77d (diff) |
Merge branch 'gallium-userbuf'
Conflicts:
src/gallium/docs/source/screen.rst
src/gallium/drivers/nv50/nv50_state.c
src/gallium/include/pipe/p_defines.h
src/mesa/state_tracker/st_draw.c
Diffstat (limited to 'src/gallium/drivers/nv30')
-rw-r--r-- | src/gallium/drivers/nv30/nv30_draw.c | 15 | ||||
-rw-r--r-- | src/gallium/drivers/nv30/nv30_screen.c | 7 | ||||
-rw-r--r-- | src/gallium/drivers/nv30/nv30_state.c | 15 |
3 files changed, 28 insertions, 9 deletions
diff --git a/src/gallium/drivers/nv30/nv30_draw.c b/src/gallium/drivers/nv30/nv30_draw.c index 61e324606f2..29e63953838 100644 --- a/src/gallium/drivers/nv30/nv30_draw.c +++ b/src/gallium/drivers/nv30/nv30_draw.c @@ -366,7 +366,7 @@ nv30_render_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) { struct nv30_context *nv30 = nv30_context(pipe); struct draw_context *draw = nv30->draw; - struct pipe_transfer *transfer[PIPE_MAX_ATTRIBS]; + struct pipe_transfer *transfer[PIPE_MAX_ATTRIBS] = {NULL}; struct pipe_transfer *transferi = NULL; int i; @@ -403,14 +403,18 @@ nv30_render_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) } for (i = 0; i < nv30->num_vtxbufs; i++) { - void *map = pipe_buffer_map(pipe, nv30->vtxbuf[i].buffer, + const void *map = nv30->vtxbuf[i].user_buffer; + if (!map) + map = pipe_buffer_map(pipe, nv30->vtxbuf[i].buffer, PIPE_TRANSFER_UNSYNCHRONIZED | PIPE_TRANSFER_READ, &transfer[i]); draw_set_mapped_vertex_buffer(draw, i, map); } if (info->indexed) { - void *map = pipe_buffer_map(pipe, nv30->idxbuf.buffer, + const void *map = nv30->idxbuf.user_buffer; + if (!map) + pipe_buffer_map(pipe, nv30->idxbuf.buffer, PIPE_TRANSFER_UNSYNCHRONIZED | PIPE_TRANSFER_READ, &transferi); draw_set_index_buffer(draw, &nv30->idxbuf); @@ -422,10 +426,11 @@ nv30_render_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) draw_vbo(draw, info); draw_flush(draw); - if (info->indexed) + if (info->indexed && transferi) pipe_buffer_unmap(pipe, transferi); for (i = 0; i < nv30->num_vtxbufs; i++) - pipe_buffer_unmap(pipe, transfer[i]); + if (transfer[i]) + pipe_buffer_unmap(pipe, transfer[i]); nv30->draw_dirty = 0; nv30_state_release(nv30); diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index d355f749a09..c3e50a58316 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -78,8 +78,13 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: - case PIPE_CAP_USER_VERTEX_BUFFERS: + case PIPE_CAP_USER_CONSTANT_BUFFERS: return 1; + case PIPE_CAP_USER_INDEX_BUFFERS: + case PIPE_CAP_USER_VERTEX_BUFFERS: + return 0; + case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: + return 16; /* nv4x capabilities */ case PIPE_CAP_BLEND_EQUATION_SEPARATE: case PIPE_CAP_NPOT_TEXTURES: diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c index 64a8f33d466..f65c8b71fdd 100644 --- a/src/gallium/drivers/nv30/nv30_state.c +++ b/src/gallium/drivers/nv30/nv30_state.c @@ -317,11 +317,18 @@ nv30_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask) static void nv30_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, - struct pipe_resource *buf) + struct pipe_constant_buffer *cb) { struct nv30_context *nv30 = nv30_context(pipe); + struct pipe_resource *buf = cb ? cb->buffer : NULL; unsigned size; + if (cb && cb->user_buffer) { + buf = nouveau_user_buffer_create(pipe->screen, cb->user_buffer, + cb->buffer_size, + PIPE_BIND_CONSTANT_BUFFER); + } + size = 0; if (buf) size = buf->width0 / (4 * sizeof(float)); @@ -336,6 +343,10 @@ nv30_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, nv30->fragprog.constbuf_nr = size; nv30->dirty |= NV30_NEW_FRAGCONST; } + + if (cb && cb->user_buffer) { + pipe_resource_reference(&buf, NULL); + } } static void @@ -442,6 +453,4 @@ nv30_state_init(struct pipe_context *pipe) pipe->set_vertex_buffers = nv30_set_vertex_buffers; pipe->set_index_buffer = nv30_set_index_buffer; - - pipe->redefine_user_buffer = u_default_redefine_user_buffer; } |