BoyC / GW2TacO

Guild Wars 2 Tactical Overlay (GW2TacO)
Other
243 stars 48 forks source link

DirectX11 SwapChain creation failed / DxgiFactory::CreateSwapChainForComposition: Not implemented #115

Open Mistreaper opened 2 years ago

Mistreaper commented 2 years ago

Note that I'm running Linux with WINE (desktop, not steam deck)

I wonder if this error is part of the project, WINE/DXVK, or this: https://gitlab.com/namoninja/gw2taco_linux/-/issues/55 itself.

Steps to reproduce

I think this occurs on all distros (including Steam Deck), and I'm using Kwin/KDE. This error also occurs when just wine-ing the TacO itself.

Over here is a the TacO "fix" I'm using: https://gitlab.com/namoninja/gw2taco_linux/ And over here there are two archives, drop the gw2taco_linux folder there: https://en-forum.guildwars2.com/topic/22771-playing-guild-wars-2-on-linux-performance-optimizations-and-more/

Extract, run the installer, and ./play.sh. cd into the gw2taco directory, ./install_taco.sh and run_taco.sh

I think it's a problem with dxgi, but I wonder if the TacO itself is causing all the errors.

BoyC commented 2 years ago

"Not implemented" is reported by the system, not TacO. Not much I can do about this on my end. If you can figure out the issue and send me a pull request I'd be happy to check it out.

Mistreaper commented 2 years ago

"Not implemented" is reported by the system, not TacO. Not much I can do about this on my end. If you can figure out the issue and send me a pull request I'd be happy to check it out.

Using Taco 0_032r works, but works badly on WINE. I found this interesting project called "Burrito": https://github.com/AsherGlick/Burrito I believe you and all Linux chads/enthusiasts would be interested.

GW2TacO_032r.zip

ghtesting2020 commented 1 year ago

is there a workaround for this? i tried Taco 0_032r and it does not work.

i tried gw2taco_linux and it cannot launch the taco portion

https://gitlab.com/namoninja/gw2taco_linux/-/issues/63

namoninja commented 5 months ago

@BoyC I am happy to try and figure this out if you can point me in the right direction.

My workarounds focused on TacO being able to start in WINE with a black screen (taco starts/no transparency). However after some version, TacO fails to start completely.

Could you guide me/hint at what changed in the code between the somewhat working black screen TacO to the latest versions compared to the mentioned 0_032r?

(It's been a long time since I've revisited this project so there may be many new versions, but TLDR, after some point none of us were able to start taco with a black screen, so either you, or WINE devs, must have changed some code related to dwmapi/dxgi implementations.)

I am currently considering 3 options,

  1. Try and get TacO to launch with black screen (because then my workarounds could work)
  2. Dive into how dwmapi/dxgi works in WINE and see if I can create a linux patch.
  3. Try to create a new workaround for BlishHUD which apparently supports tacopacks?

Option 1 is preferred since I am not really familiar with any of the WINE/Windows frameworks. Any input would help.

I know there are other people working on native builds, but they are all focusing on rebuilds. TacO is very feature packed and it would be nice to create a compatibility layer similar to Valve's Proton instead of "re-creating the wheel"..

BoyC commented 5 months ago

There was a major change at one point where TacO was changed over to the DirectComposition API to have better and more stable transparent rendering support for newer windows versions, I think that's what you're talking about. There's a fallback in the code if the directcomposition api isn't available, you may want to look into that. https://github.com/BoyC/GW2TacO/blob/023c432200ba8b48162de5a1ef61d097b9e93436/GW2TacO.cpp#L532

namoninja commented 5 months ago

Thanks! That helps, will have a look and see what I can find. :)

namoninja commented 5 months ago

This is definitely related to the transition to the DirectComposition API.

I tried running v42 which creates the swapchain fine, but v43 fails to create a swapchain. In your changelog you indicate that you moved to the DirectComposition API in v43.

I am going to look through your source code and try some tweaks. What was the previous API / Method that you used to create the swapchain?

DXVK has its own dxgi.dll implementation/support for composition. I'm not sure about dcomp.dll

BoyC commented 5 months ago

Originally it was some standard window creation (well, still is but with different window style flags) that's very flaky based on all the feedback I got over the years. You can trace the boolean set near the code I linked to see the differences, but a quick search will point you to the CreateClassicSwapChain call and its uses that acts as a fallback currently.

namoninja commented 5 months ago

@BoyC thanks for your input it has helped me understand your source code and find a temporary solution.

If I disable dcomp.dll using winecfg TacO fallsback to the old API and I can get the latest TacO v67 to start. :)

I will dig around a bit more and see if I can get TacO working with dcomp

