summaryrefslogtreecommitdiffstats
path: root/gfx/wr/wrench/script/wrench_with_renderer.py
blob: e2685e84765a38ced70e0a5edc726b2c4158f4c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import os
import subprocess
import sys


def is_linux():
    return sys.platform.startswith('linux')


if is_linux():
    requested_renderer = sys.argv[1]
    renderer = "default"

    if requested_renderer == 'hardware':
        pass
    elif requested_renderer == 'llvmpipe':
        os.environ["LIBGL_ALWAYS_SOFTWARE"] = "1"
        os.environ["GALLIUM_DRIVER"] = "llvmpipe"
    elif requested_renderer == 'softpipe':
        os.environ["LIBGL_ALWAYS_SOFTWARE"] = "1"
        os.environ["GALLIUM_DRIVER"] = "softpipe"
    elif requested_renderer == 'swiftshader':
        # TODO: Set up LD_LIBRARY_PATH to SwiftShader libraries automatically.
        renderer = 'es3'
    else:
        print('Unknown renderer ' + requested_renderer)
        sys.exit(1)

    cmd = [
        'cargo',
        'run',
        '--release',
        '--',
        '--no-block',               # Run as fast as possible, for benchmarking
        '--no-picture-caching',     # Disable picture caching, to test rasterization performance
        '--no-subpixel-aa',         # SwiftShader doesn't support dual source blending
        '--renderer',               # Select GL3/ES3 renderer API
        renderer,
        'load'
    ]

    cmd += sys.argv[2:]
    print('Running: ' + ' '.join(cmd))
    subprocess.check_call(cmd)
else:
    print('This script is only supported on Linux')