nvk: use winsys lib
authorKarol Herbst <kherbst@redhat.com>
Thu, 19 May 2022 00:48:16 +0000 (02:48 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:31:52 +0000 (21:31 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/vulkan/meson.build
src/nouveau/vulkan/nvk_physical_device.c
src/nouveau/vulkan/nvk_physical_device.h

index 14faade..63e0e33 100644 (file)
@@ -38,6 +38,7 @@ nvk_entrypoints = custom_target(
 
 nvk_deps = [
   dep_libdrm,
+  idep_nouveau_ws,
   idep_vulkan_runtime,
   idep_vulkan_util,
   idep_vulkan_wsi,
index 140e025..664d81c 100644 (file)
@@ -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);
 }
 
index f696045..4487b5d 100644 (file)
@@ -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;