Updated the mechanics of detecting GPU drivers in the system

This commit is contained in:
2025-07-26 21:40:59 +05:00
parent c33d9ba3f5
commit 9cee5b32e9
6 changed files with 239 additions and 118 deletions

View File

@ -871,7 +871,7 @@ check_vendor_gpu () {
fi
if command -v glxinfo &>/dev/null ; then
pw_check_glxinfo
background_pid --end "pw_check_glxinfo" "3"
case "$(<"${PW_TMPFS_PATH}/glxinfo.tmp" tr '[:upper:]' '[:lower:]')" in
*nvidia*)
[[ -d /sys/bus/pci/drivers/nvidia ]] && VENDOR_GPU_USE+=("nvidia")
@ -1345,7 +1345,6 @@ seconds_to_time () {
combobox_fix () {
if [[ -z "$1" ]] ; then
print_error "no argument specified for combobox_fix"
return 1
else
local name1 name2
@ -2514,7 +2513,7 @@ pw_init_db () {
# add libs from https://github.com/CosmicFusion/fedora-amdgpu-pro/tree/main/x86_64/libdrm-pro to ld_library_path (this repo is deprecated and archived but why not)
echo "$PW_VK_ICD_FILENAMES" | grep -qi "/opt/amdgpu-pro/etc/vulkan/icd.d/amd_icd.*.json" && \
var_ld_library_path_update "/opt/amdgpu/libdrm/lib64:/opt/amdgpu/libdrm/lib32"
export PW_VK_ICD_FILENAMES
;;
@ -2529,7 +2528,7 @@ pw_init_db () {
[[ "${START_FROM_STEAM}" == 1 ]] && export PW_GUI_DISABLED_CS=1
[[ "${START_FROM_PP_GUI}" == 1 ]] && export PW_GUI_DISABLED_CS=0 && unset START_FROM_PP_GUI
return 0
}
@ -2802,20 +2801,148 @@ pw_check_command () {
export -f pw_check_command
pw_check_vulkan () {
if [[ ! -f "${PW_TMPFS_PATH}/vulkaninfo.tmp" ]] ; then
TIMEOUT_CMD="5"
if ! pw_check_command vulkaninfo ; then
print_warning "use portable vulkaninfo"
"$PW_PLUGINS_PATH"/portable/bin/x86_64-linux-gnu-vulkaninfo &> "${PW_TMPFS_PATH}/vulkaninfo.tmp"
TIMEOUT_CMD="5"
export DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1="1"
if ! pw_check_command vulkaninfo ; then
print_warning "use portable vulkaninfo"
"$PW_PLUGINS_PATH"/portable/bin/x86_64-linux-gnu-vulkaninfo &> "${PW_TMPFS_PATH}/vulkaninfo.tmp"
fi
}
compare_versions () {
IFS='.' read -ra a1 <<< "$1"
IFS='.' read -ra a2 <<< "$2"
local len=$(( ${#a1[@]} > ${#a2[@]} ? ${#a1[@]} : ${#a2[@]} ))
for ((i=0; i<len; i++)) ; do
local n1=$(( ${a1[i]:-0} ))
local n2=$(( ${a2[i]:-0} ))
if (( n1 > n2 )) ; then
return 0
elif (( n1 < n2 )) ; then
return 1
fi
done
return 0
}
pw_check_dxvk () {
background_pid --end "pw_check_vulkan" "1"
if [[ -z $PW_VULKAN_DRIVER_USE ]] && [[ -f "${PW_TMPFS_PATH}/vulkaninfo.tmp" ]] ; then
if [[ -z $PW_GPU_USE ]] ; then
if [[ -z $GET_GPU_NAMES ]] ; then
GET_GPU_NAMES=$(awk -F '=' '/deviceName/{print $2}' "${PW_TMPFS_PATH}/vulkaninfo.tmp" | sed '/llvm/d' | sort -u | sed 's/^ //' | paste -sd '!')
export GET_GPU_NAMES
fi
IFS='!' read -r -a SELECTED_VULKAN_GPU <<< "$GET_GPU_NAMES"
else
IFS='' read -r -a SELECTED_VULKAN_GPU <<< "$PW_GPU_USE"
fi
for i in "${SELECTED_VULKAN_GPU[@]}" ; do
PW_CHECK_VULKAN_DRIVER="$(awk -v target="$i" '
BEGIN {
in_target = 0
}
/^GPU[0-9]+:/ {
if (in_target) {
in_target = 0
}
next
}
/apiVersion/ { var1=$0 }
/driverVersion/ { var2=$0 }
/deviceName/ { var3=$0 }
/deviceName/ && !/llvmpipe/ {
split($0, parts, "=")
device_name = parts[2]
gsub(/^[[:space:]]+|[[:space:]]+$/, "", device_name)
if (device_name == target) in_target = 1
next
}
in_target {
if ($0 ~ /driverInfo/) { var4=$0; exit }
}
END {
print var1 "!" var2 "!" var3 "!" var4 "!"
}
' "${PW_TMPFS_PATH}/vulkaninfo.tmp")"
IFS='!' read -r -a PW_CHECK_VULKAN_DRIVER_ARRAY <<< "$PW_CHECK_VULKAN_DRIVER"
if [[ ${PW_CHECK_VULKAN_DRIVER_ARRAY[2],,} =~ nvidia ]] ; then
read -r -a PW_CHECK_VULKAN_DRIVER_ARRAY_3 <<< "${PW_CHECK_VULKAN_DRIVER_ARRAY[3]}"
if compare_versions "${PW_CHECK_VULKAN_DRIVER_ARRAY_3[2]}" "550.54.14" ; then
PW_VULKAN_DRIVER_USE="6" && break
fi
elif [[ ${PW_CHECK_VULKAN_DRIVER_ARRAY[3],,} =~ mesa ]] ; then
read -r -a PW_CHECK_VULKAN_DRIVER_ARRAY_1 <<< "${PW_CHECK_VULKAN_DRIVER_ARRAY[1]}"
if compare_versions "${PW_CHECK_VULKAN_DRIVER_ARRAY_1[2]}" "25.0" ; then
PW_VULKAN_DRIVER_USE="6" && break
fi
elif [[ ${PW_CHECK_VULKAN_DRIVER_ARRAY[3],,} =~ llpc ]] ; then
read -r -a PW_CHECK_VULKAN_DRIVER_ARRAY_1 <<< "${PW_CHECK_VULKAN_DRIVER_ARRAY[1]}"
if compare_versions "${PW_CHECK_VULKAN_DRIVER_ARRAY_1[2]}" "2.0.310" ; then
PW_VULKAN_DRIVER_USE="6"
fi
fi
done
if [[ ${PW_CHECK_VULKAN_DRIVER_ARRAY[3],,} =~ llpc ]] && [[ -z $PW_AMD_VULKAN_USE || $PW_AMD_VULKAN_USE == "disabled" ]] ; then
PW_VK_ICD_FILENAMES=""
for dir in /opt/amdgpu/etc/vulkan/icd.d /etc/vulkan/icd.d /usr/share/vulkan/icd.d; do
for file in "$dir"/amd_icd*.json; do
[ -f "$file" ] && PW_VK_ICD_FILENAMES="${PW_VK_ICD_FILENAMES:+${PW_VK_ICD_FILENAMES}:}$file"
done
done
export PW_VK_ICD_FILENAMES
fi
if [[ -z ${PW_CHECK_VULKAN_DRIVER_ARRAY[3]} ]] && [[ -n $PW_GPU_USE && $PW_GPU_USE != "disabled" ]] ; then
unset PW_GPU_USE
pw_check_dxvk
fi
if [[ -z $PW_GPU_USE ]] ; then
export PW_GPU_USE=${PW_CHECK_VULKAN_DRIVER_ARRAY[2]//*= /}
edit_user_conf_from_gui PW_GPU_USE
fi
fi
if [[ $PW_VULKAN_DRIVER_USE == "6" ]] ; then
[[ -z $PW_VULKAN_USE ]] && PW_VULKAN_USE="6"
case "$PW_VULKAN_USE" in
0) PW_DEFAULT_VULKAN_USE="$SORT_OPENGL!$SORT_NEWEST!$SORT_STABLE!$SORT_SAREK" ;;
1) PW_DEFAULT_VULKAN_USE="$SORT_SAREK!$SORT_NEWEST!$SORT_STABLE!$SORT_OPENGL" ;;
2) PW_DEFAULT_VULKAN_USE="$SORT_STABLE!$SORT_NEWEST!$SORT_SAREK!$SORT_OPENGL" ;;
*) PW_DEFAULT_VULKAN_USE="$SORT_NEWEST!$SORT_STABLE!$SORT_SAREK!$SORT_OPENGL" ;;
esac
else
if [[ -z $PW_GPU_USE || $PW_GPU_USE == "disabled" ]] ; then
[[ -z $PW_VULKAN_USE ]] && PW_VULKAN_USE="0"
PW_DEFAULT_VULKAN_USE="$SORT_OPENGL"
else
read -r -a PW_CHECK_VULKAN_DRIVER_ARRAY_0 <<< "${PW_CHECK_VULKAN_DRIVER_ARRAY[0]}"
if compare_versions "${PW_CHECK_VULKAN_DRIVER_ARRAY_0[2]}" "1.3" ; then
[[ -z $PW_VULKAN_USE ]] && PW_VULKAN_USE="2"
case "$PW_VULKAN_USE" in
0) PW_DEFAULT_VULKAN_USE="$SORT_OPENGL!$SORT_STABLE!$SORT_SAREK" ;;
1) PW_DEFAULT_VULKAN_USE="$SORT_SAREK!$SORT_STABLE!$SORT_OPENGL" ;;
*) PW_DEFAULT_VULKAN_USE="$SORT_STABLE!$SORT_SAREK!$SORT_OPENGL" ;;
esac
else
[[ -z $PW_VULKAN_USE ]] && PW_VULKAN_USE="1"
case "$PW_VULKAN_USE" in
0) PW_DEFAULT_VULKAN_USE="$SORT_OPENGL!$SORT_SAREK" ;;
*) PW_DEFAULT_VULKAN_USE="$SORT_SAREK!$SORT_OPENGL" ;;
esac
fi
fi
fi
}
pw_check_glxinfo () {
if [[ ! -f "${PW_TMPFS_PATH}/glxinfo.tmp" ]] ; then
TIMEOUT_CMD="5"
pw_check_command glxinfo -B
fi
TIMEOUT_CMD="5"
pw_check_command glxinfo -B
}
pw_get_tmp_files () {
@ -2823,8 +2950,6 @@ pw_get_tmp_files () {
do pw_check_command "$f_cmd"
done
pw_check_vulkan
# GALLIUM NINE
unset FIND_D3D_MODULE D3D_MODULE_PATH
if ! check_flatpak ; then
@ -2850,16 +2975,15 @@ pw_get_tmp_files () {
pw_skip_get_info () {
if [[ "${SKIP_CHECK_UPDATES_NEW}" != "1" ]] ; then
background_pid --end "pw_get_tmp_files" "1"
background_pid --end "pw_get_tmp_files" "2"
if [[ -f "${PW_TMPFS_PATH}/gamescope.tmp" ]] ; then
export GAMESCOPE_INSTALLED="1"
fi
if [[ -f "${PW_TMPFS_PATH}/vulkaninfo.tmp" ]] ; then
VULKAN_DRIVER_NAME="$(grep -e 'driverName' "${PW_TMPFS_PATH}/vulkaninfo.tmp" | awk '{print$3}' | head -1)"
GET_GPU_NAMES=$(awk -F '=' '/deviceName/{print $2}' "${PW_TMPFS_PATH}/vulkaninfo.tmp" | sed '/llvm/d'| sort -u | sed 's/^ //' | paste -sd '!')
export VULKAN_DRIVER_NAME GET_GPU_NAMES
GET_GPU_NAMES=$(awk -F '=' '/deviceName/{print $2}' "${PW_TMPFS_PATH}/vulkaninfo.tmp" | sed '/llvm/d' | sort -u | sed 's/^ //' | paste -sd '!')
export GET_GPU_NAMES
fi
if [[ -f "${PW_TMPFS_PATH}/lspci.tmp" ]] ; then
@ -4589,7 +4713,7 @@ pw_run () {
PW_LD_LIBRARY_PATH="${PW_LD_LIBRARY_PATH}:${WINE_LIBRARY_PATH}"
echo "##### Current variables #####" > "$PW_TMPFS_PATH/var.log"
for var in "WINEDIR" "WINEPREFIX" "WINEDLLOVERRIDES" "PATH_TO_GAME" "PW_WINE_USE" "PW_VULKAN_USE" "VULKAN_DRIVER_NAME" \
for var in "WINEDIR" "WINEPREFIX" "WINEDLLOVERRIDES" "PATH_TO_GAME" "PW_WINE_USE" "PW_VULKAN_USE" \
"WINELOADER" "VKD3D_CONFIG" "PW_LD_LIBRARY_PATH" "PATH" "WINEESYNC" "WINEFSYNC" "WINEFSYNC_FUTEX2" \
"WINEDLLPATH" "WINE_CPU_TOPOLOGY" "PW_RUN_GAMESCOPE" "LD_LIBRARY_PATH" "PW_VK_ICD_FILENAMES" "PW_TASKSET_SLR"
do
@ -5543,7 +5667,6 @@ gui_edit_db () {
if [[ -n "${PW_AMD_VULKAN_USE}" ]] && \
[[ "${PW_AMD_VULKAN_USE}" != "disabled" ]] ; then
AMD_VULKAN_VAR="${PW_AMD_VULKAN_USE}"
export DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1=1
else
AMD_VULKAN_VAR="disabled"
fi
@ -6423,12 +6546,12 @@ gui_userconf () {
NEW_STEAM_BEHAVIOR="${translations[Enable]}"
fi
if [[ -n $PW_GPU_USE ]] \
&& [[ $PW_GPU_USE != "disabled" ]]
then
if [[ -n $PW_GPU_USE ]] && [[ $PW_GPU_USE != "disabled" ]] ; then
GPU_VAR="$PW_GPU_USE"
elif [[ -n $GET_GPU_NAMES ]] ; then
GPU_VAR="${GET_GPU_NAMES/!*/}"
else
GPU_VAR="disabled"
GPU_VAR="${translations[The graphics card does not support Vulkan]}"
fi
if [[ $PW_WINE_DPI_VALUE == "recommended" ]] ; then
@ -6492,7 +6615,7 @@ gui_userconf () {
--field="${translations[Change branch to]}!${translations[Depending on the version of the scripts, PortProton will receive the latest changes first (the DEVEL branch), the STABLE branch is updated later and is stable.]} :CB" "$(combobox_fix "$BRANCH" "$NEW_BRANCH")" \
--field="${translations[Change start gui to]}!${translations[When using PANED in the game start menu, additional buttons are located on one large page; if NOTEBOOK, then they are divided into several.]} :CB" "$(combobox_fix "$PW_GUI_START" "$NEW_START_GUI")" \
--field="${translations[Steam covers download]}!${translations[If downloading steam covers is enabled, they will be downloaded and created. (Disablement is provided in cases where their downloading is unavailable for some reason)]} :CB" "$(combobox_fix "$DOWNLOAD_STEAM_GRID" "$NEW_STEAM_BEHAVIOR")" \
--field="${translations[Choose a graphics card to run the game]}!${translations[Select which video card will be used to run the game (used for all running games and programs in PortProton)]} :CB" "$(combobox_fix --disabled "$GPU_VAR" "$GET_GPU_NAMES")" \
--field="${translations[Choose a graphics card to run the game]}!${translations[Select which video card will be used to run the game (used for all running games and programs in PortProton)]} :CB" "$(combobox_fix "$GPU_VAR" "$GET_GPU_NAMES")" \
--field="${translations[Force dpi]}!${translations[Here you can set forced dpi for applications wine]} :CB" "$(combobox_fix --disabled "$YAD_DPI_VAR" "${translations[Recommended value]}!80!96!120!144!168!192!216!240")" \
--field="${translations[Choice wine audio driver]}!${translations[Fixes sound popling if choice alsa]} :CB" "$(combobox_fix --disabled "$SOUND_DRIVER_VAR" "alsa!oss!pulse")" \
--field="${translations[Select PortProton theme]}!${translations[Allows you to select a theme for PortProton]} :CB" "$(combobox_fix "$GUI_THEME" "${translations[default]}!${translations[compact]}!${translations[classic]}")" \
@ -6523,6 +6646,7 @@ gui_userconf () {
gui_open_user_conf
;;
166)
unset PW_VULKAN_DRIVER_USE
IFS='%' read -r -a PW_ADD_SETTINGS_UC <"${PW_TMPFS_PATH}/tmp_yad_userconf_set_cb"
MIRROR="${PW_ADD_SETTINGS_UC[0]}"
if [[ $BRANCH != "${PW_ADD_SETTINGS_UC[1]}" ]] ; then
@ -6582,6 +6706,7 @@ gui_userconf () {
if [[ $SORT_WITH_TIME == "${translations[According to last launch]}" ]] ; then SORT_WITH_TIME="lastlaunch"
elif [[ $SORT_WITH_TIME == "${translations[By time]}" ]] ; then SORT_WITH_TIME="bytime"
fi
[[ $PW_GPU_USE == "${translations[The graphics card does not support Vulkan]}" ]] && PW_GPU_USE="disabled"
edit_user_conf_from_gui MIRROR BRANCH PW_GUI_START DOWNLOAD_STEAM_GRID PW_GPU_USE PW_WINE_DPI_VALUE PW_SOUND_DRIVER_USE \
GUI_THEME GTK_THEME DESKTOP_WITH_TIME SORT_WITH_TIME
@ -7026,9 +7151,9 @@ pw_prefix_manager () {
--tab="${translations[SETTINGS]}!$PW_GUI_ICON_PATH/$TAB_SIZE.png!" 2>/dev/null
YAD_STATUS="$?"
try_remove_file "${PW_TMPFS_PATH}/dll_list_tmp"
try_remove_file "${PW_TMPFS_PATH}/fonts_list_tmp"
try_remove_file "${PW_TMPFS_PATH}/settings_list_tmp"
try_remove_file "${PW_TMPFS_PATH}/dll_list_tmp"
try_remove_file "${PW_TMPFS_PATH}/fonts_list_tmp"
try_remove_file "${PW_TMPFS_PATH}/settings_list_tmp"
case "$YAD_STATUS" in
0)
@ -7071,11 +7196,6 @@ portwine_start_debug () {
pw_skip_get_info
kill_portwine
export PW_LOG=1
if [[ -z "$VULKAN_DRIVER_NAME" ]] || [[ "$VULKAN_DRIVER_NAME" == "llvmpipe" ]] ; then
pw_notify_send -i warning \
"${translations[Attention working version of vulkan not detected!]}" \
"${translations[It is recommended to run games in OpenGL (low performance possible)!]}"
fi
echo "${translations[PortProton was launched in creation mode PortProton.log and it is successfully stored in the root directory of the port]}" > "${PORT_WINE_PATH}/PortProton.log"
echo "${translations[To diagnose the problem, copy ALL of the log to:]} https://linux-gaming.ru/t/opisanie-kategorii-portproton-pomoshh/1642" >> "${PORT_WINE_PATH}/PortProton.log"
echo "-------------------------------------------------------------" >> "${PORT_WINE_PATH}/PortProton.log"
@ -7416,6 +7536,7 @@ gui_open_user_conf () {
restart_pp --userconf
;;
2)
unset PW_VULKAN_DRIVER_USE
echo "${PW_USERCONF_GUI}" > "${PORT_WINE_PATH}/data/user.conf"
print_info "Restarting..."
restart_pp --userconf