turnip: Gather some device info.
authorBas Nieuwenhuizen <basni@chromium.org>
Thu, 9 Aug 2018 09:09:01 +0000 (11:09 +0200)
committerChia-I Wu <olvaffe@gmail.com>
Mon, 11 Mar 2019 17:01:33 +0000 (10:01 -0700)
src/freedreno/vulkan/meson.build
src/freedreno/vulkan/tu_device.c
src/freedreno/vulkan/tu_private.h

index b7de6bd5bb8976a0db0a85a37f94f3d36fc3f1d5..a9380509afcc539b890e7efd3e8a08228630532d 100644 (file)
@@ -77,9 +77,13 @@ libvulkan_freedreno = shared_library(
   'vulkan_freedreno',
   [libtu_files, tu_entrypoints, tu_extensions_c, vk_format_table_c],
   include_directories : [
-    inc_common, inc_compiler, inc_vulkan_util,
+    inc_common,
+    inc_compiler,
+    inc_vulkan_util,
+    inc_freedreno,
   ],
   link_with : [
+    libfreedreno_drm,
     libvulkan_util,
     libmesa_util,
   ],
index 7e0f7638b8c4c3b6a0bef8e3d62b1d2d1ab3db4f..9e47c19c61cd9c6bfc8b576e0a2d67684989d2f9 100644 (file)
@@ -75,6 +75,8 @@ tu_physical_device_init(struct tu_physical_device *device,
    drmVersionPtr version;
    int fd;
    int master_fd = -1;
+   struct fd_pipe *tmp_pipe = NULL;
+   uint64_t val;
 
    fd = open(path, O_RDWR | O_CLOEXEC);
    if (fd < 0) {
@@ -130,7 +132,49 @@ tu_physical_device_init(struct tu_physical_device *device,
    device->master_fd = master_fd;
    device->local_fd = fd;
 
-   if (tu_device_get_cache_uuid(0 /* TODO */, device->cache_uuid)) {
+   device->drm_device = fd_device_new_dup(fd);
+   if (!device->drm_device) {
+      result = vk_errorf(
+        instance, VK_ERROR_INITIALIZATION_FAILED, "could not create the libdrm device");
+       goto fail;
+   }
+
+   tmp_pipe = fd_pipe_new(device->drm_device, FD_PIPE_3D);
+   if (!tmp_pipe) {
+      result = vk_errorf(
+        instance, VK_ERROR_INITIALIZATION_FAILED, "could not open the 3D pipe");
+      goto fail;
+   }
+
+   if (fd_pipe_get_param(tmp_pipe, FD_GPU_ID, &val)) {
+      result = vk_errorf(
+        instance, VK_ERROR_INITIALIZATION_FAILED, "could not get GPU ID");
+      goto fail;
+   }
+   device->gpu_id = val;
+
+   if (fd_pipe_get_param(tmp_pipe, FD_GMEM_SIZE, &val)) {
+      result = vk_errorf(
+        instance, VK_ERROR_INITIALIZATION_FAILED, "could not get GMEM size");
+      goto fail;
+   }
+   device->gmem_size = val;
+
+   fd_pipe_del(tmp_pipe);
+   tmp_pipe = NULL;
+
+   memset(device->name, 0, sizeof(device->name));
+   sprintf(device->name, "FD%d", device->gpu_id);
+
+   switch(device->gpu_id) {
+   case 530:
+      break;
+   default:
+      if (instance->debug_flags & TU_DEBUG_STARTUP)
+         tu_logi("Device '%s' is not supported.", device->name);
+      goto fail;
+   }
+   if (tu_device_get_cache_uuid(device->gpu_id, device->cache_uuid)) {
       result = vk_errorf(
         instance, VK_ERROR_INITIALIZATION_FAILED, "cannot generate UUID");
       goto fail;
@@ -160,6 +204,10 @@ tu_physical_device_init(struct tu_physical_device *device,
    return VK_SUCCESS;
 
 fail:
+   if (tmp_pipe)
+      fd_pipe_del(tmp_pipe);
+   if (device->drm_device)
+      fd_device_del(device->drm_device);
    close(fd);
    if (master_fd != -1)
       close(master_fd);
index 2f035951956b55c640eae82f8dd4f9a0de98a36a..21237fd14e7bd429afe532b45d251c331ab37435 100644 (file)
@@ -66,6 +66,8 @@ typedef uint32_t xcb_window_t;
 #include <vulkan/vulkan.h>
 #include <vulkan/vulkan_intel.h>
 
+#include "drm/freedreno_ringbuffer.h"
+
 #include "tu_entrypoints.h"
 
 #define MAX_VBS 32
@@ -292,6 +294,10 @@ struct tu_physical_device
    int local_fd;
    int master_fd;
 
+   struct fd_device *drm_device;
+   unsigned gpu_id;
+   uint32_t gmem_size;
+
    /* This is the drivers on-disk cache used as a fallback as opposed to
     * the pipeline cache defined by apps.
     */