[Mesa-dev] [PATCH 2/3] anv: Use vk_outarray in vkEnumeratePhysicalDevices
Jason Ekstrand
jason at jlekstrand.net
Mon Mar 13 21:32:33 UTC 2017
On Mon, Mar 13, 2017 at 2:23 PM, Chad Versace <chadversary at chromium.org>
wrote:
> No intended change in behavior. Just a refactor.
> ---
> src/intel/vulkan/anv_device.c | 32 ++++++--------------------------
> 1 file changed, 6 insertions(+), 26 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index f04e177771e..35c5a4645ff 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -390,6 +390,7 @@ VkResult anv_EnumeratePhysicalDevices(
> VkPhysicalDevice* pPhysicalDevices)
> {
> ANV_FROM_HANDLE(anv_instance, instance, _instance);
> + VK_OUTARRAY_MAKE(out, pPhysicalDevices, pPhysicalDeviceCount);
> VkResult result;
>
> if (instance->physicalDeviceCount < 0) {
> @@ -411,34 +412,13 @@ VkResult anv_EnumeratePhysicalDevices(
> }
> }
>
> - /* pPhysicalDeviceCount is an out parameter if pPhysicalDevices is
> NULL;
> - * otherwise it's an inout parameter.
> - *
> - * The Vulkan spec (git aaed022) says:
> - *
> - * pPhysicalDeviceCount is a pointer to an unsigned integer variable
> - * that is initialized with the number of devices the application is
> - * prepared to receive handles to. pname:pPhysicalDevices is
> pointer to
> - * an array of at least this many VkPhysicalDevice handles [...].
> - *
> - * Upon success, if pPhysicalDevices is NULL,
> vkEnumeratePhysicalDevices
> - * overwrites the contents of the variable pointed to by
> - * pPhysicalDeviceCount with the number of physical devices in in
> the
> - * instance; otherwise, vkEnumeratePhysicalDevices overwrites
> - * pPhysicalDeviceCount with the number of physical handles written
> to
> - * pPhysicalDevices.
> - */
> - if (!pPhysicalDevices) {
> - *pPhysicalDeviceCount = instance->physicalDeviceCount;
> - } else if (*pPhysicalDeviceCount >= 1) {
> - pPhysicalDevices[0] = anv_physical_device_to_handle(
> &instance->physicalDevice);
> - *pPhysicalDeviceCount = 1;
> - } else if (*pPhysicalDeviceCount < instance->physicalDeviceCount) {
> - return VK_INCOMPLETE;
> - } else {
> - *pPhysicalDeviceCount = 0;
> + vk_outarray_append(&out, i) {
> + *i = anv_physical_device_to_handle(&instance->physicalDevice);
> }
>
> + if (vk_outarray_is_incomple(&out))
> + return VK_INCOMPLETE;
>
I still think I'd prefer a vk_outarray_status() helper and this would be
"return vk_outarray_status(&out)". But meh...
> +
> return VK_SUCCESS;
> }
>
> --
> 2.12.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170313/c68a59a1/attachment-0001.html>
More information about the mesa-dev
mailing list