From 8741be3365ea0e69aaed86b62ab8bda61d93fca6 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Sat, 15 Feb 2025 22:47:46 -0800 Subject: [PATCH] venus: fix maintenance5 props init and create flags2 More are found missed from prior maint5 support. This change has properly initialized the maint5 props as well as fixing its new VkPipelineCreateFlags2CreateInfo integrations. Verified with dEQP-VK.*maintenance5* Fixes: be6fece6e1e ("venus: enable VK_KHR_maintenance5") Signed-off-by: Yiwei Zhang Part-of: --- src/virtio/vulkan/vn_physical_device.c | 3 ++ src/virtio/vulkan/vn_pipeline.c | 40 ++++++++++++++++++-------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/virtio/vulkan/vn_physical_device.c b/src/virtio/vulkan/vn_physical_device.c index 05d7fa6467f..57f02507c72 100644 --- a/src/virtio/vulkan/vn_physical_device.c +++ b/src/virtio/vulkan/vn_physical_device.c @@ -481,6 +481,7 @@ vn_physical_device_init_properties(struct vn_physical_device *physical_dev) /* KHR */ VkPhysicalDeviceLineRasterizationPropertiesKHR line_rasterization; + VkPhysicalDeviceMaintenance5PropertiesKHR maintenance_5; VkPhysicalDevicePushDescriptorPropertiesKHR push_descriptor; VkPhysicalDeviceFragmentShadingRatePropertiesKHR fragment_shading_rate; VkPhysicalDeviceVertexAttributeDivisorPropertiesKHR @@ -546,6 +547,7 @@ vn_physical_device_init_properties(struct vn_physical_device *physical_dev) /* KHR */ VN_ADD_PNEXT_EXT(props2, LINE_RASTERIZATION_PROPERTIES_KHR, local_props.line_rasterization, exts->KHR_line_rasterization || exts->EXT_line_rasterization); + VN_ADD_PNEXT_EXT(props2, MAINTENANCE_5_PROPERTIES_KHR, local_props.maintenance_5, exts->KHR_maintenance5); VN_ADD_PNEXT_EXT(props2, FRAGMENT_SHADING_RATE_PROPERTIES_KHR, local_props.fragment_shading_rate, exts->KHR_fragment_shading_rate); VN_ADD_PNEXT_EXT(props2, PUSH_DESCRIPTOR_PROPERTIES_KHR, local_props.push_descriptor, exts->KHR_push_descriptor); VN_ADD_PNEXT_EXT(props2, VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_KHR, local_props.vertex_attribute_divisor, exts->KHR_vertex_attribute_divisor); @@ -611,6 +613,7 @@ vn_physical_device_init_properties(struct vn_physical_device *physical_dev) /* KHR */ VN_SET_VK_PROPS_EXT(props, &local_props.fragment_shading_rate, exts->KHR_fragment_shading_rate); VN_SET_VK_PROPS_EXT(props, &local_props.line_rasterization, exts->KHR_line_rasterization || exts->EXT_line_rasterization); + VN_SET_VK_PROPS_EXT(props, &local_props.maintenance_5, exts->KHR_maintenance5); VN_SET_VK_PROPS_EXT(props, &local_props.push_descriptor, exts->KHR_push_descriptor); VN_SET_VK_PROPS_EXT(props, &local_props.vertex_attribute_divisor, exts->KHR_vertex_attribute_divisor); diff --git a/src/virtio/vulkan/vn_pipeline.c b/src/virtio/vulkan/vn_pipeline.c index 465c84eb57f..ee5768bd5de 100644 --- a/src/virtio/vulkan/vn_pipeline.c +++ b/src/virtio/vulkan/vn_pipeline.c @@ -643,8 +643,8 @@ vn_destroy_failed_pipeline_handles(struct vn_device *dev, } #define VN_PIPELINE_CREATE_SYNC_MASK \ - (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT | \ - VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT) + (VK_PIPELINE_CREATE_2_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT | \ + VK_PIPELINE_CREATE_2_EARLY_RETURN_ON_FAILURE_BIT) static struct vn_graphics_pipeline_fix_tmp * vn_graphics_pipeline_fix_tmp_alloc(const VkAllocationCallbacks *alloc, @@ -726,6 +726,7 @@ vn_graphics_pipeline_fix_tmp_alloc(const VkAllocationCallbacks *alloc, static void vn_graphics_pipeline_library_state_update( const VkGraphicsPipelineCreateInfo *info, + VkPipelineCreateFlags2 flags2, struct vn_graphics_pipeline_library_state *restrict gpl) { const VkGraphicsPipelineLibraryCreateInfoEXT *gpl_info = @@ -737,7 +738,7 @@ vn_graphics_pipeline_library_state_update( if (gpl_info) { gpl->mask |= gpl_info->flags; - } else if ((info->flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) || + } else if ((flags2 & VK_PIPELINE_CREATE_2_LIBRARY_BIT_KHR) || lib_count > 0) { gpl->mask |= 0; } else { @@ -1053,6 +1054,7 @@ vn_graphics_pipeline_state_merge( static void vn_graphics_pipeline_state_fill( const VkGraphicsPipelineCreateInfo *info, + VkPipelineCreateFlags2 flags2, struct vn_graphics_pipeline_state *restrict state, struct vn_graphics_pipeline_fix_desc *out_fix_desc) { @@ -1107,7 +1109,7 @@ vn_graphics_pipeline_state_fill( * directly (without linking). */ struct vn_graphics_pipeline_library_state direct_gpl = { 0 }; - vn_graphics_pipeline_library_state_update(info, &direct_gpl); + vn_graphics_pipeline_library_state_update(info, flags2, &direct_gpl); /* From the Vulkan 1.3.251 spec: * VUID-VkGraphicsPipelineCreateInfo-pLibraries-06611 @@ -1260,7 +1262,7 @@ vn_graphics_pipeline_state_fill( if (!is_raster_statically_disabled) { if (state->render_pass.attachment_aspects == VK_IMAGE_ASPECT_METADATA_BIT && - (info->flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR)) { + (flags2 & VK_PIPELINE_CREATE_2_LIBRARY_BIT_KHR)) { /* The app has not yet provided render pass info, neither directly * in this VkGraphicsPipelineCreateInfo nor in any linked pipeline * libraries. Therefore we do not know if the final complete @@ -1313,7 +1315,7 @@ vn_graphics_pipeline_state_fill( * basePipelineIndex is -1, basePipelineHandle must be a valid graphics * VkPipeline handle */ - if ((info->flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) && + if ((flags2 & VK_PIPELINE_CREATE_2_DERIVATIVE_BIT) && info->basePipelineIndex == -1) valid.self.base_pipeline_handle = true; @@ -1635,6 +1637,14 @@ vn_invalidate_pipeline_creation_feedback(const VkBaseInStructure *chain) feedback_info->pPipelineStageCreationFeedbacks[i].flags = 0; } +static inline VkPipelineCreateFlags2 +vn_pipeline_create_flags2(const void *pnext, VkPipelineCreateFlags flags) +{ + const VkPipelineCreateFlags2CreateInfo *flags2 = + vk_find_struct_const(pnext, PIPELINE_CREATE_FLAGS_2_CREATE_INFO); + return flags2 ? flags2->flags : flags; +} + VkResult vn_CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, @@ -1665,8 +1675,14 @@ vn_CreateGraphicsPipelines(VkDevice device, for (uint32_t i = 0; i < createInfoCount; i++) { struct vn_graphics_pipeline *pipeline = vn_graphics_pipeline_from_handle(pPipelines[i]); - vn_graphics_pipeline_state_fill(&pCreateInfos[i], &pipeline->state, - &fix_descs[i]); + + const VkPipelineCreateFlags2 flags2 = vn_pipeline_create_flags2( + pCreateInfos[i].pNext, pCreateInfos[i].flags); + if (flags2 & VN_PIPELINE_CREATE_SYNC_MASK) + want_sync = true; + + vn_graphics_pipeline_state_fill(&pCreateInfos[i], flags2, + &pipeline->state, &fix_descs[i]); } struct vn_graphics_pipeline_fix_tmp *fix_tmp = NULL; @@ -1687,9 +1703,6 @@ vn_CreateGraphicsPipelines(VkDevice device, pipeline->layout = vn_pipeline_layout_ref(dev, layout); } - if ((pCreateInfos[i].flags & VN_PIPELINE_CREATE_SYNC_MASK)) - want_sync = true; - vn_invalidate_pipeline_creation_feedback( (const VkBaseInStructure *)pCreateInfos[i].pNext); } @@ -1753,7 +1766,10 @@ vn_CreateComputePipelines(VkDevice device, layout->has_push_constant_ranges) { pipeline->layout = vn_pipeline_layout_ref(dev, layout); } - if ((pCreateInfos[i].flags & VN_PIPELINE_CREATE_SYNC_MASK)) + + if (vn_pipeline_create_flags2(pCreateInfos[i].pNext, + pCreateInfos[i].flags) & + VN_PIPELINE_CREATE_SYNC_MASK) want_sync = true; vn_invalidate_pipeline_creation_feedback(