From 1893c81521c878c3440fcccbfb76ceff70690605 Mon Sep 17 00:00:00 2001 From: Igor Torrente Date: Wed, 29 Jun 2022 17:38:43 -0300 Subject: [PATCH] venus: Add support to VK_KHR_maintenance4 extension Signed-off-by: Igor Torrente Part-of: --- src/virtio/vulkan/vn_buffer.c | 14 +++++++++++++ src/virtio/vulkan/vn_image.c | 28 ++++++++++++++++++++++++++ src/virtio/vulkan/vn_physical_device.c | 13 ++++++++++++ src/virtio/vulkan/vn_physical_device.h | 2 ++ 4 files changed, 57 insertions(+) diff --git a/src/virtio/vulkan/vn_buffer.c b/src/virtio/vulkan/vn_buffer.c index fa370e079ce..6cc571c90b0 100644 --- a/src/virtio/vulkan/vn_buffer.c +++ b/src/virtio/vulkan/vn_buffer.c @@ -253,6 +253,7 @@ vn_buffer_cache_get_memory_requirements( */ for (uint32_t i = 0; i < cache->entry_count; i++) { const struct vn_buffer_cache_entry *entry = &cache->entries[i]; + // TODO: Fix the spec regarding the usage and alignment behavior if ((entry->create_info->flags == create_info->flags) && ((entry->create_info->usage & create_info->usage) == create_info->usage)) { @@ -528,3 +529,16 @@ vn_DestroyBufferView(VkDevice device, vn_object_base_fini(&view->base); vk_free(alloc, view); } + +void +vn_GetDeviceBufferMemoryRequirements( + VkDevice device, + const VkDeviceBufferMemoryRequirements *pInfo, + VkMemoryRequirements2 *pMemoryRequirements) +{ + struct vn_device *dev = vn_device_from_handle(device); + + /* TODO per-device cache */ + vn_call_vkGetDeviceBufferMemoryRequirements(dev->instance, device, pInfo, + pMemoryRequirements); +} diff --git a/src/virtio/vulkan/vn_image.c b/src/virtio/vulkan/vn_image.c index 44b23c5d1a7..4181522a9f1 100644 --- a/src/virtio/vulkan/vn_image.c +++ b/src/virtio/vulkan/vn_image.c @@ -746,3 +746,31 @@ vn_DestroySamplerYcbcrConversion(VkDevice device, vn_object_base_fini(&conv->base); vk_free(alloc, conv); } + +void +vn_GetDeviceImageMemoryRequirements( + VkDevice device, + const VkDeviceImageMemoryRequirements *pInfo, + VkMemoryRequirements2 *pMemoryRequirements) +{ + struct vn_device *dev = vn_device_from_handle(device); + + /* TODO per-device cache */ + vn_call_vkGetDeviceImageMemoryRequirements(dev->instance, device, pInfo, + pMemoryRequirements); +} + +void +vn_GetDeviceImageSparseMemoryRequirements( + VkDevice device, + const VkDeviceImageMemoryRequirements *pInfo, + uint32_t *pSparseMemoryRequirementCount, + VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) +{ + struct vn_device *dev = vn_device_from_handle(device); + + /* TODO per-device cache */ + vn_call_vkGetDeviceImageSparseMemoryRequirements( + dev->instance, device, pInfo, pSparseMemoryRequirementCount, + pSparseMemoryRequirements); +} diff --git a/src/virtio/vulkan/vn_physical_device.c b/src/virtio/vulkan/vn_physical_device.c index f03d49fe339..2dc2e4f3df8 100644 --- a/src/virtio/vulkan/vn_physical_device.c +++ b/src/virtio/vulkan/vn_physical_device.c @@ -132,6 +132,8 @@ vn_physical_device_init_features(struct vn_physical_device *physical_dev) VN_ADD_EXT_TO_PNEXT(exts->EXT_inline_uniform_block, feats->inline_uniform_block, INLINE_UNIFORM_BLOCK_FEATURES, features2); + VN_ADD_EXT_TO_PNEXT(exts->KHR_maintenance4, feats->maintenance4, + MAINTENANCE_4_FEATURES, features2); VN_ADD_EXT_TO_PNEXT(exts->EXT_shader_demote_to_helper_invocation, feats->shader_demote_to_helper_invocation, SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES, @@ -491,6 +493,8 @@ vn_physical_device_init_properties(struct vn_physical_device *physical_dev) VN_ADD_EXT_TO_PNEXT(exts->EXT_transform_feedback, props->transform_feedback, TRANSFORM_FEEDBACK_PROPERTIES_EXT, properties2); + VN_ADD_EXT_TO_PNEXT(exts->KHR_maintenance4, props->maintenance4, + MAINTENANCE_4_PROPERTIES, properties2); VN_ADD_EXT_TO_PNEXT(exts->EXT_vertex_attribute_divisor, props->vertex_attribute_divisor, VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT, properties2); @@ -996,6 +1000,7 @@ vn_physical_device_get_passthrough_extensions( .EXT_inline_uniform_block = true, .EXT_shader_demote_to_helper_invocation = true, .KHR_copy_commands2 = true, + .KHR_maintenance4 = true, /* EXT */ .EXT_calibrated_timestamps = true, @@ -1621,6 +1626,7 @@ vn_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, *extended_dynamic_state2; VkPhysicalDeviceImageRobustnessFeaturesEXT *image_robustness; VkPhysicalDeviceInlineUniformBlockFeatures *inline_uniform_block; + VkPhysicalDeviceMaintenance4Features *maintenance4; VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures *shader_demote_to_helper_invocation; @@ -1844,6 +1850,9 @@ vn_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT: *u.vertex_attribute_divisor = feats->vertex_attribute_divisor; break; + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES: + *u.maintenance4 = feats->maintenance4; + break; default: break; } @@ -1901,6 +1910,7 @@ vn_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDevicePresentationPropertiesANDROID *presentation_properties; VkPhysicalDeviceProvokingVertexPropertiesEXT *provoking_vertex; VkPhysicalDeviceRobustness2PropertiesEXT *robustness_2; + VkPhysicalDeviceMaintenance4PropertiesKHR *maintenance4; VkPhysicalDeviceTransformFeedbackPropertiesEXT *transform_feedback; VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT *vertex_attribute_divisor; @@ -2145,6 +2155,9 @@ vn_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT: *u.vertex_attribute_divisor = props->vertex_attribute_divisor; break; + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES: + *u.maintenance4 = props->maintenance4; + break; default: break; } diff --git a/src/virtio/vulkan/vn_physical_device.h b/src/virtio/vulkan/vn_physical_device.h index 6a9fb005ec7..8fa4ddc683e 100644 --- a/src/virtio/vulkan/vn_physical_device.h +++ b/src/virtio/vulkan/vn_physical_device.h @@ -28,6 +28,7 @@ struct vn_physical_device_features { VkPhysicalDeviceExtendedDynamicState2FeaturesEXT extended_dynamic_state_2; VkPhysicalDeviceImageRobustnessFeaturesEXT image_robustness; VkPhysicalDeviceInlineUniformBlockFeatures inline_uniform_block; + VkPhysicalDeviceMaintenance4Features maintenance4; VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures shader_demote_to_helper_invocation; @@ -51,6 +52,7 @@ struct vn_physical_device_properties { /* Vulkan 1.3 */ VkPhysicalDeviceInlineUniformBlockProperties inline_uniform_block; + VkPhysicalDeviceMaintenance4Properties maintenance4; /* EXT */ VkPhysicalDeviceConservativeRasterizationPropertiesEXT