1bf215546Sopenharmony_ciVMware SVGA3D
2bf215546Sopenharmony_ci=============
3bf215546Sopenharmony_ci
4bf215546Sopenharmony_ciThis page describes how to build, install and use the
5bf215546Sopenharmony_ci`VMware <https://www.vmware.com/>`__ guest GL driver (aka the SVGA or
6bf215546Sopenharmony_ciSVGA3D driver) for Linux using the latest source code. This driver gives
7bf215546Sopenharmony_cia Linux virtual machine access to the host's GPU for
8bf215546Sopenharmony_cihardware-accelerated 3D. VMware Workstation running on Linux or Windows
9bf215546Sopenharmony_ciand VMware Fusion running on MacOS are all supported.
10bf215546Sopenharmony_ci
11bf215546Sopenharmony_ciWith the August 2015 Workstation 12 / Fusion 8 releases, OpenGL 3.3 is
12bf215546Sopenharmony_cisupported in the guest. This requires:
13bf215546Sopenharmony_ci
14bf215546Sopenharmony_ci-  The VM is configured for virtual hardware version 12.
15bf215546Sopenharmony_ci-  The host OS, GPU and graphics driver supports DX11 (Windows) or
16bf215546Sopenharmony_ci   OpenGL 4.0 (Linux, Mac)
17bf215546Sopenharmony_ci-  On Linux, the vmwgfx kernel module must be version 2.9.0 or later.
18bf215546Sopenharmony_ci-  A recent version of Mesa with the updated svga Gallium driver.
19bf215546Sopenharmony_ci
20bf215546Sopenharmony_ciOtherwise, OpenGL 2.1 is supported.
21bf215546Sopenharmony_ci
22bf215546Sopenharmony_ciWith the Fall 2018 Workstation 15 / Fusion 11 releases, additional
23bf215546Sopenharmony_cifeatures are supported in the driver:
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci-  Multisample antialiasing (2x, 4x)
26bf215546Sopenharmony_ci-  GL_ARB/AMD_draw_buffers_blend
27bf215546Sopenharmony_ci-  GL_ARB_sample_shading
28bf215546Sopenharmony_ci-  GL_ARB_texture_cube_map_array
29bf215546Sopenharmony_ci-  GL_ARB_texture_gather
30bf215546Sopenharmony_ci-  GL_ARB_texture_query_lod
31bf215546Sopenharmony_ci-  GL_EXT/OES_draw_buffers_indexed
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ciThis requires version 2.15.0 or later of the vmwgfx kernel module and
34bf215546Sopenharmony_cithe VM must be configured for hardware version 16 or later.
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_ciOpenGL 3.3 support can be disabled by setting the environment variable
37bf215546Sopenharmony_ciSVGA_VGPU10=0. You will then have OpenGL 2.1 support. This may be useful
38bf215546Sopenharmony_cito work around application bugs (such as incorrect use of the OpenGL 3.x
39bf215546Sopenharmony_cicore profile).
40bf215546Sopenharmony_ci
41bf215546Sopenharmony_ciMost modern Linux distros include the SVGA3D driver so end users
42bf215546Sopenharmony_cishouldn't be concerned with this information. But if your distro lacks
43bf215546Sopenharmony_cithe driver or you want to update to the latest code these instructions
44bf215546Sopenharmony_ciexplain what to do.
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_ciFor more information about the X components see these wiki pages at
47bf215546Sopenharmony_cix.org:
48bf215546Sopenharmony_ci
49bf215546Sopenharmony_ci-  `Driver Overview <https://wiki.x.org/wiki/vmware>`__
50bf215546Sopenharmony_ci-  `xf86-video-vmware
51bf215546Sopenharmony_ci   Details <https://wiki.x.org/wiki/vmware/vmware3D>`__
52bf215546Sopenharmony_ci
53bf215546Sopenharmony_ciComponents
54bf215546Sopenharmony_ci----------
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_ciThe components involved in this include:
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ci-  Linux kernel module: vmwgfx
59bf215546Sopenharmony_ci-  X server 2D driver: xf86-video-vmware
60bf215546Sopenharmony_ci-  User-space libdrm library
61bf215546Sopenharmony_ci-  Mesa/Gallium OpenGL driver: "svga"
62bf215546Sopenharmony_ci
63bf215546Sopenharmony_ciAll of these components reside in the guest Linux virtual machine. On
64bf215546Sopenharmony_cithe host, all you're doing is running VMware
65bf215546Sopenharmony_ci`Workstation <https://www.vmware.com/products/workstation/>`__ or
66bf215546Sopenharmony_ci`Fusion <https://www.vmware.com/products/fusion/>`__.
67bf215546Sopenharmony_ci
68bf215546Sopenharmony_ciPrerequisites
69bf215546Sopenharmony_ci-------------
70bf215546Sopenharmony_ci
71bf215546Sopenharmony_ci-  Kernel version at least 2.6.25
72bf215546Sopenharmony_ci-  Xserver version at least 1.7
73bf215546Sopenharmony_ci-  Ubuntu: For Ubuntu you need to install a number of build
74bf215546Sopenharmony_ci   dependencies.
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_ci   ::
77bf215546Sopenharmony_ci
78bf215546Sopenharmony_ci      sudo apt-get install git-core
79bf215546Sopenharmony_ci      sudo apt-get install ninja-build meson libpthread-stubs0-dev
80bf215546Sopenharmony_ci      sudo apt-get install xserver-xorg-dev x11proto-xinerama-dev libx11-xcb-dev
81bf215546Sopenharmony_ci      sudo apt-get install libxcb-glx0-dev libxrender-dev
82bf215546Sopenharmony_ci      sudo apt-get build-dep libgl1-mesa-dri libxcb-glx0-dev
83bf215546Sopenharmony_ci        
84bf215546Sopenharmony_ci
85bf215546Sopenharmony_ci-  Fedora: For Fedora you also need to install a number of build
86bf215546Sopenharmony_ci   dependencies.
87bf215546Sopenharmony_ci
88bf215546Sopenharmony_ci   ::
89bf215546Sopenharmony_ci
90bf215546Sopenharmony_ci      sudo yum install mesa-libGL-devel xorg-x11-server-devel xorg-x11-util-macros
91bf215546Sopenharmony_ci      sudo yum install libXrender-devel.i686
92bf215546Sopenharmony_ci      sudo yum install ninja-build meson gcc expat-devel kernel-devel git-core
93bf215546Sopenharmony_ci      sudo yum install makedepend flex bison
94bf215546Sopenharmony_ci        
95bf215546Sopenharmony_ci
96bf215546Sopenharmony_ciDepending on your Linux distro, other packages may be needed. Meson
97bf215546Sopenharmony_cishould tell you what's missing.
98bf215546Sopenharmony_ci
99bf215546Sopenharmony_ciGetting the Latest Source Code
100bf215546Sopenharmony_ci------------------------------
101bf215546Sopenharmony_ci
102bf215546Sopenharmony_ciBegin by saving your current directory location:
103bf215546Sopenharmony_ci
104bf215546Sopenharmony_ci::
105bf215546Sopenharmony_ci
106bf215546Sopenharmony_ci   export TOP=$PWD
107bf215546Sopenharmony_ci     
108bf215546Sopenharmony_ci
109bf215546Sopenharmony_ci-  Mesa/Gallium main branch. This code is used to build libGL, and the
110bf215546Sopenharmony_ci   direct rendering svga driver for libGL, vmwgfx_dri.so, and the X
111bf215546Sopenharmony_ci   acceleration library libxatracker.so.x.x.x.
112bf215546Sopenharmony_ci
113bf215546Sopenharmony_ci   ::
114bf215546Sopenharmony_ci
115bf215546Sopenharmony_ci      git clone https://gitlab.freedesktop.org/mesa/mesa.git
116bf215546Sopenharmony_ci        
117bf215546Sopenharmony_ci
118bf215546Sopenharmony_ci-  VMware Linux guest kernel module. Note that this repo contains the
119bf215546Sopenharmony_ci   complete DRM and TTM code. The vmware-specific driver is really only
120bf215546Sopenharmony_ci   the files prefixed with vmwgfx.
121bf215546Sopenharmony_ci
122bf215546Sopenharmony_ci   ::
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_ci      git clone git://anongit.freedesktop.org/git/mesa/vmwgfx
125bf215546Sopenharmony_ci        
126bf215546Sopenharmony_ci
127bf215546Sopenharmony_ci-  libdrm, a user-space library that interfaces with DRM. Most distros
128bf215546Sopenharmony_ci   ship with this but it's safest to install a newer version. To get the
129bf215546Sopenharmony_ci   latest code from Git:
130bf215546Sopenharmony_ci
131bf215546Sopenharmony_ci   ::
132bf215546Sopenharmony_ci
133bf215546Sopenharmony_ci      git clone https://gitlab.freedesktop.org/mesa/drm.git
134bf215546Sopenharmony_ci        
135bf215546Sopenharmony_ci
136bf215546Sopenharmony_ci-  xf86-video-vmware. The chainloading driver, vmware_drv.so, the legacy
137bf215546Sopenharmony_ci   driver vmwlegacy_drv.so, and the vmwgfx driver vmwgfx_drv.so.
138bf215546Sopenharmony_ci
139bf215546Sopenharmony_ci   ::
140bf215546Sopenharmony_ci
141bf215546Sopenharmony_ci      git clone git://anongit.freedesktop.org/git/xorg/driver/xf86-video-vmware
142bf215546Sopenharmony_ci        
143bf215546Sopenharmony_ci
144bf215546Sopenharmony_ciBuilding the Code
145bf215546Sopenharmony_ci-----------------
146bf215546Sopenharmony_ci
147bf215546Sopenharmony_ci-  Determine where the GL-related libraries reside on your system and
148bf215546Sopenharmony_ci   set the LIBDIR environment variable accordingly.
149bf215546Sopenharmony_ci
150bf215546Sopenharmony_ci   For 32-bit Ubuntu systems:
151bf215546Sopenharmony_ci
152bf215546Sopenharmony_ci   ::
153bf215546Sopenharmony_ci
154bf215546Sopenharmony_ci      export LIBDIR=/usr/lib/i386-linux-gnu
155bf215546Sopenharmony_ci
156bf215546Sopenharmony_ci   For 64-bit Ubuntu systems:
157bf215546Sopenharmony_ci
158bf215546Sopenharmony_ci   ::
159bf215546Sopenharmony_ci
160bf215546Sopenharmony_ci      export LIBDIR=/usr/lib/x86_64-linux-gnu
161bf215546Sopenharmony_ci
162bf215546Sopenharmony_ci   For 32-bit Fedora systems:
163bf215546Sopenharmony_ci
164bf215546Sopenharmony_ci   ::
165bf215546Sopenharmony_ci
166bf215546Sopenharmony_ci      export LIBDIR=/usr/lib
167bf215546Sopenharmony_ci
168bf215546Sopenharmony_ci   For 64-bit Fedora systems:
169bf215546Sopenharmony_ci
170bf215546Sopenharmony_ci   ::
171bf215546Sopenharmony_ci
172bf215546Sopenharmony_ci      export LIBDIR=/usr/lib64
173bf215546Sopenharmony_ci
174bf215546Sopenharmony_ci-  Build libdrm:
175bf215546Sopenharmony_ci
176bf215546Sopenharmony_ci   ::
177bf215546Sopenharmony_ci
178bf215546Sopenharmony_ci      cd $TOP/drm
179bf215546Sopenharmony_ci      meson builddir --prefix=/usr --libdir=${LIBDIR}
180bf215546Sopenharmony_ci      ninja -C builddir
181bf215546Sopenharmony_ci      sudo ninja -C builddir install
182bf215546Sopenharmony_ci        
183bf215546Sopenharmony_ci
184bf215546Sopenharmony_ci-  Build Mesa and the vmwgfx_dri.so driver, the vmwgfx_drv.so xorg
185bf215546Sopenharmony_ci   driver, the X acceleration library libxatracker. The vmwgfx_dri.so is
186bf215546Sopenharmony_ci   used by the OpenGL libraries during direct rendering, and by the Xorg
187bf215546Sopenharmony_ci   server during accelerated indirect GL rendering. The libxatracker
188bf215546Sopenharmony_ci   library is used exclusively by the X server to do render, copy and
189bf215546Sopenharmony_ci   video acceleration:
190bf215546Sopenharmony_ci
191bf215546Sopenharmony_ci   The following configure options doesn't build the EGL system.
192bf215546Sopenharmony_ci
193bf215546Sopenharmony_ci   ::
194bf215546Sopenharmony_ci
195bf215546Sopenharmony_ci      cd $TOP/mesa
196bf215546Sopenharmony_ci      meson builddir --prefix=/usr --libdir=${LIBDIR} -Dgallium-drivers=svga -Ddri-drivers=swrast -Dgallium-xa=true -Ddri3=false
197bf215546Sopenharmony_ci      ninja -C builddir
198bf215546Sopenharmony_ci      sudo ninja -C builddir install
199bf215546Sopenharmony_ci        
200bf215546Sopenharmony_ci
201bf215546Sopenharmony_ci   Note that you may have to install other packages that Mesa depends
202bf215546Sopenharmony_ci   upon if they're not installed in your system. You should be told
203bf215546Sopenharmony_ci   what's missing.
204bf215546Sopenharmony_ci
205bf215546Sopenharmony_ci-  xf86-video-vmware: Now, once libxatracker is installed, we proceed
206bf215546Sopenharmony_ci   with building and replacing the current Xorg driver. First check if
207bf215546Sopenharmony_ci   your system is 32- or 64-bit.
208bf215546Sopenharmony_ci
209bf215546Sopenharmony_ci   ::
210bf215546Sopenharmony_ci
211bf215546Sopenharmony_ci      cd $TOP/xf86-video-vmware
212bf215546Sopenharmony_ci      ./autogen.sh --prefix=/usr --libdir=${LIBDIR}
213bf215546Sopenharmony_ci      make
214bf215546Sopenharmony_ci      sudo make install
215bf215546Sopenharmony_ci        
216bf215546Sopenharmony_ci
217bf215546Sopenharmony_ci-  vmwgfx kernel module. First make sure that any old version of this
218bf215546Sopenharmony_ci   kernel module is removed from the system by issuing
219bf215546Sopenharmony_ci
220bf215546Sopenharmony_ci   ::
221bf215546Sopenharmony_ci
222bf215546Sopenharmony_ci      sudo rm /lib/modules/`uname -r`/kernel/drivers/gpu/drm/vmwgfx.ko*
223bf215546Sopenharmony_ci
224bf215546Sopenharmony_ci   Build and install:
225bf215546Sopenharmony_ci
226bf215546Sopenharmony_ci   ::
227bf215546Sopenharmony_ci
228bf215546Sopenharmony_ci      cd $TOP/vmwgfx
229bf215546Sopenharmony_ci      make
230bf215546Sopenharmony_ci      sudo make install
231bf215546Sopenharmony_ci      sudo depmod -a
232bf215546Sopenharmony_ci
233bf215546Sopenharmony_ci   If you're using a Ubuntu OS:
234bf215546Sopenharmony_ci
235bf215546Sopenharmony_ci   ::
236bf215546Sopenharmony_ci
237bf215546Sopenharmony_ci      sudo update-initramfs -u
238bf215546Sopenharmony_ci
239bf215546Sopenharmony_ci   If you're using a Fedora OS:
240bf215546Sopenharmony_ci
241bf215546Sopenharmony_ci   ::
242bf215546Sopenharmony_ci
243bf215546Sopenharmony_ci      sudo dracut --force
244bf215546Sopenharmony_ci
245bf215546Sopenharmony_ci   Add 'vmwgfx' to the /etc/modules file:
246bf215546Sopenharmony_ci
247bf215546Sopenharmony_ci   ::
248bf215546Sopenharmony_ci
249bf215546Sopenharmony_ci      echo vmwgfx | sudo tee -a /etc/modules
250bf215546Sopenharmony_ci
251bf215546Sopenharmony_ci   .. note::
252bf215546Sopenharmony_ci
253bf215546Sopenharmony_ci      some distros put DRM kernel drivers in different directories.
254bf215546Sopenharmony_ci      For example, sometimes vmwgfx.ko might be found in
255bf215546Sopenharmony_ci      ``/lib/modules/{version}/extra/vmwgfx.ko`` or in
256bf215546Sopenharmony_ci      ``/lib/modules/{version}/kernel/drivers/gpu/drm/vmwgfx/vmwgfx.ko``.
257bf215546Sopenharmony_ci
258bf215546Sopenharmony_ci      After installing vmwgfx.ko you might want to run the following
259bf215546Sopenharmony_ci      command to check that the new kernel module is in the expected place:
260bf215546Sopenharmony_ci
261bf215546Sopenharmony_ci      ::
262bf215546Sopenharmony_ci
263bf215546Sopenharmony_ci         find /lib/modules -name vmwgfx.ko -exec ls -l '{}' \;
264bf215546Sopenharmony_ci
265bf215546Sopenharmony_ci      If you see the kernel module listed in more than one place, you may
266bf215546Sopenharmony_ci      need to move things around.
267bf215546Sopenharmony_ci
268bf215546Sopenharmony_ci   Finally, if you update your kernel you'll probably have to rebuild
269bf215546Sopenharmony_ci   and reinstall the vmwgfx.ko module again.
270bf215546Sopenharmony_ci
271bf215546Sopenharmony_ciNow try to load the kernel module by issuing
272bf215546Sopenharmony_ci
273bf215546Sopenharmony_ci::
274bf215546Sopenharmony_ci
275bf215546Sopenharmony_ci   sudo modprobe vmwgfx
276bf215546Sopenharmony_ci
277bf215546Sopenharmony_ciThen type
278bf215546Sopenharmony_ci
279bf215546Sopenharmony_ci::
280bf215546Sopenharmony_ci
281bf215546Sopenharmony_ci   dmesg
282bf215546Sopenharmony_ci
283bf215546Sopenharmony_cito watch the debug output. It should contain a number of lines prefixed
284bf215546Sopenharmony_ciwith "[vmwgfx]".
285bf215546Sopenharmony_ci
286bf215546Sopenharmony_ciThen restart the Xserver (or reboot). The lines starting with
287bf215546Sopenharmony_ci"vmwlegacy" or "VMWARE" in the file /var/log/Xorg.0.log should now have
288bf215546Sopenharmony_cibeen replaced with lines starting with "vmwgfx", indicating that the new
289bf215546Sopenharmony_ciXorg driver is in use.
290bf215546Sopenharmony_ci
291bf215546Sopenharmony_ciRunning OpenGL Programs
292bf215546Sopenharmony_ci-----------------------
293bf215546Sopenharmony_ci
294bf215546Sopenharmony_ciIn a shell, run 'glxinfo' and look for the following to verify that the
295bf215546Sopenharmony_cidriver is working:
296bf215546Sopenharmony_ci
297bf215546Sopenharmony_ci::
298bf215546Sopenharmony_ci
299bf215546Sopenharmony_ci   OpenGL vendor string: VMware, Inc.
300bf215546Sopenharmony_ci   OpenGL renderer string: Gallium 0.4 on SVGA3D; build: RELEASE;
301bf215546Sopenharmony_ci   OpenGL version string: 2.1 Mesa 8.0
302bf215546Sopenharmony_ci
303bf215546Sopenharmony_ciIf you don't see this, try setting this environment variable:
304bf215546Sopenharmony_ci
305bf215546Sopenharmony_ci::
306bf215546Sopenharmony_ci
307bf215546Sopenharmony_ci   export LIBGL_DEBUG=verbose
308bf215546Sopenharmony_ci
309bf215546Sopenharmony_cithen rerun glxinfo and examine the output for error messages.
310bf215546Sopenharmony_ci
311bf215546Sopenharmony_ciIf OpenGL 3.3 is not working (you only get OpenGL 2.1):
312bf215546Sopenharmony_ci
313bf215546Sopenharmony_ci-  Make sure the VM uses hardware version 12.
314bf215546Sopenharmony_ci-  Make sure the vmwgfx kernel module is version 2.9.0 or later.
315bf215546Sopenharmony_ci-  Check the vmware.log file for errors.
316bf215546Sopenharmony_ci-  Run 'dmesg \| grep vmwgfx' and look for "DX: yes".
317