st/nine: Optimize volume upload with conversion
authorAxel Davy <davyaxel0@gmail.com>
Wed, 10 Apr 2019 20:21:48 +0000 (22:21 +0200)
committerAxel Davy <davyaxel0@gmail.com>
Tue, 30 Apr 2019 17:18:50 +0000 (19:18 +0200)
Use nine_context_box_upload instead of locking the pipe
for volume upload with format conversion.
nine_context_box_upload already handles format
conversion.

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
src/gallium/state_trackers/nine/volume9.c

index d6d80611f3c746380240a3954ea33c5699ab6322..f2a2865b0a32074e7c6f47cad04882fb64a8474b 100644 (file)
@@ -372,39 +372,37 @@ NineVolume9_UnlockBox( struct NineVolume9 *This )
     --This->lock_count;
 
     if (This->data_conversion) {
-        struct pipe_transfer *transfer;
-        uint8_t *dst = This->data;
         struct pipe_box box;
 
         u_box_3d(0, 0, 0, This->desc.Width, This->desc.Height, This->desc.Depth,
                  &box);
 
-        pipe = NineDevice9_GetPipe(This->base.device);
-        if (!dst) {
-            dst = pipe->transfer_map(pipe,
-                                     This->resource,
-                                     This->level,
-                                     PIPE_TRANSFER_WRITE |
-                                     PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE,
-                                     &box, &transfer);
-            if (!dst)
-                return D3D_OK;
-        }
-
-        (void) util_format_translate_3d(This->info.format,
-                                        dst, This->data ? This->stride : transfer->stride,
-                                        This->data ? This->layer_stride : transfer->layer_stride,
-                                        0, 0, 0,
-                                        This->format_conversion,
-                                        This->data_conversion,
-                                        This->stride_conversion,
-                                        This->layer_stride_conversion,
-                                        0, 0, 0,
-                                        This->desc.Width, This->desc.Height,
-                                        This->desc.Depth);
 
-        if (!This->data)
-            pipe_transfer_unmap(pipe, transfer);
+        if (This->data) {
+            (void) util_format_translate_3d(This->info.format,
+                                            This->data, This->stride,
+                                            This->layer_stride,
+                                            0, 0, 0,
+                                            This->format_conversion,
+                                            This->data_conversion,
+                                            This->stride_conversion,
+                                            This->layer_stride_conversion,
+                                            0, 0, 0,
+                                            This->desc.Width, This->desc.Height,
+                                            This->desc.Depth);
+        } else {
+            nine_context_box_upload(This->base.device,
+                                    &This->pending_uploads_counter,
+                                    (struct NineUnknown *)This,
+                                    This->resource,
+                                    This->level,
+                                    &box,
+                                    This->format_conversion,
+                                    This->data_conversion,
+                                    This->stride_conversion,
+                                    This->layer_stride_conversion,
+                                    &box);
+        }
     }
 
     return D3D_OK;