jp7677 / dxvk-nvapi

Alternative NVAPI implementation on top of DXVK.
MIT License
353 stars 32 forks source link

DXVK-NVAPI Broken in Dead Space Remake #126

Closed gardotd426 closed 1 year ago

gardotd426 commented 1 year ago

So, every time I try to launch the Dead Space Remake through Lutris (EA App), the logs read DXGI: NVApi Workaround enabled, reporting AMD GPU, despite the fact that I have a dxvk.conf with the option set to false, I have DXVK_ENABLE_NVAPI=1 set, and DLSS works in all my other Lutris games (CP2077 on GoG, Control Ult Edition on GoG, Rise of the Tomb Raider on EGS, Control standard edition on EGS, etc).

Just to see what was going on, I launched CP2077 back to back with Dead Space, both with DXVK_LOG_LEVEL=info DXVK_LOG_PATH=~/tmp, and my dxvk-nvapi.log file shows that initialization is failing:

CP2077 Log:

---------- 2023-05-27 04:14:46 ----------
NvAPI_QueryInterface (0xad298d3f): Unknown function ID
DXVK-NVAPI v0.6.3-4-g2483eac (Cyberpunk2077.exe)
Successfully acquired Vulkan vkGetInstanceProcAddr @ 0x2d4add570
NvAPI Device: NVIDIA GeForce RTX 3090 (530.41.3)
NvAPI Output: \\.\DISPLAY1
NvAPI_Initialize: OK
NvAPI_QueryInterface (0x33c7358c): Unknown function ID
NvAPI_QueryInterface (0x593e8644): Unknown function ID
NvAPI_EnumPhysicalGPUs: OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_GPU_GetArchInfo: OK
NvAPI_Initialize: OK
NvAPI_EnumPhysicalGPUs: OK
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_DRS_CreateSession: OK
NvAPI_DRS_LoadSettings: OK
NvAPI_DRS_GetBaseProfile: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_QueryInterface (0xf2400ab): Unknown function ID
NvAPI_EnumPhysicalGPUs: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_GPU_GetArchInfo: OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_DRS_GetSetting (0x10afb764/Unknown): Setting not found
NvAPI_DRS_CreateSession: OK
NvAPI_QueryInterface (0xa782ea46): Unknown function ID
NvAPI_DRS_FindApplicationByName (C:\Program Files (x86)\GOG Galaxy\Games\Cyberpunk 2077\bin\x64\Cyberpunk2077.exe): Executable not found
NvAPI_DRS_DestroySession: OK
NvAPI_Initialize: OK
NvAPI_EnumPhysicalGPUs: OK
NvAPI_DRS_GetSetting (0x10afb764/Unknown): Setting not found
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_GPU_GetArchInfo: OK
NvAPI_DRS_GetSetting (0x10afb76b/Unknown): Setting not found
NvAPI_EnumPhysicalGPUs: OK
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_EnumPhysicalGPUs: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_GPU_GetArchInfo: OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_DRS_GetSetting (0x10afb764/Unknown): Setting not found
NvAPI_DRS_CreateSession: OK
NvAPI_DRS_FindApplicationByName (C:\Program Files (x86)\GOG Galaxy\Games\Cyberpunk 2077\bin\x64\Cyberpunk2077.exe): Executable not found
NvAPI_DRS_DestroySession: OK
NvAPI_DRS_GetSetting (0x10afb764/Unknown): Setting not found
NvAPI_DRS_GetSetting (0x10afb76b/Unknown): Setting not found
NvAPI_Initialize: OK
NvAPI_D3D12_GetRaytracingCaps (1): OK
NvAPI_D3D12_GetRaytracingCaps (0): OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_DRS_GetSetting (0x10afb76b/Unknown): Setting not found
NvAPI_EnumPhysicalGPUs: OK
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_EnumPhysicalGPUs: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_GPU_GetArchInfo: OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_DRS_GetSetting (0x10afb764/Unknown): Setting not found
NvAPI_DRS_CreateSession: OK
NvAPI_DRS_FindApplicationByName (C:\Program Files (x86)\GOG Galaxy\Games\Cyberpunk 2077\bin\x64\Cyberpunk2077.exe): Executable not found
NvAPI_DRS_DestroySession: OK
NvAPI_DRS_CreateSession: OK
NvAPI_DRS_LoadSettings: OK
NvAPI_DRS_GetBaseProfile: OK
NvAPI_DRS_GetSetting (0x10afb76b/Unknown): Setting not found
NvAPI_D3D12_IsFatbinPTXSupported: OK
NvAPI_EnumPhysicalGPUs: OK
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_GPU_GetArchInfo: OK
NvAPI_D3D12_GetGraphicsCapabilities (sm_86): OK
NvAPI_DRS_GetSetting (0x10afb76a/Unknown): Setting not found
NvAPI_DRS_GetSetting (0x10afb76c/Unknown): Setting not found
NvAPI_D3D12_CreateCubinComputeShaderWithName: OK
NvAPI_D3D_GetSleepStatus: No implementation
NvAPI_D3D_GetLatency: No implementation
NvAPI_QueryInterface NvAPI_D3D12_SetNvShaderExtnSlotSpaceLocalThread: Not implemented method
NvAPI_QueryInterface NvAPI_D3D12_SetNvShaderExtnSlotSpaceLocalThread: Not implemented method
NvAPI_QueryInterface NvAPI_D3D12_SetNvShaderExtnSlotSpaceLocalThread: Not implemented method
NvAPI_QueryInterface NvAPI_D3D12_SetNvShaderExtnSlotSpaceLocalThread: Not implemented method
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_D3D12_GetRaytracingAccelerationStructurePrebuildInfoEx: OK
NvAPI_D3D12_CaptureUAVInfo: OK
NvAPI_D3D12_GetCudaTextureObject: OK
NvAPI_D3D12_LaunchCubinShader: OK
NvAPI_QueryInterface (0xd7c61344): Unknown function ID

