[PATCH vkd3d 08/10] vkd3d: Introduce a helper function to chain vkd3d structures.
Henri Verbeet
hverbeet at codeweavers.com
Thu Oct 14 18:37:44 CDT 2021
From: Conor McCarthy <cmccarthy at codeweavers.com>
Analogous to vk_prepend_struct().
Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
v2:
- Initialise shader_interface.next to NULL inside the loop. This avoids
chained structures from previous loop iterations hanging around.
- Do not add the vkd3d_shader_base_in_structure structure to the public
interface.
This supersedes patches 216994 and 216995.
libs/vkd3d/state.c | 9 ++++-----
libs/vkd3d/vkd3d_private.h | 13 +++++++++++++
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 277afe42..29d8618e 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -2689,12 +2689,11 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
goto fail;
}
- shader_interface.next = shader_stages[i].stage == xfb_stage ? &xfb_info : NULL;
+ shader_interface.next = NULL;
+ if (shader_stages[i].stage == xfb_stage)
+ vkd3d_prepend_struct(&shader_interface, &xfb_info);
if (target_info)
- {
- target_info->next = shader_interface.next;
- shader_interface.next = target_info;
- }
+ vkd3d_prepend_struct(&shader_interface, target_info);
if (FAILED(hr = create_shader_stage(device, &graphics->stages[graphics->stage_count],
shader_stages[i].stage, b, &shader_interface)))
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index f8474caa..0594eea2 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -1395,4 +1395,17 @@ static inline void vk_prepend_struct(void *header, void *structure)
vk_header->pNext = vk_structure;
}
+static inline void vkd3d_prepend_struct(void *header, void *structure)
+{
+ struct
+ {
+ unsigned int type;
+ const void *next;
+ } *vkd3d_header = header, *vkd3d_structure = structure;
+
+ assert(!vkd3d_structure->next);
+ vkd3d_structure->next = vkd3d_header->next;
+ vkd3d_header->next = vkd3d_structure;
+}
+
#endif /* __VKD3D_PRIVATE_H */
--
2.20.1
More information about the wine-devel
mailing list