mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-06 13:10:10 +01:00
venus: cache VkFormatProperties
This is for fossilize-replay which keeps querying for the same formats. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14966>
This commit is contained in:
parent
e392dd8237
commit
7cb2e9a8f0
2 changed files with 62 additions and 2 deletions
|
|
@ -1166,6 +1166,10 @@ vn_physical_device_init(struct vn_physical_device *physical_dev)
|
|||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
simple_mtx_init(&physical_dev->format_update_mutex, mtx_plain);
|
||||
util_sparse_array_init(&physical_dev->format_properties,
|
||||
sizeof(struct vn_format_properties_entry), 64);
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
||||
fail:
|
||||
|
|
@ -1180,6 +1184,9 @@ vn_physical_device_fini(struct vn_physical_device *physical_dev)
|
|||
struct vn_instance *instance = physical_dev->instance;
|
||||
const VkAllocationCallbacks *alloc = &instance->base.base.alloc;
|
||||
|
||||
simple_mtx_destroy(&physical_dev->format_update_mutex);
|
||||
util_sparse_array_finish(&physical_dev->format_properties);
|
||||
|
||||
vn_wsi_fini(physical_dev);
|
||||
vk_free(alloc, physical_dev->extension_spec_versions);
|
||||
vk_free(alloc, physical_dev->queue_family_properties);
|
||||
|
|
@ -1574,6 +1581,27 @@ vn_GetPhysicalDeviceMemoryProperties(
|
|||
*pMemoryProperties = physical_dev->memory_properties.memoryProperties;
|
||||
}
|
||||
|
||||
static struct vn_format_properties_entry *
|
||||
vn_physical_device_get_format_properties(
|
||||
struct vn_physical_device *physical_dev, VkFormat format)
|
||||
{
|
||||
return util_sparse_array_get(&physical_dev->format_properties, format);
|
||||
}
|
||||
|
||||
static void
|
||||
vn_physical_device_add_format_properties(
|
||||
struct vn_physical_device *physical_dev,
|
||||
struct vn_format_properties_entry *entry,
|
||||
const VkFormatProperties *props)
|
||||
{
|
||||
simple_mtx_lock(&physical_dev->format_update_mutex);
|
||||
if (!entry->valid) {
|
||||
entry->properties = *props;
|
||||
entry->valid = true;
|
||||
}
|
||||
simple_mtx_unlock(&physical_dev->format_update_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
vn_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice,
|
||||
VkFormat format,
|
||||
|
|
@ -1581,10 +1609,19 @@ vn_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice,
|
|||
{
|
||||
struct vn_physical_device *physical_dev =
|
||||
vn_physical_device_from_handle(physicalDevice);
|
||||
struct vn_format_properties_entry *entry =
|
||||
vn_physical_device_get_format_properties(physical_dev, format);
|
||||
|
||||
if (entry->valid) {
|
||||
*pFormatProperties = entry->properties;
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO query all formats during init */
|
||||
vn_call_vkGetPhysicalDeviceFormatProperties(
|
||||
physical_dev->instance, physicalDevice, format, pFormatProperties);
|
||||
|
||||
vn_physical_device_add_format_properties(physical_dev, entry,
|
||||
pFormatProperties);
|
||||
}
|
||||
|
||||
VkResult
|
||||
|
|
@ -2137,9 +2174,22 @@ vn_GetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice,
|
|||
struct vn_physical_device *physical_dev =
|
||||
vn_physical_device_from_handle(physicalDevice);
|
||||
|
||||
/* TODO query all formats during init */
|
||||
struct vn_format_properties_entry *entry = NULL;
|
||||
if (!pFormatProperties->pNext) {
|
||||
entry = vn_physical_device_get_format_properties(physical_dev, format);
|
||||
if (entry->valid) {
|
||||
pFormatProperties->formatProperties = entry->properties;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
vn_call_vkGetPhysicalDeviceFormatProperties2(
|
||||
physical_dev->instance, physicalDevice, format, pFormatProperties);
|
||||
|
||||
if (entry) {
|
||||
vn_physical_device_add_format_properties(
|
||||
physical_dev, entry, &pFormatProperties->formatProperties);
|
||||
}
|
||||
}
|
||||
|
||||
struct vn_physical_device_image_format_info {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,15 @@
|
|||
|
||||
#include "vn_common.h"
|
||||
|
||||
#include "util/sparse_array.h"
|
||||
|
||||
#include "vn_wsi.h"
|
||||
|
||||
struct vn_format_properties_entry {
|
||||
atomic_bool valid;
|
||||
VkFormatProperties properties;
|
||||
};
|
||||
|
||||
struct vn_physical_device {
|
||||
struct vn_physical_device_base base;
|
||||
|
||||
|
|
@ -69,6 +76,9 @@ struct vn_physical_device {
|
|||
VkExternalSemaphoreHandleTypeFlags external_timeline_semaphore_handles;
|
||||
|
||||
struct wsi_device wsi_device;
|
||||
|
||||
simple_mtx_t format_update_mutex;
|
||||
struct util_sparse_array format_properties;
|
||||
};
|
||||
VK_DEFINE_HANDLE_CASTS(vn_physical_device,
|
||||
base.base.base,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue