From a0d521d268d31eb90ecf4a5303b68dff04deba2f Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Thu, 19 May 2022 02:48:16 +0200 Subject: [PATCH] nvk: use winsys lib Part-of: --- src/nouveau/vulkan/meson.build | 1 + src/nouveau/vulkan/nvk_physical_device.c | 20 ++++++++++++++++++-- src/nouveau/vulkan/nvk_physical_device.h | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/nouveau/vulkan/meson.build b/src/nouveau/vulkan/meson.build index 14faade..63e0e33 100644 --- a/src/nouveau/vulkan/meson.build +++ b/src/nouveau/vulkan/meson.build @@ -38,6 +38,7 @@ nvk_entrypoints = custom_target( nvk_deps = [ dep_libdrm, + idep_nouveau_ws, idep_vulkan_runtime, idep_vulkan_util, idep_vulkan_wsi, diff --git a/src/nouveau/vulkan/nvk_physical_device.c b/src/nouveau/vulkan/nvk_physical_device.c index 140e025..664d81c 100644 --- a/src/nouveau/vulkan/nvk_physical_device.c +++ b/src/nouveau/vulkan/nvk_physical_device.c @@ -59,11 +59,15 @@ VKAPI_ATTR void VKAPI_CALL nvk_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2 *pProperties) { - // VK_FROM_HANDLE(nvk_physical_device, pdevice, physicalDevice); + VK_FROM_HANDLE(nvk_physical_device, pdevice, physicalDevice); pProperties->properties = (VkPhysicalDeviceProperties) { .apiVersion = VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION), .driverVersion = vk_get_driver_version(), + .vendorID = pdevice->dev->vendor_id, + .deviceID = pdevice->dev->device_id, + .deviceType = pdevice->dev->is_integrated ? VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU + : VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, /* More properties */ }; @@ -135,6 +139,12 @@ nvk_physical_device_try_create(struct nvk_instance *instance, instance, VK_ERROR_INCOMPATIBLE_DRIVER, "Unable to open device %s: %m", path); } + struct nouveau_ws_device *ndev = nouveau_ws_device_new(fd); + if (!ndev) { + result = vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER); + goto fail_fd; + } + vk_warn_non_conformant_implementation("nvk"); struct nvk_physical_device *device = @@ -142,7 +152,7 @@ nvk_physical_device_try_create(struct nvk_instance *instance, if (device == NULL) { result = vk_error(instance, VK_ERROR_OUT_OF_HOST_MEMORY); - goto fail_fd; + goto fail_dev_alloc; } struct vk_physical_device_dispatch_table dispatch_table; @@ -164,6 +174,7 @@ nvk_physical_device_try_create(struct nvk_instance *instance, } device->instance = instance; + device->dev = ndev; *device_out = device; @@ -172,6 +183,10 @@ nvk_physical_device_try_create(struct nvk_instance *instance, fail_alloc: vk_free(&instance->vk.alloc, device); +fail_dev_alloc: + nouveau_ws_device_destroy(ndev); + return result; + fail_fd: close(fd); return result; @@ -180,6 +195,7 @@ fail_fd: void nvk_physical_device_destroy(struct nvk_physical_device *device) { + nouveau_ws_device_destroy(device->dev); vk_free(&device->instance->vk.alloc, device); } diff --git a/src/nouveau/vulkan/nvk_physical_device.h b/src/nouveau/vulkan/nvk_physical_device.h index f696045..4487b5d 100644 --- a/src/nouveau/vulkan/nvk_physical_device.h +++ b/src/nouveau/vulkan/nvk_physical_device.h @@ -3,6 +3,8 @@ #include "nvk_private.h" +#include "nouveau_device.h" + #include "vulkan/runtime/vk_physical_device.h" struct nvk_instance; @@ -10,6 +12,7 @@ struct nvk_instance; struct nvk_physical_device { struct vk_physical_device vk; struct nvk_instance *instance; + struct nouveau_ws_device *dev; /* Link in nvk_instance::physical_devices */ struct list_head link; -- 2.7.4