Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
July 2019
- 65 participants
- 633 messages
[PATCH vkd3d 4/5] vkd3d: Use vk_append_struct() in more places.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/device.c | 38 ++++++++++++++++----------------------
libs/vkd3d/state.c | 10 ----------
libs/vkd3d/vkd3d_private.h | 10 ++++++++++
3 files changed, 26 insertions(+), 32 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index 3cc224992742..0060afe475a3 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -84,12 +84,6 @@ static const void *vkd3d_find_struct_(const struct vkd3d_struct *chain,
return NULL;
}
-struct vk_struct
-{
- VkStructureType sType;
- struct vk_struct *pNext;
-};
-
static uint32_t vkd3d_get_vk_version(void)
{
int major, minor;
@@ -716,40 +710,40 @@ static void vkd3d_physical_device_info_init(struct vkd3d_physical_device_info *i
xfb_features = &info->xfb_features;
xfb_properties = &info->xfb_properties;
+ 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);
depth_clip_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT;
- depth_clip_features->pNext = conditional_rendering_features;
+ vk_append_struct(&info->features2, depth_clip_features);
descriptor_indexing_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT;
- descriptor_indexing_features->pNext = depth_clip_features;
+ vk_append_struct(&info->features2, descriptor_indexing_features);
demote_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES_EXT;
- demote_features->pNext = descriptor_indexing_features;
+ vk_append_struct(&info->features2, demote_features);
buffer_alignment_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT;
- buffer_alignment_features->pNext = demote_features;
+ vk_append_struct(&info->features2, buffer_alignment_features);
xfb_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT;
- xfb_features->pNext = buffer_alignment_features;
+ vk_append_struct(&info->features2, xfb_features);
vertex_divisor_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT;
- vertex_divisor_features->pNext = xfb_features;
-
- info->features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
- info->features2.pNext = vertex_divisor_features;
+ vk_append_struct(&info->features2, vertex_divisor_features);
if (vulkan_info->KHR_get_physical_device_properties2)
VK_CALL(vkGetPhysicalDeviceFeatures2KHR(physical_device, &info->features2));
else
VK_CALL(vkGetPhysicalDeviceFeatures(physical_device, &info->features2.features));
+ 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);
descriptor_indexing_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES_EXT;
- descriptor_indexing_properties->pNext = maintenance3_properties;
+ vk_append_struct(&info->properties2, descriptor_indexing_properties);
buffer_alignment_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES_EXT;
- buffer_alignment_properties->pNext = descriptor_indexing_properties;
+ vk_append_struct(&info->properties2, buffer_alignment_properties);
xfb_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT;
- xfb_properties->pNext = buffer_alignment_properties;
+ vk_append_struct(&info->properties2, xfb_properties);
vertex_divisor_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT;
- vertex_divisor_properties->pNext = xfb_properties;
-
- info->properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
- info->properties2.pNext = vertex_divisor_properties;
+ vk_append_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 59a70b92be99..45d543535a3e 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -19,16 +19,6 @@
#include "vkd3d_private.h"
-static void vk_append_struct(void *h, void *structure)
-{
- VkBaseOutStructure *header = h;
-
- while (header->pNext)
- header = header->pNext;
-
- header->pNext = structure;
-}
-
/* ID3D12RootSignature */
static inline struct d3d12_root_signature *impl_from_ID3D12RootSignature(ID3D12RootSignature *iface)
{
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 6fe852492a67..9255580d9b05 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -1215,4 +1215,14 @@ 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)
+{
+ VkBaseOutStructure *header = h;
+
+ while (header->pNext)
+ header = header->pNext;
+
+ header->pNext = structure;
+}
+
#endif /* __VKD3D_PRIVATE_H */
--
2.21.0
July 6, 2019
[PATCH vkd3d 3/5] vkd3d: Use macros to define optional extensions tables.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/device.c | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index 979bb8cdb433..3cc224992742 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -105,13 +105,17 @@ struct vkd3d_optional_extension_info
bool is_debug_only;
};
+#define VK_EXTENSION(name, member) \
+ {VK_ ## name ## _EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, member)}
+#define VK_DEBUG_EXTENSION(name, member) \
+ {VK_ ## name ## _EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, member), true}
+
static const struct vkd3d_optional_extension_info optional_instance_extensions[] =
{
/* KHR extensions */
- {VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
- offsetof(struct vkd3d_vulkan_info, KHR_get_physical_device_properties2)},
+ VK_EXTENSION(KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2, KHR_get_physical_device_properties2),
/* EXT extensions */
- {VK_EXT_DEBUG_REPORT_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, EXT_debug_report), true},
+ VK_DEBUG_EXTENSION(EXT_DEBUG_REPORT, EXT_debug_report),
};
static const char * const required_device_extensions[] =
@@ -123,23 +127,20 @@ static const char * const required_device_extensions[] =
static const struct vkd3d_optional_extension_info optional_device_extensions[] =
{
/* KHR extensions */
- {VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, KHR_dedicated_allocation)},
- {VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, KHR_draw_indirect_count)},
- {VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, KHR_get_memory_requirements2)},
- {VK_KHR_MAINTENANCE3_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, KHR_maintenance3)},
- {VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, KHR_push_descriptor)},
+ VK_EXTENSION(KHR_DEDICATED_ALLOCATION, KHR_dedicated_allocation),
+ VK_EXTENSION(KHR_DRAW_INDIRECT_COUNT, KHR_draw_indirect_count),
+ VK_EXTENSION(KHR_GET_MEMORY_REQUIREMENTS_2, KHR_get_memory_requirements2),
+ VK_EXTENSION(KHR_MAINTENANCE3, KHR_maintenance3),
+ VK_EXTENSION(KHR_PUSH_DESCRIPTOR, KHR_push_descriptor),
/* EXT extensions */
- {VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, EXT_conditional_rendering)},
- {VK_EXT_DEBUG_MARKER_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, EXT_debug_marker)},
- {VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, EXT_depth_clip_enable)},
- {VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, EXT_descriptor_indexing)},
- {VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME,
- offsetof(struct vkd3d_vulkan_info, EXT_shader_demote_to_helper_invocation)},
- {VK_EXT_TEXEL_BUFFER_ALIGNMENT_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, EXT_texel_buffer_alignment)},
- {VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME,
- offsetof(struct vkd3d_vulkan_info, EXT_transform_feedback)},
- {VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
- offsetof(struct vkd3d_vulkan_info, EXT_vertex_attribute_divisor)},
+ VK_EXTENSION(EXT_CONDITIONAL_RENDERING, EXT_conditional_rendering),
+ VK_EXTENSION(EXT_DEBUG_MARKER, EXT_debug_marker),
+ VK_EXTENSION(EXT_DEPTH_CLIP_ENABLE, EXT_depth_clip_enable),
+ VK_EXTENSION(EXT_DESCRIPTOR_INDEXING, EXT_descriptor_indexing),
+ VK_EXTENSION(EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION, EXT_shader_demote_to_helper_invocation),
+ VK_EXTENSION(EXT_TEXEL_BUFFER_ALIGNMENT, EXT_texel_buffer_alignment),
+ VK_EXTENSION(EXT_TRANSFORM_FEEDBACK, EXT_transform_feedback),
+ VK_EXTENSION(EXT_VERTEX_ATTRIBUTE_DIVISOR, EXT_vertex_attribute_divisor),
};
static unsigned int get_spec_version(const VkExtensionProperties *extensions,
--
2.21.0
July 6, 2019
[PATCH vkd3d 2/5] vkd3d: Add support for VK_EXT_shader_demote_to_helper_invocation.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/device.c | 23 ++++++++++++++++++++++-
libs/vkd3d/state.c | 4 ++--
libs/vkd3d/vkd3d_private.h | 5 +++++
3 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index b9ac829734f4..979bb8cdb433 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -133,6 +133,8 @@ static const struct vkd3d_optional_extension_info optional_device_extensions[] =
{VK_EXT_DEBUG_MARKER_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, EXT_debug_marker)},
{VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, EXT_depth_clip_enable)},
{VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, EXT_descriptor_indexing)},
+ {VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME,
+ offsetof(struct vkd3d_vulkan_info, EXT_shader_demote_to_helper_invocation)},
{VK_EXT_TEXEL_BUFFER_ALIGNMENT_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, EXT_texel_buffer_alignment)},
{VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME,
offsetof(struct vkd3d_vulkan_info, EXT_transform_feedback)},
@@ -673,6 +675,7 @@ struct vkd3d_physical_device_info
VkPhysicalDeviceConditionalRenderingFeaturesEXT conditional_rendering_features;
VkPhysicalDeviceDepthClipEnableFeaturesEXT depth_clip_features;
VkPhysicalDeviceDescriptorIndexingFeaturesEXT descriptor_indexing_features;
+ VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT demote_features;
VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT texel_buffer_alignment_features;
VkPhysicalDeviceTransformFeedbackFeaturesEXT xfb_features;
VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT vertex_divisor_features;
@@ -690,6 +693,7 @@ static void vkd3d_physical_device_info_init(struct vkd3d_physical_device_info *i
VkPhysicalDeviceDescriptorIndexingFeaturesEXT *descriptor_indexing_features;
VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT *vertex_divisor_features;
VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT *buffer_alignment_features;
+ VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT *demote_features;
VkPhysicalDeviceDepthClipEnableFeaturesEXT *depth_clip_features;
VkPhysicalDeviceMaintenance3Properties *maintenance3_properties;
VkPhysicalDeviceTransformFeedbackPropertiesEXT *xfb_properties;
@@ -703,6 +707,7 @@ static void vkd3d_physical_device_info_init(struct vkd3d_physical_device_info *i
descriptor_indexing_features = &info->descriptor_indexing_features;
descriptor_indexing_properties = &info->descriptor_indexing_properties;
maintenance3_properties = &info->maintenance3_properties;
+ demote_features = &info->demote_features;
buffer_alignment_features = &info->texel_buffer_alignment_features;
buffer_alignment_properties = &info->texel_buffer_alignment_properties;
vertex_divisor_features = &info->vertex_divisor_features;
@@ -715,8 +720,10 @@ static void vkd3d_physical_device_info_init(struct vkd3d_physical_device_info *i
depth_clip_features->pNext = conditional_rendering_features;
descriptor_indexing_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT;
descriptor_indexing_features->pNext = depth_clip_features;
+ demote_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES_EXT;
+ demote_features->pNext = descriptor_indexing_features;
buffer_alignment_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT;
- buffer_alignment_features->pNext = descriptor_indexing_features;
+ buffer_alignment_features->pNext = demote_features;
xfb_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT;
xfb_features->pNext = buffer_alignment_features;
vertex_divisor_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT;
@@ -1023,6 +1030,7 @@ static void vkd3d_trace_physical_device_limits(const struct vkd3d_physical_devic
static void vkd3d_trace_physical_device_features(const struct vkd3d_physical_device_info *info)
{
const VkPhysicalDeviceConditionalRenderingFeaturesEXT *conditional_rendering_features;
+ const VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT *demote_features;
const VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT *buffer_alignment_features;
const VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT *divisor_features;
const VkPhysicalDeviceDescriptorIndexingFeaturesEXT *descriptor_indexing;
@@ -1142,6 +1150,10 @@ static void vkd3d_trace_physical_device_features(const struct vkd3d_physical_dev
TRACE(" VkPhysicalDeviceDepthClipEnableFeaturesEXT:\n");
TRACE(" depthClipEnable: %#x.\n", depth_clip_features->depthClipEnable);
+ demote_features = &info->demote_features;
+ TRACE(" VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT:\n");
+ TRACE(" shaderDemoteToHelperInvocation: %#x.\n", demote_features->shaderDemoteToHelperInvocation);
+
buffer_alignment_features = &info->texel_buffer_alignment_features;
TRACE(" VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT:\n");
TRACE(" texelBufferAlignment: %#x.\n", buffer_alignment_features->texelBufferAlignment);
@@ -1374,6 +1386,8 @@ static HRESULT vkd3d_init_device_caps(struct d3d12_device *device,
vulkan_info->EXT_conditional_rendering = false;
if (!physical_device_info->depth_clip_features.depthClipEnable)
vulkan_info->EXT_depth_clip_enable = false;
+ if (!physical_device_info->demote_features.shaderDemoteToHelperInvocation)
+ vulkan_info->EXT_shader_demote_to_helper_invocation = false;
if (!physical_device_info->texel_buffer_alignment_features.texelBufferAlignment)
vulkan_info->EXT_texel_buffer_alignment = false;
@@ -1403,6 +1417,13 @@ static HRESULT vkd3d_init_device_caps(struct d3d12_device *device,
return E_INVALIDARG;
}
+ /* Shader extensions. */
+ if (vulkan_info->EXT_shader_demote_to_helper_invocation)
+ {
+ vulkan_info->shader_extension_count = 1;
+ vulkan_info->shader_extensions[0] = VKD3D_SHADER_TARGET_EXTENSION_SPV_EXT_DEMOTE_TO_HELPER_INVOCATION;
+ }
+
/* Disable unused Vulkan features. */
features->shaderTessellationAndGeometryPointSize = VK_FALSE;
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 26d4a7aabf56..59a70b92be99 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -2254,8 +2254,8 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
ps_compile_args.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_ARGUMENTS;
ps_compile_args.next = NULL;
ps_compile_args.target = VKD3D_SHADER_TARGET_SPIRV_VULKAN_1_0;
- ps_compile_args.target_extension_count = 0;
- ps_compile_args.target_extensions = NULL;
+ ps_compile_args.target_extension_count = vk_info->shader_extension_count;
+ ps_compile_args.target_extensions = vk_info->shader_extensions;
ps_compile_args.parameter_count = ARRAY_SIZE(ps_shader_parameters);
ps_compile_args.parameters = ps_shader_parameters;
ps_compile_args.dual_source_blending = is_dual_source_blending(&desc->BlendState.RenderTarget[0]);
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 6e2dc2b2bb8e..6fe852492a67 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -49,6 +49,7 @@
#define VKD3D_DESCRIPTOR_MAGIC_RTV 0x00565452u
#define VKD3D_MAX_QUEUE_FAMILY_COUNT 3u
+#define VKD3D_MAX_SHADER_EXTENSIONS 1u
#define VKD3D_MAX_SHADER_STAGES 5u
#define VKD3D_MAX_VK_SYNC_OBJECTS 4u
@@ -102,6 +103,7 @@ struct vkd3d_vulkan_info
bool EXT_debug_marker;
bool EXT_depth_clip_enable;
bool EXT_descriptor_indexing;
+ bool EXT_shader_demote_to_helper_invocation;
bool EXT_texel_buffer_alignment;
bool EXT_transform_feedback;
bool EXT_vertex_attribute_divisor;
@@ -117,6 +119,9 @@ struct vkd3d_vulkan_info
VkPhysicalDeviceTexelBufferAlignmentPropertiesEXT texel_buffer_alignment_properties;
+ unsigned int shader_extension_count;
+ enum vkd3d_shader_target_extension shader_extensions[VKD3D_MAX_SHADER_EXTENSIONS];
+
D3D_FEATURE_LEVEL max_feature_level;
};
--
2.21.0
July 6, 2019
[PATCH vkd3d 1/5] vkd3d-shader: Add support for SPV_EXT_demote_to_helper_invocation.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Requires SPIRV-Headers commit dcce859e34cf0c23625ec75ac44df750aa2f4d70.
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
include/vkd3d_shader.h | 12 ++++++++++-
libs/vkd3d-shader/spirv.c | 42 ++++++++++++++++++++++++++++++++++++++-
libs/vkd3d/state.c | 2 ++
3 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h
index fcf5db8efc03..6b4d3f570c7b 100644
--- a/include/vkd3d_shader.h
+++ b/include/vkd3d_shader.h
@@ -224,6 +224,13 @@ enum vkd3d_shader_target
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_TARGET),
};
+enum vkd3d_shader_target_extension
+{
+ VKD3D_SHADER_TARGET_EXTENSION_NONE,
+
+ VKD3D_SHADER_TARGET_EXTENSION_SPV_EXT_DEMOTE_TO_HELPER_INVOCATION,
+};
+
struct vkd3d_shader_compile_arguments
{
enum vkd3d_shader_structure_type type;
@@ -231,8 +238,11 @@ struct vkd3d_shader_compile_arguments
enum vkd3d_shader_target target;
+ unsigned int target_extension_count;
+ const enum vkd3d_shader_target_extension *target_extensions;
+
unsigned int parameter_count;
- struct vkd3d_shader_parameter *parameters;
+ const struct vkd3d_shader_parameter *parameters;
bool dual_source_blending;
const unsigned int *output_swizzles;
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index f17c7fa137e7..0fb499e96807 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -266,6 +266,7 @@ struct vkd3d_spirv_builder
{
uint64_t capability_mask;
uint64_t capability_draw_parameters : 1;
+ uint64_t capability_demote_to_helper_invocation : 1;
uint32_t ext_instr_set_glsl_450;
SpvExecutionModel execution_model;
@@ -311,6 +312,10 @@ static void vkd3d_spirv_enable_capability(struct vkd3d_spirv_builder *builder,
{
builder->capability_draw_parameters = 1;
}
+ else if (cap == SpvCapabilityDemoteToHelperInvocationEXT)
+ {
+ builder->capability_demote_to_helper_invocation = 1;
+ }
else
{
FIXME("Unhandled capability %#x.\n", cap);
@@ -1222,6 +1227,11 @@ static void vkd3d_spirv_build_op_kill(struct vkd3d_spirv_builder *builder)
vkd3d_spirv_build_op(&builder->function_stream, SpvOpKill);
}
+static void vkd3d_spirv_build_op_demote_to_helper_invocation(struct vkd3d_spirv_builder *builder)
+{
+ vkd3d_spirv_build_op(&builder->function_stream, SpvOpDemoteToHelperInvocationEXT);
+}
+
static void vkd3d_spirv_build_op_return(struct vkd3d_spirv_builder *builder)
{
vkd3d_spirv_build_op(&builder->function_stream, SpvOpReturn);
@@ -1703,10 +1713,14 @@ static bool vkd3d_spirv_compile_module(struct vkd3d_spirv_builder *builder,
}
if (builder->capability_draw_parameters)
vkd3d_spirv_build_op_capability(&stream, SpvCapabilityDrawParameters);
+ if (builder->capability_demote_to_helper_invocation)
+ vkd3d_spirv_build_op_capability(&stream, SpvCapabilityDemoteToHelperInvocationEXT);
/* extensions */
if (builder->capability_draw_parameters)
vkd3d_spirv_build_op_extension(&stream, "SPV_KHR_shader_draw_parameters");
+ if (builder->capability_demote_to_helper_invocation)
+ vkd3d_spirv_build_op_extension(&stream, "SPV_EXT_demote_to_helper_invocation");
if (builder->ext_instr_set_glsl_450)
vkd3d_spirv_build_op_ext_inst_import(&stream, builder->ext_instr_set_glsl_450, "GLSL.std.450");
@@ -2148,6 +2162,21 @@ static bool vkd3d_dxbc_compiler_is_opengl_target(const struct vkd3d_dxbc_compile
return vkd3d_dxbc_compiler_get_target(compiler) == VKD3D_SHADER_TARGET_SPIRV_OPENGL_4_5;
}
+static bool vkd3d_dxbc_compiler_is_target_extension_supported(const struct vkd3d_dxbc_compiler *compiler,
+ enum vkd3d_shader_target_extension extension)
+{
+ const struct vkd3d_shader_compile_arguments *args = compiler->compile_args;
+ unsigned int i;
+
+ for (i = 0; args && i < args->target_extension_count; ++i)
+ {
+ if (args->target_extensions[i] == extension)
+ return true;
+ }
+
+ return false;
+}
+
static bool vkd3d_dxbc_compiler_check_shader_visibility(const struct vkd3d_dxbc_compiler *compiler,
enum vkd3d_shader_visibility visibility)
{
@@ -6477,7 +6506,18 @@ static void vkd3d_dxbc_compiler_emit_kill(struct vkd3d_dxbc_compiler *compiler,
merge_block_id = vkd3d_dxbc_compiler_emit_conditional_branch(compiler, instruction, target_id);
vkd3d_spirv_build_op_label(builder, target_id);
- vkd3d_spirv_build_op_kill(builder);
+
+ if (vkd3d_dxbc_compiler_is_target_extension_supported(compiler,
+ VKD3D_SHADER_TARGET_EXTENSION_SPV_EXT_DEMOTE_TO_HELPER_INVOCATION))
+ {
+ vkd3d_spirv_build_op_demote_to_helper_invocation(builder);
+ vkd3d_spirv_build_op_branch(builder, merge_block_id);
+ }
+ else
+ {
+ vkd3d_spirv_build_op_kill(builder);
+ }
+
vkd3d_spirv_build_op_label(builder, merge_block_id);
}
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 794668041fa2..26d4a7aabf56 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -2254,6 +2254,8 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
ps_compile_args.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_ARGUMENTS;
ps_compile_args.next = NULL;
ps_compile_args.target = VKD3D_SHADER_TARGET_SPIRV_VULKAN_1_0;
+ ps_compile_args.target_extension_count = 0;
+ ps_compile_args.target_extensions = NULL;
ps_compile_args.parameter_count = ARRAY_SIZE(ps_shader_parameters);
ps_compile_args.parameters = ps_shader_parameters;
ps_compile_args.dual_source_blending = is_dual_source_blending(&desc->BlendState.RenderTarget[0]);
--
2.21.0
July 6, 2019
[PATCH 15/15] widl: bump MIDL version to 5.2.202 to avoid RPC_X_WRONG_STUB_VERSION exception in combase!ObjectStublessClient
by Richard Pospesel
Signed-off-by: Richard Pospesel <richard(a)torproject.org>
---
tools/widl/client.c | 4 ++--
tools/widl/proxy.c | 2 +-
tools/widl/server.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/widl/client.c b/tools/widl/client.c
index 93a7f36e4b..d27c6cad2b 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -20,7 +20,7 @@
#include "config.h"
#include "wine/port.h"
-
+
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
@@ -426,7 +426,7 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
print_client("1, /* -error bounds_check flag */\n");
print_client("0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001);
print_client("0,\n");
- print_client("0x50100a4, /* MIDL Version 5.1.164 */\n");
+ print_client("0x50200ca, /* MIDL Version 5.2.202 */\n");
print_client("0,\n");
print_client("%s,\n", list_empty(&user_type_list) ? "0" : "UserMarshalRoutines");
print_client("0, /* notify & notify_flag routine table */\n");
diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c
index 9f7fd530b1..36b552be68 100644
--- a/tools/widl/proxy.c
+++ b/tools/widl/proxy.c
@@ -67,7 +67,7 @@ static void write_stubdesc(int expr_eval_routines)
print_proxy( "1, /* -error bounds_check flag */\n");
print_proxy( "0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001);
print_proxy( "0,\n");
- print_proxy( "0x50100a4, /* MIDL Version 5.1.164 */\n");
+ print_proxy( "0x50200ca, /* MIDL Version 5.2.202 */\n");
print_proxy( "0,\n");
print_proxy("%s,\n", list_empty(&user_type_list) ? "0" : "UserMarshalRoutines");
print_proxy( "0, /* notify & notify_flag routine table */\n");
diff --git a/tools/widl/server.c b/tools/widl/server.c
index fa457af2f3..dbed870aa2 100644
--- a/tools/widl/server.c
+++ b/tools/widl/server.c
@@ -387,7 +387,7 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
print_server("1, /* -error bounds_check flag */\n");
print_server("0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001);
print_server("0,\n");
- print_server("0x50100a4, /* MIDL Version 5.1.164 */\n");
+ print_server("0x50200ca, /* MIDL Version 5.2.202 */\n");
print_server("0,\n");
print_server("%s,\n", list_empty(&user_type_list) ? "0" : "UserMarshalRoutines");
print_server("0, /* notify & notify_flag routine table */\n");
--
2.17.1
July 5, 2019
[PATCH 14/15] widl: add public attribute to typedefs with generated names when building typelib
by Richard Pospesel
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47050
Signed-off-by: Richard Pospesel <richard(a)torproject.org>
---
tools/widl/parser.y | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index f7c51c1d64..ef8c040f37 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -2058,7 +2058,13 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at
type_get_type_detect_alias(type) == TYPE_ENCAPSULATED_UNION)
{
if (!type->name)
+ {
type->name = gen_name();
+ /* the generated name will be used and this typedef excluded from the
+ * built typelib unless the typedef has the 'public' attribute, so add it here */
+ if (do_typelib && !is_attr(attrs, ATTR_PUBLIC))
+ attrs = append_attr(attrs, make_attr(ATTR_PUBLIC));
+ }
/* replace existing attributes when generating a typelib */
if (do_typelib)
--
2.17.1
July 5, 2019
[PATCH 13/15] widl: ensure that typedefs with wire_marshal attribute are included in generated typelib
by Richard Pospesel
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47041
Signed-off-by: Richard Pospesel <richard(a)torproject.org>
---
tools/widl/typelib.c | 3 +-
tools/widl/write_msft.c | 74 ++++++++++++++++++++++++++++-------------
2 files changed, 53 insertions(+), 24 deletions(-)
diff --git a/tools/widl/typelib.c b/tools/widl/typelib.c
index 4f6b4fc38a..2c2b127699 100644
--- a/tools/widl/typelib.c
+++ b/tools/widl/typelib.c
@@ -129,7 +129,8 @@ unsigned short get_type_vt(type_t *t)
if (vt) return vt;
}
- if (type_is_alias(t) && is_attr(t->attrs, ATTR_PUBLIC))
+ if (type_is_alias(t) &&
+ (is_attr(t->attrs, ATTR_PUBLIC) || is_attr(t->attrs, ATTR_WIREMARSHAL)))
return VT_USERDEFINED;
switch (type_get_type(t)) {
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c
index 13d768ab2e..da7ce89d12 100644
--- a/tools/widl/write_msft.c
+++ b/tools/widl/write_msft.c
@@ -763,7 +763,7 @@ static void add_enum_typeinfo(msft_typelib_t *typelib, type_t *enumeration);
static void add_union_typeinfo(msft_typelib_t *typelib, type_t *tunion);
static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls);
static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinterface);
-
+static void add_typedef_typeinfo(msft_typelib_t *typelib, type_t *tdef);
/****************************************************************************
* encode_type
@@ -966,33 +966,61 @@ static int encode_type(
}
else
{
- /* typedef'd types without public attribute aren't included in the typelib */
- while (type_is_alias(type) && !is_attr(type->attrs, ATTR_PUBLIC))
- type = type_alias_get_aliasee_type(type);
+ /* typedef'd types without public attribute aren't included in the typelib
+ * typedef'd types with a wire_marshal attribute must be included
+ */
+ while (type_is_alias(type))
+ {
+ if (is_attr(type->attrs, ATTR_WIREMARSHAL))
+ {
+ type = get_attrp(type->attrs, ATTR_WIREMARSHAL);
+ break;
+ }
+ else if(!is_attr(type->attrs, ATTR_PUBLIC))
+ {
+ type = type_alias_get_aliasee_type(type);
+ }
+ else
+ {
+ break;
+ }
+ }
chat("encode_type: VT_USERDEFINED - adding new type %s, real type %d\n",
type->name, type_get_type(type));
- switch (type_get_type(type))
+ /* we've either fully resolved the typedef down to an actual type or
+ * we must include the typedef because it's a wiremarshal (or public) type
+ */
+ if (type_is_alias(type))
{
- case TYPE_STRUCT:
- add_structure_typeinfo(typelib, type);
- break;
- case TYPE_INTERFACE:
- add_interface_typeinfo(typelib, type);
- break;
- case TYPE_ENUM:
- add_enum_typeinfo(typelib, type);
- break;
- case TYPE_UNION:
- add_union_typeinfo(typelib, type);
- break;
- case TYPE_COCLASS:
- add_coclass_typeinfo(typelib, type);
- break;
- default:
- error("encode_type: VT_USERDEFINED - unhandled type %d\n",
- type_get_type(type));
+ add_typedef_typeinfo(typelib, type);
+ }
+ else
+ {
+ switch (type_get_type(type))
+ {
+ case TYPE_STRUCT:
+ add_structure_typeinfo(typelib, type);
+ break;
+ case TYPE_INTERFACE:
+ add_interface_typeinfo(typelib, type);
+ break;
+ case TYPE_ENUM:
+ add_enum_typeinfo(typelib, type);
+ break;
+ /* fallthrough */
+ case TYPE_UNION:
+ case TYPE_ENCAPSULATED_UNION:
+ add_union_typeinfo(typelib, type);
+ break;
+ case TYPE_COCLASS:
+ add_coclass_typeinfo(typelib, type);
+ break;
+ default:
+ error("encode_type: VT_USERDEFINED - unhandled type %d\n",
+ type_get_type(type));
+ }
}
typeinfo_offset = typelib->typelib_typeinfo_offsets[type->typelib_idx];
--
2.17.1
July 5, 2019
[PATCH 12/15] widl: do not output 'inline' function specifier when type is a function pointer
by Richard Pospesel
Signed-off-by: Richard Pospesel <richard(a)torproject.org>
---
tools/widl/header.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c
index 5ccc9f8b66..d0d0dc4b1c 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -510,7 +510,7 @@ static void write_type_v(FILE *h, const decl_spec_t *ds, int is_field, int declo
int i;
const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV);
if (!callconv && is_object_interface) callconv = "STDMETHODCALLTYPE";
- if (dpt->funcspecifier == FUNCTION_SPECIFIER_INLINE) fprintf(h, "inline ");
+ if (!is_ptr(ds->type) && dpt->funcspecifier == FUNCTION_SPECIFIER_INLINE) fprintf(h, "inline ");
write_declspec_left(h, type_function_get_retdeclspec(pt), NAME_DEFAULT, declonly);
fputc(' ', h);
if (ptr_level) fputc('(', h);
--
2.17.1
July 5, 2019
[PATCH 11/15] widl: take FUNCTION_SPECIFIER_INLINE into account when writing client function declarations and function prototypes to match midl.exe output
by Richard Pospesel
Signed-off-by: Richard Pospesel <richard(a)torproject.org>
---
tools/widl/client.c | 1 +
tools/widl/header.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/tools/widl/client.c b/tools/widl/client.c
index 9a15153bab..93a7f36e4b 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -58,6 +58,7 @@ static void write_client_func_decl( const type_t *iface, const var_t *func )
if (!callconv) callconv = "__cdecl";
write_declspec_decl_left(client, retdeclspec);
+ if (func->declspec.funcspecifier == FUNCTION_SPECIFIER_INLINE) fprintf(client, " inline");
fprintf(client, " %s ", callconv);
fprintf(client, "%s%s(\n", prefix_client, get_name(func));
indent++;
diff --git a/tools/widl/header.c b/tools/widl/header.c
index f58ad19927..5ccc9f8b66 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -1418,6 +1418,7 @@ static void write_function_proto(FILE *header, const type_t *iface, const var_t
if (!callconv) callconv = "__cdecl";
/* FIXME: do we need to handle call_as? */
write_declspec_decl_left(header, type_function_get_retdeclspec(fun->declspec.type));
+ if (fun->declspec.funcspecifier == FUNCTION_SPECIFIER_INLINE) fprintf(header, " inline");
fprintf(header, " %s ", callconv);
fprintf(header, "%s%s(\n", prefix, get_name(fun));
if (type_function_get_args(fun->declspec.type))
--
2.17.1
July 5, 2019
[PATCH 10/15] widl: check for existance of named struct, union and enum to avoid duplicate type_t definitions
by Richard Pospesel
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47035
Signed-off-by: Richard Pospesel <richard(a)torproject.org>
---
tools/widl/header.c | 31 ++++++-------
tools/widl/parser.y | 29 ++++++++++--
tools/widl/typetree.c | 103 ++++++++++++++++++++++++-----------------
tools/widl/typetree.h | 32 +++++++++++++
tools/widl/widltypes.h | 14 ++++++
5 files changed, 146 insertions(+), 63 deletions(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c
index 9e9cd5f6ff..f58ad19927 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -43,7 +43,7 @@ user_type_list_t user_type_list = LIST_INIT(user_type_list);
context_handle_list_t context_handle_list = LIST_INIT(context_handle_list);
generic_handle_list_t generic_handle_list = LIST_INIT(generic_handle_list);
-static void write_type_def_or_decl(FILE *f, const decl_spec_t *ds, int field, const char *name);
+static void write_type_v(FILE *h, const decl_spec_t *ds, int is_field, int declonly, const char *name);
static void indent(FILE *h, int delta)
{
@@ -252,7 +252,7 @@ static void write_fields(FILE *h, var_list_t *fields)
default:
;
}
- write_type_def_or_decl(h, &v->declspec, TRUE, name);
+ write_type_v(h, &v->declspec, TRUE, v->declonly, name);
fprintf(h, ";\n");
}
}
@@ -317,7 +317,7 @@ void write_declspec_left(FILE* h, const decl_spec_t *ds, enum name_type name_typ
else {
switch (type_get_type_detect_alias(t)) {
case TYPE_ENUM:
- if (!declonly && t->defined && !t->written) {
+ if (!declonly && type_is_defined(t) && !t->written) {
if (name) fprintf(h, "enum %s {\n", name);
else fprintf(h, "enum {\n");
t->written = TRUE;
@@ -330,7 +330,7 @@ void write_declspec_left(FILE* h, const decl_spec_t *ds, enum name_type name_typ
break;
case TYPE_STRUCT:
case TYPE_ENCAPSULATED_UNION:
- if (!declonly && t->defined && !t->written) {
+ if (!declonly && type_is_defined(t) && !t->written) {
if (name) fprintf(h, "struct %s {\n", name);
else fprintf(h, "struct {\n");
t->written = TRUE;
@@ -345,7 +345,7 @@ void write_declspec_left(FILE* h, const decl_spec_t *ds, enum name_type name_typ
else fprintf(h, "struct %s", name ? name : "");
break;
case TYPE_UNION:
- if (!declonly && t->defined && !t->written) {
+ if (!declonly && type_is_defined(t) && !t->written) {
if (t->name) fprintf(h, "union %s {\n", t->name);
else fprintf(h, "union {\n");
t->written = TRUE;
@@ -539,12 +539,7 @@ static void write_type_v(FILE *h, const decl_spec_t *ds, int is_field, int declo
}
}
-static void write_type_def_or_decl(FILE *f, const decl_spec_t *ds, int field, const char *name)
-{
- write_type_v(f, ds, field, FALSE, name);
-}
-
-static void write_type_definition(FILE *f, type_t *t)
+static void write_type_definition(FILE *f, type_t *t, int declonly)
{
int in_namespace = t->namespace && !is_global_namespace(t->namespace);
int save_written = t->written;
@@ -555,14 +550,14 @@ static void write_type_definition(FILE *f, type_t *t)
write_namespace_start(f, t->namespace);
}
indent(f, 0);
- write_type_left(f, t, NAME_DEFAULT, FALSE);
+ write_type_left(f, t, NAME_DEFAULT, declonly);
fprintf(f, ";\n");
if(in_namespace) {
t->written = save_written;
write_namespace_end(f, t->namespace);
fprintf(f, "extern \"C\" {\n");
fprintf(f, "#else\n");
- write_type_left(f, t, NAME_C, FALSE);
+ write_type_left(f, t, NAME_C, declonly);
fprintf(f, ";\n");
fprintf(f, "#endif\n\n");
}
@@ -802,10 +797,10 @@ static void write_generic_handle_routines(FILE *header)
}
}
-static void write_typedef(FILE *header, type_t *type)
+static void write_typedef(FILE *header, type_t *type, int declonly)
{
fprintf(header, "typedef ");
- write_type_def_or_decl(header, type_alias_get_aliasee(type), FALSE, type->name);
+ write_type_v(header, type_alias_get_aliasee(type), FALSE, declonly, type->name);
fprintf(header, ";\n");
}
@@ -849,7 +844,7 @@ static void write_declaration(FILE *header, const var_t *v)
fprintf(header, "extern ");
break;
}
- write_type_def_or_decl(header, &v->declspec, FALSE, v->name);
+ write_type_v(header, &v->declspec, FALSE, FALSE, v->name);
fprintf(header, ";\n\n");
}
}
@@ -1731,7 +1726,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons
write_coclass(header, stmt->u.type);
else
{
- write_type_definition(header, stmt->u.type);
+ write_type_definition(header, stmt->u.type, stmt->declonly);
}
break;
case STMT_TYPEREF:
@@ -1752,7 +1747,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons
{
const type_list_t *type_entry = stmt->u.type_list;
for (; type_entry; type_entry = type_entry->next)
- write_typedef(header, type_entry->type);
+ write_typedef(header, type_entry->type, stmt->declonly);
break;
}
case STMT_LIBRARY:
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index de1dc709fc..f7c51c1d64 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -1821,6 +1821,10 @@ var_list_t *append_var(var_list_t *list, var_t *var)
list_init( list );
}
list_add_tail( list, &var->entry );
+
+ if (var->declspec.type)
+ var->declonly = !type_is_defined(var->declspec.type);
+
return list;
}
@@ -1844,6 +1848,7 @@ var_t *make_var(char *name)
v->attrs = NULL;
v->eval = NULL;
init_loc_info(&v->loc_info);
+ v->declonly = TRUE;
return v;
}
@@ -1979,14 +1984,14 @@ type_t *reg_type(type_t *type, const char *name, struct namespace *namespace, in
nt->t = t;
nt->next = namespace->type_hash[hash];
namespace->type_hash[hash] = nt;
- if ((t == tsSTRUCT || t == tsUNION))
+ if ((t == tsSTRUCT || t == tsUNION || t == tsENUM))
fix_incomplete_types(type);
return type;
}
static int is_incomplete(const type_t *t)
{
- return !t->defined &&
+ return !type_is_defined(t) &&
(type_get_type_detect_alias(t) == TYPE_ENUM ||
type_get_type_detect_alias(t) == TYPE_STRUCT ||
type_get_type_detect_alias(t) == TYPE_UNION ||
@@ -3046,6 +3051,10 @@ static statement_t *make_statement_type_decl(type_t *type)
{
statement_t *stmt = make_statement(STMT_TYPE);
stmt->u.type = type;
+ if (type_is_defined(type))
+ {
+ stmt->declonly = FALSE;
+ }
return stmt;
}
@@ -3121,6 +3130,7 @@ static statement_t *make_statement_typedef(declarator_list_t *decls)
declarator_t *decl, *next;
statement_t *stmt;
type_list_t **type_list;
+ int defined = TRUE;
if (!decls) return NULL;
@@ -3132,6 +3142,18 @@ static statement_t *make_statement_typedef(declarator_list_t *decls)
{
var_t *var = decl->var;
type_t *type = find_type_or_error(var->name, 0);
+
+ /* ensure that all of the types in this typedef statement have been defined
+ * before setting its declonly flag */
+ if (type_is_pointerish(type))
+ {
+ defined = defined & type_is_defined(type_get_pointer_chain_tail(type));
+ }
+ else
+ {
+ defined = defined & type_is_defined(type_get_real_type(type));
+ }
+
*type_list = xmalloc(sizeof(type_list_t));
(*type_list)->type = type;
(*type_list)->next = NULL;
@@ -3141,6 +3163,7 @@ static statement_t *make_statement_typedef(declarator_list_t *decls)
free(var);
}
+ stmt->declonly = !defined;
return stmt;
}
@@ -3181,7 +3204,7 @@ void init_loc_info(loc_info_t *i)
static void check_def(const type_t *t)
{
- if (t->defined)
+ if (type_is_defined(t))
error_loc("%s: redefinition error; original definition was at %s:%d\n",
t->name, t->loc_info.input_name, t->loc_info.line_number);
}
diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c
index f08bee0bac..dc3e038dfa 100644
--- a/tools/widl/typetree.c
+++ b/tools/widl/typetree.c
@@ -198,7 +198,7 @@ type_t *type_new_alias(const decl_spec_t *ds, const char *name)
type_t *type_new_module(char *name)
{
type_t *type = get_type(TYPE_MODULE, name, NULL, 0);
- if (type->type_type != TYPE_MODULE || type->defined)
+ if (type->type_type != TYPE_MODULE || type_is_defined(type))
error_loc("%s: redefinition error; original definition was at %s:%d\n",
type->name, type->loc_info.input_name, type->loc_info.line_number);
type->name = name;
@@ -208,7 +208,7 @@ type_t *type_new_module(char *name)
type_t *type_new_coclass(char *name)
{
type_t *type = get_type(TYPE_COCLASS, name, NULL, 0);
- if (type->type_type != TYPE_COCLASS || type->defined)
+ if (type->type_type != TYPE_COCLASS || type_is_defined(type))
error_loc("%s: redefinition error; original definition was at %s:%d\n",
type->name, type->loc_info.input_name, type->loc_info.line_number);
type->name = name;
@@ -268,80 +268,99 @@ type_t *type_new_void(void)
type_t *type_new_enum(const char *name, struct namespace *namespace, int defined, var_list_t *enums)
{
- type_t *tag_type = name ? find_type(name, namespace, tsENUM) : NULL;
- type_t *t = make_type(TYPE_ENUM);
- t->name = name;
- t->namespace = namespace;
-
- if (tag_type && tag_type->details.enumeration)
- t->details.enumeration = tag_type->details.enumeration;
- else if (defined)
+ type_t *t = NULL;
+
+ if (name)
+ t = find_type(name, namespace, tsENUM);
+
+ if (!t)
{
- t->details.enumeration = xmalloc(sizeof(*t->details.enumeration));
- t->details.enumeration->enums = enums;
- t->defined = TRUE;
+ t = make_type(TYPE_ENUM);
+ t->name = name;
+ t->namespace = namespace;
+ if (name)
+ reg_type(t, name, namespace, tsENUM);
}
- if (name)
+ if (!type_is_defined(t))
{
if (defined)
- reg_type(t, name, namespace, tsENUM);
+ {
+ t->details.enumeration = xmalloc(sizeof(*t->details.enumeration));
+ t->details.enumeration->enums = enums;
+ t->defined = TRUE;
+ }
else
+ {
add_incomplete(t);
+ }
}
+
return t;
}
type_t *type_new_struct(char *name, struct namespace *namespace, int defined, var_list_t *fields)
{
- type_t *tag_type = name ? find_type(name, namespace, tsSTRUCT) : NULL;
- type_t *t;
+ type_t *t = NULL;
- /* avoid creating duplicate typelib type entries */
- if (tag_type && do_typelib) return tag_type;
-
- t = make_type(TYPE_STRUCT);
- t->name = name;
- t->namespace = namespace;
+ if (name)
+ t = find_type(name, namespace, tsSTRUCT);
- if (tag_type && tag_type->details.structure)
- t->details.structure = tag_type->details.structure;
- else if (defined)
+ if (!t)
{
- t->details.structure = xmalloc(sizeof(*t->details.structure));
- t->details.structure->fields = fields;
- t->defined = TRUE;
+ t = make_type(TYPE_STRUCT);
+ t->name = name;
+ t->namespace = namespace;
+ if (name)
+ reg_type(t, name, namespace, tsSTRUCT);
}
- if (name)
+
+ if (!type_is_defined(t))
{
if (defined)
- reg_type(t, name, namespace, tsSTRUCT);
+ {
+ t->details.structure = xmalloc(sizeof(*t->details.structure));
+ t->details.structure->fields = fields;
+ t->defined = TRUE;
+ }
else
+ {
add_incomplete(t);
+ }
}
+
return t;
}
type_t *type_new_nonencapsulated_union(const char *name, int defined, var_list_t *fields)
{
- type_t *tag_type = name ? find_type(name, NULL, tsUNION) : NULL;
- type_t *t = make_type(TYPE_UNION);
- t->name = name;
- if (tag_type && tag_type->details.structure)
- t->details.structure = tag_type->details.structure;
- else if (defined)
+ type_t *t = NULL;
+
+ if (name)
+ t = find_type(name, NULL, tsUNION);
+
+ if (!t)
{
- t->details.structure = xmalloc(sizeof(*t->details.structure));
- t->details.structure->fields = fields;
- t->defined = TRUE;
+ t = make_type(TYPE_UNION);
+ t->name = name;
+ if (name)
+ reg_type(t, name, NULL, tsUNION);
}
- if (name)
+
+ if (!type_is_defined(t))
{
if (defined)
- reg_type(t, name, NULL, tsUNION);
+ {
+ t->details.structure = xmalloc(sizeof(*t->details.structure));
+ t->details.structure->fields = fields;
+ t->defined = TRUE;
+ }
else
+ {
add_incomplete(t);
+ }
}
+
return t;
}
diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h
index a68bc981cf..4ab8f8935b 100644
--- a/tools/widl/typetree.h
+++ b/tools/widl/typetree.h
@@ -379,4 +379,36 @@ static inline const details_t *type_get_const_details(const type_t* type)
return &type->details;
}
+static inline int type_is_pointerish(const type_t *type)
+{
+ type = type_get_real_type(type);
+ return type_get_type(type) == TYPE_ARRAY || type_get_type(type) == TYPE_POINTER;
+}
+
+static inline type_t * type_get_pointer_chain_tail(const type_t *type)
+{
+ type_t *pointee = NULL;
+ type_t *pointer = type_get_real_type(type);
+
+ if (type_get_type(pointer) == TYPE_ARRAY)
+ {
+ pointee = type_array_get_element_type(pointer);
+ }
+ else if (type_get_type(pointer) == TYPE_POINTER)
+ {
+ pointee = type_pointer_get_ref_type(pointer);
+ }
+ else
+ {
+ assert(FALSE);
+ }
+
+ if (type_is_pointerish(pointee))
+ {
+ return type_get_pointer_chain_tail(pointee);
+ }
+
+ return pointee;
+}
+
#endif /* WIDL_TYPE_TREE_H */
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index 108e537383..cd71e9af76 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -482,6 +482,13 @@ struct _var_t {
unsigned int typestring_offset;
struct _loc_info_t loc_info;
+ /* this flag indicates that this var's type (or pointed to type in the case of
+ * array or pointer) was not fully defined at the time of declaration.
+ * If this flag is set to TRUE then the type definition will not be written for this var
+ * If this flag is set to FALSE then the type definition will only be written if it has not
+ * been written yet (determined by the type_t's 'written' flag)
+ */
+ int declonly : 1;
/* parser-internal */
struct list entry;
@@ -565,6 +572,13 @@ struct _statement_t {
typelib_t *lib;
type_list_t *type_list;
} u;
+ /* this flag indicates that this statement's type (or pointed to type in the case of
+ * array or pointer) was not fully defined at the time of declaration.
+ * If this flag is set to TRUE then the type definition will not be written for this statement
+ * If this flag is set to FALSE then the type definition will only be written if it has not
+ * been written yet (determined by the type_t's 'written' flag)
+ */
+ int declonly : 1;
};
struct _warning_t {
--
2.17.1
July 5, 2019