From 156136a465d1e26835a4bfa4831394155a5da03a Mon Sep 17 00:00:00 2001 From: Pierre Equoy Date: Thu, 16 Jun 2016 15:17:53 +0800 Subject: provider:checkbox: Add ability to test AMD hybrid graphics with open source drivers on Xenial Starting with Xenial, AMD discrete GPU will use the open source drivers (either 'amdgpu' either 'radeon'). For the moment, these drivers do not come with a GUI, so in order to activate the discrete GPU, users must setup PRIME offloading and use the CLI and prefix any command with 'DRI_PRIME=1'. Graphics tests were updated to reflect this. It should only impact devices using an AMD discrete GPU and Ubuntu 16.04 (Xenial). --- bin/graphics_env | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 bin/graphics_env (limited to 'bin') diff --git a/bin/graphics_env b/bin/graphics_env new file mode 100755 index 0000000..719865d --- /dev/null +++ b/bin/graphics_env @@ -0,0 +1,31 @@ +#!/bin/bash +# This script checks if the submitted VIDEO resource is from AMD and if it is +# a discrete GPU (graphics_card_resource orders GPUs by index: 1 is the +# integrated one, 2 is the discrete one). +# +# This script has to be sourced in order to set an environment variable that +# is used by the open source AMD driver to trigger the use of discrete GPU. + +VENDOR_SLUG=$1 +INDEX=$2 +UBUNTU_CODENAME=`lsb_release -c | awk {'print $2'}` + +# We only want to set the DRI_PRIME env variable on Xenial (16.04) systems +# running more than 1 GPU. +if [[ $UBUNTU_CODENAME == "xenial" ]]; then + NB_GPU=`cat /var/log/gpu-manager.log | grep "How many cards?" | awk {'print $NF'}` + if [ $NB_GPU -gt 1 ]; then + if [[ $VENDOR_SLUG == *AMD* ]]; then + if [ $INDEX -gt 1 ]; then + # See https://wiki.archlinux.org/index.php/PRIME + echo "Setting up PRIME GPU offloading for AMD discrete GPU" + PROVIDER_ID=`xrandr --listproviders | grep "Sink Output" | awk {'print $4'} | tail -1` + SINK_ID=`xrandr --listproviders | grep "Source Output" | awk {'print $4'} | tail -1` + xrandr --setprovideroffloadsink ${PROVIDER_ID} ${SINK_ID} + export DRI_PRIME=1 + else + export DRI_PRIME= + fi + fi + fi +fi -- cgit v1.2.3