u_transfer_helper: Use common code for interleaved unmap.
authorEmma Anholt <emma@anholt.net>
Wed, 4 Jan 2023 19:52:19 +0000 (11:52 -0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 6 Jan 2023 19:00:17 +0000 (19:00 +0000)
The function was static and only used from this caller, and the only
difference was that the interleaved case didn't handle trans->ss (which
will always be unset for an interleaved mapping since interleaving splits
the underlying map of the MSAA resource into trans->trans and
trans->trans2).

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20523>

src/gallium/auxiliary/util/u_transfer_helper.c

index dad0a4c..dc011a0 100644 (file)
@@ -495,22 +495,14 @@ u_transfer_helper_transfer_flush_region(struct pipe_context *pctx,
    }
 }
 
-static void
-u_transfer_helper_deinterleave_transfer_unmap(struct pipe_context *pctx,
-                                              struct pipe_transfer *ptrans);
-
 void
 u_transfer_helper_transfer_unmap(struct pipe_context *pctx,
                                  struct pipe_transfer *ptrans)
 {
    struct u_transfer_helper *helper = pctx->screen->transfer_helper;
+   bool interleave = need_interleave_path(helper, ptrans->resource->format);
 
-   if (need_interleave_path(helper, ptrans->resource->format)) {
-      u_transfer_helper_deinterleave_transfer_unmap(pctx, ptrans);
-      return;
-   }
-
-   if (handle_transfer(ptrans->resource)) {
+   if (handle_transfer(ptrans->resource) || interleave) {
       struct u_transfer *trans = u_transfer(ptrans);
 
       if (!(ptrans->usage & PIPE_MAP_FLUSH_EXPLICIT)) {
@@ -671,27 +663,3 @@ fail:
    free(trans);
    return NULL;
 }
-
-static void
-u_transfer_helper_deinterleave_transfer_unmap(struct pipe_context *pctx,
-                                              struct pipe_transfer *ptrans)
-{
-   struct u_transfer_helper *helper = pctx->screen->transfer_helper;
-
-   struct u_transfer *trans = (struct u_transfer *)ptrans;
-
-   if (!(ptrans->usage & PIPE_MAP_FLUSH_EXPLICIT)) {
-      struct pipe_box box;
-      u_box_2d(0, 0, ptrans->box.width, ptrans->box.height, &box);
-      flush_region(pctx, ptrans, &box);
-   }
-
-   helper->vtbl->transfer_unmap(pctx, trans->trans);
-   if (trans->trans2)
-      helper->vtbl->transfer_unmap(pctx, trans->trans2);
-
-   pipe_resource_reference(&ptrans->resource, NULL);
-
-   free(trans->staging);
-   free(trans);
-}