BC46 / freelancer-hd-edition

Freelancer: HD Edition is a mod that aims to improve every aspect of the game Freelancer (2003) while keeping the look and feel as close to vanilla as possible.
https://www.moddb.com/mods/freelancer-hd-edition
161 stars 14 forks source link

Consider D8VK support #146

Open keenanweaver opened 1 year ago

keenanweaver commented 1 year ago

D8VK recently hit 1.0, so I've been testing it out with FL:HDE. Working very well out of the box on Linux and an AMD card. Haven't noticed anything glaringly bad, but I'm not a FL expert.

d8vk

The only changes I made in the dxvk.conf file were d3d9.forceSwapchainMSAA = 16 and d3d9.forceSampleRateShading = True to get rid of aliasing and sharp edges on textures.

Comparison between enabling & disabling forceSampleRateShading:

Enabled: rateshadeenable

Disabled: rateshadedisable

It should work on Windows, but I haven't tested it. I believe they are working on merging D8VK with DXVK, so it may be wise to wait until that happens if you think this is worth pursuing.

BC46 commented 1 year ago

Good suggestion! I'll be sure to give it a spin on my Windows machine soon.

keenanweaver commented 2 weeks ago

D8VK's been upstreamed into DXVK, so the next release will offer support for DX8 games out of the box.

BC46 commented 2 weeks ago

Do you happen to know whether a new release will come any time soon?

keenanweaver commented 2 weeks ago

I do not, but I'm assuming not soon. You can always grab an artifact from the CI and that'd probably work fine if you wanted to.

keenanweaver commented 1 week ago

Never mind: https://github.com/doitsujin/dxvk/releases/tag/v2.4

BC46 commented 1 week ago

I just tested it on my Windows machine and it seems to work fine. Though on rare occasions I noticed some stuttering occurring (probably caching or shader compilation), and a slight overall latency. Also the MSAA setting appears to be significantly heavier on the GPU than the MSAA options provided by DxWrapper and dgVoodoo. I can include a copy of DXVK, but it most likely won't be enabled by default.

keenanweaver commented 1 week ago

The stuttering is expected on Windows, but the resource intensity & latency I don't think is. I haven't exactly measured it compared to other solutions, but you're the Freelancer expert here. I think I'll do some tests on Linux to see if I observe the same. DXVK isn't really made for Windows at all, it's just a sort-of happy accident it works there.

keenanweaver commented 1 week ago

Did a bit of testing, here are some videos.

dgVoodoo, defaults

https://github.com/BC46/freelancer-hd-edition/assets/37268985/c9a02db7-405c-4696-8e41-272c90822cb5

Notice the judder, performance seems OK otherwise. Not great for Linux users out of the box.


DxWrapper, defaults

https://github.com/BC46/freelancer-hd-edition/assets/37268985/3382c64d-5ecb-4e45-828a-9cb921e0e9fa

Best looking, GPU performance load looks decent, no issues as far as I can see.


DXVK, no antialiasing (also no reshade)

https://github.com/BC46/freelancer-hd-edition/assets/37268985/c4aee866-28c2-428c-8945-b9e26773518f

Looks pretty bad by default (hard to tell in video, but it is).

DXVK, 4x antialiasing (also no reshade)

https://github.com/BC46/freelancer-hd-edition/assets/37268985/7a165117-705a-4e17-98e3-418e34623fc0

Better, load jumps a little.

DXVK, 16x antialiasing (also no reshade)

https://github.com/BC46/freelancer-hd-edition/assets/37268985/35ccafb4-ba59-4ee2-a41d-e390d6af74d7

Best looking of the DXVK-native bunch, but also high load activity as noted by you.


And for fun, wined3d (no enhancements at all)

https://github.com/BC46/freelancer-hd-edition/assets/37268985/ca9ccb7e-0ac6-4e67-8f0d-76b85b299d7c


My conclusions at this time are this:

I think DxWrapper at defaults is still the best for FLHDE Linux users.

BC46 commented 1 week ago

Thanks for sharing the videos and your conclusions! I'll add a copy of DXVK to the repository and for now also make DxWrapper the default for Linux users.

By the way, can you recommend using DXVK's anisotropic filtering option? I used d3d9.samplerAnisotropy = 16 and that seemed to positively affect the texture appearance on my end.

keenanweaver commented 1 week ago

You're welcome! Yeah, the anisotropic filtering option would work just fine. I didn't check it specifically for these tests, but in the past it worked great. Maybe the expertise of someone like @WinterSnowfall would benefit here.

WinterSnowfall commented 1 week ago

First off, I'm also a huge Freelancer fan, so thanks for letting me know this mod exists (TIL!).

Now, a couple of things:

The only changes I made in the dxvk.conf file were d3d9.forceSwapchainMSAA = 16 and d3d9.forceSampleRateShading = True to get rid of aliasing and sharp edges on textures.

