diff options
author | Lina Versace <linyaa@google.com> | 2023-03-23 13:57:08 -0700 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-03-30 09:55:40 +0000 |
commit | 85007a5caf124a5924eee5189d1b71d89c8e74ec (patch) | |
tree | dfd429ae13c3dec9e2b6b2efcfc411e45a0f32eb /src/virtio | |
parent | 436a0d2609426c32ed708290bfa7b43a3de3dedd (diff) | |
download | mesa-85007a5caf124a5924eee5189d1b71d89c8e74ec.tar.gz |
venus: Refactor vn_physical_device_init_memory_properties
Improve readability.
Signed-off-by: Lina Versace <linyaa@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22099>
Diffstat (limited to 'src/virtio')
-rw-r--r-- | src/virtio/vulkan/vn_physical_device.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/virtio/vulkan/vn_physical_device.c b/src/virtio/vulkan/vn_physical_device.c index 0acdaf0bcc5..19ac85b2981 100644 --- a/src/virtio/vulkan/vn_physical_device.c +++ b/src/virtio/vulkan/vn_physical_device.c @@ -770,29 +770,26 @@ vn_physical_device_init_memory_properties( struct vn_physical_device *physical_dev) { struct vn_instance *instance = physical_dev->instance; + VkPhysicalDeviceMemoryProperties2 *props2 = + &physical_dev->memory_properties; + VkPhysicalDeviceMemoryProperties *props1 = &props2->memoryProperties; - physical_dev->memory_properties.sType = - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2; + props2->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2; vn_call_vkGetPhysicalDeviceMemoryProperties2( - instance, vn_physical_device_to_handle(physical_dev), - &physical_dev->memory_properties); + instance, vn_physical_device_to_handle(physical_dev), props2); - VkPhysicalDeviceMemoryProperties *props = - &physical_dev->memory_properties.memoryProperties; - const uint32_t host_flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | - VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | - VK_MEMORY_PROPERTY_HOST_CACHED_BIT; + for (uint32_t i = 0; i < props1->memoryTypeCount; i++) { + VkMemoryType *type = &props1->memoryTypes[i]; - for (uint32_t i = 0; i < props->memoryTypeCount; i++) { /* Kernel makes every mapping coherent. If a memory type is truly * incoherent, it's better to remove the host-visible flag than silently * making it coherent. */ - const bool coherent = props->memoryTypes[i].propertyFlags & - VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; - if (!coherent) - props->memoryTypes[i].propertyFlags &= ~host_flags; + if (!(type->propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) { + type->propertyFlags &= ~(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_CACHED_BIT); + } } } |