vulkan-overlay-layer: Use the new dispatch tables

This lets us drop the dispatch tables in enum_to_str and replace them
with the new, better versions.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
This commit is contained in:
Jason Ekstrand
2021-01-23 11:47:35 -06:00
committed by Marge Bot
parent 74617eea46
commit 1cf035a96b
2 changed files with 21 additions and 102 deletions
+19 -13
View File
@@ -43,11 +43,13 @@
#include "util/simple_mtx.h"
#include "vk_enum_to_str.h"
#include "vk_dispatch_table.h"
#include "vk_util.h"
/* Mapped from VkInstace/VkPhysicalDevice */
struct instance_data {
struct vk_instance_dispatch_table vtable;
struct vk_physical_device_dispatch_table pd_vtable;
VkInstance instance;
struct overlay_params params;
@@ -419,14 +421,14 @@ static void device_map_queues(struct device_data *data,
struct instance_data *instance_data = data->instance;
uint32_t n_family_props;
instance_data->vtable.GetPhysicalDeviceQueueFamilyProperties(data->physical_device,
&n_family_props,
NULL);
instance_data->pd_vtable.GetPhysicalDeviceQueueFamilyProperties(data->physical_device,
&n_family_props,
NULL);
VkQueueFamilyProperties *family_props =
(VkQueueFamilyProperties *)malloc(sizeof(VkQueueFamilyProperties) * n_family_props);
instance_data->vtable.GetPhysicalDeviceQueueFamilyProperties(data->physical_device,
&n_family_props,
family_props);
instance_data->pd_vtable.GetPhysicalDeviceQueueFamilyProperties(data->physical_device,
&n_family_props,
family_props);
uint32_t queue_index = 0;
for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++) {
@@ -1007,7 +1009,7 @@ static uint32_t vk_memory_type(struct device_data *data,
uint32_t type_bits)
{
VkPhysicalDeviceMemoryProperties prop;
data->instance->vtable.GetPhysicalDeviceMemoryProperties(data->physical_device, &prop);
data->instance->pd_vtable.GetPhysicalDeviceMemoryProperties(data->physical_device, &prop);
for (uint32_t i = 0; i < prop.memoryTypeCount; i++)
if ((prop.memoryTypes[i].propertyFlags & properties) == properties && type_bits & (1<<i))
return i;
@@ -2499,10 +2501,11 @@ static VkResult overlay_CreateDevice(
struct device_data *device_data = new_device_data(*pDevice, instance_data);
device_data->physical_device = physicalDevice;
vk_load_device_commands(*pDevice, fpGetDeviceProcAddr, &device_data->vtable);
vk_device_dispatch_table_load(&device_data->vtable,
fpGetDeviceProcAddr, *pDevice);
instance_data->vtable.GetPhysicalDeviceProperties(device_data->physical_device,
&device_data->properties);
instance_data->pd_vtable.GetPhysicalDeviceProperties(device_data->physical_device,
&device_data->properties);
VkLayerDeviceCreateInfo *load_data_info =
get_device_chain_info(pCreateInfo, VK_LOADER_DATA_CALLBACK);
@@ -2547,9 +2550,12 @@ static VkResult overlay_CreateInstance(
if (result != VK_SUCCESS) return result;
struct instance_data *instance_data = new_instance_data(*pInstance);
vk_load_instance_commands(instance_data->instance,
fpGetInstanceProcAddr,
&instance_data->vtable);
vk_instance_dispatch_table_load(&instance_data->vtable,
fpGetInstanceProcAddr,
instance_data->instance);
vk_physical_device_dispatch_table_load(&instance_data->pd_vtable,
fpGetInstanceProcAddr,
instance_data->instance);
instance_data_map_physical_devices(instance_data, true);
parse_overlay_env(&instance_data->params, getenv("VK_LAYER_MESA_OVERLAY_CONFIG"));