diff --git a/.gitmodules b/.gitmodules
index 895597cd..373b9e34 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -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
diff --git a/Makefile b/Makefile
index 1226ac96..2f256704 100644
--- a/Makefile
+++ b/Makefile
@@ -181,6 +181,14 @@ dxvk: downloads
cp -f $(BUILD_DIR)/dist/dist/lib/wine/dxvk/*.dll /vagrant/dxvk/lib/wine/dxvk/ && \
cp -f $(BUILD_DIR)/dist/dist/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)
diff --git a/README.md b/README.md
index 82d9c811..8d732c75 100644
--- a/README.md
+++ b/README.md
@@ -315,6 +315,7 @@ the Wine prefix. Removing the option will revert to the previous behavior.
| noesync | PROTON_NO_ESYNC | Do not use eventfd-based in-process synchronization primitives. |
| nofsync | PROTON_NO_FSYNC | Do not use futex-based in-process synchronization primitives. (Automatically disabled on systems with no `FUTEX_WAIT_MULTIPLE` support.) |
| noxim | PROTON_NO_XIM | 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. |
+| enablenvapi | PROTON_ENABLE_NVAPI | Enable NVIDIA's NVAPI GPU support library. |
| nativevulkanloader | | 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. |
| forcelgadd | PROTON_FORCE_LARGE_ADDRESS_AWARE | Force Wine to enable the LARGE_ADDRESS_AWARE flag for all executables. Enabled by default. |
| heapdelayfree| PROTON_HEAP_DELAY_FREE| Delay freeing some memory, to work around application use-after-free bugs. |
diff --git a/build/makefile_base.mak b/build/makefile_base.mak
index 26a6de9f..d978a990 100644
--- a/build/makefile_base.mak
+++ b/build/makefile_base.mak
@@ -744,6 +744,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
##
diff --git a/dxvk-nvapi b/dxvk-nvapi
new file mode 160000
index 00000000..8b3987f6
--- /dev/null
+++ b/dxvk-nvapi
@@ -0,0 +1 @@
+Subproject commit 8b3987f6707946b9202eda3dda38632197d2286b
diff --git a/proton b/proton
index 9e071e16..52fc1869 100755
--- a/proton
+++ b/proton
@@ -550,6 +550,7 @@ class CompatData:
use_wined3d = "wined3d" in g_session.compat_config
use_dxvk_dxgi = not use_wined3d and \
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
@@ -594,6 +595,7 @@ class CompatData:
str(use_wined3d),
str(use_dxvk_dxgi),
builtin_dll_copy,
+ str(use_nvapi),
))
# check whether any prefix config has changed
@@ -686,6 +688,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",
@@ -870,6 +889,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", "")