6

I want to force chrome to render WebGL using software drivers, not hardware.

I'm using Ubuntu Linux and I understand that the Mesa GL drivers can be forced to use a software implementation by specifying the environment variable, LIBGL_ALWAYS_SOFTWARE=1, when launching a program. I confirmed that the driver changes when specifying the env var.

bash$ glxinfo | grep -i "opengl"
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) 945GM x86/MMX/SSE2
OpenGL version string: 1.4 Mesa 10.1.3
OpenGL extensions:

bash$ LIBGL_ALWAYS_SOFTWARE=1 glxinfo | grep -i "opengl"
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: Gallium 0.4 on llvmpipe (LLVM 3.4, 128 bits)
OpenGL version string: 2.1 Mesa 10.1.3
OpenGL shading language version string: 1.30
OpenGL extensions:

The default GL driver provides OpenGL 1.4 support, and the software driver provides OpenGL 2.1 support.

I tracked down where the desktop launcher exists (/usr/share/applications/) and edited it to specify the env var, but chrome://gpu still shows GL version 1.4. The Chrome GPU info contains a promising value:

Command Line Args --flag-switches-begin --disable-accelerated-2d-canvas --ignore-gpu-blacklist --flag-switches-end

I wonder if I can customize the --flag-switches-begin.

I also found the '--use-gl' command line switch, but I'm not sure how to leverage it to force the driver into software mode.

As a side note, I have already enabled 'Override software rendering list' in chrome://flags/, which did remove my model from the 'blacklist' making it possible to use WebGL, but the OpenGL feature set is still quite limited.

I have an old laptop with a terrible 'gpu' that I would like to use to develop some shaders and test in WebGL, no matter the performance.

Is it possible to tell Chrome to use the software drivers?

cyrf
  • 5,127
  • 6
  • 25
  • 42

1 Answers1

4

I don't have a linux box so I can't check but you can specify a prefix chrome will use for launching the GPU process with

--gpu-launcher=<prefix>

It's normally used for debugging for example

--gpu-launcher="xterm -e gdb --args"

When chrome launches a process it calls spawn. Normally it just launches

path/to/chrome <various flags>

--gpu-launcher lets you add a prefix to that. So for example

 --gpu-launcher=/usr/local/yourname/launch.sh 

would make it spawn

 /usr/local/yourname/launch.sh path/to/chrome <various flags>

You can now make /usr/local/yourname/launch.sh do whatever you want and finally launch chrome. The simplest would be something like

#!/bin/sh
"$@"

In your case I'd guess you'd want

#!/bin/sh
export LIBGL_ALWAYS_SOFTWARE=1
"$@"

Be sure to mark launch.sh as executable.


given the script above this worked for me

/opt/google/chrome/chrome --ignore-gpu-blacklist --gpu-launcher=/usr/local/gman/launch.sh

after which about:gpu gives me

GL_VENDOR   VMware, Inc.
GL_RENDERER Gallium 0.4 on llvmpipe (LLVM 0x301)
GL_VERSION  2.1 Mesa 9.0.3
gman
  • 100,619
  • 31
  • 269
  • 393
  • Thanks for the suggestion. I have since tried to use the flag you mention, but I am not sure what process I need to be launching. Simply specifying the env var, or xterm, leads to WebGL being disabled on chrome://gpu. Could you be more specific? – cyrf Jun 24 '14 at 05:02
  • I'm very close. I did like you suggested, and I can see a difference. chrome://gpu now shows WebGL support when specifying the --gpu-launcher. However, chrome://gpu also shows the OpenGL version still at 1.4, when I was hoping to see OpenGL 2.1. Any ideas? Maybe 'export' is wrong? Maybe chrome does not use glx? – cyrf Jun 24 '14 at 16:44
  • Thanks for this answer, this works. Should be the accepted answer. – Arne Sep 29 '17 at 11:12
  • Is it possible to force one webgl context on a page to use software, while another one uses hardware? – trusktr Apr 20 '21 at 23:08