Skip to content

Commit c8e124f

Browse files
committed
Added check_vendor_gpu function
1 parent 35a0ae9 commit c8e124f

File tree

1 file changed

+52
-9
lines changed

1 file changed

+52
-9
lines changed

data_from_portwine/scripts/functions_helper

+52-9
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,53 @@ check_selinux () {
833833
}
834834
export -f check_selinux
835835

836+
check_vendor_gpu () {
837+
if [[ $PW_GPU_USE != disabled ]] ; then
838+
case "${PW_GPU_USE,,}" in
839+
*nvidia*)
840+
if [[ -d /sys/bus/pci/drivers/nvidia ]] ; then export NVIDIA_IN_USE=1
841+
elif [[ -d /sys/bus/pci/drivers/nouveau ]] ; then export NOUVEAU_IN_USE=1
842+
fi
843+
;;
844+
*amd*)
845+
export AMD_IN_USE=1
846+
;;
847+
*intel*)
848+
export INTEL_IN_USE=1
849+
;;
850+
esac
851+
fi
852+
if [[ -z $NVIDIA_IN_USE && -z $NOUVEAU_IN_USE && -z $AMD_IN_USE && -z $INTEL_IN_USE ]] ; then
853+
if command -v glxinfo &>/dev/null ; then
854+
glxinfo -B &> "${PW_TMPFS_PATH}/glxinfo.tmp"
855+
case "$(<"${PW_TMPFS_PATH}/glxinfo.tmp" tr '[:upper:]' '[:lower:]')" in
856+
*nvidia*)
857+
if [[ -d /sys/bus/pci/drivers/nvidia ]] ; then export NVIDIA_IN_USE=1
858+
elif [[ -d /sys/bus/pci/drivers/nouveau ]] ; then export NOUVEAU_IN_USE=1
859+
fi
860+
;;
861+
*amd*)
862+
export AMD_IN_USE=1
863+
;;
864+
*intel*)
865+
export INTEL_IN_USE=1
866+
;;
867+
esac
868+
else
869+
[[ -d /sys/bus/pci/drivers/nvidia ]] && export NVIDIA_IN_USE=1
870+
[[ -d /sys/bus/pci/drivers/nouveau ]] && export NOUVEAU_IN_USE=1
871+
[[ -d /sys/bus/pci/drivers/amdgpu ]] && export AMD_IN_USE=1
872+
[[ -d /sys/bus/pci/drivers/i915 ]] && export INTEL_IN_USE=1
873+
fi
874+
fi
875+
if [[ -n $NVIDIA_IN_USE ]] ; then echo 'nvidia'
876+
elif [[ -n $NOUVEAU_IN_USE ]] ; then echo 'nouveau'
877+
elif [[ -n $AMD_IN_USE ]] ; then echo 'amd'
878+
elif [[ -n $INTEL_IN_USE ]] ; then echo 'intel'
879+
else echo ''
880+
fi
881+
}
882+
836883
background_pid () {
837884
local arg1 arg2 arg3 PID
838885
arg1=$1 # --start или --end
@@ -3265,11 +3312,7 @@ start_portwine () {
32653312
fi
32663313

32673314
#https://github.com/flathub/net.lutris.Lutris/pull/368#issuecomment-1751381312
3268-
if [[ "${PW_GPU_USE,,}" =~ nvidia ]] \
3269-
|| [[ $(glxinfo | grep "OpenGL renderer" | grep -i nvidia) ]]
3270-
then
3271-
export WEBKIT_DISABLE_DMABUF_RENDERER=1
3272-
fi
3315+
[[ $(check_vendor_gpu) == nvidia ]] && export WEBKIT_DISABLE_DMABUF_RENDERER=1
32733316

32743317
if check_gamescope_session ; then
32753318
export PW_GAMEMODERUN_SLR=""
@@ -3462,7 +3505,7 @@ start_portwine () {
34623505
then
34633506
export LIBGL_KOPPER_DRI2="1"
34643507
fi
3465-
if [[ -d /sys/bus/pci/drivers/nouveau ]] ; then
3508+
if [[ $(check_vendor_gpu) == nouveau ]] ; then
34663509
export NOUVEAU_USE_ZINK="1"
34673510
fi
34683511
;;
@@ -3979,18 +4022,18 @@ start_portwine () {
39794022
|| check_gamescope_session
39804023
then
39814024
export vk_xwayland_wait_ready="false"
3982-
if [[ -d /sys/bus/pci/drivers/amdgpu ]] ; then
4025+
if [[ $(check_vendor_gpu) == amd ]] ; then
39834026
export RADV_DEBUG+="nodcc "
39844027
export AMD_DEBUG="nodcc"
39854028
if [[ ! $(<"${PW_TMPFS_PATH}/vulkaninfo.tmp") =~ VK_EXT_image_drm_format_modifier ]] ; then
39864029
export R600_DEBUG="nodcc"
39874030
grep -e '--backend' "${PW_TMPFS_PATH}/gamescope.tmp" &>/dev/null && PW_GS_BACKEND_SDL="1"
39884031
fi
39894032
fi
3990-
if [[ -d /sys/bus/pci/drivers/i915 ]] ; then
4033+
if [[ $(check_vendor_gpu) == intel ]] ; then
39914034
export INTEL_DEBUG="norbc"
39924035
fi
3993-
if [[ -d /sys/bus/pci/drivers/nvidia ]] ; then
4036+
if [[ $(check_vendor_gpu) == nvidia ]] ; then
39944037
PW_GAMESCOPE_VARIABLES_BEFORE+="__GL_THREADED_OPTIMIZATIONS=0 "
39954038
PW_GAMESCOPE_VARIABLES_AFTER+="__GL_THREADED_OPTIMIZATIONS=1 "
39964039
fi

0 commit comments

Comments
 (0)