diff --git a/arch/0-dxvk-nvapi-git/PKGBUILD b/arch/0-dxvk-nvapi-git/PKGBUILD new file mode 100755 index 0000000..1ec1da5 --- /dev/null +++ b/arch/0-dxvk-nvapi-git/PKGBUILD @@ -0,0 +1,112 @@ +# Maintainer: Pekka Helenius (~Fincer) + +# Override /etc/makepkg.conf PKGDEST variable if it's enabled +PKGDEST="${PWD}" + +pkgname=dxvk-nvapi-git +_pkgname=dxvk-nvapi +pkgver=580.6268 +pkgrel=1 +pkgdesc="Alternative NVAPI implementation on top of DXVK." +url="https://github.com/jp7677/dxvk-nvapi" +license=('MIT') + +arch=('x86_64') +conflicts=( + 'dxvk-nvapi' +) +depends=('dxvk' 'wine' 'vulkan-icd-loader' 'lib32-vulkan-icd-loader') +makedepends=( + 'ninja' + 'meson>=0.49' + 'glslang' + 'mingw-w64-gcc' + 'git' + 'wine' + 'python' +) + +_dxvknvapi_gitsrc= +_git_branch_dxvknvapi=master +_dxvknvapi_commit=HEAD + +provides=('dxvk-nvapi') +options=(!strip !buildflags staticlibs) +source=( + ${pkgname}::"${_dxvknvapi_gitsrc}#commit=${_dxvknvapi_commit}" + 'setup_dxvk_nvapi.sh' +) +sha256sums=( + 'SKIP' + 'e2ff99af4ecb739629e0f873077f986cffcc9418c8ecb7e6040744f05110afbb' +) + +############################## + +# Copy custom patches to correct location +if [[ $(find "${startdir}/dxvk-nvapi-patches" -mindepth 1 -maxdepth 1 -regex ".*\.\(patch\|diff\)$") ]]; then + cp -r "${startdir}/dxvk-nvapi-patches/"*.{patch,diff} "${startdir}"/ + p=0 + for patch in $(find . -mindepth 1 -maxdepth 1 -regex ".*\.\(patch\|diff\)$"); do + patches[$p]="$(basename ${patch})" + let p++ + done + unset p + source+=(${source[@]} ${patches[@]}) +fi + +# Reset git tree and apply custom patches +prepare() { + + cd "${srcdir}/dxvk-nvapi-git" + git checkout ${_git_branch_dxvknvapi} + git reset --hard ${_dxvknvapi_commit} # Restore tracked files + git clean -d -x -f # Delete untracked files + git submodule update --init --recursive + + # Apply patches, if present + if [[ $(ls "${srcdir}"/*.{patch,diff} 2>/dev/null | wc -w) -ne 0 ]]; then + + # Apply all custom patches + msg2 "Applying custom patches..." + + for i in "${srcdir}"/*.{patch,diff}; do + if [[ -f ${i} ]]; then + patch -Np1 < ${i} + fi + done + + fi + +} + +############################## + +# Retrieve DXVK NVAPI version tag +pkgver() { + cd "${pkgname}" + printf '%s.%s' $(git rev-list --count HEAD) $(git rev-parse --short HEAD | sed 's/\-[a-z].*//; s/\-/\./g; s/[a-z]//g') +} + +# Launch DXVK NVAPI build script +build() { + cd "${pkgname}" + ./package-release.sh ${pkgver} "${srcdir}"/build +} + +# Bundle the compiled files +package() { + mkdir -p "${pkgdir}"/usr/{bin,share/dxvk_nvapi} + cp -r "${srcdir}"/build/${_pkgname}-${pkgver}/* "${pkgdir}/usr/share/dxvk_nvapi/" + + cp "${srcdir}"/setup_dxvk_nvapi.sh "${pkgdir}/usr/share/dxvk_nvapi/" + + echo -e "#!/bin/sh" > "${pkgdir}/usr/bin/setup_dxvk_nvapi" + echo -e " +cd /usr/share/dxvk_nvapi/ +./setup_dxvk_nvapi.sh \${@} +" >> "${pkgdir}/usr/bin/setup_dxvk_nvapi" + + chmod +x "${pkgdir}/usr/share/dxvk_nvapi/setup_dxvk_nvapi.sh" + chmod +x "${pkgdir}/usr/bin/setup_dxvk_nvapi" +} diff --git a/arch/0-dxvk-nvapi-git/setup_dxvk_nvapi.sh b/arch/0-dxvk-nvapi-git/setup_dxvk_nvapi.sh new file mode 100644 index 0000000..25f2610 --- /dev/null +++ b/arch/0-dxvk-nvapi-git/setup_dxvk_nvapi.sh @@ -0,0 +1,201 @@ +#!/usr/bin/env bash + +# NOTE: This is a modified version of script file +# https://github.com/HansKristian-Work/vkd3d-proton/blob/master/setup_vkd3d_proton.sh +# + +# default directories +dxvk_nvapi_lib32=${dxvk_nvapi_lib32:-"x32"} +dxvk_nvapi_lib64=${dxvk_nvapi_lib64:-"x64"} + +# figure out where we are +basedir=$(dirname "$(readlink -f "$0")") + +# figure out which action to perform +action="$1" + +case "$action" in +install) + ;; +uninstall) + ;; +*) + echo "Unrecognized action: $action" + echo "Usage: $0 [install|uninstall] [--symlink]" + exit 1 +esac + +# process arguments +shift + +file_cmd="cp -v" + +while (($# > 0)); do + case "$1" in + "--symlink") + file_cmd="ln -s -v" + ;; + esac + shift +done + +# check wine prefix before invoking wine, so that we +# don't accidentally create one if the user screws up +if [ -n "$WINEPREFIX" ] && ! [ -f "$WINEPREFIX/system.reg" ]; then + echo "$WINEPREFIX:"' Not a valid wine prefix.' >&2 + exit 1 +fi + +# find wine executable +export WINEDEBUG=-all +# disable mscoree and mshtml to avoid downloading +# wine gecko and mono +export WINEDLLOVERRIDES="mscoree,mshtml=" + +wine="wine" +wine64="wine64" +wineboot="wineboot" + +# $PATH is the way for user to control where wine is located (including custom Wine versions). +# Pure 64-bit Wine (non Wow64) requries skipping 32-bit steps. +# In such case, wine64 and winebooot will be present, but wine binary will be missing, +# however it can be present in other PATHs, so it shouldn't be used, to avoid versions mixing. +wine_path=$(dirname "$(which $wineboot)") +wow64=true +if ! [ -f "$wine_path/$wine" ]; then + wine=$wine64 + wow64=false +fi + +# resolve 32-bit and 64-bit system32 path +winever=$($wine --version | grep wine) +if [ -z "$winever" ]; then + echo "$wine: Not a wine executable. Check your $wine." >&2 + exit 1 +fi + +# ensure wine placeholder dlls are recreated +# if they are missing +$wineboot -u + +win64_sys_path=$($wine64 winepath -u 'C:\windows\system32' 2> /dev/null) +win64_sys_path="${win64_sys_path/$'\r'/}" +if $wow64; then + win32_sys_path=$($wine winepath -u 'C:\windows\system32' 2> /dev/null) + win32_sys_path="${win32_sys_path/$'\r'/}" +fi + +if [ -z "$win32_sys_path" ] && [ -z "$win64_sys_path" ]; then + echo 'Failed to resolve C:\windows\system32.' >&2 + exit 1 +fi + +# create native dll override +overrideDll() { + if ! $wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v "$1" /d native /f >/dev/null 2>&1 + then + echo -e "Failed to add override for $1" + exit 1 + fi +} + +# remove dll override +restoreDll() { + if ! $wine reg delete 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v "$1" /f > /dev/null 2>&1 + then + echo "Failed to remove override for $1" + fi +} + +# copy or link nvapi dll, back up original file +installFile() { + dstfile="${1}/${3}.dll" + srcfile="${basedir}/${2}/${3}.dll" + + if ! [ -f "${srcfile}" ]; then + echo "${srcfile}: File not found. Skipping." >&2 + return 1 + fi + + if [ -n "$1" ]; then + if [ -f "${dstfile}" ] || [ -h "${dstfile}" ]; then + if ! [ -f "${dstfile}.old" ]; then + mv -v "${dstfile}" "${dstfile}.old" + else + rm -v "${dstfile}" + fi + else + touch "${dstfile}.old_none" + fi + $file_cmd "${srcfile}" "${dstfile}" + fi + return 0 +} + +# remove nvapi dll, restore original file +uninstallFile() { + dstfile="${1}/${3}.dll" + srcfile="${basedir}/${2}/${3}.dll" + + if ! [ -f "${srcfile}" ]; then + echo "${srcfile}: File not found. Skipping." >&2 + return 1 + fi + + if ! [ -f "${dstfile}" ] && ! [ -h "${dstfile}" ]; then + echo "${dstfile}: File not found. Skipping." >&2 + return 1 + fi + + if [ -f "${dstfile}.old" ]; then + rm -v "${dstfile}" + mv -v "${dstfile}.old" "${dstfile}" + return 0 + elif [ -f "${dstfile}.old_none" ]; then + rm -v "${dstfile}.old_none" + rm -v "${dstfile}" + return 0 + else + return 1 + fi +} + +install() { + installFile "$win64_sys_path" "$dxvk_nvapi_lib64" "${1}64" + inst64_ret="$?" + + inst32_ret=-1 + if $wow64; then + installFile "$win32_sys_path" "$dxvk_nvapi_lib32" "$1" + inst32_ret="$?" + fi + + if (( (inst32_ret == 0) )); then + overrideDll "$1" + fi + + if (( (inst64_ret == 0) )); then + overrideDll "${1}64" + fi +} + +uninstall() { + uninstallFile "$win64_sys_path" "$dxvk_nvapi_lib64" "${1}64" + uninst64_ret="$?" + + uninst32_ret=-1 + if $wow64; then + uninstallFile "$win32_sys_path" "$dxvk_nvapi_lib32" "$1" + uninst32_ret="$?" + fi + + if (( (uninst32_ret == 0) )); then + restoreDll "$1" + fi + + if (( (uninst64_ret == 0) )); then + restoreDll "${1}64" + fi +} + +$action nvapi diff --git a/dxvk-nvapi_custom_patches/put_your_dxvk-nvapi_patches_here b/dxvk-nvapi_custom_patches/put_your_dxvk-nvapi_patches_here new file mode 100644 index 0000000..e5ca62e --- /dev/null +++ b/dxvk-nvapi_custom_patches/put_your_dxvk-nvapi_patches_here @@ -0,0 +1,4 @@ +Put your custom DXVK patches here. +Valid file suffix formats are: .diff and .patch + +These patches are applied during DXVK compilation diff --git a/options.conf b/options.conf index 19c08ed..5c86c10 100644 --- a/options.conf +++ b/options.conf @@ -15,6 +15,7 @@ ######### +git_source_dxvknvapi="git://github.com/jp7677/dxvk-nvapi.git" git_source_vkd3dproton="git://github.com/HansKristian-Work/vkd3d-proton.git" git_source_dxvk="git://github.com/doitsujin/dxvk.git" git_source_wine="git://source.winehq.org/git/wine.git" @@ -24,6 +25,10 @@ git_source_winestaging="git://github.com/wine-staging/wine-staging.git" git_commithash_dxvk=HEAD git_branch_dxvk=master +# DXVK NVAPI commits & branches +git_commithash_dxvknvapi=HEAD +git_branch_dxvknvapi=master + # VKD3D commits & branches git_commithash_vkd3dproton=HEAD git_branch_vkd3dproton=master diff --git a/updatewine.sh b/updatewine.sh index e317674..9bc9ce6 100755 --- a/updatewine.sh +++ b/updatewine.sh @@ -149,6 +149,10 @@ for arg in ${@}; do # Skip VKD3D Proton build & installation process all together NO_VKD3D= ;; + --no-nvapi) + # Skip DXVK NVAPI build & installation process all together + NO_NVAPI= + ;; --no-pol) # Skip PlayOnLinux Wine prefixes update process ;; @@ -160,6 +164,7 @@ Usage:\n\nbash updatewine.sh\n\nArguments:\n\n\ --no-install\tDo not install Wine or DXVK. Just compile them. Wine, meson & glslang must be installed for DXVK compilation.\n\ --no-dxvk\tDo not compile or install DXVK\n\ --no-vkd3d\tDo not compile or install VKD3D Proton\n\ +--no-nvapi\tDo not compile or install DXVK NVAPI\n\ --no-pol\tDo not update PlayOnLinux Wine prefixes\n\n\ --no-staging\tCompile Wine instead of Wine Staging\n\ --no-wine\tDo not compile or install Wine/Wine Staging\n\n\ @@ -187,34 +192,37 @@ datesuffix=$(echo $(date '+%Y-%m-%d-%H%M%S')) # Pass them to subscripts, as well. githash_overrides=( - "${git_commithash_vkd3dproton}" # 0 - "${git_commithash_dxvk}" # 1 - "${git_commithash_glslang}" # 2 - "${git_commithash_meson}" # 3 - "${git_commithash_wine}" # 4 + "${git_commithash_dxvknvapi}" # 0 + "${git_commithash_vkd3dproton}" # 1 + "${git_commithash_dxvk}" # 2 + "${git_commithash_glslang}" # 3 + "${git_commithash_meson}" # 4 + "${git_commithash_wine}" # 5 ) # Add git branches to argument list # Pass them to subscripts, as well. gitbranch_overrides=( - "${git_branch_vkd3dproton}" # 5 - "${git_branch_dxvk}" # 6 - "${git_branch_glslang}" # 7 - "${git_branch_meson}" # 8 - "${git_branch_wine}" # 9 + "${git_branch_dxvknvapi}" # 6 + "${git_branch_vkd3dproton}" # 7 + "${git_branch_dxvk}" # 8 + "${git_branch_glslang}" # 9 + "${git_branch_meson}" # 10 + "${git_branch_wine}" # 11 ) # Add git sources to argument list # Pass them to subscripts, as well. gitsources=( - "${git_source_vkd3dproton}" # 10 - "${git_source_dxvk}" # 11 - "${git_source_glslang}" # 12 - "${git_source_meson}" # 13 - "${git_source_wine}" # 14 - "${git_source_winestaging}" # 15 + "${git_source_dxvknvapi}" # 12 + "${git_source_vkd3dproton}" # 13 + "${git_source_dxvk}" # 14 + "${git_source_glslang}" # 15 + "${git_source_meson}" # 16 + "${git_source_wine}" # 17 + "${git_source_winestaging}" # 18 ) ############################# @@ -386,7 +394,7 @@ function determineDistroFamily() { esac } -if [[ ! -v NO_WINE ]] || [[ ! -v NO_DXVK ]] || [[ ! -v NO_VKD3D ]]; then +if [[ ! -v NO_WINE ]] || [[ ! -v NO_DXVK ]] || [[ ! -v NO_VKD3D ]] || [[ ! -v NO_NVAPI ]]; then echo -e "\n${SCRIPT_TITLE}\n\nBuild identifier:\t${datesuffix}\n" else echo "" @@ -403,7 +411,7 @@ echo -e "\e[1mNOTE: \e[0mDXVK requires very latest Nvidia/AMD drivers to work.\n This script comes with GPU driver installation scripts for Debian-based Linux distributions.\n" INFO_SEP -if [[ ! -v NO_WINE ]] || [[ ! -v NO_DXVK ]]|| [[ ! -v NO_VKD3D ]]; then +if [[ ! -v NO_WINE ]] || [[ ! -v NO_DXVK ]] || [[ ! -v NO_VKD3D ]] || [[ ! -v NO_NVAPI ]]; then reqsCheck sudoQuestion echo ""