v3dv: add support to use v3d simulator
authorAlejandro Piñeiro <apinheiro@igalia.com>
Fri, 29 Nov 2019 12:55:38 +0000 (13:55 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 13 Oct 2020 21:21:25 +0000 (21:21 +0000)
v2: use spaces on both sides of ':'

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

src/broadcom/vulkan/meson.build
src/broadcom/vulkan/v3dv_device.c
src/broadcom/vulkan/v3dv_private.h

index ed3d11b..abf2762 100644 (file)
@@ -63,9 +63,15 @@ libv3dv_files = files(
 # driver.
 v3dv_flags = ['-DV3D_VERSION=42']
 
+dep_v3dv3 = dependency('v3dv3', required : false)
+if dep_v3dv3.found()
+  v3dv_flags += '-DUSE_V3D_SIMULATOR'
+endif
+
 v3dv_deps = [
   dep_libdrm,
   dep_valgrind,
+  dep_v3dv3,
   idep_vulkan_util,
 ]
 
index c1de793..1cde4bc 100644 (file)
@@ -209,6 +209,10 @@ physical_device_finish(struct v3dv_physical_device *device)
    close(device->local_fd);
    if (device->master_fd >= 0)
       close(device->master_fd);
+
+#if using_v3d_simulator
+   v3d_simulator_destroy(device->sim_file);
+#endif
 }
 
 void
@@ -255,13 +259,16 @@ physical_device_init(struct v3dv_physical_device *device,
    snprintf(device->path, ARRAY_SIZE(device->path), "%s", path);
 
    /* FIXME: we will have to do plenty more here */
-   device->name = "Broadcom Video Core VI";
    device->local_fd = fd;
    device->master_fd = -1;
 
    uint8_t zeroes[VK_UUID_SIZE] = { 0 };
    memcpy(device->pipeline_cache_uuid, zeroes, VK_UUID_SIZE);
 
+#if using_v3d_simulator
+   device->sim_file = v3d_simulator_init(device->local_fd);
+#endif
+
    return VK_SUCCESS;
 }
 
index 0d70414..8df8218 100644 (file)
@@ -35,6 +35,8 @@
 #include <vulkan/vulkan.h>
 #include <vulkan/vk_icd.h>
 
+#include <xf86drm.h>
+
 #ifdef HAVE_VALGRIND
 #include <valgrind/valgrind.h>
 #include <valgrind/memcheck.h>
@@ -52,6 +54,7 @@
 #include "v3dv_extensions.h"
 
 #include "vk_alloc.h"
+#include "simulator/v3d_simulator.h"
 
 /*
  * FIXME: confirm value
 
 struct v3dv_instance;
 
+#ifdef USE_V3D_SIMULATOR
+#define using_v3d_simulator true
+#else
+#define using_v3d_simulator false
+#endif
+
+struct v3d_simulator_file;
+
 struct v3dv_device {
    VK_LOADER_DATA _loader_data;
 
@@ -92,6 +103,9 @@ struct v3dv_physical_device {
    uint8_t pipeline_cache_uuid[VK_UUID_SIZE];
 
    /* FIXME: stub */
+   struct v3d_device_info devinfo;
+
+   struct v3d_simulator_file *sim_file;
 };
 
 struct v3dv_app_info {
@@ -220,4 +234,13 @@ V3DV_DEFINE_HANDLE_CASTS(v3dv_queue, VkQueue)
 
 V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_device_memory, VkDeviceMemory)
 
+static inline int
+v3dv_ioctl(int fd, unsigned long request, void *arg)
+{
+   if (using_v3d_simulator)
+      return v3d_simulator_ioctl(fd, request, arg);
+   else
+      return drmIoctl(fd, request, arg);
+}
+
 #endif /* V3DV_PRIVATE_H */