Mesa (main): venus: Use maintenance4 to get max_size_buffer
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jul 8 04:36:09 UTC 2022
Module: Mesa
Branch: main
Commit: 48be8a9875455562cc26d3ea662ca0eeccea08e2
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=48be8a9875455562cc26d3ea662ca0eeccea08e2
Author: Igor Torrente <igor.torrente at collabora.com>
Date: Thu Jun 30 09:50:36 2022 -0300
venus: Use maintenance4 to get max_size_buffer
This should help speedup the device initalization process.
Signed-off-by: Igor Torrente <igor.torrente at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17399>
---
src/virtio/vulkan/vn_buffer.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/virtio/vulkan/vn_buffer.c b/src/virtio/vulkan/vn_buffer.c
index 6cc571c90b0..00782301341 100644
--- a/src/virtio/vulkan/vn_buffer.c
+++ b/src/virtio/vulkan/vn_buffer.c
@@ -15,6 +15,7 @@
#include "vn_android.h"
#include "vn_device.h"
+#include "vn_physical_device.h"
#include "vn_device_memory.h"
/* buffer commands */
@@ -120,7 +121,7 @@ vn_buffer_cache_entries_create(struct vn_device *dev,
buf = vn_buffer_from_handle(buf_handle);
- /* TODO remove below after VK_KHR_maintenance4 is available */
+ /* TODO remove below after VK_KHR_maintenance4 becomes a requirement */
if (buf->requirements.memory.memoryRequirements.alignment <
buf->requirements.memory.memoryRequirements.size) {
vk_free(alloc, entries);
@@ -155,8 +156,8 @@ static VkResult
vn_buffer_get_max_buffer_size(struct vn_device *dev,
uint64_t *out_max_buffer_size)
{
- /* TODO use VK_KHR_maintenance4 when available */
const VkAllocationCallbacks *alloc = &dev->base.base.alloc;
+ struct vn_physical_device *pdev = dev->physical_device;
VkDevice dev_handle = vn_device_to_handle(dev);
VkBuffer buf_handle;
VkBufferCreateInfo create_info = {
@@ -168,6 +169,16 @@ vn_buffer_get_max_buffer_size(struct vn_device *dev,
uint8_t begin = 0;
uint8_t end = 64;
+ if (pdev->features.maintenance4.maintenance4) {
+ *out_max_buffer_size = pdev->properties.maintenance4.maxBufferSize;
+ return VK_SUCCESS;
+ }
+
+ /* For drivers that don't support VK_KHR_maintenance4, we try to estimate
+ * the maxBufferSize using binary search.
+ * TODO remove all the search code after VK_KHR_maintenance4 becomes
+ * a requirement.
+ */
while (begin < end) {
uint8_t mid = (begin + end) >> 1;
create_info.size = 1ull << mid;
@@ -259,7 +270,8 @@ vn_buffer_cache_get_memory_requirements(
create_info->usage)) {
*out = entry->requirements;
- /* TODO remove the comment after VK_KHR_maintenance4 is available
+ /* TODO remove the comment after VK_KHR_maintenance4 becomes a
+ * requirement
*
* This is based on below implementation defined behavior:
*
More information about the mesa-commit
mailing list