diff options
author | Marek Olšák <[email protected]> | 2017-04-02 16:24:39 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-05-10 19:00:16 +0200 |
commit | 330d0607ed60fd3edca192e54b4246310f06652f (patch) | |
tree | 56bceba5b291ffcf42209ef1ab7ec515a8f5b666 /src/gallium/drivers/etnaviv | |
parent | 22f6624ed318e8131681ec1f2e7b3a59449df412 (diff) |
gallium: remove pipe_index_buffer and set_index_buffer
pipe_draw_info::indexed is replaced with index_size. index_size == 0 means
non-indexed.
Instead of pipe_index_buffer::offset, pipe_draw_info::start is used.
For indexed indirect draws, pipe_draw_info::start is added to the indirect
start. This is the only case when "start" affects indirect draws.
pipe_draw_info::index is a union. Use either index::resource or
index::user depending on the value of pipe_draw_info::has_user_indices.
v2: fixes for nine, svga
Diffstat (limited to 'src/gallium/drivers/etnaviv')
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_context.c | 29 | ||||
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_context.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_emit.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_state.c | 29 |
4 files changed, 19 insertions, 43 deletions
diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index 2e5e7f6446a..306cb6fc498 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -92,7 +92,7 @@ etna_update_state_for_draw(struct etna_context *ctx, const struct pipe_draw_info * buffer state as dirty */ - if (info->indexed) { + if (info->index_size) { uint32_t new_control = ctx->index_buffer.FE_INDEX_STREAM_CONTROL; if (info->primitive_restart) @@ -159,7 +159,6 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) if (!(ctx->prim_hwsupport & (1 << info->mode))) { struct primconvert_context *primconvert = ctx->primconvert; - util_primconvert_save_index_buffer(primconvert, &ctx->index_buffer.ib); util_primconvert_save_rasterizer_state(primconvert, ctx->rasterizer); util_primconvert_draw_vbo(primconvert, info); return; @@ -178,15 +177,23 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) } /* Upload a user index buffer. */ - struct pipe_index_buffer ibuffer_saved = {}; - if (info->indexed && ctx->index_buffer.ib.user_buffer && - !util_save_and_upload_index_buffer(pctx, info, &ctx->index_buffer.ib, - &ibuffer_saved)) { + unsigned index_offset = 0; + struct pipe_resource *indexbuf = info->has_user_indices ? NULL : info->index.resource; + if (info->index_size && info->has_user_indices && + !util_upload_index_buffer(pctx, info, &indexbuf, &index_offset)) { BUG("Index buffer upload failed."); return; } - if (info->indexed && !ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo) { + if (info->index_size && indexbuf) { + ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo = etna_resource(indexbuf)->bo; + ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.offset = index_offset; + ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.flags = ETNA_RELOC_READ; + ctx->index_buffer.FE_INDEX_STREAM_CONTROL = translate_index_size(info->index_size); + ctx->dirty |= ETNA_DIRTY_INDEX_BUFFER; + } + + if (info->index_size && !ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo) { BUG("Unsupported or no index buffer"); return; } @@ -239,7 +246,7 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) } /* Mark index buffer as being read */ - resource_read(ctx, ctx->index_buffer.ib.buffer); + resource_read(ctx, indexbuf); /* Mark textures as being read */ for (i = 0; i < PIPE_MAX_SAMPLERS; i++) @@ -255,7 +262,7 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) /* First, sync state, then emit DRAW_PRIMITIVES or DRAW_INDEXED_PRIMITIVES */ etna_emit_state(ctx); - if (info->indexed) + if (info->index_size) etna_draw_indexed_primitives(ctx->stream, draw_mode, info->start, prims, info->index_bias); else etna_draw_primitives(ctx->stream, draw_mode, info->start, prims); @@ -274,8 +281,8 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) etna_resource(ctx->framebuffer.cbuf->texture)->seqno++; if (ctx->framebuffer.zsbuf) etna_resource(ctx->framebuffer.zsbuf->texture)->seqno++; - if (info->indexed && ibuffer_saved.user_buffer) - pctx->set_index_buffer(pctx, &ibuffer_saved); + if (info->index_size && indexbuf != info->index.resource) + pipe_resource_reference(&indexbuf, NULL); } static void diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.h b/src/gallium/drivers/etnaviv/etnaviv_context.h index 56b57b55a81..2bb8cf51af2 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.h +++ b/src/gallium/drivers/etnaviv/etnaviv_context.h @@ -44,7 +44,6 @@ struct pipe_screen; struct etna_shader_variant; struct etna_index_buffer { - struct pipe_index_buffer ib; struct etna_reloc FE_INDEX_STREAM_BASE_ADDR; uint32_t FE_INDEX_STREAM_CONTROL; uint32_t FE_PRIMITIVE_RESTART_INDEX; diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.c b/src/gallium/drivers/etnaviv/etnaviv_emit.c index 7ced5fcd11c..81aaca96deb 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_emit.c +++ b/src/gallium/drivers/etnaviv/etnaviv_emit.c @@ -369,8 +369,7 @@ etna_emit_state(struct etna_context *ctx) /*03818*/ EMIT_STATE(GL_MULTI_SAMPLE_CONFIG, val); } - if (likely(dirty & (ETNA_DIRTY_INDEX_BUFFER)) && - ctx->index_buffer.ib.buffer) { + if (likely(dirty & (ETNA_DIRTY_INDEX_BUFFER))) { /*00644*/ EMIT_STATE_RELOC(FE_INDEX_STREAM_BASE_ADDR, &ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR); /*00648*/ EMIT_STATE(FE_INDEX_STREAM_CONTROL, ctx->index_buffer.FE_INDEX_STREAM_CONTROL); } diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c b/src/gallium/drivers/etnaviv/etnaviv_state.c index dcc587daccb..cd9f974112d 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_state.c +++ b/src/gallium/drivers/etnaviv/etnaviv_state.c @@ -447,34 +447,6 @@ etna_set_vertex_buffers(struct pipe_context *pctx, unsigned start_slot, } static void -etna_set_index_buffer(struct pipe_context *pctx, const struct pipe_index_buffer *ib) -{ - struct etna_context *ctx = etna_context(pctx); - uint32_t ctrl; - - if (ib) { - pipe_resource_reference(&ctx->index_buffer.ib.buffer, ib->buffer); - memcpy(&ctx->index_buffer.ib, ib, sizeof(ctx->index_buffer.ib)); - ctrl = translate_index_size(ctx->index_buffer.ib.index_size); - } else { - pipe_resource_reference(&ctx->index_buffer.ib.buffer, NULL); - ctrl = 0; - } - - if (ctx->index_buffer.ib.buffer && ctrl != ETNA_NO_MATCH) { - ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo = etna_resource(ctx->index_buffer.ib.buffer)->bo; - ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.offset = ctx->index_buffer.ib.offset; - ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.flags = ETNA_RELOC_READ; - ctx->index_buffer.FE_INDEX_STREAM_CONTROL = ctrl; - } else { - ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo = NULL; - ctx->index_buffer.FE_INDEX_STREAM_CONTROL = 0; - } - - ctx->dirty |= ETNA_DIRTY_INDEX_BUFFER; -} - -static void etna_blend_state_bind(struct pipe_context *pctx, void *bs) { struct etna_context *ctx = etna_context(pctx); @@ -652,7 +624,6 @@ etna_state_init(struct pipe_context *pctx) pctx->set_viewport_states = etna_set_viewport_states; pctx->set_vertex_buffers = etna_set_vertex_buffers; - pctx->set_index_buffer = etna_set_index_buffer; pctx->bind_blend_state = etna_blend_state_bind; pctx->delete_blend_state = etna_blend_state_delete; |