=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d: Prepend pNext chain structures.

Alexandre Julliard julliard at winehq.org
Tue Aug 6 17:39:38 CDT 2019


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

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Mon Aug  5 18:03:39 2019 +0200

vkd3d: Prepend pNext chain structures.

Order of structures doesn't matter so we can simply prepend instead of
apending.

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/device.c        | 24 ++++++++++++------------
 libs/vkd3d/state.c         |  4 ++--
 libs/vkd3d/vkd3d_private.h | 11 +++++------
 3 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index 18c7bf6..cb70578 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -714,19 +714,19 @@ static void vkd3d_physical_device_info_init(struct vkd3d_physical_device_info *i
     info->features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
 
     conditional_rendering_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT;
-    vk_append_struct(&info->features2, conditional_rendering_features);
+    vk_prepend_struct(&info->features2, conditional_rendering_features);
     depth_clip_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT;
-    vk_append_struct(&info->features2, depth_clip_features);
+    vk_prepend_struct(&info->features2, depth_clip_features);
     descriptor_indexing_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT;
-    vk_append_struct(&info->features2, descriptor_indexing_features);
+    vk_prepend_struct(&info->features2, descriptor_indexing_features);
     demote_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES_EXT;
-    vk_append_struct(&info->features2, demote_features);
+    vk_prepend_struct(&info->features2, demote_features);
     buffer_alignment_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT;
-    vk_append_struct(&info->features2, buffer_alignment_features);
+    vk_prepend_struct(&info->features2, buffer_alignment_features);
     xfb_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT;
-    vk_append_struct(&info->features2, xfb_features);
+    vk_prepend_struct(&info->features2, xfb_features);
     vertex_divisor_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT;
-    vk_append_struct(&info->features2, vertex_divisor_features);
+    vk_prepend_struct(&info->features2, vertex_divisor_features);
 
     if (vulkan_info->KHR_get_physical_device_properties2)
         VK_CALL(vkGetPhysicalDeviceFeatures2KHR(physical_device, &info->features2));
@@ -736,15 +736,15 @@ static void vkd3d_physical_device_info_init(struct vkd3d_physical_device_info *i
     info->properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
 
     maintenance3_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES;
-    vk_append_struct(&info->properties2, maintenance3_properties);
+    vk_prepend_struct(&info->properties2, maintenance3_properties);
     descriptor_indexing_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES_EXT;
-    vk_append_struct(&info->properties2, descriptor_indexing_properties);
+    vk_prepend_struct(&info->properties2, descriptor_indexing_properties);
     buffer_alignment_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES_EXT;
-    vk_append_struct(&info->properties2, buffer_alignment_properties);
+    vk_prepend_struct(&info->properties2, buffer_alignment_properties);
     xfb_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT;
-    vk_append_struct(&info->properties2, xfb_properties);
+    vk_prepend_struct(&info->properties2, xfb_properties);
     vertex_divisor_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT;
-    vk_append_struct(&info->properties2, vertex_divisor_properties);
+    vk_prepend_struct(&info->properties2, vertex_divisor_properties);
 
     if (vulkan_info->KHR_get_physical_device_properties2)
         VK_CALL(vkGetPhysicalDeviceProperties2KHR(physical_device, &info->properties2));
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 45d5435..8ddbd4f 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -1729,7 +1729,7 @@ static void rs_depth_clip_info_from_d3d12(VkPipelineRasterizationDepthClipStateC
     depth_clip_info->flags = 0;
     depth_clip_info->depthClipEnable = d3d12_desc->DepthClipEnable;
 
-    vk_append_struct(vk_rs_desc, depth_clip_info);
+    vk_prepend_struct(vk_rs_desc, depth_clip_info);
 }
 
 static void rs_stream_info_from_d3d12(VkPipelineRasterizationStateStreamCreateInfoEXT *stream_info,
@@ -1750,7 +1750,7 @@ static void rs_stream_info_from_d3d12(VkPipelineRasterizationStateStreamCreateIn
     stream_info->flags = 0;
     stream_info->rasterizationStream = so_desc->RasterizedStream;
 
-    vk_append_struct(vk_rs_desc, stream_info);
+    vk_prepend_struct(vk_rs_desc, stream_info);
 }
 
 static enum VkStencilOp vk_stencil_op_from_d3d12(D3D12_STENCIL_OP op)
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 4f2559c..51bfba9 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -1233,14 +1233,13 @@ VkResult vkd3d_set_vk_object_name_utf8(struct d3d12_device *device, uint64_t vk_
 HRESULT vkd3d_set_vk_object_name(struct d3d12_device *device, uint64_t vk_object,
         VkDebugReportObjectTypeEXT vk_object_type, const WCHAR *name) DECLSPEC_HIDDEN;
 
-static inline void vk_append_struct(void *h, void *structure)
+static inline void vk_prepend_struct(void *header, void *structure)
 {
-    VkBaseOutStructure *header = h;
+    VkBaseOutStructure *vk_header = header, *vk_structure = structure;
 
-    while (header->pNext)
-        header = header->pNext;
-
-    header->pNext = structure;
+    assert(!vk_structure->pNext);
+    vk_structure->pNext = vk_header->pNext;
+    vk_header->pNext = vk_structure;
 }
 
 #endif  /* __VKD3D_PRIVATE_H */




More information about the wine-cvs mailing list