=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d: Add support for VK_EXT_shader_demote_to_helper_invocation.

Alexandre Julliard julliard at winehq.org
Wed Jul 31 13:43:29 CDT 2019


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

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Sat Jul  6 07:36:30 2019 +0200

vkd3d: Add support for VK_EXT_shader_demote_to_helper_invocation.

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        | 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 b9ac829..979bb8c 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 26d4a7a..59a70b9 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 6e2dc2b..6fe8524 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;
 };
 




More information about the wine-cvs mailing list