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/virgl | |
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/virgl')
-rw-r--r-- | src/gallium/drivers/virgl/virgl_context.c | 39 | ||||
-rw-r--r-- | src/gallium/drivers/virgl/virgl_context.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/virgl/virgl_encode.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/virgl/virgl_encode.h | 9 |
4 files changed, 23 insertions, 32 deletions
diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index 8d7094f4e18..232d2951c0b 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -130,12 +130,13 @@ static void virgl_attach_res_vertex_buffers(struct virgl_context *vctx) } } -static void virgl_attach_res_index_buffer(struct virgl_context *vctx) +static void virgl_attach_res_index_buffer(struct virgl_context *vctx, + struct virgl_indexbuf *ib) { struct virgl_winsys *vws = virgl_screen(vctx->base.screen)->vws; struct virgl_resource *res; - res = virgl_resource(vctx->index_buffer.buffer); + res = virgl_resource(ib->buffer); if (res) vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE); } @@ -183,7 +184,6 @@ static void virgl_reemit_res(struct virgl_context *vctx) virgl_attach_res_sampler_views(vctx, shader_type); virgl_attach_res_uniform_buffers(vctx, shader_type); } - virgl_attach_res_index_buffer(vctx); virgl_attach_res_vertex_buffers(vctx); virgl_attach_res_so_targets(vctx); } @@ -404,25 +404,12 @@ static void virgl_set_blend_color(struct pipe_context *ctx, virgl_encoder_set_blend_color(vctx, color); } -static void virgl_set_index_buffer(struct pipe_context *ctx, - const struct pipe_index_buffer *ib) -{ - struct virgl_context *vctx = virgl_context(ctx); - - if (ib) { - pipe_resource_reference(&vctx->index_buffer.buffer, ib->buffer); - memcpy(&vctx->index_buffer, ib, sizeof(*ib)); - } else { - pipe_resource_reference(&vctx->index_buffer.buffer, NULL); - } -} - static void virgl_hw_set_index_buffer(struct pipe_context *ctx, - struct pipe_index_buffer *ib) + struct virgl_indexbuf *ib) { struct virgl_context *vctx = virgl_context(ctx); virgl_encoder_set_index_buffer(vctx, ib); - virgl_attach_res_index_buffer(vctx); + virgl_attach_res_index_buffer(vctx, ib); } static void virgl_set_constant_buffer(struct pipe_context *ctx, @@ -590,7 +577,7 @@ static void virgl_draw_vbo(struct pipe_context *ctx, { struct virgl_context *vctx = virgl_context(ctx); struct virgl_screen *rs = virgl_screen(ctx->screen); - struct pipe_index_buffer ib = {}; + struct virgl_indexbuf ib = {}; struct pipe_draw_info info = *dinfo; if (!dinfo->count_from_stream_output && !dinfo->indirect && @@ -599,15 +586,14 @@ static void virgl_draw_vbo(struct pipe_context *ctx, return; if (!(rs->caps.caps.v1.prim_mask & (1 << dinfo->mode))) { - util_primconvert_save_index_buffer(vctx->primconvert, &vctx->index_buffer); util_primconvert_draw_vbo(vctx->primconvert, dinfo); return; } - if (info.indexed) { - pipe_resource_reference(&ib.buffer, vctx->index_buffer.buffer); - ib.user_buffer = vctx->index_buffer.user_buffer; - ib.index_size = vctx->index_buffer.index_size; - ib.offset = vctx->index_buffer.offset + info.start * ib.index_size; + if (info.index_size) { + pipe_resource_reference(&ib.buffer, info.has_user_indices ? NULL : info.index.resource); + ib.user_buffer = info.has_user_indices ? info.index.user : NULL; + ib.index_size = dinfo->index_size; + ib.offset = info.start * ib.index_size; if (ib.user_buffer) { u_upload_data(vctx->uploader, 0, info.count * ib.index_size, 256, @@ -620,7 +606,7 @@ static void virgl_draw_vbo(struct pipe_context *ctx, vctx->num_draws++; virgl_hw_set_vertex_buffers(ctx); - if (info.indexed) + if (info.index_size) virgl_hw_set_index_buffer(ctx, &ib); virgl_encoder_draw_vbo(vctx, &info); @@ -905,7 +891,6 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen, vctx->base.bind_vertex_elements_state = virgl_bind_vertex_elements_state; vctx->base.delete_vertex_elements_state = virgl_delete_vertex_elements_state; vctx->base.set_vertex_buffers = virgl_set_vertex_buffers; - vctx->base.set_index_buffer = virgl_set_index_buffer; vctx->base.set_constant_buffer = virgl_set_constant_buffer; vctx->base.create_vs_state = virgl_create_vs_state; diff --git a/src/gallium/drivers/virgl/virgl_context.h b/src/gallium/drivers/virgl/virgl_context.h index 597ed49e34e..d8d4ccbb392 100644 --- a/src/gallium/drivers/virgl/virgl_context.h +++ b/src/gallium/drivers/virgl/virgl_context.h @@ -58,7 +58,6 @@ struct virgl_context { struct slab_child_pool texture_transfer_pool; - struct pipe_index_buffer index_buffer; struct u_upload_mgr *uploader; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c index 8a6a5fbcd6d..3c8a0f46811 100644 --- a/src/gallium/drivers/virgl/virgl_encode.c +++ b/src/gallium/drivers/virgl/virgl_encode.c @@ -398,7 +398,7 @@ int virgl_encoder_set_vertex_buffers(struct virgl_context *ctx, } int virgl_encoder_set_index_buffer(struct virgl_context *ctx, - const struct pipe_index_buffer *ib) + const struct virgl_indexbuf *ib) { int length = VIRGL_SET_INDEX_BUFFER_SIZE(ib); struct virgl_resource *res = NULL; @@ -409,7 +409,7 @@ int virgl_encoder_set_index_buffer(struct virgl_context *ctx, virgl_encoder_write_res(ctx, res); if (ib) { virgl_encoder_write_dword(ctx->cbuf, ib->index_size); - virgl_encoder_write_dword(ctx->cbuf, ib->offset); + virgl_encoder_write_dword(ctx->cbuf, 0); } return 0; } @@ -421,7 +421,7 @@ int virgl_encoder_draw_vbo(struct virgl_context *ctx, virgl_encoder_write_dword(ctx->cbuf, info->start); virgl_encoder_write_dword(ctx->cbuf, info->count); virgl_encoder_write_dword(ctx->cbuf, info->mode); - virgl_encoder_write_dword(ctx->cbuf, info->indexed); + virgl_encoder_write_dword(ctx->cbuf, !!info->index_size); virgl_encoder_write_dword(ctx->cbuf, info->instance_count); virgl_encoder_write_dword(ctx->cbuf, info->index_bias); virgl_encoder_write_dword(ctx->cbuf, info->start_instance); diff --git a/src/gallium/drivers/virgl/virgl_encode.h b/src/gallium/drivers/virgl/virgl_encode.h index 78d4194683b..02c032d673e 100644 --- a/src/gallium/drivers/virgl/virgl_encode.h +++ b/src/gallium/drivers/virgl/virgl_encode.h @@ -39,6 +39,13 @@ struct virgl_surface { uint32_t handle; }; +struct virgl_indexbuf { + unsigned offset; + unsigned index_size; /**< size of an index, in bytes */ + struct pipe_resource *buffer; /**< the actual buffer */ + const void *user_buffer; /**< pointer to a user buffer if buffer == NULL */ +}; + static inline struct virgl_surface *virgl_surface(struct pipe_surface *surf) { return (struct virgl_surface *)surf; @@ -167,7 +174,7 @@ int virgl_encode_bind_sampler_states(struct virgl_context *ctx, uint32_t *handles); int virgl_encoder_set_index_buffer(struct virgl_context *ctx, - const struct pipe_index_buffer *ib); + const struct virgl_indexbuf *ib); uint32_t virgl_object_assign_handle(void); |