diff options
author | Christoph Bumiller <[email protected]> | 2012-05-22 15:33:12 +0200 |
---|---|---|
committer | Christoph Bumiller <[email protected]> | 2012-05-25 22:42:54 +0200 |
commit | 384ef28cb376eb53c43167f0e8f0f7c3fec7d288 (patch) | |
tree | 2ae55147544d0333165e06ec92019a6fc0c1e4b4 | |
parent | 704eac09166aa6dc4c1aa82f8d0938c4060e51f4 (diff) |
nv30: handle user index buffers
-rw-r--r-- | src/gallium/drivers/nv30/nv30_push.c | 11 | ||||
-rw-r--r-- | src/gallium/drivers/nv30/nv30_screen.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/nv30/nv30_state.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/nv30/nv30_vbo.c | 26 |
4 files changed, 27 insertions, 17 deletions
diff --git a/src/gallium/drivers/nv30/nv30_push.c b/src/gallium/drivers/nv30/nv30_push.c index 16575ee2686..c5867bfa11a 100644 --- a/src/gallium/drivers/nv30/nv30_push.c +++ b/src/gallium/drivers/nv30/nv30_push.c @@ -37,7 +37,7 @@ struct push_context { struct nouveau_pushbuf *push; - void *idxbuf; + const void *idxbuf; float edgeflag; int edgeflag_attr; @@ -221,9 +221,12 @@ nv30_push_vbo(struct nv30_context *nv30, const struct pipe_draw_info *info) } if (info->indexed) { - ctx.idxbuf = nouveau_resource_map_offset(&nv30->base, - nv04_resource(nv30->idxbuf.buffer), - nv30->idxbuf.offset, NOUVEAU_BO_RD); + if (nv30->idxbuf.buffer) + ctx.idxbuf = nouveau_resource_map_offset(&nv30->base, + nv04_resource(nv30->idxbuf.buffer), nv30->idxbuf.offset, + NOUVEAU_BO_RD); + else + ctx.idxbuf = nv30->idxbuf.user_buffer; if (!ctx.idxbuf) { nv30_state_release(nv30); return; diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index 67de8c03f45..f9e647dbd13 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -79,8 +79,8 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: case PIPE_CAP_USER_CONSTANT_BUFFERS: - return 1; case PIPE_CAP_USER_INDEX_BUFFERS: + return 1; case PIPE_CAP_USER_VERTEX_BUFFERS: return 0; case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c index f65c8b71fdd..25755ba471d 100644 --- a/src/gallium/drivers/nv30/nv30_state.c +++ b/src/gallium/drivers/nv30/nv30_state.c @@ -420,9 +420,12 @@ nv30_set_index_buffer(struct pipe_context *pipe, if (ib) { pipe_resource_reference(&nv30->idxbuf.buffer, ib->buffer); - memcpy(&nv30->idxbuf, ib, sizeof(nv30->idxbuf)); + nv30->idxbuf.index_size = ib->index_size; + nv30->idxbuf.offset = ib->offset; + nv30->idxbuf.user_buffer = ib->user_buffer; } else { pipe_resource_reference(&nv30->idxbuf.buffer, NULL); + nv30->idxbuf.user_buffer = NULL; } } diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c index 78d106880d0..128457f7aa9 100644 --- a/src/gallium/drivers/nv30/nv30_vbo.c +++ b/src/gallium/drivers/nv30/nv30_vbo.c @@ -358,7 +358,7 @@ nv30_draw_arrays(struct nv30_context *nv30, } static void -nv30_draw_elements_inline_u08(struct nouveau_pushbuf *push, uint8_t *map, +nv30_draw_elements_inline_u08(struct nouveau_pushbuf *push, const uint8_t *map, unsigned start, unsigned count) { map += start; @@ -383,7 +383,7 @@ nv30_draw_elements_inline_u08(struct nouveau_pushbuf *push, uint8_t *map, } static void -nv30_draw_elements_inline_u16(struct nouveau_pushbuf *push, uint16_t *map, +nv30_draw_elements_inline_u16(struct nouveau_pushbuf *push, const uint16_t *map, unsigned start, unsigned count) { map += start; @@ -407,7 +407,7 @@ nv30_draw_elements_inline_u16(struct nouveau_pushbuf *push, uint16_t *map, } static void -nv30_draw_elements_inline_u32(struct nouveau_pushbuf *push, uint32_t *map, +nv30_draw_elements_inline_u32(struct nouveau_pushbuf *push, const uint32_t *map, unsigned start, unsigned count) { map += start; @@ -424,7 +424,8 @@ nv30_draw_elements_inline_u32(struct nouveau_pushbuf *push, uint32_t *map, } static void -nv30_draw_elements_inline_u32_short(struct nouveau_pushbuf *push, uint32_t *map, +nv30_draw_elements_inline_u32_short(struct nouveau_pushbuf *push, + const uint32_t *map, unsigned start, unsigned count) { map += start; @@ -456,7 +457,6 @@ nv30_draw_elements(struct nv30_context *nv30, boolean shorten, struct nouveau_pushbuf *push = nv30->base.pushbuf; struct nouveau_object *eng3d = nv30->screen->eng3d; unsigned prim = nv30_prim_gl(mode); - void *data; #if 0 /*XXX*/ if (index_bias != nv30->state.index_bias) { @@ -467,10 +467,12 @@ nv30_draw_elements(struct nv30_context *nv30, boolean shorten, #endif if (eng3d->oclass == NV40_3D_CLASS && index_size > 1 && - nouveau_resource_mapped_by_gpu(nv30->idxbuf.buffer)) { + nv30->idxbuf.buffer) { struct nv04_resource *res = nv04_resource(nv30->idxbuf.buffer); unsigned offset = nv30->idxbuf.offset; + assert(nouveau_resource_mapped_by_gpu(&res->base)); + BEGIN_NV04(push, NV30_3D(IDXBUF_OFFSET), 2); PUSH_RESRC(push, NV30_3D(IDXBUF_OFFSET), BUFCTX_IDXBUF, res, offset, NOUVEAU_BO_LOW | NOUVEAU_BO_RD, 0, 0); @@ -501,9 +503,13 @@ nv30_draw_elements(struct nv30_context *nv30, boolean shorten, PUSH_DATA (push, NV30_3D_VERTEX_BEGIN_END_STOP); PUSH_RESET(push, BUFCTX_IDXBUF); } else { - data = nouveau_resource_map_offset(&nv30->base, - nv04_resource(nv30->idxbuf.buffer), - nv30->idxbuf.offset, NOUVEAU_BO_RD); + const void *data; + if (nv30->idxbuf.buffer) + data = nouveau_resource_map_offset(&nv30->base, + nv04_resource(nv30->idxbuf.buffer), + nv30->idxbuf.offset, NOUVEAU_BO_RD); + else + data = nv30->idxbuf.user_buffer; if (!data) return; @@ -577,8 +583,6 @@ nv30_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) } else { boolean shorten = info->max_index <= 65535; - assert(nv30->idxbuf.buffer); - if (info->primitive_restart != nv30->state.prim_restart) { if (info->primitive_restart) { BEGIN_NV04(push, NV40_3D(PRIM_RESTART_ENABLE), 2); |