ghtesting2020 commented 4 months ago

@BoyC thanks for your input it has helped me understand your source code and find a temporary solution.

If I disable dcomp.dll using winecfg TacO fallsback to the old API and I can get the latest TacO v67 to start. :)

I will dig around a bit more and see if I can get TacO working with dcomp

Hi @namoninja can you please write a quick little tutorial of how I can get this working on Linux? GW2 isn't the same since I moved over to Linux and couldn't use TacO

namoninja commented 2 months ago

@ghtesting2020 this conversation is more regarding the swapchain issue, and a workaround for that is to disable dcomp in wine dll overrides.

I can't give you a tutorial on how to get taco to work lol but if you are referring to my tweaks then rather follow the instructions on the gw2taco_linux repo repo or open an issue there.

@BoyC I suspect linux support via wine would be possible if your dcomp calls are translated/replaced with vulkan ones.

Would you be able to give me a rough idea of the following:

  1. Would it be possible to use Vulkan API instead of dcomp? I don't know how much vulkan supports but I did see APIs for creating swapchains, so in theory I would just replace your dcomp swapchain creations with vulkan ones.
  2. If it would be possible, how much of your code would need to be modified? ie, is it just 1 file/the initialization/swapchain creation or are you using dcomp calls everywhere in your project?

I am considering only porting some parts like the swapchain creation to vulkan and leaving others to use dcomp but I suspect that won't work and all the calls would have to be via vulkan. I don't think vulkan has as much support for composition/etc as dcomp so not sure everything could be run through the vulkan api.

I am complete noob at this so don't really know what I am talking about but just trying to figure out what might work to get some linux support.

BoyC commented 2 months ago

That won't be enough. You can't just mix and match graphics api calls as you wish. If you want to create the swapchain with vulkan you'll need to rewrite the whole display system in vulkan.

namoninja commented 2 months ago

I suspected as much. The only other solution I can think of is adding to the dxvk project. They are translating dx calls to vulkan and taco works with wine using their d3d11.dll and dxgi.dll

The only thing that doesn't work is the transparency, so maybe they are missing something.

I'm assuming the transparency happens somewhere using D3D11_BLEND or SetLayeredWindowAttributes

coderedart commented 2 months ago

For some reason, my previous comment seems to have disappeared.

Anyway, I would recommend avoiding vulkan for transparency support (using dxvk or rewriting taco's renderer). wine seems to hardcode the OPAQUE flag for vulkan swapchain's composite attribute https://github.com/wine-mirror/wine/blob/25c58e6887647a223aa74f7e7d0402abb4a2a2b8/dlls/dxgi/swapchain.c#L1916C40-L1916C73

And Nvidia only supports Opaque flag for swapchain on vulkan. It will probably work on x11 + nvidia, due to a longstanding bug in mesa https://gitlab.freedesktop.org/mesa/mesa/-/issues/6007 . But wayland definitely won't work.

Honestly, anything short of contributing to wine directly is just a huge time sink with little payoff. You will need to deal with X11 visuals and translate the win32's ex_layered flags properly to enable transparency for taco's window. And then, you also need to make sure that wine is using openGL (or give up on Nvidia hardware) for taco's window.

namoninja commented 2 months ago

Ok well the only easiest solution I have to this right now is using GLSL shaders to replace the black with alpha. I'm having issues however because i've moved over to wayland and I was using picom to pass the shaders.

I see in the TacO source code there is a bunch of shader classes and some commented out code.

Is it possible to just add this somewhere in the taco code?

uniform float opacity;
uniform bool invert_color;
uniform sampler2D tex;

void main() {
    vec4 c = texture2D(tex, gl_TexCoord[0].st);
    {
            vec4 vdiff = abs(vec4(0.0, 0.0, 0.0, 1.0) - c); //Solid Black
            float diff = max(max(max(vdiff.r, vdiff.g), vdiff.b), vdiff.a);
            if (diff < 0.001)
                    c *= 0.0; //Full Opacity
    }
    if (invert_color)
            c = vec4(vec3(c.a, c.a, c.a) - vec3(c), c.a);
    c *= opacity;
    gl_FragColor = c;
}
BoyC commented 2 months ago

Obviously TacO already outputs a backbuffer with the proper alpha values otherwise the windows compositor wouldn't be able to overlay transparently so there should be no need for all of that. Also TacO uses directx and thus HLSL.

namoninja commented 2 months ago

Thanks for the input @coderedart and @BoyC

I'm going to try see if I can get the shaders working on wayland as it did on x11... but yeah contributing to wine/dxvk is way out of my league here lol and I can barely grasp what's happening in the taco code. :sweat_smile: