diff options
author | Yiwei Zhang <zzyiwei@chromium.org> | 2023-06-15 13:34:18 -0700 |
---|---|---|
committer | Yiwei Zhang <zzyiwei@chromium.org> | 2023-06-16 16:28:50 -0700 |
commit | bb33fb10fad9d27b0b2737a691df6e75ce099829 (patch) | |
tree | c2f1efb8bbe10f5242fb67b7115a9cbff4c0c25d | |
parent | d616f6575c73ce87d8c6f6278e5c60479beb9c95 (diff) |
vkr: properly bail physical device group enumeration failure
Updated comments around as well, and left a TODO to fix it.
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1163>
-rw-r--r-- | src/venus/vkr_physical_device.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/venus/vkr_physical_device.c b/src/venus/vkr_physical_device.c index a3bbde4..3ba4393 100644 --- a/src/venus/vkr_physical_device.c +++ b/src/venus/vkr_physical_device.c @@ -88,7 +88,11 @@ vkr_instance_lookup_physical_device(struct vkr_instance *instance, VkPhysicalDevice handle) { for (uint32_t i = 0; i < instance->physical_device_count; i++) { - /* XXX this assumes VkPhysicalDevice handles are unique */ + /* VkPhysicalDevice handles are fine to contain duplicates. Client side always + * returns unique handles upon the first enumeration call (either physical deivces + * or groups). The other enumeration call later can return duplicate handles based + * on this lookup, which is fine since still matching the Vulkan driver. + */ if (instance->physical_device_handles[i] == handle) return instance->physical_devices[i]; } @@ -380,7 +384,7 @@ vkr_dispatch_vkEnumeratePhysicalDeviceGroups( if (!orig_props) return; - /* XXX this assumes vkEnumeratePhysicalDevices is called first */ + /* TODO avoid requiring venus driver to call vkEnumeratePhysicalDevices first */ /* replace VkPhysicalDevice handles by object ids */ for (uint32_t i = 0; i < *args->pPhysicalDeviceGroupCount; i++) { const VkPhysicalDeviceGroupProperties *props = @@ -392,6 +396,14 @@ vkr_dispatch_vkEnumeratePhysicalDeviceGroups( for (uint32_t j = 0; j < props->physicalDeviceCount; j++) { const struct vkr_physical_device *physical_dev = vkr_instance_lookup_physical_device(instance, props->physicalDevices[j]); + if (!physical_dev) { + vkr_log("venus driver is required to call vkEnumeratePhysicalDevices first"); + args->ret = VK_ERROR_INITIALIZATION_FAILED; + if (orig_props) + free(args->pPhysicalDeviceGroupProperties); + return; + } + vkr_cs_handle_store_id((void **)&out->physicalDevices[j], physical_dev->base.id, VK_OBJECT_TYPE_PHYSICAL_DEVICE); } |