If users are running mesa under old version of qemu or have turned off
GL at runtime, virtio gpu driver actually doesn't work. Adds a detection
here so mesa can fall back to software rendering.
v2:
- move detection from loader to virgl (Ilia, Emil)
Signed-off-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Dave Airlie <airlied@redhat.com>
{
struct virgl_drm_winsys *qdws;
int ret;
+ int gl = 0;
struct drm_virtgpu_getparam getparam = {0};
+ getparam.param = VIRTGPU_PARAM_3D_FEATURES;
+ getparam.value = (uint64_t)(uintptr_t)≷
+ ret = drmIoctl(drmFD, DRM_IOCTL_VIRTGPU_GETPARAM, &getparam);
+ if (ret < 0 || !gl)
+ return NULL;
+
qdws = CALLOC_STRUCT(virgl_drm_winsys);
if (!qdws)
return NULL;
int dup_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
vws = virgl_drm_winsys_create(dup_fd);
+ if (!vws) {
+ close(dup_fd);
+ goto unlock;
+ }
pscreen = virgl_create_screen(vws);
if (pscreen) {