Dead Space:

---------- 2023-05-27 04:17:17 ----------
NvAPI_QueryInterface (0xad298d3f): Unknown function ID
DXVK-NVAPI v0.6.3-4-g2483eac (Dead Space.exe)
Successfully acquired Vulkan vkGetInstanceProcAddr @ 0x2d4ad3fa0
NvAPI_Initialize: NVIDIA or other suitable device not found or initialization failed

I've tried everything I can think of. It also doesn't work in ANY Proton 8.X games (regardless of 8.X version, whether official, experimental, TKG, or GE), but if I switch to ANY 7.X version, it works fine. But I believe that's a separate bug, because the Reporting AMD GPU doesn't show up, I'll get some logs tomorrow and either add them here or open a separate issue if the logs aren't the same.

jp7677 commented 1 year ago

I don’t think that dxvk-nvapi is the issue here, but something in your setup prevents dxvk from disabling the nvapi work around.

You are seeing NVIDIA or other suitable device not found because dxvk still has the NVApi Workaround enabled, reporting AMD GPU. So dxvk-nvapi skips your NVIDIA GPU because dxvk reports it as AMD. Do you have DXVK_CONFIG_FILE set, thus pointing accidentally to another configuration file? Note also that dxvk is picky about casing, so it should be False instead of false. The top of the dxvk log file should print the applied settings.

About Proton 8, I’m very sure that Proton 8 works just fine (at least the official Proton versions). The recently updated Experimental branch even ships current dxvk-nvapi master, so I’m quite confident that there is no regression. But let’s see indeed what your logs are saying.

gardotd426 commented 1 year ago

I don’t think that dxvk-nvapi is the issue here, but something in your setup prevents dxvk from disabling the nvapi work around.

My env has DXVK_CONFIG_FILE=/home/matt/Documents/dxvk.conf (same as literally all my other games, including the games I mentioned earlier that work fine).

And in my dxvk.conf, I have:

 dxgi.nvapiHack = False
 dxgi.customDeviceId = 10DE
 dxgi.customVendorId = 2204

You are seeing NVIDIA or other suitable device not found because dxvk still has the NVApi Workaround enabled, reporting AMD GPU. So dxvk-nvapi skips your NVIDIA GPU because dxvk reports it as AMD. Do you have DXVK_CONFIG_FILE set, thus pointing accidentally to another configuration file? Note also that dxvk is picky about casing, so it should be False instead of false. The top of the dxvk log file should print the applied settings.

