[PATCH vkd3d 1/6] vkd3d: Clarify DSV attachment mask handling.
Józef Kucia
joseph.kucia at gmail.com
Wed Jun 12 07:07:59 CDT 2019
From: Józef Kucia <jkucia at codeweavers.com>
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>
---
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 fcb7a4899091..55a15d9546c5 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 514fdc3a74f2..be2aa4f4bca4 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 4118d5d170e0..9f00d327b73b 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,
--
2.21.0
More information about the wine-devel
mailing list