[Mesa-dev] [PATCH] st/nine: make use of common uploaders v2
Axel Davy
axel.davy at ens.fr
Mon Feb 20 19:49:35 UTC 2017
On 20/02/2017 20:22, Constantine Charlamov wrote:
> Make use of common uploaders that landed recently to Mesa
>
> v2: fixed formatting, broken due to thunderbird configuration
>
> ---
> src/gallium/state_trackers/nine/device9.c | 48 ++++------------------------
> src/gallium/state_trackers/nine/device9.h | 5 ---
> src/gallium/state_trackers/nine/nine_ff.c | 8 ++---
> src/gallium/state_trackers/nine/nine_state.c | 48 ++++++++++++++--------------
> 4 files changed, 35 insertions(+), 74 deletions(-)
>
> diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
> index b9b7a637d7..2ae8678c31 100644
> --- a/src/gallium/state_trackers/nine/device9.c
> +++ b/src/gallium/state_trackers/nine/device9.c
> @@ -477,31 +477,8 @@ NineDevice9_ctor( struct NineDevice9 *This,
> This->driver_caps.user_cbufs = GET_PCAP(USER_CONSTANT_BUFFERS);
> This->driver_caps.user_sw_vbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_VERTEX_BUFFERS);
> This->driver_caps.user_sw_cbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_CONSTANT_BUFFERS);
> -
> - /* Implicit use of context pipe for vertex and index uploaded when
> - * csmt is not active. Does not need to sync since csmt is unactive,
> - * thus no need to call NineDevice9_GetPipe at each upload. */
I'd like to have this comment kept somehow (though the use of context
pipe is not implicit anymore).
I guess it should be in NineDevice9_DrawPrimitiveUP just before if
(!This->driver_caps.user_vbufs).
It could be: csmt is unactive when user vertex or index buffers are
used, thus no need to call NineDevice8_GetPipe.
Axel
> - if (!This->driver_caps.user_vbufs)
> - This->vertex_uploader = u_upload_create(This->csmt_active ?
> - This->pipe_secondary : This->context.pipe,
> - 65536,
> - PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM);
> - This->vertex_sw_uploader = u_upload_create(This->pipe_sw, 65536,
> - PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM);
> - if (!This->driver_caps.user_ibufs)
> - This->index_uploader = u_upload_create(This->csmt_active ?
> - This->pipe_secondary : This->context.pipe,
> - 128 * 1024,
> - PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STREAM);
> - if (!This->driver_caps.user_cbufs) {
> + if (!This->driver_caps.user_cbufs)
> This->constbuf_alignment = GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT);
> - This->constbuf_uploader = u_upload_create(This->context.pipe, This->vs_const_size,
> - PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_STREAM);
> - }
> -
> - This->constbuf_sw_uploader = u_upload_create(This->pipe_sw, 128 * 1024,
> - PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_STREAM);
> -
> This->driver_caps.window_space_position_support = GET_PCAP(TGSI_VS_WINDOW_SPACE_POSITION);
> This->driver_caps.vs_integer = pScreen->get_shader_param(pScreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_INTEGERS);
> This->driver_caps.ps_integer = pScreen->get_shader_param(pScreen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_INTEGERS);
> @@ -552,17 +529,6 @@ NineDevice9_dtor( struct NineDevice9 *This )
> nine_state_clear(&This->state, TRUE);
> nine_context_clear(This);
>
> - if (This->vertex_uploader)
> - u_upload_destroy(This->vertex_uploader);
> - if (This->index_uploader)
> - u_upload_destroy(This->index_uploader);
> - if (This->constbuf_uploader)
> - u_upload_destroy(This->constbuf_uploader);
> - if (This->vertex_sw_uploader)
> - u_upload_destroy(This->vertex_sw_uploader);
> - if (This->constbuf_sw_uploader)
> - u_upload_destroy(This->constbuf_sw_uploader);
> -
> nine_bind(&This->record, NULL);
>
> pipe_sampler_view_reference(&This->dummy_sampler_view, NULL);
> @@ -2853,14 +2819,14 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This,
> vtxbuf.user_buffer = pVertexStreamZeroData;
>
> if (!This->driver_caps.user_vbufs) {
> - u_upload_data(This->vertex_uploader,
> + u_upload_data(This->context.pipe->stream_uploader,
> 0,
> (prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * VertexStreamZeroStride, /* XXX */
> 4,
> vtxbuf.user_buffer,
> &vtxbuf.buffer_offset,
> &vtxbuf.buffer);
> - u_upload_unmap(This->vertex_uploader);
> + u_upload_unmap(This->context.pipe->stream_uploader);
> vtxbuf.user_buffer = NULL;
> }
>
> @@ -2916,27 +2882,27 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
>
> if (!This->driver_caps.user_vbufs) {
> const unsigned base = MinVertexIndex * VertexStreamZeroStride;
> - u_upload_data(This->vertex_uploader,
> + u_upload_data(This->context.pipe->stream_uploader,
> base,
> NumVertices * VertexStreamZeroStride, /* XXX */
> 4,
> (const uint8_t *)vbuf.user_buffer + base,
> &vbuf.buffer_offset,
> &vbuf.buffer);
> - u_upload_unmap(This->vertex_uploader);
> + u_upload_unmap(This->context.pipe->stream_uploader);
> /* Won't be used: */
> vbuf.buffer_offset -= base;
> vbuf.user_buffer = NULL;
> }
> if (!This->driver_caps.user_ibufs) {
> - u_upload_data(This->index_uploader,
> + u_upload_data(This->context.pipe->stream_uploader,
> 0,
> (prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * ibuf.index_size,
> 4,
> ibuf.user_buffer,
> &ibuf.offset,
> &ibuf.buffer);
> - u_upload_unmap(This->index_uploader);
> + u_upload_unmap(This->context.pipe->stream_uploader);
> ibuf.user_buffer = NULL;
> }
>
> diff --git a/src/gallium/state_trackers/nine/device9.h b/src/gallium/state_trackers/nine/device9.h
> index 71b88a42b4..71ebbdc935 100644
> --- a/src/gallium/state_trackers/nine/device9.h
> +++ b/src/gallium/state_trackers/nine/device9.h
> @@ -141,11 +141,6 @@ struct NineDevice9
> boolean buggy_barycentrics;
> } driver_bugs;
>
> - struct u_upload_mgr *vertex_uploader;
> - struct u_upload_mgr *index_uploader;
> - struct u_upload_mgr *constbuf_uploader;
> - struct u_upload_mgr *vertex_sw_uploader;
> - struct u_upload_mgr *constbuf_sw_uploader;
> unsigned constbuf_alignment;
>
> struct nine_range_pool range_pool;
> diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c
> index 7cbe3f7d38..279ba37489 100644
> --- a/src/gallium/state_trackers/nine/nine_ff.c
> +++ b/src/gallium/state_trackers/nine/nine_ff.c
> @@ -2063,14 +2063,14 @@ nine_ff_update(struct NineDevice9 *device)
>
> if (!device->driver_caps.user_cbufs) {
> context->pipe_data.cb_vs_ff.buffer_size = cb.buffer_size;
> - u_upload_data(device->constbuf_uploader,
> + u_upload_data(device->context.pipe->const_uploader,
> 0,
> cb.buffer_size,
> device->constbuf_alignment,
> cb.user_buffer,
> &context->pipe_data.cb_vs_ff.buffer_offset,
> &context->pipe_data.cb_vs_ff.buffer);
> - u_upload_unmap(device->constbuf_uploader);
> + u_upload_unmap(device->context.pipe->const_uploader);
> context->pipe_data.cb_vs_ff.user_buffer = NULL;
> } else
> context->pipe_data.cb_vs_ff = cb;
> @@ -2087,14 +2087,14 @@ nine_ff_update(struct NineDevice9 *device)
>
> if (!device->driver_caps.user_cbufs) {
> context->pipe_data.cb_ps_ff.buffer_size = cb.buffer_size;
> - u_upload_data(device->constbuf_uploader,
> + u_upload_data(device->context.pipe->const_uploader,
> 0,
> cb.buffer_size,
> device->constbuf_alignment,
> cb.user_buffer,
> &context->pipe_data.cb_ps_ff.buffer_offset,
> &context->pipe_data.cb_ps_ff.buffer);
> - u_upload_unmap(device->constbuf_uploader);
> + u_upload_unmap(device->context.pipe->const_uploader);
> context->pipe_data.cb_ps_ff.user_buffer = NULL;
> } else
> context->pipe_data.cb_ps_ff = cb;
> diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
> index 8909692594..bdb0ba13ea 100644
> --- a/src/gallium/state_trackers/nine/nine_state.c
> +++ b/src/gallium/state_trackers/nine/nine_state.c
> @@ -424,47 +424,47 @@ prepare_vs_constants_userbuf_swvp(struct NineDevice9 *device)
>
> if (!device->driver_caps.user_cbufs) {
> struct pipe_constant_buffer *cb = &(context->pipe_data.cb0_swvp);
> - u_upload_data(device->constbuf_uploader,
> + u_upload_data(device->context.pipe->const_uploader,
> 0,
> cb->buffer_size,
> device->constbuf_alignment,
> cb->user_buffer,
> &(cb->buffer_offset),
> &(cb->buffer));
> - u_upload_unmap(device->constbuf_uploader);
> + u_upload_unmap(device->context.pipe->const_uploader);
> cb->user_buffer = NULL;
>
> cb = &(context->pipe_data.cb1_swvp);
> - u_upload_data(device->constbuf_uploader,
> + u_upload_data(device->context.pipe->const_uploader,
> 0,
> cb->buffer_size,
> device->constbuf_alignment,
> cb->user_buffer,
> &(cb->buffer_offset),
> &(cb->buffer));
> - u_upload_unmap(device->constbuf_uploader);
> + u_upload_unmap(device->context.pipe->const_uploader);
> cb->user_buffer = NULL;
>
> cb = &(context->pipe_data.cb2_swvp);
> - u_upload_data(device->constbuf_uploader,
> + u_upload_data(device->context.pipe->const_uploader,
> 0,
> cb->buffer_size,
> device->constbuf_alignment,
> cb->user_buffer,
> &(cb->buffer_offset),
> &(cb->buffer));
> - u_upload_unmap(device->constbuf_uploader);
> + u_upload_unmap(device->context.pipe->const_uploader);
> cb->user_buffer = NULL;
>
> cb = &(context->pipe_data.cb3_swvp);
> - u_upload_data(device->constbuf_uploader,
> + u_upload_data(device->context.pipe->const_uploader,
> 0,
> cb->buffer_size,
> device->constbuf_alignment,
> cb->user_buffer,
> &(cb->buffer_offset),
> &(cb->buffer));
> - u_upload_unmap(device->constbuf_uploader);
> + u_upload_unmap(device->context.pipe->const_uploader);
> cb->user_buffer = NULL;
> }
>
> @@ -523,14 +523,14 @@ prepare_vs_constants_userbuf(struct NineDevice9 *device)
>
> if (!device->driver_caps.user_cbufs) {
> context->pipe_data.cb_vs.buffer_size = cb.buffer_size;
> - u_upload_data(device->constbuf_uploader,
> + u_upload_data(device->context.pipe->const_uploader,
> 0,
> cb.buffer_size,
> device->constbuf_alignment,
> cb.user_buffer,
> &context->pipe_data.cb_vs.buffer_offset,
> &context->pipe_data.cb_vs.buffer);
> - u_upload_unmap(device->constbuf_uploader);
> + u_upload_unmap(device->context.pipe->const_uploader);
> context->pipe_data.cb_vs.user_buffer = NULL;
> } else
> context->pipe_data.cb_vs = cb;
> @@ -594,14 +594,14 @@ prepare_ps_constants_userbuf(struct NineDevice9 *device)
>
> if (!device->driver_caps.user_cbufs) {
> context->pipe_data.cb_ps.buffer_size = cb.buffer_size;
> - u_upload_data(device->constbuf_uploader,
> + u_upload_data(device->context.pipe->const_uploader,
> 0,
> cb.buffer_size,
> device->constbuf_alignment,
> cb.user_buffer,
> &context->pipe_data.cb_ps.buffer_offset,
> &context->pipe_data.cb_ps.buffer);
> - u_upload_unmap(device->constbuf_uploader);
> + u_upload_unmap(device->context.pipe->const_uploader);
> context->pipe_data.cb_ps.user_buffer = NULL;
> } else
> context->pipe_data.cb_ps = cb;
> @@ -3296,14 +3296,14 @@ update_vertex_buffers_sw(struct NineDevice9 *device, int start_vertice, int num_
> &(sw_internal->transfers_so[i]));
> vtxbuf.buffer = NULL;
> if (!device->driver_caps.user_sw_vbufs) {
> - u_upload_data(device->vertex_sw_uploader,
> + u_upload_data(device->pipe_sw->stream_uploader,
> 0,
> box.width,
> 16,
> vtxbuf.user_buffer,
> &(vtxbuf.buffer_offset),
> &(vtxbuf.buffer));
> - u_upload_unmap(device->vertex_sw_uploader);
> + u_upload_unmap(device->pipe_sw->stream_uploader);
> vtxbuf.user_buffer = NULL;
> }
> pipe_sw->set_vertex_buffers(pipe_sw, i, 1, &vtxbuf);
> @@ -3352,14 +3352,14 @@ update_vs_constants_sw(struct NineDevice9 *device)
>
> buf = cb.user_buffer;
> if (!device->driver_caps.user_sw_cbufs) {
> - u_upload_data(device->constbuf_sw_uploader,
> + u_upload_data(device->pipe_sw->const_uploader,
> 0,
> cb.buffer_size,
> 16,
> cb.user_buffer,
> &(cb.buffer_offset),
> &(cb.buffer));
> - u_upload_unmap(device->constbuf_sw_uploader);
> + u_upload_unmap(device->pipe_sw->const_uploader);
> cb.user_buffer = NULL;
> }
>
> @@ -3369,14 +3369,14 @@ update_vs_constants_sw(struct NineDevice9 *device)
>
> cb.user_buffer = (char *)buf + 4096 * sizeof(float[4]);
> if (!device->driver_caps.user_sw_cbufs) {
> - u_upload_data(device->constbuf_sw_uploader,
> + u_upload_data(device->pipe_sw->const_uploader,
> 0,
> cb.buffer_size,
> 16,
> cb.user_buffer,
> &(cb.buffer_offset),
> &(cb.buffer));
> - u_upload_unmap(device->constbuf_sw_uploader);
> + u_upload_unmap(device->pipe_sw->const_uploader);
> cb.user_buffer = NULL;
> }
>
> @@ -3394,14 +3394,14 @@ update_vs_constants_sw(struct NineDevice9 *device)
> cb.user_buffer = state->vs_const_i;
>
> if (!device->driver_caps.user_sw_cbufs) {
> - u_upload_data(device->constbuf_sw_uploader,
> + u_upload_data(device->pipe_sw->const_uploader,
> 0,
> cb.buffer_size,
> 16,
> cb.user_buffer,
> &(cb.buffer_offset),
> &(cb.buffer));
> - u_upload_unmap(device->constbuf_sw_uploader);
> + u_upload_unmap(device->pipe_sw->const_uploader);
> cb.user_buffer = NULL;
> }
>
> @@ -3419,14 +3419,14 @@ update_vs_constants_sw(struct NineDevice9 *device)
> cb.user_buffer = state->vs_const_b;
>
> if (!device->driver_caps.user_sw_cbufs) {
> - u_upload_data(device->constbuf_sw_uploader,
> + u_upload_data(device->pipe_sw->const_uploader,
> 0,
> cb.buffer_size,
> 16,
> cb.user_buffer,
> &(cb.buffer_offset),
> &(cb.buffer));
> - u_upload_unmap(device->constbuf_sw_uploader);
> + u_upload_unmap(device->pipe_sw->const_uploader);
> cb.user_buffer = NULL;
> }
>
> @@ -3450,14 +3450,14 @@ update_vs_constants_sw(struct NineDevice9 *device)
> cb.user_buffer = viewport_data;
>
> {
> - u_upload_data(device->constbuf_sw_uploader,
> + u_upload_data(device->pipe_sw->const_uploader,
> 0,
> cb.buffer_size,
> 16,
> cb.user_buffer,
> &(cb.buffer_offset),
> &(cb.buffer));
> - u_upload_unmap(device->constbuf_sw_uploader);
> + u_upload_unmap(device->pipe_sw->const_uploader);
> cb.user_buffer = NULL;
> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170220/350a1994/attachment-0001.html>
More information about the mesa-dev
mailing list