=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d: Clarify DSV attachment mask handling.

Alexandre Julliard julliard at winehq.org
Wed Jun 12 16:27:17 CDT 2019


Module: vkd3d
Branch: master
Commit: 895aaa461b53f99517f774339810aac4ceb78201
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=895aaa461b53f99517f774339810aac4ceb78201

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Wed Jun 12 14:07:59 2019 +0200

vkd3d: Clarify DSV attachment mask handling.

It isn't immediately obvious what "1u << graphics->rt_count" means.
Use dsv_attachment_mask() helper instead.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d/command.c       | 15 ++-------------
 libs/vkd3d/state.c         |  8 ++++----
 libs/vkd3d/vkd3d_private.h | 17 +++++++++++++++++
 3 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c
index fcb7a48..55a15d9 100644
--- a/libs/vkd3d/command.c
+++ b/libs/vkd3d/command.c
@@ -2278,17 +2278,6 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_list_ClearState(ID3D12GraphicsCom
     return E_NOTIMPL;
 }
 
-static bool d3d12_command_list_has_unknown_dsv_format(struct d3d12_command_list *list)
-{
-    struct d3d12_graphics_pipeline_state *graphics;
-
-    if (!d3d12_pipeline_state_is_graphics(list->state))
-        return false;
-
-    graphics = &list->state->u.graphics;
-    return graphics->null_attachment_mask & (1u << graphics->rt_count);
-}
-
 static bool d3d12_command_list_has_depth_stencil_view(struct d3d12_command_list *list)
 {
     struct d3d12_graphics_pipeline_state *graphics;
@@ -2296,7 +2285,7 @@ static bool d3d12_command_list_has_depth_stencil_view(struct d3d12_command_list
     assert(d3d12_pipeline_state_is_graphics(list->state));
     graphics = &list->state->u.graphics;
 
-    return graphics->dsv_format || (d3d12_command_list_has_unknown_dsv_format(list) && list->dsv_format);
+    return graphics->dsv_format || (d3d12_pipeline_state_has_unknown_dsv_format(list->state) && list->dsv_format);
 }
 
 static void d3d12_command_list_get_fb_extent(struct d3d12_command_list *list,
@@ -4386,7 +4375,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_OMSetRenderTargets(ID3D12Graphi
         }
     }
 
-    if (prev_dsv_format != list->dsv_format && d3d12_command_list_has_unknown_dsv_format(list))
+    if (prev_dsv_format != list->dsv_format && d3d12_pipeline_state_has_unknown_dsv_format(list->state))
         d3d12_command_list_invalidate_current_pipeline(list);
 
     d3d12_command_list_invalidate_current_framebuffer(list);
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 514fdc3..be2aa4f 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -2038,7 +2038,7 @@ static HRESULT d3d12_graphics_pipeline_state_create_render_pass(
     memcpy(key.vk_formats, graphics->rtv_formats, sizeof(graphics->rtv_formats));
     key.attachment_count = graphics->rt_count;
 
-    if (!(dsv_format = graphics->dsv_format) && (graphics->null_attachment_mask & (1u << graphics->rt_count)))
+    if (!(dsv_format = graphics->dsv_format) && (graphics->null_attachment_mask & dsv_attachment_mask(graphics)))
         dsv_format = dynamic_dsv_format;
 
     if (dsv_format)
@@ -2220,7 +2220,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
         {
             WARN("DSV format is DXGI_FORMAT_UNKNOWN.\n");
             graphics->dsv_format = VK_FORMAT_UNDEFINED;
-            graphics->null_attachment_mask |= 1u << graphics->rt_count;
+            graphics->null_attachment_mask |= dsv_attachment_mask(graphics);
         }
         else if ((format = vkd3d_get_format(device, desc->DSVFormat, true)))
         {
@@ -2503,7 +2503,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
             goto fail;
     }
 
-    is_dsv_format_unknown = graphics->null_attachment_mask & (1u << graphics->rt_count);
+    is_dsv_format_unknown = graphics->null_attachment_mask & dsv_attachment_mask(graphics);
 
     rs_desc_from_d3d12(&graphics->rs_desc, &desc->RasterizerState);
     have_attachment = graphics->rt_count || graphics->dsv_format || is_dsv_format_unknown;
@@ -2855,7 +2855,7 @@ VkPipeline d3d12_pipeline_state_get_or_create_pipeline(struct d3d12_pipeline_sta
     /* Create a render pass for pipelines with DXGI_FORMAT_UNKNOWN. */
     if (!(pipeline_desc.renderPass = graphics->render_pass))
     {
-        if (graphics->null_attachment_mask & (1u << graphics->rt_count))
+        if (graphics->null_attachment_mask & dsv_attachment_mask(graphics))
             TRACE("Compiling %p with DSV format %#x.\n", state, dsv_format);
 
         if (FAILED(hr = d3d12_graphics_pipeline_state_create_render_pass(graphics, device, dsv_format,
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 4118d5d..9f00d32 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -706,6 +706,11 @@ struct d3d12_graphics_pipeline_state
     bool xfb_enabled;
 };
 
+static inline unsigned int dsv_attachment_mask(const struct d3d12_graphics_pipeline_state *graphics)
+{
+    return 1u << graphics->rt_count;
+}
+
 struct d3d12_compute_pipeline_state
 {
     VkPipeline vk_pipeline;
@@ -746,6 +751,18 @@ static inline bool d3d12_pipeline_state_is_graphics(const struct d3d12_pipeline_
     return state && state->vk_bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS;
 }
 
+static inline bool d3d12_pipeline_state_has_unknown_dsv_format(struct d3d12_pipeline_state *state)
+{
+    if (d3d12_pipeline_state_is_graphics(state))
+    {
+        struct d3d12_graphics_pipeline_state *graphics = &state->u.graphics;
+
+        return graphics->null_attachment_mask & dsv_attachment_mask(graphics);
+    }
+
+    return false;
+}
+
 HRESULT d3d12_pipeline_state_create_compute(struct d3d12_device *device,
         const D3D12_COMPUTE_PIPELINE_STATE_DESC *desc, struct d3d12_pipeline_state **state) DECLSPEC_HIDDEN;
 HRESULT d3d12_pipeline_state_create_graphics(struct d3d12_device *device,




More information about the wine-cvs mailing list