From 6a88c57f5d776ad4978ffad3918e4c3a75b9c332 Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Fri, 15 Oct 2021 01:37:44 +0200 Subject: [PATCH] vkd3d: Introduce a helper function to chain vkd3d structures. Analogous to vk_prepend_struct(). Signed-off-by: Conor McCarthy Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- 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 */