v3dv: check that GPU device matches requirements
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 26 May 2020 06:38:31 +0000 (08:38 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 13 Oct 2020 21:21:30 +0000 (21:21 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

src/broadcom/vulkan/v3dv_device.c

index 52775ba..d0545aa 100644 (file)
@@ -323,6 +323,25 @@ create_display_fd_xcb()
 #endif
 #endif
 
+static bool
+v3d_has_feature(struct v3dv_physical_device *device, enum drm_v3d_param feature)
+{
+   struct drm_v3d_get_param p = {
+      .param = feature,
+   };
+   if (v3dv_ioctl(device->render_fd, DRM_IOCTL_V3D_GET_PARAM, &p) != 0)
+      return false;
+   return p.value;
+}
+
+static bool
+device_has_expected_features(struct v3dv_physical_device *device)
+{
+   return v3d_has_feature(device, DRM_V3D_PARAM_SUPPORTS_TFU) &&
+          v3d_has_feature(device, DRM_V3D_PARAM_SUPPORTS_CSD) &&
+          v3d_has_feature(device, DRM_V3D_PARAM_SUPPORTS_CACHE_FLUSH);
+}
+
 static VkResult
 physical_device_init(struct v3dv_physical_device *device,
                      struct v3dv_instance *instance,
@@ -368,6 +387,16 @@ physical_device_init(struct v3dv_physical_device *device,
       goto fail;
    }
 
+   if (device->devinfo.ver < 42) {
+      result = VK_ERROR_INCOMPATIBLE_DRIVER;
+      goto fail;
+   }
+
+   if (!device_has_expected_features(device)) {
+      result = VK_ERROR_INCOMPATIBLE_DRIVER;
+      goto fail;
+   }
+
    device->compiler = v3d_compiler_init(&device->devinfo);
    device->next_program_id = 0;