protonscr

Optiscaler D3D11on12

dxvkclosed
doitsujin/dxvk#4897 · opened 2025-05-05 by MGThePro · updated 2025-05-06 · 15 comments · github
1 matching comments, n / p to jump
MMGThePro 2025-05-05 github

Hello, so for those who don't know Optiscaler is a tool that allows you to take the upscaler inputs from a game from DLSS, FSR3 or XeSS and feed these inputs into a different upscaling algorithm.

One case where this could be useful is with Dx11 games. Since newer versions of FSR and XeSS (on non Arc GPUs) do not support Dx11, Optiscaler tricks some of these upscalers by using D3D11on12 to run the upscalers in DirectX 12 and copy the upscaler input from the Dx11 game to the Dx12 upscaler.

To quote Optiscaler directly:

These implementations use a background DirectX12 device to be able to use Dirext12-only upscalers. There is a 10-15% performance penalty for this method, but allows many more upscaler options. [...] These implementations do not support Linux and will result in a black screen.

Now the question is; Can this be fixed on Linux? The upscalers themselves can run on vkd3d, but something with D3D11on12 or the background device seem to prevent it from working on Linux.

Ddoitsujin maintainer 2025-05-05 github

So what's the issue exactly and what is the easiest way to reproduce it? Where does the black screen assumption come from? Is there a demo app or something that's not a huge pain in the arse to debug?

We do support some (but not all) of the 11on12 APis already.

MMGThePro 2025-05-05 github

Well I'm not really sure why it doesn't work. But essentially, the parts of the screen that are supposed to get upscaled either freeze or are just black once selecting one of the upscalers that run through D3D11on12

Personally I could reproduce it in Baldurs Gate 3 when selecting the Dx11 version in the launcher and picking an upscaler that runs through D3D11on12. It should be reproducable in any Dx11 game or application with DLSS support (as long as it's compatible with optiscaler, which should be most)

If I select one of these D3D11on12 upscalers while already ingame, the upscaled parts of the image just freeze until I select a working upscaler. If I load into the game with a D3D11on12 upscaler enabled, the upscaled parts of the image stay black until I select a working upscaler. Not sure if that's relevant. The game keeps running even when frozen/blacked out however.

In the Optiscaler log once I select one of the D3D11on12 upscalers it keeps spamming this error message over and over again:

[14:55:44.244251] [E] IFeature_Dx11wDx12::ProcessDx11Textures Depth OpenSharedHandle error: -7ff8ffa9
[14:55:44.244278] [E] FSR31FeatureDx11on12::Evaluate Can't process Dx11 textures!

Working, regular upscaler:
Image

Broken D3D11on12 upscaler:
Image

Ddoitsujin maintainer 2025-05-05 github

https://github.com/doitsujin/vkd3d/tree/optiscaler two-line hack that makes it work for me with BG3 (tested with DLSS -> FSR 3.x Dx12)

Need to verify how Windows behaves here, but this seems to be a very trivial vkd3d-proton bug.

MMGThePro 2025-05-05 github

Hmm, I'm still having the same issue even with that build.

Just to retrace my steps and make sure I didn't do something wrong:
I downloaded the artifact (vkd3d-proton-optiscaler-f8804aa32d1139ed7aff5b0932eaac80d82966fa.zip), and extracted the d3d12.dll and d3d12core.dll from the x64 folder into the folder where the bg3 executable sits (steamapps/common/Baldurs Gate 3/bin/).
That didn't fix it, so I added the env variable WINEDLLOVERRIDES="d3d12,d3d12core"=n,b, which unfortunately still didn't change anything.

Was that not enough to overwrite the vkd3d version proton uses or something else going on?

EDIT: I made vkd3d output info log and it confirmed it is using build f8804aa32d1139e, so it matches the artifact from the optiscaler fork

BBlisto91 2025-05-05 github

It is better to directly replace the files that Proton ship and put in to the prefix system folders. Some games or tools might not work with them just next to the exe.
If as an example you are using current Proton Exeperimental that would be in steamapps/common/Proton - Experimental/files/lib/wine/vkd3d-proton/x86_64-windows/

Note that they will get overwritten when Experimental then has a update. You can also revert it by then verifying Proton in Steam.

MMGThePro 2025-05-05 github

That didn't change anything either unfortunately

Ddoitsujin maintainer 2025-05-05 github

Well, I can't repro it here anymore, so :shrug:

There seems to be a sync bug though, not sure if ours since there's some jank with shared fences, or if it's an optiscaler issue.

Mmbriar 2025-05-05 github

Fwiw, I've seen a very similar bug with optiscaler in FFVII Rebirth (pure dx12). The upscaling is fine, but if you open the optiscaler config gui, the game turns black and only the gui is visible. Maybe it's related somehow.

MMGThePro 2025-05-05 github

There seems to be a sync bug though, not sure if ours since there's some jank with shared fences, or if it's an optiscaler issue.

Under the Upscaler selection there is a "Dx11 with Dx12 Settings" section where input and output sync methods can be picked. Not sure if that's related but maybe it could help with troubleshooting

Ddoitsujin maintainer 2025-05-05 github

Fwiw, I've seen a very similar bug with optiscaler in FFVII Rebirth (pure dx12). The upscaling is fine, but if you open the optiscaler config gui, the game turns black and only the gui is visible. Maybe it's related somehow.

Is that not intended behaviour? Because that happens regardless of dx12 settings.

Mmbriar 2025-05-05 github

Fwiw, I've seen a very similar bug with optiscaler in FFVII Rebirth (pure dx12). The upscaling is fine, but if you open the optiscaler config gui, the game turns black and only the gui is visible. Maybe it's related somehow.

Is that not intended behaviour? Because that happens regardless of dx12 settings.

I'm pretty sure the game is supposed to continue rendering while the gui is displayed.

Ddoitsujin maintainer 2025-05-05 github

The optiscaler UI must be a separate window or something, it even hides the dxvk hud. Don't think this is within our scope.

Ddoitsujin maintainer 2025-05-05 github

Also, yeah, while there certainly is an issue wrt shared fences in vkd3d-proton that could potentially cause the app to observe a fence signal before we release a command allocator, the dx12 path in optiscaler
a) doesn't synchronize command allocator usage at all, and
b) uses hard-coded fence values that inherently lead to race conditions and randomly cause the whole thing to lock up.

This is so broken that we can't even work around it on our end.

MMGThePro 2025-05-06 github

With the merged PR on vkd3d-proton and some extra work on Optiscaler yesterday and today these upscaler implementations now also work on Linux. 🎊

Thanks for looking into it 👍

Ddoitsujin maintainer 2025-05-06 github

Cool, I was actually going to file an Optiscaler bug report about their dx12 usage but it looks like they fixed all of that.

Launch options

DLLs