So, for some reason DXVK will NOT create a log file. I just launched the game 6 times, with DXVK_LOG_PATH=/home/matt/tmp and DXVK_LOG_LEVEL=info, DXVK_LOG_LEVEL=error, DXVK_LOG_LEVEL=debug (not all at once obviously, I tried all of them multiple times. But there is no log file there. Or anywhere in the wineprefix (I used find). But dxvk-nvapi.log shows up there perfectly fine.

*.dxvk-cache files ARE being created, though.

About Proton 8, I’m very sure that Proton 8 works just fine (at least the official Proton versions). The recently updated Experimental branch even ships current dxvk-nvapi master, so I’m quite confident that there is no regression. But let’s see indeed what your logs are saying.

I mean, it's universal. The bug might be somewhere in Proton/the Sniper runtime that isn't DXVK-NVAPI, but like I said:

I don't see how that could possibly indicate a configuration issue, when all non-Steam games (except Dead Space) work on Proton 8.X wine builds with the latest VKD3D-Protton/DXVK/DXVK-NVAPI master builds, and ALL Steam games work with Proton 7.X. Like how could simply switching a Proton version from the dropdown break DLSS, switching back to 7.x will fix it, and I can use the 8.x Proton build in Lutris to run another game and it'll work? I have wracked my brain for like a month trying to figure that out.

Okay, so concerning Dead Space, there has to be some sort of hard-coded nvapiHack enabling within DXVK's code, because I just did the following:

info:  DXGI: NvAPI workaround enabled, reporting AMD GPU

This is in a prefix with a KNOWN working game, using the EXACT same env. Something is wrong.

jp7677 commented 1 year ago

Could you try Deathloop on Steam set to vanilla Proton 8 without any settings applied whatsoever? Thus no env vars, no launch options, no app-settings.py etc? Proton 8 enables nvapi by default for this game (https://github.com/ValveSoftware/Proton/blob/proton_8.0/proton#L1104) thus nothing is needed to enable dlss.

This is in a prefix with a KNOWN working game, using the EXACT same env. Something is wrong.

Sorry, I’m not that familiar with Lutris magic and when what settings gets applied. But yeah, something is definitely weird.

gardotd426 commented 1 year ago

WTF IS HAPPENING

Sure enough, DLSS is available, and I even switched between Quality and Performance while looking at the fps counter to make sure it was actually working, it was. I guess I could try re-adding my envvars one-by-one to see what breaks it. Or if anything breaks it. With my luck it won't break again, because now Cyberpunk 2077 is broken.

I launched CP2077, DLSS worked (you saw the log yourself, timestamped from this morning). I killed the game, and installed EA App into that wineprefix, and launching EA App did the Reporting AMD GPU nonsense. So I killed that, then launched CP2077. Reporting AMD GPU. So I copied just the game files into a new wineprefix, never touched, and launched the new wineprefix (after installing dxvk-nvapi, vkd3d, and dxvk into the prefix). Still reporting AMD GPU. But I guess I can remove every single environment variable and see if that fixes it, it should work with zero launch options because enabling DLSS support in Lutris in the configure menu only sets DLL overrides and installs the files into the prefix, no envvars.

gardotd426 commented 1 year ago

REGRESSION! lol sorry, I'm excited. So, I found it. I haven't been able to bisect it or anything, cause that'll entail deleting prefixes and running git bisect and compiling dxvk and dxvk-nvapi and installing them into a Proton build each time.

But anyway, I added the first envvar, VKD3D_CONFIG=dxr11 %command%. DLSS still worked.

So, I switched to Proton Experimental, instead of vanilla 8.0-2. Sure enough, DLSS is now dead.

Just to confirm, I added PROTON_ENABLE_NVAPI=1 PROTON_HIDE_NVIDIA_GPU=0 to the envvars, still dead, so then I went back to 8.0-2 and kept those same exact envvars, and sure enough, it came back.

jp7677 commented 1 year ago

Does your Proton Experimental installation contains any modifications or is this vanilla Experimental? Like app-settings.py entries or updated components (dxvk) etc?

gardotd426 commented 1 year ago

Nope, I haven't touched a single thing. It's pure bleeding edge experimental.

jp7677 commented 1 year ago

Experimental or Bleeding Edge? Those are two different versions.

gardotd426 commented 1 year ago

Well no, I'm using Proton Experimental, but I've opted into the bleeding edge branch of it. But that's not the problem, because it's been broken for well over a month, so it's not some bleeding edge update. But I'm starting the bisect right now, I'm starting with DXVK first, I checked out the commit used in Proton 8.0-2 and built it and I'm gonna see what that does and go from there.

If you want, I can opt into the stable branch of Proton Experimental just to confirm that it's broken too, just so there aren't any unnecessary assumptions I might be making. Should I do that?

jp7677 commented 1 year ago

Yes, let’s make sure first if there is a difference between Experimental and Experimental Beelding Edge.

gardotd426 commented 1 year ago

Yeah, I was already downloading the stable version right after I commented that, cause I figured you'd want me to confirm it. No difference, still broken. I'm copying the DXVK dlls into another 8.x build that I've confirmed to be broken to see what happens, if it's a DXVK issue this should fix it. After that I'll try DXVK-NVAPI.

jp7677 commented 1 year ago

Leaving Experimental untouched and comparing Proton/DXVK/DXVK-NVAPI log files between Experimental and non-Experimental Proton might also reveal some hints.

gardotd426 commented 1 year ago

Okay, yeah I am leaving Experimental untouched, I just switched to a...

Okay I stopped typing that cause I started the dxvk-nvapi bisection (installing the older dxvk didn't work).

Sure enough: it works.

Good commit starting at commit 80397ea.

I can probably just go ahead and do the bisect since I have such a head start, if you want.

jp7677 commented 1 year ago

Yeah sure :) all good as long as you do one thing at a time.

gardotd426 commented 1 year ago

Yeah, I thought about just trying to bisect it before even reporting (I think you may remember that usually I bisect stuff before I even come to you or Phillip or Hans-Kristian or anything), but at the time I thought all 8.x builds were bad which would mean I'd have to bisect forever, but now that I've found that it's for sure dxvk-nvapi, and it's for sure good at 80397ea, that's not too bad. I'm done with step 1, still bad, I have 3 steps left.

gardotd426 commented 1 year ago

Well whaddya know....

The culprit is:

    nvapi-adapter: Skip NVIDIA adapter when DXVK reports another vendor

    In other words, the DXVK NVAPI-hack is enabled and the NVIDIA GPU is
    supposed to be seen as an AMD GPU.

commit hash d4b1371

I saw that in the commit history and I thought about just reverting that one, that completely explains why in Lutris games it coincides with the nvapi hack being reported.

I'm assuming now I'm gonna have to frickin bisect DXVK to find out why the hell it's FORCING nvapiHack when I have it completely disabled in all possible ways.

But yeah, I found the culprit.

gardotd426 commented 1 year ago

So, I did a fresh git clone and reverted only the bad commit, and compiled it, and placed the dlls in my Proton TKG build I've been using to bisect, and it does indeed work now.

Only problem is, it doesn't fix Lutris. Likely because the way they do things requires nvapihack to be disabled or something. So I'll have to bisect DXVK too, if I even can, which I mean it obviously needs bisecting anyway, since the issue stems from both DXVK and DXVK-NVAPI.

I will add that I've been compiling my own proton, dxvk, vkd3d, and dxvk-nvapi (and wine-nvml) builds for like 2 years at least (longer for some things), and nvapihack was NEVER forced before this all happened.

jp7677 commented 1 year ago

If you are compiling DXVK anyway, the switch in code is here: https://github.com/doitsujin/dxvk/blob/master/src/dxgi/dxgi_options.cpp#L76 , you might set this->nvapiHack = false; unconditionally to see how this goes. But the question remains why un-setting the nvapiHack using DXVK_ENABLE_NVAPI=1 (or PROTON_ENABLE_NVAPI=1 within Proton) isn't working in your setup.

gardotd426 commented 1 year ago

Yeah, what's even weirder is I've never even needed DXVK_ENABLE_NVAPI=1 before, I've always just disabled it in my dxvk.conf (but I did start using DXVK_ENABLE_NVAPI back when this stuff all broke, so yeah it is indeed not applying).

I'm globally enabling it in the source code now, I'll see what that does.

gardotd426 commented 1 year ago

So, Lutris is still failing, but I've found that it seems to be due to nvml failing to load. I have NO idea why it would be failing to load, all I did was run the included build.sh script. But before I bisected everything, dxvk-nvapi.log was just completely erroring out because it couldn't find an Nvidia adapter (because of the nvapiHack). Now it doesn't fail like that, it says this:

---------- 2023-05-27 09:39:42 ----------
NvAPI_QueryInterface (0xad298d3f): Unknown function ID
DXVK-NVAPI v0.6.3-5-g2baf2fc (Cyberpunk2077.exe)
Successfully acquired Vulkan vkGetInstanceProcAddr @ 0x2d4ad3fa0
Loading nvml.dll failed with error code: 1114
NvAPI Device: NVIDIA GeForce RTX 3090 (530.41.3)
NvAPI Output: \\.\DISPLAY1
NvAPI Output: \\.\DISPLAY2
NvAPI_Initialize: OK
NvAPI_QueryInterface (0x33c7358c): Unknown function ID
NvAPI_QueryInterface (0x593e8644): Unknown function ID
NvAPI_D3D12_GetRaytracingCaps (1): OK
NvAPI_D3D12_GetRaytracingCaps (0): OK
NvAPI_D3D12_GetRaytracingAccelerationStructurePrebuildInfoEx: OK
gardotd426 commented 1 year ago

Is nvml.dll even needed? Can I delete it from the wineprefix?

jp7677 commented 1 year ago

The DXVK_ENABLE_NVAPI switch was added later in DXVK to make it easier for Proton to disable the nvapiHack. Proton automatically sets DXVK_ENABLE_NVAPI=1 when PROTON_ENABLE_NVAPI=1 (Proton also copies the nvapi dll's when that switch is specified, so there is more to it). As you can see in the DXVK code, the env var has preference above the setting in the configuration file, thus when DXVK_ENABLE_NVAPI=1 is set, it doesn't matter any more what your configuration file says about the nvapiHack.

(as a side note, DXVK-NVAPI looks at the VendorId reported from DXVK (https://github.com/jp7677/dxvk-nvapi/blob/master/src/sysinfo/nvapi_adapter.cpp#L75), thus if you disable the nvapi hack, but still spoof AMD as a VendorId, DXVK-NVAPI still skips this GPU).

gardotd426 commented 1 year ago

I wonder why it's force enabling it then? I've used DXVK_ENABLE_NVAPI=1, and set Nvidia vendor and device IDs (the actual ones for my card) in my dxvk.conf, like I reported above.

jp7677 commented 1 year ago

Is nvml.dll even needed? Can I delete it from the wineprefix?

No, it is not needed and failing it to load really makes no difference to DLSS . Proton doesn't ship nvml. (That it fails to load is a Lutris packing issue, https://github.com/lutris/dxvk-nvapi/issues/6)

jp7677 commented 1 year ago

I wonder why it's force enabling it then? I've used DXVK_ENABLE_NVAPI=1, and set Nvidia vendor and device IDs (the actual ones for my card) in my dxvk.conf, like I reported above.

There is no need to set your vendor/device ID to your hardware, using DXVK_ENABLE_NVAPI=1 is the better way to disable any AMD spoofing.

gardotd426 commented 1 year ago

Welp, looks like we have another bug, I replaced the nvml.dlls with the original ones in the wineprefix, and it's still not working:

---------- 2023-05-27 09:52:48 ----------
NvAPI_QueryInterface (0xad298d3f): Unknown function ID
DXVK-NVAPI v0.6.3-5-g2baf2fc (Cyberpunk2077.exe)
Successfully acquired Vulkan vkGetInstanceProcAddr @ 0x2d4ad3fa0
Successfully loaded nvml.dll
NVML loaded and initialized successfully
NvAPI Device: NVIDIA GeForce RTX 3090 (530.41.3)
NvAPI Output: \\.\DISPLAY1
NvAPI Output: \\.\DISPLAY2
NvAPI_Initialize: OK
NvAPI_QueryInterface (0x33c7358c): Unknown function ID
NvAPI_QueryInterface (0x593e8644): Unknown function ID
NvAPI_D3D12_GetRaytracingCaps (1): OK
NvAPI_D3D12_GetRaytracingCaps (0): OK
NvAPI_D3D12_GetRaytracingAccelerationStructurePrebuildInfoEx: OK

It's picking up my GPU, nvapiHack is disabled, and yet it's not showing up in CP2077. Even though it showed up this morning.

I'm using the bisected version of dxvk-nvapi and the modified version of DXVK (which is why the nvapiHack is disabled). dxvk-nvapi is loading, but it's not fully completing the process. This morning, I had a shitload of stuff in the log when launching CP2077:

---------- 2023-05-27 04:14:46 ----------
NvAPI_QueryInterface (0xad298d3f): Unknown function ID
DXVK-NVAPI v0.6.3-4-g2483eac (Cyberpunk2077.exe)
Successfully acquired Vulkan vkGetInstanceProcAddr @ 0x2d4add570
NvAPI Device: NVIDIA GeForce RTX 3090 (530.41.3)
NvAPI Output: \\.\DISPLAY1
NvAPI_Initialize: OK
NvAPI_QueryInterface (0x33c7358c): Unknown function ID
NvAPI_QueryInterface (0x593e8644): Unknown function ID
NvAPI_EnumPhysicalGPUs: OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_GPU_GetArchInfo: OK
NvAPI_Initialize: OK
NvAPI_EnumPhysicalGPUs: OK
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_DRS_CreateSession: OK
NvAPI_DRS_LoadSettings: OK
NvAPI_DRS_GetBaseProfile: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_QueryInterface (0xf2400ab): Unknown function ID
NvAPI_EnumPhysicalGPUs: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_GPU_GetArchInfo: OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_DRS_GetSetting (0x10afb764/Unknown): Setting not found
NvAPI_DRS_CreateSession: OK
NvAPI_QueryInterface (0xa782ea46): Unknown function ID
NvAPI_DRS_FindApplicationByName (C:\Program Files (x86)\GOG Galaxy\Games\Cyberpunk 2077\bin\x64\Cyberpunk2077.exe): Executable not found
NvAPI_DRS_DestroySession: OK
NvAPI_Initialize: OK
NvAPI_EnumPhysicalGPUs: OK
NvAPI_DRS_GetSetting (0x10afb764/Unknown): Setting not found
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_GPU_GetArchInfo: OK
NvAPI_DRS_GetSetting (0x10afb76b/Unknown): Setting not found
NvAPI_EnumPhysicalGPUs: OK
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_EnumPhysicalGPUs: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_GPU_GetArchInfo: OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_DRS_GetSetting (0x10afb764/Unknown): Setting not found
NvAPI_DRS_CreateSession: OK
NvAPI_DRS_FindApplicationByName (C:\Program Files (x86)\GOG Galaxy\Games\Cyberpunk 2077\bin\x64\Cyberpunk2077.exe): Executable not found
NvAPI_DRS_DestroySession: OK
NvAPI_DRS_GetSetting (0x10afb764/Unknown): Setting not found
NvAPI_DRS_GetSetting (0x10afb76b/Unknown): Setting not found
NvAPI_Initialize: OK
NvAPI_D3D12_GetRaytracingCaps (1): OK
NvAPI_D3D12_GetRaytracingCaps (0): OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_DRS_GetSetting (0x10afb76b/Unknown): Setting not found
NvAPI_EnumPhysicalGPUs: OK
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_EnumPhysicalGPUs: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_GPU_GetArchInfo: OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_DRS_GetSetting (0x10afb764/Unknown): Setting not found
NvAPI_DRS_CreateSession: OK
NvAPI_DRS_FindApplicationByName (C:\Program Files (x86)\GOG Galaxy\Games\Cyberpunk 2077\bin\x64\Cyberpunk2077.exe): Executable not found
NvAPI_DRS_DestroySession: OK
NvAPI_DRS_CreateSession: OK
NvAPI_DRS_LoadSettings: OK
NvAPI_DRS_GetBaseProfile: OK
NvAPI_DRS_GetSetting (0x10afb76b/Unknown): Setting not found
NvAPI_D3D12_IsFatbinPTXSupported: OK
NvAPI_EnumPhysicalGPUs: OK
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_GPU_GetArchInfo: OK
NvAPI_D3D12_GetGraphicsCapabilities (sm_86): OK
NvAPI_DRS_GetSetting (0x10afb76a/Unknown): Setting not found
NvAPI_DRS_GetSetting (0x10afb76c/Unknown): Setting not found
NvAPI_D3D12_CreateCubinComputeShaderWithName: OK
NvAPI_D3D_GetSleepStatus: No implementation
NvAPI_D3D_GetLatency: No implementation
NvAPI_QueryInterface NvAPI_D3D12_SetNvShaderExtnSlotSpaceLocalThread: Not implemented method
NvAPI_QueryInterface NvAPI_D3D12_SetNvShaderExtnSlotSpaceLocalThread: Not implemented method
NvAPI_QueryInterface NvAPI_D3D12_SetNvShaderExtnSlotSpaceLocalThread: Not implemented method
NvAPI_QueryInterface NvAPI_D3D12_SetNvShaderExtnSlotSpaceLocalThread: Not implemented method
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_D3D12_GetRaytracingAccelerationStructurePrebuildInfoEx: OK
NvAPI_D3D12_CaptureUAVInfo: OK
NvAPI_D3D12_GetCudaTextureObject: OK
NvAPI_D3D12_LaunchCubinShader: OK
NvAPI_QueryInterface (0xd7c61344): Unknown function ID
gardotd426 commented 1 year ago

Also, when I switch back to master for dxvk-nvapi, it still fails to load.

---------- 2023-05-27 09:57:01 ----------
NvAPI_QueryInterface (0xad298d3f): Unknown function ID
DXVK-NVAPI v0.6.3-4-g2483eac (Cyberpunk2077.exe)
Successfully acquired Vulkan vkGetInstanceProcAddr @ 0x2d4ad3fa0
NvAPI_Initialize: NVIDIA or other suitable device not found or initialization failed

That's with the patched DXVK. And I've discovered that no dxgi.logs have been created in my CP2077 prefix since January (despite constant launching). 2.0-76 is the version in the last log.

jp7677 commented 1 year ago

My guess is that Lutris is not using your just compiled DXVK version but another one. Thus for the game you are still running an AMD card.

gardotd426 commented 1 year ago

The logs show that it's reading my card.

---------- 2023-05-27 09:52:48 ----------
NvAPI_QueryInterface (0xad298d3f): Unknown function ID
DXVK-NVAPI v0.6.3-5-g2baf2fc (Cyberpunk2077.exe)
Successfully acquired Vulkan vkGetInstanceProcAddr @ 0x2d4ad3fa0
Successfully loaded nvml.dll
NVML loaded and initialized successfully
NvAPI Device: NVIDIA GeForce RTX 3090 (530.41.3)
NvAPI Output: \\.\DISPLAY1
NvAPI Output: \\.\DISPLAY2
NvAPI_Initialize: OK
NvAPI_QueryInterface (0x33c7358c): Unknown function ID
NvAPI_QueryInterface (0x593e8644): Unknown function ID
NvAPI_D3D12_GetRaytracingCaps (1): OK
NvAPI_D3D12_GetRaytracingCaps (0): OK
NvAPI_D3D12_GetRaytracingAccelerationStructurePrebuildInfoEx: OK

NvAPI Device: NVIDIA GeForce RTX 3090 (530.41.3)

It is in fact using my just-compiled DXVK. But it doesn't need to, the necessary patch is reverting the bad DXVK-NVAPI commit (and it's using the correct DXVK-NVAPI build too).

Lutris symlinks your selected DXVK/DXVK-NVAPI/VKD3D dlls into the wineprefix, so a simple file /path/to/dlls will tell you what version is being used.

Plus, I just now launched Control Ultimate Edition, using the same exact DXVK build, the same exact DXVK-NVAPI build, and the same wine build, the only thing different is the wine prefix. And DLSS works.

Control dxvk-nvapi.log:

---------- 2023-05-27 10:11:55 ----------
NvAPI_QueryInterface (0xad298d3f): Unknown function ID
DXVK-NVAPI v0.6.3-5-g2baf2fc (Control_DX12.exe)
Successfully acquired Vulkan vkGetInstanceProcAddr @ 0x2d4ad3fa0
Loading nvml.dll failed with error code: 1114
NvAPI Device: NVIDIA GeForce RTX 3090 (530.41.3)
NvAPI Output: \\.\DISPLAY1
NvAPI Output: \\.\DISPLAY2
NvAPI_Initialize: OK
NvAPI_QueryInterface (0x33c7358c): Unknown function ID
NvAPI_QueryInterface (0x593e8644): Unknown function ID
NvAPI_DRS_CreateSession: OK
NvAPI_DRS_LoadSettings: OK
NvAPI_DRS_GetBaseProfile: OK
NvAPI_DRS_GetSetting (0x10afb76b/Unknown): Setting not found
NvAPI_EnumPhysicalGPUs: OK
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_QueryInterface (0xf2400ab): Unknown function ID
NvAPI_EnumPhysicalGPUs: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_GPU_GetArchInfo: OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_DRS_GetSetting (0x10afb764/Unknown): Setting not found
NvAPI_DRS_CreateSession: OK
NvAPI_QueryInterface (0xa782ea46): Unknown function ID
NvAPI_DRS_FindApplicationByName (C:\GOG\Control Ultimate Edition\Control_DX12.exe): Executable not found
NvAPI_DRS_DestroySession: OK
NvAPI_Initialize: OK
NvAPI_DRS_CreateSession: OK
NvAPI_DRS_LoadSettings: OK
NvAPI_DRS_GetBaseProfile: OK
NvAPI_DRS_GetSetting (0x10afb76b/Unknown): Setting not found
NvAPI_EnumPhysicalGPUs: OK
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_GPU_GetArchInfo: OK
NvAPI_D3D12_GetGraphicsCapabilities (sm_86): OK
NvAPI_DRS_GetSetting (0x10afb76a/Unknown): Setting not found
NvAPI_DRS_GetSetting (0x10afb76c/Unknown): Setting not found
NvAPI_D3D12_CreateCubinComputeShaderWithName: OK

When it reports an AMD GPU, the dxvk-nvapi.log file shows this:

---------- 2023-05-27 09:57:01 ----------
NvAPI_QueryInterface (0xad298d3f): Unknown function ID
DXVK-NVAPI v0.6.3-4-g2483eac (Cyberpunk2077.exe)
Successfully acquired Vulkan vkGetInstanceProcAddr @ 0x2d4ad3fa0
NvAPI_Initialize: NVIDIA or other suitable device not found or initialization failed

But in the first log in this comment, you'll see that it does find my NV GPU, and it successfully loads, it just doesn't complete the process.

jp7677 commented 1 year ago

Ah yeah, my bad, I had a wrong thought :) Startup in the logs is looking indeed good now.

Could you play a bit with the settings in Cyberpunk? May be another AA settings, that got enabled somehow in the meantime, prevents you from enabling DLSS?

gardotd426 commented 1 year ago

Nope, FSR and XeSS are both disabled, and DLSS is grayed out. Before the breakage, I could enable whichever one I wanted and turning on DLSS would just turn the others off. Nothing was grayed out except frame gen

gardotd426 commented 1 year ago

So, Dead Space works now too.

I switched over to the patched DXVK-NVAPI build and the patched DXVK (both were required), and DLSS has shown up for the first time ever in Dead Space.

Before today, it never once showed up in the whole time I've owned it.

Same prefix as CP2077, too.

gardotd426 commented 1 year ago

I have pretty fast internet, like 300Mbps, so I'm going to download a completely fresh install of CP2077 in a new wineprefix, and see what happens, because as you saw, it worked this morning even with full master everything, something has to have broken when I installed EA App into the prefix. If that doesn't work, I'll go from there.

But it's pretty confirmed at this point, nvapiHack is force-enabled no matter what DXVK_ENABLE_NVAPI says, I'll try to bisect it if I can (right now I'm having trouble finding a good commit, because 2.0 is too old to work with DXVK-NVAPI).

jp7677 commented 1 year ago

Do you still use your dxvk config in Lutris?

gardotd426 commented 1 year ago

Yeah, but it doesn't matter, I've tried both ways and it never makes a difference. It's not even needed now, because I hardcoded DXVK to disable nvapiHack. Plus DeadSpace is using the dxvk.conf, as is Control. Both work with DLSS using the same builds as CP2077.

jp7677 commented 1 year ago

Ok. Still weird that you also need that dxvk-nvapi commit to be reverted, because that commit only adds a check for the reported vendor Id from dxvk. If dxvk reports nvidia, that check should just pass.

jp7677 commented 1 year ago

Just to be sure, you really need a modified dxvk and a modified dxvk-nvapi? Only one of those is not sufficient?

gardotd426 commented 1 year ago

I just switched to master dxvk-nvapi and launched Dead Space, and sure enough it was broken:

---------- 2023-05-27 10:41:04 ----------
NvAPI_QueryInterface (0xad298d3f): Unknown function ID
DXVK-NVAPI v0.6.3-4-g2483eac (Dead Space.exe)
Successfully acquired Vulkan vkGetInstanceProcAddr @ 0x2d4ad3fa0
Loading nvml.dll failed with error code: 1114
NvAPI_Initialize: NVIDIA or other suitable device not found or initialization failed

Using the patched version fixes it.

But to respond to this:

Just to be sure, you really need a modified dxvk and a modified dxvk-nvapi? Only one of those is not sufficient?

Not counting CP2077 since that's broken regardless right now, in Dead Space and in Control, I ONLY need the patched dxvk-nvapi.

Without the patched dxvk, I still get the "Reporting AMD GPU" in the logs, but when the game launches, DXVK-NVAPI loads, and DLSS is available in the menu (before I patched DXVK-NVAPI, it never once showed me DLSS, the upscaling menu only showed TAA and FSR 2, now there are 3 options).

I just tried Dead Space with ONLY the patched DXVK. DLSS doesn't work. Even though the nvapiHack IS disabled (I'm piping all these attempts to log files, the workaround doesn't show up unless I use an UN-patched DXVK). But DXVK-NVAPI still fails:

---------- 2023-05-27 10:54:45 ----------
NvAPI_QueryInterface (0xad298d3f): Unknown function ID
DXVK-NVAPI v0.6.3-4-g2483eac (Dead Space.exe)
Successfully acquired Vulkan vkGetInstanceProcAddr @ 0x2d4ad3fa0
NvAPI_Initialize: NVIDIA or other suitable device not found or initialization failed

But if I switch to the patched dxvk-nvapi, DLSS does work, whether I used the patched DXVK or not. It always works.

So there's obviously a bug in DXVK that's force-enabling the nvapiHack, but there is seemingly also a bug in dxvk-nvapi because unless I revert that bad commit, DLSS will not work no matter what I do.

jp7677 commented 1 year ago

Oh wow, just seeing this now:

And in my dxvk.conf, I have:

dxgi.nvapiHack = False dxgi.customDeviceId = 10DE dxgi.customVendorId = 2204

Your vendor and device IDs are reverted. 0x10de is the NVIDIA vendor ID, see eg https://devicehunt.com/view/type/pci/vendor/10DE (first Google hit, there are probably better sites)

gardotd426 commented 1 year ago

Okay, so what the hell lmao.

I hadn't edited that dxvk.conf in months, and I don't even remember the last time I edited the vendor id and device id, but this morning, even with the bad vendor id and device id, the nvapihack wasn't getting enabled in CP2077 and DLSS was working. I mean you saw it yourself in that very first CP2077 log I showed you. That was with an unmodified DXVK-NVAPI and an unmodified dxvk.conf.

But now I have fixed it, and DLSS is working in CP2077, Dead Space, and Control, with DXVK master and DXVK-NVAPI master, but get this - in Dead Space, it's STILL reporting the nvapiHack being enabled, even after fixing the dxvk.conf file.

game log:

info:  DXGI: NvAPI workaround enabled, reporting AMD GPU

dxvk-nvapi.log:

---------- 2023-05-27 10:58:42 ----------
NvAPI_QueryInterface (0xad298d3f): Unknown function ID
DXVK-NVAPI v0.6.3-5-g2baf2fc (Dead Space.exe)
Successfully acquired Vulkan vkGetInstanceProcAddr @ 0x2d4ad3fa0
NvAPI Device: NVIDIA GeForce RTX 3090 (530.41.3)
NvAPI Output: \\.\DISPLAY1
NvAPI Output: \\.\DISPLAY2
NvAPI_Initialize: OK
NvAPI_QueryInterface (0x33c7358c): Unknown function ID
NvAPI_QueryInterface (0x593e8644): Unknown function ID
NvAPI_EnumPhysicalGPUs: OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_GPU_GetArchInfo: OK
NvAPI_Initialize: OK
NvAPI_DRS_CreateSession: OK
NvAPI_DRS_LoadSettings: OK
NvAPI_DRS_GetBaseProfile: OK
NvAPI_DRS_GetSetting (0x10afb76b/Unknown): Setting not found
NvAPI_EnumPhysicalGPUs: OK
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_QueryInterface (0xf2400ab): Unknown function ID
NvAPI_EnumPhysicalGPUs: OK
NvAPI_DRS_GetSetting (0x10e41df2/Unknown): Setting not found
NvAPI_GPU_GetArchInfo: OK
NvAPI_SYS_GetDriverAndBranchVersion: OK
NvAPI_DRS_GetSetting (0x10afb764/Unknown): Setting not found
NvAPI_DRS_CreateSession: OK
NvAPI_QueryInterface (0xa782ea46): Unknown function ID
NvAPI_DRS_FindApplicationByName (D:\EA\Dead Space (2023)\Dead Space.exe): Executable not found
NvAPI_DRS_DestroySession: OK
NvAPI_Initialize: OK
NvAPI_DRS_CreateSession: OK
NvAPI_DRS_LoadSettings: OK
NvAPI_DRS_GetBaseProfile: OK
NvAPI_DRS_GetSetting (0x10afb76b/Unknown): Setting not found
NvAPI_D3D12_IsFatbinPTXSupported: OK
NvAPI_EnumPhysicalGPUs: OK
NvAPI_GPU_GetAdapterIdFromPhysicalGpu: OK
NvAPI_GPU_GetArchInfo: OK
NvAPI_D3D12_GetGraphicsCapabilities (sm_86): OK
NvAPI_DRS_GetSetting (0x10afb76a/Unknown): Setting not found
NvAPI_DRS_GetSetting (0x10afb76c/Unknown): Setting not found
NvAPI_D3D12_CreateCubinComputeShaderWithName: OK
NvAPI_D3D_Sleep: No implementation
NvAPI_GPU_GetDynamicPstatesInfoEx: No implementation

Like, wat?

But anyway, I suppose that's more of a curiosity at this point, since DLSS is now working in the Lutris games now too. I'll go ahead and close this, and if I can figure out why nvapiHack is being force-enabled only for EA App I'll report it to Phillip. Thanks Jens.

jp7677 commented 1 year ago

You are welcome! I’m glad that we could track this down.

I would advise to remove those configuration option for the ID overrides, those are easily forgotten and can cause issues when you switch GPUs (e.g. Ada is detected by looking at the device ID) and, as you have seen, those are prone to errors :)

gardotd426 commented 1 year ago

You're totally right, I've just had it for years and so now I have about 70 games pointing to that file, because before there wasn't a DXVK_ENABLE_NVAPI option.

I've also finally got DLSS working in Dying Light 2 (Steam), it along with Dead Space was the only game I couldn't get DLSS in on Proton 7 OR 8. Thanks again man