mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 22:49:13 +02:00
venus: group physical device fields with a struct
This makes it clear what the mutex protects. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Ryan Neph <ryanneph@google.com> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12653>
This commit is contained in:
parent
7aef59ccd2
commit
fc74233363
3 changed files with 28 additions and 26 deletions
|
|
@ -670,7 +670,7 @@ vn_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
|||
return vn_error(NULL, result);
|
||||
}
|
||||
|
||||
mtx_init(&instance->physical_device_mutex, mtx_plain);
|
||||
mtx_init(&instance->physical_device.mutex, mtx_plain);
|
||||
|
||||
if (!vn_icd_supports_api_version(
|
||||
instance->base.base.app_info.api_version)) {
|
||||
|
|
@ -759,7 +759,7 @@ fail:
|
|||
vn_renderer_destroy(instance->renderer, alloc);
|
||||
}
|
||||
|
||||
mtx_destroy(&instance->physical_device_mutex);
|
||||
mtx_destroy(&instance->physical_device.mutex);
|
||||
|
||||
vn_instance_base_fini(&instance->base);
|
||||
vk_free(alloc, instance);
|
||||
|
|
@ -778,12 +778,13 @@ vn_DestroyInstance(VkInstance _instance,
|
|||
if (!instance)
|
||||
return;
|
||||
|
||||
if (instance->physical_devices) {
|
||||
vk_free(alloc, instance->physical_device_groups);
|
||||
for (uint32_t i = 0; i < instance->physical_device_count; i++)
|
||||
vn_physical_device_fini(&instance->physical_devices[i]);
|
||||
vk_free(alloc, instance->physical_devices);
|
||||
if (instance->physical_device.devices) {
|
||||
for (uint32_t i = 0; i < instance->physical_device.device_count; i++)
|
||||
vn_physical_device_fini(&instance->physical_device.devices[i]);
|
||||
vk_free(alloc, instance->physical_device.devices);
|
||||
vk_free(alloc, instance->physical_device.groups);
|
||||
}
|
||||
mtx_destroy(&instance->physical_device.mutex);
|
||||
|
||||
vn_call_vkDestroyInstance(instance, _instance, NULL);
|
||||
|
||||
|
|
@ -804,8 +805,6 @@ vn_DestroyInstance(VkInstance _instance,
|
|||
mtx_destroy(&instance->roundtrip_mutex);
|
||||
vn_renderer_destroy(instance->renderer, alloc);
|
||||
|
||||
mtx_destroy(&instance->physical_device_mutex);
|
||||
|
||||
driDestroyOptionCache(&instance->dri_options);
|
||||
driDestroyOptionInfo(&instance->available_dri_options);
|
||||
|
||||
|
|
|
|||
|
|
@ -71,11 +71,14 @@ struct vn_instance {
|
|||
void *ptr;
|
||||
} reply;
|
||||
|
||||
mtx_t physical_device_mutex;
|
||||
struct vn_physical_device *physical_devices;
|
||||
uint32_t physical_device_count;
|
||||
VkPhysicalDeviceGroupProperties *physical_device_groups;
|
||||
uint32_t physical_device_group_count;
|
||||
struct {
|
||||
mtx_t mutex;
|
||||
|
||||
struct vn_physical_device *devices;
|
||||
uint32_t device_count;
|
||||
VkPhysicalDeviceGroupProperties *groups;
|
||||
uint32_t group_count;
|
||||
} physical_device;
|
||||
|
||||
/* XXX staged features to be merged to core venus protocol */
|
||||
VkVenusExperimentalFeatures100000MESA experimental;
|
||||
|
|
|
|||
|
|
@ -1252,8 +1252,8 @@ vn_instance_enumerate_physical_device_groups_locked(
|
|||
|
||||
vk_free(alloc, temp_objs);
|
||||
|
||||
instance->physical_device_groups = groups;
|
||||
instance->physical_device_group_count = count;
|
||||
instance->physical_device.groups = groups;
|
||||
instance->physical_device.group_count = count;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
|
@ -1265,9 +1265,9 @@ vn_instance_enumerate_physical_devices(struct vn_instance *instance)
|
|||
struct vn_physical_device *physical_devs = NULL;
|
||||
VkResult result;
|
||||
|
||||
mtx_lock(&instance->physical_device_mutex);
|
||||
mtx_lock(&instance->physical_device.mutex);
|
||||
|
||||
if (instance->physical_devices) {
|
||||
if (instance->physical_device.devices) {
|
||||
result = VK_SUCCESS;
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -1348,8 +1348,8 @@ vn_instance_enumerate_physical_devices(struct vn_instance *instance)
|
|||
goto out;
|
||||
}
|
||||
|
||||
instance->physical_devices = physical_devs;
|
||||
instance->physical_device_count = count;
|
||||
instance->physical_device.devices = physical_devs;
|
||||
instance->physical_device.device_count = count;
|
||||
|
||||
out:
|
||||
if (result != VK_SUCCESS && physical_devs) {
|
||||
|
|
@ -1358,7 +1358,7 @@ out:
|
|||
vk_free(alloc, physical_devs);
|
||||
}
|
||||
|
||||
mtx_unlock(&instance->physical_device_mutex);
|
||||
mtx_unlock(&instance->physical_device.mutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -1376,10 +1376,10 @@ vn_EnumeratePhysicalDevices(VkInstance _instance,
|
|||
return vn_error(instance, result);
|
||||
|
||||
VK_OUTARRAY_MAKE(out, pPhysicalDevices, pPhysicalDeviceCount);
|
||||
for (uint32_t i = 0; i < instance->physical_device_count; i++) {
|
||||
for (uint32_t i = 0; i < instance->physical_device.device_count; i++) {
|
||||
vk_outarray_append(&out, physical_dev) {
|
||||
*physical_dev =
|
||||
vn_physical_device_to_handle(&instance->physical_devices[i]);
|
||||
*physical_dev = vn_physical_device_to_handle(
|
||||
&instance->physical_device.devices[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1400,9 +1400,9 @@ vn_EnumeratePhysicalDeviceGroups(
|
|||
|
||||
VK_OUTARRAY_MAKE(out, pPhysicalDeviceGroupProperties,
|
||||
pPhysicalDeviceGroupCount);
|
||||
for (uint32_t i = 0; i < instance->physical_device_group_count; i++) {
|
||||
for (uint32_t i = 0; i < instance->physical_device.group_count; i++) {
|
||||
vk_outarray_append(&out, props) {
|
||||
*props = instance->physical_device_groups[i];
|
||||
*props = instance->physical_device.groups[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue