2
# This script checks if the submitted VIDEO resource is from AMD and if it is
3
# a discrete GPU (graphics_card_resource orders GPUs by index: 1 is the
4
# integrated one, 2 is the discrete one).
6
# This script has to be sourced in order to set an environment variable that
7
# is used by the open source AMD driver to trigger the use of discrete GPU.
11
UBUNTU_CODENAME=`lsb_release -c | awk {'print $2'}`
13
# We only want to set the DRI_PRIME env variable on Xenial (16.04) systems
14
# running more than 1 GPU.
15
if [[ $UBUNTU_CODENAME == "xenial" ]]; then
16
NB_GPU=`cat /var/log/gpu-manager.log | grep "How many cards?" | awk {'print $NF'}`
17
if [ $NB_GPU -gt 1 ]; then
18
if [[ $VENDOR_SLUG == *AMD* ]]; then
19
if [ $INDEX -gt 1 ]; then
20
# See https://wiki.archlinux.org/index.php/PRIME
21
echo "Setting up PRIME GPU offloading for AMD discrete GPU"
22
PROVIDER_ID=`xrandr --listproviders | grep "Sink Output" | awk {'print $4'} | tail -1`
23
SINK_ID=`xrandr --listproviders | grep "Source Output" | awk {'print $4'} | tail -1`
24
xrandr --setprovideroffloadsink ${PROVIDER_ID} ${SINK_ID}