From fac3f993772edc9be1682b439b45ddbe3463bd4f Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Wed, 10 Apr 2019 22:16:54 +0200 Subject: [PATCH] st/nine: Optimize surface upload with conversion Use nine_context_box_upload instead of locking the pipe for surface upload with format conversion. nine_context_box_upload already handles format conversion. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/surface9.c | 55 +++++++++++----------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c index 7f4ecf559e8..f0bdf6372de 100644 --- a/src/gallium/state_trackers/nine/surface9.c +++ b/src/gallium/state_trackers/nine/surface9.c @@ -539,6 +539,7 @@ NineSurface9_LockRect( struct NineSurface9 *This, HRESULT NINE_WINAPI NineSurface9_UnlockRect( struct NineSurface9 *This ) { + struct pipe_box dst_box, src_box; struct pipe_context *pipe; DBG("This=%p lock_count=%u\n", This, This->lock_count); user_assert(This->lock_count, D3DERR_INVALIDCALL); @@ -551,35 +552,33 @@ NineSurface9_UnlockRect( struct NineSurface9 *This ) --This->lock_count; if (This->data_conversion) { - struct pipe_transfer *transfer; - uint8_t *dst = This->data; - struct pipe_box box; - - u_box_origin_2d(This->desc.Width, This->desc.Height, &box); - - pipe = NineDevice9_GetPipe(This->base.base.device); - if (!dst) { - dst = pipe->transfer_map(pipe, - This->base.resource, - This->level, - PIPE_TRANSFER_WRITE | - PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE, - &box, &transfer); - if (!dst) - return D3D_OK; + if (This->data) { + (void) util_format_translate(This->base.info.format, + This->data, This->stride, + 0, 0, + This->format_conversion, + This->data_conversion, + This->stride_conversion, + 0, 0, + This->desc.Width, This->desc.Height); + } else { + u_box_2d_zslice(0, 0, This->layer, + This->desc.Width, This->desc.Height, &dst_box); + u_box_2d_zslice(0, 0, 0, + This->desc.Width, This->desc.Height, &src_box); + + nine_context_box_upload(This->base.base.device, + &This->pending_uploads_counter, + (struct NineUnknown *)This, + This->base.resource, + This->level, + &dst_box, + This->format_conversion, + This->data_conversion, + This->stride_conversion, + 0, /* depth = 1 */ + &src_box); } - - (void) util_format_translate(This->base.info.format, - dst, This->data ? This->stride : transfer->stride, - 0, 0, - This->format_conversion, - This->data_conversion, - This->stride_conversion, - 0, 0, - This->desc.Width, This->desc.Height); - - if (!This->data) - pipe_transfer_unmap(pipe, transfer); } return D3D_OK; } -- 2.30.2