From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- configure.ac | 2 +- libs/vkd3d/device.c | 22 ++++++++++++++++++ libs/vkd3d/state.c | 47 +++++++++++++++++++++++++++++--------- libs/vkd3d/vkd3d_private.h | 4 +++- tests/d3d12.c | 2 +- tests/d3d12_crosstest.h | 11 +++++++++ 6 files changed, 74 insertions(+), 14 deletions(-)
diff --git a/configure.ac b/configure.ac index 4d7b83a6e161..029278126b49 100644 --- a/configure.ac +++ b/configure.ac @@ -67,7 +67,7 @@ AS_IF([test "x$ac_cv_header_spirv_unified1_GLSL_std_450_h" != "xyes" \ -a "x$ac_cv_header_vulkan_GLSL_std_450_h" != "xyes"], [AC_MSG_ERROR([GLSL.std.450.h not found.])])
-VKD3D_CHECK_VULKAN_HEADER_VERSION([88], [AC_MSG_ERROR([Vulkan headers are too old, 1.1.88 is required.])]) +VKD3D_CHECK_VULKAN_HEADER_VERSION([101], [AC_MSG_ERROR([Vulkan headers are too old, 1.1.101 is required.])])
dnl Check for libraries m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG], [m4_fatal([pkg-config autoconf macros not found.])]) diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 0dbbde4c2d20..bdea5a9067d9 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -135,6 +135,7 @@ static const struct vkd3d_optional_extension_info optional_device_extensions[] = {VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, KHR_push_descriptor)}, /* EXT 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_TRANSFORM_FEEDBACK_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, EXT_transform_feedback)}, @@ -899,6 +900,7 @@ static void vkd3d_trace_physical_device_features(const VkPhysicalDeviceFeatures2 { const VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT *divisor_features; const VkPhysicalDeviceDescriptorIndexingFeaturesEXT *descriptor_indexing; + const VkPhysicalDeviceDepthClipEnableFeaturesEXT *depth_clip_features; const VkPhysicalDeviceFeatures *features = &features2->features; const VkPhysicalDeviceTransformFeedbackFeaturesEXT *xfb;
@@ -1009,6 +1011,13 @@ static void vkd3d_trace_physical_device_features(const VkPhysicalDeviceFeatures2 descriptor_indexing->runtimeDescriptorArray); }
+ depth_clip_features = vk_find_struct(features2->pNext, PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT); + if (depth_clip_features) + { + TRACE(" VkPhysicalDeviceDepthClipEnableFeaturesEXT:\n"); + TRACE(" depthClipEnable: %#x.\n", depth_clip_features->depthClipEnable); + } + xfb = vk_find_struct(features2->pNext, PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT); if (xfb) { @@ -1080,6 +1089,8 @@ static void vkd3d_init_feature_level(struct vkd3d_vulkan_info *vk_info, CHECK_FEATURE(shaderStorageImageWriteWithoutFormat); CHECK_FEATURE(tessellationShader);
+ if (!vk_info->EXT_depth_clip_enable) + WARN("Depth clip enable is not supported.\n"); if (!vk_info->EXT_transform_feedback) WARN("Stream output is not supported.\n");
@@ -1113,6 +1124,7 @@ static HRESULT vkd3d_init_device_caps(struct d3d12_device *device, VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT vertex_divisor_properties; const VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT *divisor_features; const struct vkd3d_optional_device_extensions_info *optional_extensions; + const VkPhysicalDeviceDepthClipEnableFeaturesEXT *depth_clip_features; VkPhysicalDeviceDescriptorIndexingFeaturesEXT *descriptor_indexing; VkPhysicalDeviceMaintenance3Properties maintenance3_properties; VkPhysicalDeviceTransformFeedbackPropertiesEXT xfb_properties; @@ -1240,6 +1252,12 @@ static HRESULT vkd3d_init_device_caps(struct d3d12_device *device, optional_extensions ? optional_extensions->extension_count : 0, *user_extension_supported, vulkan_info, "device");
+ depth_clip_features = vk_find_struct(features2->pNext, PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT); + if (depth_clip_features) + { + vulkan_info->EXT_depth_clip_enable = depth_clip_features->depthClipEnable; + } + divisor_features = vk_find_struct(features2->pNext, PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT); if (get_spec_version(vk_extensions, count, VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME) >= 3 && divisor_features) @@ -1522,6 +1540,7 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device, VkPhysicalDeviceDescriptorIndexingFeaturesEXT descriptor_indexing_features; VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT vertex_divisor_features; const struct vkd3d_optional_device_extensions_info *optional_extensions; + VkPhysicalDeviceDepthClipEnableFeaturesEXT depth_clip_features; VkPhysicalDeviceTransformFeedbackFeaturesEXT xfb_features; struct vkd3d_vulkan_info *vulkan_info = &device->vk_info; struct vkd3d_device_queue_info device_queue_info; @@ -1558,8 +1577,11 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device,
VK_CALL(vkGetPhysicalDeviceMemoryProperties(physical_device, &device->memory_properties));
+ memset(&depth_clip_features, 0, sizeof(depth_clip_features)); + depth_clip_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT; memset(&descriptor_indexing_features, 0, sizeof(descriptor_indexing_features)); descriptor_indexing_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT; + descriptor_indexing_features.pNext = &depth_clip_features.pNext; memset(&xfb_features, 0, sizeof(xfb_features)); xfb_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT; xfb_features.pNext = &descriptor_indexing_features; diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index c7ae63bdc315..85ecb395f3dc 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -19,6 +19,16 @@
#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) { @@ -1496,7 +1506,7 @@ static enum VkCullModeFlagBits vk_cull_mode_from_d3d12(D3D12_CULL_MODE mode) } }
-static void rs_desc_from_d3d12(struct VkPipelineRasterizationStateCreateInfo *vk_desc, +static void rs_desc_from_d3d12(VkPipelineRasterizationStateCreateInfo *vk_desc, const D3D12_RASTERIZER_DESC *d3d12_desc) { vk_desc->sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; @@ -1523,7 +1533,20 @@ static void rs_desc_from_d3d12(struct VkPipelineRasterizationStateCreateInfo *vk FIXME("Ignoring ConservativeRaster %#x.\n", d3d12_desc->ConservativeRaster); }
-static void rs_stream_desc_from_d3d12(VkPipelineRasterizationStateStreamCreateInfoEXT *vk_desc, +static void rs_depth_clip_info_from_d3d12(VkPipelineRasterizationDepthClipStateCreateInfoEXT *depth_clip_info, + VkPipelineRasterizationStateCreateInfo *vk_rs_desc, const D3D12_RASTERIZER_DESC *d3d12_desc) +{ + vk_rs_desc->depthClampEnable = VK_TRUE; + + depth_clip_info->sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT; + depth_clip_info->pNext = NULL; + depth_clip_info->flags = 0; + depth_clip_info->depthClipEnable = d3d12_desc->DepthClipEnable; + + vk_append_struct(vk_rs_desc, depth_clip_info); +} + +static void rs_stream_info_from_d3d12(VkPipelineRasterizationStateStreamCreateInfoEXT *stream_info, VkPipelineRasterizationStateCreateInfo *vk_rs_desc, const D3D12_STREAM_OUTPUT_DESC *so_desc, const struct vkd3d_vulkan_info *vk_info) { @@ -1536,12 +1559,12 @@ static void rs_stream_desc_from_d3d12(VkPipelineRasterizationStateStreamCreateIn return; }
- vk_desc->sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT; - vk_desc->pNext = NULL; - vk_desc->flags = 0; - vk_desc->rasterizationStream = so_desc->RasterizedStream; + stream_info->sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT; + stream_info->pNext = NULL; + stream_info->flags = 0; + stream_info->rasterizationStream = so_desc->RasterizedStream;
- vk_rs_desc->pNext = vk_desc; + vk_append_struct(vk_rs_desc, stream_info); }
static enum VkStencilOp vk_stencil_op_from_d3d12(D3D12_STENCIL_OP op) @@ -1859,13 +1882,13 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s struct vkd3d_shader_interface_info shader_interface; const struct d3d12_root_signature *root_signature; struct vkd3d_shader_signature input_signature; - struct VkSubpassDescription sub_pass_desc; - struct VkRenderPassCreateInfo pass_desc; VkShaderStageFlagBits xfb_stage = 0; VkSampleCountFlagBits sample_count; + VkSubpassDescription sub_pass_desc; const struct vkd3d_format *format; - enum VkVertexInputRate input_rate; + VkRenderPassCreateInfo pass_desc; unsigned int instance_divisor; + VkVertexInputRate input_rate; unsigned int i, j; size_t rt_count; uint32_t mask; @@ -2333,7 +2356,9 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s || so_desc->RasterizedStream == D3D12_SO_NO_RASTERIZED_STREAM) graphics->rs_desc.rasterizerDiscardEnable = VK_TRUE;
- rs_stream_desc_from_d3d12(&graphics->rs_stream_desc, &graphics->rs_desc, so_desc, vk_info); + rs_stream_info_from_d3d12(&graphics->rs_stream_info, &graphics->rs_desc, so_desc, vk_info); + if (vk_info->EXT_depth_clip_enable) + rs_depth_clip_info_from_d3d12(&graphics->rs_depth_clip_info, &graphics->rs_desc, &desc->RasterizerState);
graphics->ms_desc.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; graphics->ms_desc.pNext = NULL; diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 24d26d90ebf5..76fec700f82e 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -95,6 +95,7 @@ struct vkd3d_vulkan_info bool KHR_push_descriptor; /* EXT device extensions */ bool EXT_debug_marker; + bool EXT_depth_clip_enable; bool EXT_descriptor_indexing; bool EXT_transform_feedback; bool EXT_vertex_attribute_divisor; @@ -629,7 +630,8 @@ struct d3d12_graphics_pipeline_state VkPipelineDepthStencilStateCreateInfo ds_desc;
VkSampleMask sample_mask[2]; - VkPipelineRasterizationStateStreamCreateInfoEXT rs_stream_desc; + VkPipelineRasterizationDepthClipStateCreateInfoEXT rs_depth_clip_info; + VkPipelineRasterizationStateStreamCreateInfoEXT rs_stream_info;
const struct d3d12_root_signature *root_signature;
diff --git a/tests/d3d12.c b/tests/d3d12.c index 1f88e68fc0b3..0c19bf3289b8 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -16823,7 +16823,7 @@ static void test_depth_clip(void)
transition_resource_state(command_list, ds.texture, D3D12_RESOURCE_STATE_DEPTH_WRITE, D3D12_RESOURCE_STATE_COPY_SOURCE); - todo_if(!is_mesa_intel_device(context.device)) + bug_if(!is_depth_clip_enable_supported(context.device)) check_sub_resource_float(ds.texture, 0, queue, command_list, 1.0f, 2); reset_command_list(command_list, context.allocator);
diff --git a/tests/d3d12_crosstest.h b/tests/d3d12_crosstest.h index 2103cafd03c4..171c23418028 100644 --- a/tests/d3d12_crosstest.h +++ b/tests/d3d12_crosstest.h @@ -364,6 +364,11 @@ static inline bool is_radv_device(ID3D12Device *device) return false; }
+static inline bool is_depth_clip_enable_supported(ID3D12Device *device) +{ + return true; +} + #else
static bool check_device_extension(VkPhysicalDevice vk_physical_device, const char *name) @@ -585,6 +590,12 @@ static inline bool is_radv_device(ID3D12Device *device) get_driver_properties(device, &properties); return properties.driverID == VK_DRIVER_ID_MESA_RADV_KHR; } + +static inline bool is_depth_clip_enable_supported(ID3D12Device *device) +{ + VkPhysicalDevice vk_physical_device = vkd3d_get_vk_physical_device(device); + return check_device_extension(vk_physical_device, VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME); +} #endif
static void parse_args(int argc, char **argv)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=50512
Your paranoid android.
=== debian9 (build log) ===
error: patch failed: configure.ac:67 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: configure.ac:67 Task: Patch failed to apply