Skip to content

Commit

Permalink
dxvk-nvapi: Add to Proton
Browse files Browse the repository at this point in the history
Add https://github.com/jp7677/dxvk-nvapi as a submodule. dxvk-nvapi will
not be copied into Proton prefixes by default, but instead will be
controlled via the environment variable PROTON_ENABLE_NVAPI. This is
done to avoid any potential adverse effects of the nvapi DLL existing
in cases where an application may require a function that is not
implemented by dxvk-nvapi.

This new functionality can be enabled by setting the following environment
variable to a value of `1`:
    `PROTON_ENABLE_NVAPI`

This functionality is needed in order to support DLSS within Proton.

Reviewed-by: Adam Moss <[email protected]>
  • Loading branch information
liam-middlebrook authored and aeikum committed Jun 2, 2021
1 parent 5a30a04 commit 0503dde
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@
[submodule "OpenXR-SDK"]
path = OpenXR-SDK
url = https://github.com/KhronosGroup/OpenXR-SDK
[submodule "dxvk-nvapi"]
path = dxvk-nvapi
url = https://github.com/jp7677/dxvk-nvapi
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ dxvk: downloads
cp -f $(BUILD_DIR)/dist/files/lib/wine/dxvk/*.dll /vagrant/dxvk/lib/wine/dxvk/ && \
cp -f $(BUILD_DIR)/dist/files/lib64/wine/dxvk/*.dll /vagrant/dxvk/lib64/wine/dxvk/

dxvk-nvapi: | vagrant_share/dxvk-nvapi/lib/wine/nvapi
dxvk-nvapi: | vagrant_share/dxvk-nvapi/lib64/wine/nvapi
dxvk-nvapi: private SHELL := $(VAGRANT_SHELL)
dxvk-nvapi: downloads
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) dxvk-nvapi && \
cp -f $(BUILD_DIR)/dist/files/lib/wine/nvapi/*.dll /vagrant/dxvk-nvapi/lib/wine/nvapi/ && \
cp -f $(BUILD_DIR)/dist/files/lib64/wine/nvapi/*.dll /vagrant/dxvk-nvapi/lib64/wine/nvapi/

vkd3d-proton: | vagrant_share/vkd3d-proton/lib/wine/vkd3d-proton
vkd3d-proton: | vagrant_share/vkd3d-proton/lib64/wine/vkd3d-proton
vkd3d-proton: private SHELL := $(VAGRANT_SHELL)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ the Wine prefix. Removing the option will revert to the previous behavior.
| <tt>noesync</tt> | <tt>PROTON_NO_ESYNC</tt> | Do not use eventfd-based in-process synchronization primitives. |
| <tt>nofsync</tt> | <tt>PROTON_NO_FSYNC</tt> | Do not use futex-based in-process synchronization primitives. (Automatically disabled on systems with no `FUTEX_WAIT_MULTIPLE` support.) |
| <tt>noxim</tt> | <tt>PROTON_NO_XIM</tt> | Enabled by default. Do not attempt to use XIM (X Input Methods) support. XIM support is known to cause crashes with libx11 older than version 1.7. |
| <tt>enablenvapi</tt> | <tt>PROTON_ENABLE_NVAPI</tt> | Enable NVIDIA's NVAPI GPU support library. |
| <tt>nativevulkanloader</tt> | | Use the Vulkan loader shipped with the game instead of Proton's built-in Vulkan loader. This breaks VR support, but is required by a few games. |
| <tt>forcelgadd</tt> | <tt>PROTON_FORCE_LARGE_ADDRESS_AWARE</tt> | Force Wine to enable the LARGE_ADDRESS_AWARE flag for all executables. Enabled by default. |
| <tt>heapdelayfree</tt>| <tt>PROTON_HEAP_DELAY_FREE</tt>| Delay freeing some memory, to work around application use-after-free bugs. |
Expand Down
26 changes: 26 additions & 0 deletions build/makefile_base.mak
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,32 @@ $(OBJ)/.dxvk-post-build32:
touch $@


##
## dxvk-nvapi
##

DXVK_NVAPI_MESON_ARGS32 = \
--bindir=$(DXVK_NVAPI_DST32)/lib/wine/nvapi \
--cross-file=$(DXVK_NVAPI_OBJ32)/build-win32.txt
DXVK_NVAPI_MESON_ARGS64 = \
--bindir=$(DXVK_NVAPI_DST64)/lib64/wine/nvapi \
--cross-file=$(DXVK_NVAPI_OBJ64)/build-win64.txt

$(eval $(call rules-source,dxvk-nvapi,$(SRCDIR)/dxvk-nvapi))
$(eval $(call rules-meson,dxvk-nvapi,32))
$(eval $(call rules-meson,dxvk-nvapi,64))

$(OBJ)/.dxvk-nvapi-post-build64:
mkdir -p "$(DST_DIR)"/lib64/wine/nvapi
rm -f "$(DST_DIR)"/lib64/wine/nvapi/version && if test -e $(SRCDIR)/.git; then ( cd $(SRCDIR) && git submodule status -- dxvk-nvapi ) > "$(DST_DIR)"/lib64/wine/nvapi/version; fi
touch $@

$(OBJ)/.dxvk-nvapi-post-build32:
mkdir -p "$(DST_DIR)"/lib/wine/nvapi
rm -f "$(DST_DIR)"/lib/wine/nvapi/version && if test -e $(SRCDIR)/.git; then ( cd $(SRCDIR) && git submodule status -- dxvk-nvapi ) > "$(DST_DIR)"/lib/wine/nvapi/version; fi
touch $@


##
## vkd3d-proton
##
Expand Down
1 change: 1 addition & 0 deletions dxvk-nvapi
Submodule dxvk-nvapi added at 8b3987
20 changes: 20 additions & 0 deletions proton
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ class CompatData:

use_wined3d = "wined3d" in g_session.compat_config
use_dxvk_dxgi = not ("WINEDLLOVERRIDES" in g_session.env and "dxgi=b" in g_session.env["WINEDLLOVERRIDES"])
use_nvapi = 'enablenvapi' in g_session.compat_config

builtin_dll_copy = os.environ.get("PROTON_DLL_COPY",
#dxsetup redist
Expand Down Expand Up @@ -493,6 +494,7 @@ class CompatData:
str(use_wined3d),
str(use_dxvk_dxgi),
builtin_dll_copy,
str(use_nvapi),
))

if old_ver == CURRENT_PREFIX_VERSION:
Expand Down Expand Up @@ -586,6 +588,23 @@ class CompatData:
self.prefix_dir + "drive_c/windows/syswow64/" + f + ".dll")
g_session.dlloverrides[f] = "n"

# If the user requested the NVAPI be available, copy it into place.
# If they didn't, clean up any stray nvapi DLLs.
if use_nvapi:
try_copy(g_proton.lib64_dir + "wine/nvapi/nvapi64.dll",
self.prefix_dir + "drive_c/windows/system32/nvapi64.dll")
try_copy(g_proton.lib_dir + "wine/nvapi/nvapi.dll",
self.prefix_dir + "drive_c/windows/syswow64/nvapi.dll")
g_session.dlloverrides["nvapi64"] = "n"
g_session.dlloverrides["nvapi"] = "n"
else:
nvapi64_dll = self.prefix_dir + "drive_c/windows/system32/nvapi64.dll"
nvapi32_dll = self.prefix_dir + "drive_c/windows/syswow64/nvapi.dll"
if os.path.exists(nvapi64_dll):
os.unlink(nvapi64_dll)
if os.path.exists(nvapi32_dll):
os.unlink(nvapi32_dll)

try_copy(g_proton.lib64_dir + "wine/vkd3d-proton/d3d12.dll",
self.prefix_dir + "drive_c/windows/system32/d3d12.dll")
try_copy(g_proton.lib_dir + "wine/vkd3d-proton/d3d12.dll",
Expand Down Expand Up @@ -751,6 +770,7 @@ class Session:
self.check_environment("PROTON_SET_GAME_DRIVE", "gamedrive")
self.check_environment("PROTON_NO_XIM", "noxim")
self.check_environment("PROTON_HEAP_DELAY_FREE", "heapdelayfree")
self.check_environment("PROTON_ENABLE_NVAPI", "enablenvapi")

if "noesync" in self.compat_config:
self.env.pop("WINEESYNC", "")
Expand Down

0 comments on commit 0503dde

Please sign in to comment.