d3d9.forceSampleRateShading combined with d3d9.forceSwapchainMSAA may produce a better looking image, however note that it comes with a significant peformance penalty. Largely, you are asking the GPU to do the rendering work equivalent to 16x its default, which isn't exactly cheap, not even with d3d8.

* If DXVK is included, put a dxvk.conf next to Freelancer.exe with the contents:

I acknowledge the goal of this mod is to improve image quality, but the general recommendation is not to force MSAA, as it can mess with depth in some games. Applying post-processing AA techniques such as SMAA with Vulkan layers (e.g. vkBasalt) is generally a far better (performance-wise) and more compatible approach.

By the way, can you recommend using DXVK's anisotropic filtering option? I used d3d9.samplerAnisotropy = 16 and that seemed to positively affect the texture appearance on my end.

If it doesn't introduce any artifacting (some games take issue with custom anisotropy), feel free to use it. It does vastly improve texture quality in games that don't apply it, and if you want to play games from this generation at higher resolutions, you generally want that to happen. Games like Mafia, for example, look atrocious without using this override.

keenanweaver commented 1 week ago

Well, I'd recommend going back to the drawing board and ignoring everything I've said thus far now that someone who knows what they're talking about is here!

d3d9.forceSampleRateShading combined with d3d9.forceSwapchainMSAA may produce a better looking image, however note that it comes with a significant peformance penalty. Largely, you are asking the GPU to do the rendering work equivalent to 16x its default, which isn't exactly cheap, not even with d3d8.

Pardon my ignorance, but is this the same methodology as dgVoodoo2? What's the layman's difference between that and DXVK?

I acknowledge the goal of this mod is to improve image quality, but the general recommendation is not to force MSAA, as it can mess with depth in some games. Applying post-processing AA techniques such as SMAA with Vulkan layers (e.g. vkBasalt) is generally a far better (performance-wise) and more compatible approach.

I genuinely thought that the vkBasalt/ReShade AA/AF paradigm was what DXVK (and dgVoodoo2/DxWrapper, etc.) did with those config options. Thanks for letting me know otherwise!

If it doesn't introduce any artifacting (some games take issue with custom anisotropy), feel free to use it. It does vastly improve texture quality in games that don't apply it, and if you want to play games from this generation at higher resolutions, you generally want that to happen. Games like Mafia, for example, look atrocious without using this override.

Any other options in the config you could recommend for Freelancer? I think BC46 can tell you all about an issue with AMD GPUs and light sources in this game. Maybe something that could be fixed in DXVK?

WinterSnowfall commented 1 week ago

Pardon my ignorance, but is this the same methodology as dgVoodoo2? What's the layman's difference between that and DXVK?

I have no idea what dgVoodoo2 does, nor is it easy to tell, since it's not open source. But I doubt it is using sample rate shading; it's probably only forced MSAA.

I genuinely thought that the vkBasalt/ReShade AA/AF paradigm was what DXVK (and dgVoodoo2/DxWrapper, etc.) did with those config options. Thanks for letting me know otherwise!

DXVK's goals are to ensure games are rendered on modern systems the same as they were back in the day. It obviously tries to improve performance and fix bugs when it can, but the "knobs" it exposes are mainly there for compatibility reasons, not to alter or enhance a game's behavior. dgVoodoo2/ReShade/other Vulkan layers, in contrast, can enable you to do a lot of things that go beyond a game's standard behavior.

Any other options in the config you could recommend for Freelancer?

Not that I can think of. I've gone through the entire game with dxvk as is (no tinkering whatsoever) and it perfectly recreated the original experience, which is what I was going for. For use with an HD mod, you can consider touching it up a bit, but that's entirely up to you.

I think BC46 can tell you all about an issue with AMD GPUs and light sources in this game. Maybe something that could be fixed in DXVK?

Feel free to open an issue with dxvk, but if it's a driver specific bug, then it's rather out of scope for us to address. Some games pick different rendering paths when reporting a different vendorID (e.g. Nvidia), so maybe that's something to try?

BC46 commented 1 week ago

I think BC46 can tell you all about an issue with AMD GPUs and light sources in this game. Maybe something that could be fixed in DXVK?

The issue with AMD GPUs has to do with dgVoodoo's D3D11 API where odd-looking colors can appear during gameplay. This issue is not present with the D3D12 API, nor with the D3D11 API on some older dgVoodoo versions.

As for the light sources, that's a separate issue which can occur with any GPU. Basically in Windows build 19041, Microsoft modified the D3D8 dll to delegate some functionalities to D3D9. With this, a bug was introduced where the Theta values of spot lights are handled differently. This resulted the lighting in some of Freelancer's base interiors to appear a lot harsher than intended.

Modern D3D8: image

Legacy D3D8: image

This lighting problem has previously been discussed in more detail here: https://github.com/elishacloud/dxwrapper/issues/134#issuecomment-1453541118. Since then, several solutions have been proposed, the best of which has been implemented in d3d8to9, and thus also in DxWrapper.

I also checked out the scene from the two examples I shared above while running the game with DXVK, and the lighting bug does not appear to be present there, so that's quite nice!