Mesa (master): d3d12: transition the right planes

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 18 17:31:58 UTC 2020


Module: Mesa
Branch: master
Commit: 17ebce2f1308a8b95c0eb0a761032fa3e0961310
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=17ebce2f1308a8b95c0eb0a761032fa3e0961310

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Mon Aug 24 22:47:59 2020 +0200

d3d12: transition the right planes

We need to start transitioning at plane 1 for stencil-only resources,
otherwise we end up transitioning the depth-plane instead.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3837
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7672>

---

 src/gallium/drivers/d3d12/d3d12_blit.cpp |  6 ++++--
 src/gallium/drivers/d3d12/d3d12_draw.cpp |  6 ++++--
 src/gallium/drivers/d3d12/d3d12_format.c | 10 ++++++++++
 src/gallium/drivers/d3d12/d3d12_format.h |  3 +++
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/d3d12/d3d12_blit.cpp b/src/gallium/drivers/d3d12/d3d12_blit.cpp
index 685c0c22199..04428a3a2ad 100644
--- a/src/gallium/drivers/d3d12/d3d12_blit.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_blit.cpp
@@ -419,11 +419,13 @@ d3d12_direct_copy(struct d3d12_context *ctx,
                    src_subres, dst_subres);
 
 
-   d3d12_transition_subresources_state(ctx, src, src_subres, 1, 0, 1, 0,
+   d3d12_transition_subresources_state(ctx, src, src_subres, 1, 0, 1,
+                                       d3d12_get_format_start_plane(src->base.format),
                                        d3d12_get_format_num_planes(src->base.format),
                                        D3D12_RESOURCE_STATE_COPY_SOURCE);
 
-   d3d12_transition_subresources_state(ctx, dst, dst_subres, 1, 0, 1, 0,
+   d3d12_transition_subresources_state(ctx, dst, dst_subres, 1, 0, 1,
+                                       d3d12_get_format_start_plane(dst->base.format),
                                        d3d12_get_format_num_planes(dst->base.format),
                                        D3D12_RESOURCE_STATE_COPY_DEST);
 
diff --git a/src/gallium/drivers/d3d12/d3d12_draw.cpp b/src/gallium/drivers/d3d12/d3d12_draw.cpp
index b78d144ff11..f7c0ffd16e8 100644
--- a/src/gallium/drivers/d3d12/d3d12_draw.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_draw.cpp
@@ -114,7 +114,8 @@ fill_srv_descriptors(struct d3d12_context *ctx,
             d3d12_transition_subresources_state(ctx, d3d12_resource(view->base.texture),
                                                 view->base.u.tex.first_level, view->mip_levels,
                                                 view->base.u.tex.first_layer, view->array_size,
-                                                0, d3d12_get_format_num_planes(view->base.format),
+                                                d3d12_get_format_start_plane(view->base.format),
+                                                d3d12_get_format_num_planes(view->base.format),
                                                 state);
          }
       } else {
@@ -384,7 +385,8 @@ transition_surface_subresources_state(struct d3d12_context *ctx,
    d3d12_transition_subresources_state(ctx, res,
                                        psurf->u.tex.level, 1,
                                        start_layer, num_layers,
-                                       0, d3d12_get_format_num_planes(psurf->format),
+                                       d3d12_get_format_start_plane(psurf->format),
+                                       d3d12_get_format_num_planes(psurf->format),
                                        state);
 }
 
diff --git a/src/gallium/drivers/d3d12/d3d12_format.c b/src/gallium/drivers/d3d12/d3d12_format.c
index 302b182f56b..5bf4e6110bf 100644
--- a/src/gallium/drivers/d3d12/d3d12_format.c
+++ b/src/gallium/drivers/d3d12/d3d12_format.c
@@ -290,6 +290,16 @@ d3d12_non_opaque_plane_count(DXGI_FORMAT format)
    return 1;
 }
 
+unsigned
+d3d12_get_format_start_plane(enum pipe_format fmt)
+{
+   const struct util_format_description *desc = util_format_description(fmt);
+   if (util_format_has_stencil(desc) && !util_format_has_depth(desc))
+      return 1;
+
+   return 0;
+}
+
 unsigned
 d3d12_get_format_num_planes(enum pipe_format fmt)
 {
diff --git a/src/gallium/drivers/d3d12/d3d12_format.h b/src/gallium/drivers/d3d12/d3d12_format.h
index b578f4ce383..538de9c2fdd 100644
--- a/src/gallium/drivers/d3d12/d3d12_format.h
+++ b/src/gallium/drivers/d3d12/d3d12_format.h
@@ -56,6 +56,9 @@ d3d12_get_format_info(enum pipe_format format, enum pipe_texture_target);
 enum pipe_format
 d3d12_emulated_vtx_format(enum pipe_format fmt);
 
+unsigned
+d3d12_get_format_start_plane(enum pipe_format fmt);
+
 unsigned
 d3d12_get_format_num_planes(enum pipe_format fmt);
 



More information about the mesa-commit mailing list