Skip to content

Commit

Permalink
New port: graphics/libxatracker
Browse files Browse the repository at this point in the history
XA Tracker is built from Mesa sources and is required by xf86-video-vmware
in order to take advantage of accelerated graphics using the vmwgfx kernel
DRM driver.

This commit also adds libdrm as a runtime requirement for xf86-video-vmware
and patches the DRI device loading routine to work outside of Linux. If no
DRI device exists (vmwgfx kernel driver is not loaded), xf86-video-vmware
will fallback to software rendering.

The vmwgfx kernel driver is available in the drm-kmod port.

Reviewed by:	zeising
Approved by:	imp (mentor), zeising
Differential Revision:	D20153
  • Loading branch information
johalun authored and johalun committed Jun 17, 2019
1 parent 40ce40a commit 434b197
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions graphics/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@
SUBDIR += libwmf
SUBDIR += libwmf-nox11
SUBDIR += libwpg03
SUBDIR += libxatracker
SUBDIR += libyuv
SUBDIR += libzmf
SUBDIR += lightzone
Expand Down
36 changes: 36 additions & 0 deletions graphics/libxatracker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Created by: johalun
# $FreeBSD$

PORTNAME= libxatracker
PORTVERSION= ${MESAVERSION}
CATEGORIES= graphics

COMMENT= Mesa XA state tracker

USE_XORG= xorgproto

.include <bsd.port.options.mk>
.include "${.CURDIR:H:H}/graphics/mesa-dri/Makefile.common"

ONLY_FOR_ARCHS= i386 amd64
ONLY_FOR_ARCHS_REASON= Used only by VMWare supported architectures

CONFIGURE_ARGS+= --disable-dri \
--disable-egl \
--disable-gbm \
--disable-gles2 \
--disable-glx \
--disable-opengl \
--disable-shared-glapi \
--with-gallium-drivers= \
--with-platforms=

MESA_BUILD_WRKSRC= src/util src/compiler
LDFLAGS_i386= -Wl,-znotext

CONFIGURE_ARGS+= --enable-xa
MESA_BUILD_WRKSRC+= src/gallium
MESA_INSTALL_WRKSRC= src/gallium/state_trackers/xa src/gallium/targets/xa

.include "${MASTERDIR}/Makefile.targets"
.include <bsd.port.post.mk>
9 changes: 9 additions & 0 deletions graphics/libxatracker/pkg-descr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Mesa is a 3-D graphics library with an API which is very similar to that
of OpenGL*. To the extent that Mesa utilizes the OpenGL command syntax or
state machine, it is being used with authorization from Silicon Graphics,
Inc. However, the author makes no claim that Mesa is in any way a
compatible replacement for OpenGL or associated with Silicon Graphics, Inc.

XA is a new state tracker designed by VMWare for their virtual GPU driver "vmwgfx".

WWW: http://www.mesa3d.org/
7 changes: 7 additions & 0 deletions graphics/libxatracker/pkg-plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include/xa_composite.h
include/xa_context.h
include/xa_tracker.h
lib/libxatracker.so
lib/libxatracker.so.2
lib/libxatracker.so.2.4.0
libdata/pkgconfig/xatracker.pc
5 changes: 5 additions & 0 deletions x11-drivers/xf86-video-vmware/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ ONLY_FOR_ARCHS_REASON= The vmware gfx protocol is only supported on x86-compatib

XORG_CAT= driver

LIB_DEPENDS+= libdrm.so:graphics/libdrm \
libxatracker.so:graphics/libxatracker

CONFIGURE_ARGS= --without-libudev

.include <bsd.port.options.mk>

.if ${ARCH} == i386
Expand Down
44 changes: 44 additions & 0 deletions x11-drivers/xf86-video-vmware/files/patch-vmwgfx_vmwgfx__dri2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
--- vmwgfx/vmwgfx_dri2.c.orig 2018-05-17 07:42:24 UTC
+++ vmwgfx/vmwgfx_dri2.c
@@ -413,8 +413,7 @@ xorg_dri2_init(ScreenPtr pScreen)
modesettingPtr ms = modesettingPTR(pScrn);
DRI2InfoRec dri2info;
int major, minor;
- char fdPath[VMWGFX_FD_PATH_LEN];
- ssize_t numChar;
+ const char *dev_name;

memset(&dri2info, 0, sizeof(dri2info));

@@ -430,20 +429,13 @@ xorg_dri2_init(ScreenPtr pScreen)
dri2info.fd = ms->fd;
dri2info.driverName = "vmwgfx";

- /*
- * This way of obtaining the DRM device name is a bit
- * os-specific. It would be better to obtain it from
- * drmOpen. Currently this works only for Linux.
- */
- memset(fdPath, 0, VMWGFX_FD_PATH_LEN);
- snprintf(fdPath, VMWGFX_FD_PATH_LEN - 1, "/proc/self/fd/%d", ms->fd);
- numChar = readlink(fdPath, ms->dri2_device_name, VMWGFX_DRI_DEVICE_LEN);
- if (numChar <= 0 || numChar >= VMWGFX_DRI_DEVICE_LEN) {
+ dev_name = drmGetDeviceNameFromFd2(ms->fd);
+ if (!dev_name) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Could not find the drm device name. Disabling dri2.\n");
return FALSE;
}
- ms->dri2_device_name[numChar] = 0;
+ strncpy(ms->dri2_device_name, dev_name, VMWGFX_DRI_DEVICE_LEN);
dri2info.deviceName = ms->dri2_device_name;
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"Path of drm device is \"%s\".\n", ms->dri2_device_name);
@@ -466,6 +458,7 @@ xorg_dri2_init(ScreenPtr pScreen)
dri2info.AuthMagic3 = vmw_dri_auth_magic3;
}
#endif
+ free(dev_name);

return DRI2ScreenInit(pScreen, &dri2info);
}

0 comments on commit 434b197

Please sign in to comment.