Closed micwoj92 closed 1 year ago
Is DirectX actually the cause of your performance issues?
Effort should be spent unifying optimizations on a single renderer. While moving to DX11 would be ideal, adding DX12 or Vulkan would split development focus, and we can't exclusively ship builds for those renderers because of how many TF2 players use hardware that doesn't have proper Vulkan or DX12 support.
That being said, even moving to primarily DX11 will drop support for Sandy Bridge iGPUs. I feel like 10 is the best we should aim for here.
Moving to Vulkan/DX12/DX11/whatever doesn't automatically make performance better, it simply gives developers lower level access to make further optimizations. When the game is already in need of dire optimization, we should probably be working on the game itself, rather than pushing for the last 5%.
Is DirectX actually the cause of your performance issues? Back when I used Windows, I had better fps when using -r_emulate_gl launch option. Also Dota2 supports Vulkan and opengl on windows (I know that's source2 technically, but still).
Moving to opengl/vulkan would allow to have unified backend on all platforms (NOT really, because mac has moltenvk).
But I think you get my point.
Yes, you could use Vulkan on both Windows and Linux, but we couldn't only have Vulkan, because we'd drop support for far too many GPUs. Additionally, we wouldn't really gain anything by adding Vulkan, when most of TF2's performance issues are outside of the renderer in the first place.
but we couldn't only have Vulkan, because we'd drop support for far too many GPUs.
In 20 years? maybe? :pleading_face: :point_right: :point_left:
Marking as "help wanted" cause this is a decent idea but we will probably not be working on it
One of the devs behind DXVK was working on a native version that would allow for games working under DirectX to have Vulkan support. It's not as fast as using Vulkan normally but it could have some performance benefits on TF2 (especially for Linux, which uses openGL). I'm not sure about the status of the project now however.
DXVK can work on Linux now, but you need to use the Windows version under WINE. It works just fine, but it would be nice to have it work on Linux natively.
As listed in the original post, there already is a (semi) working vulkan backend for TF2, so I don't think DXVK will really be necessary.
TF2 uses OpenGL on linux/OSX iirc?
TF2 uses OpenGL on linux/OSX iirc?
Originally dx9, but translated through ToGL to opengl. There are remnants of a shaderapigl
in the code, which would have been a direct OpenGL backend, but it was abandoned and deleted.
I think this is out of scope for a Source 1 patch like TC2. None of Valve's own games touch on this area until Source 2, which does have native OpenGL and Vulkan rendering.
The Vulkan backend that Pazer was working on hasn't been committed to since October 19th in 2019. I'll try to see if DXVK works on Windows. I'm available to work on DirectX 10/11/12 support if I can find where the rendering happens. I won't work on Metal support until there is a 64x build that is somewhat stable.
We've talked about this a lot on the discord and we've basically decided against adding any new backends. If you want to help optimize DX9 or OpenGL that's fine but we're likely not going to add any new DX support (except maybe DX10 but don't quote me on that) or vulkan support.
From what I understood, you agreed that it was not something that the "main contributors" were ever going to work on. What would be the issue if someone else implements it? Edit: Especially on MacOS, OpenGL is not really viable.
Even if someone else implements it, it likely won't be accepted as a PR due to being out of scope and possibly causing other problems. Adding a graphics backend is no small feat and could cause some major issues. I don't really know how Mac does things, so that might be the exception, but if I had to guess it would be something similar to DXVK or some way to translate GL to Vulkan.
If any translation is happening on MacOS, it would be from DX to VK/Metal, not from GL (because GL calls are already translated from DX)
My goal was to have the new DX levels use there respective functions, not to implement new features. I would leave that to someone else who would understand that better. I thought this might be easier than making a native OpenGL/Vulkan/Metal support because the Source Engine already deals with DirectX level switching. Also, just a side note: According to a GitHub issue on the Source Engine 1 Games repo, when DXVK was ran on Linux with Wine it ran 20% faster. I believe it works similar to ReShade with dragging and dropping the DirectX DLLs.
I'm not entirely sure how easy it is to just add in baseline support for newer versions of DX, but I doubt its very easy. Personally I'd love to have newer graphics backends, but given the conversations i've had with other devs in the past, I wouldn't get your hopes up.
If you still want to give it a shot, go for it! even if its not accepted into TC2 you could always send it to valve yourself, but be careful it doesn't rely on any TC2 code.
Should I post my findings here on DXVK or make a new issue?
I think this would be the best spot, as it fits the issue.
Alright. When running DXVK on Windows with vanilla TF2, there was screen tearing in borderless windowed mode but the FPS was worse than DirectX which was to be expected. When running DXVK on TC2 it didn't have any screen tearing at the same settings. This could mean that regressions would happen with any rendering changes TC2 made if pushed into vanilla TF2. Screenshots break but I think that's an issue with Steam not hooking with the game properly. This happened with both TF2 and TC2. I'm working on a set of benchmarks to see the comparisons between DX levels. I'm also trying to see if the Source Engine still supports all the way down to DX6 because the DLLs are missing for Windows 10. I'll try to see if it's any better than ToGL for Linux and MacOS and post again. If it is, it might be worth implementing.
it might've been fixed already but screenshots were broken in general in TC2. if its happening in live as well then its probably a steam issue. also DX6-8 has been completely removed from TC2. even live TF2 won't let you use anything under DX8, but it does still load some of their DLLs.
Does TC2 only support DX9?
Yes, DX8 "Features" (AKA lower quality fallbacks) are implemented as console commands
This is great for minimizing DirectX version confusion and finding the best one for performance, but makes my plan for the new DX levels more complicated.
I kinda doubt its really that different tbh, I'm also fairly certain that TF2 comes with a DX_overrides.cfg (or something) in one of its VPKs or just in cfg and that determines some things.
could also look at some of the commits that removed DX8 support and see what they changed.
Dxvk is definitely faster than the ToGL code valve uses for its native ports to linux and macosx, It is primarily due to better multi-core utilization , the overhead is probably a bit worse overall as there are some cases where valves code is faster(In my experience when not much is being drawn)
that said its probably not that important, as modern cpus have high enough single threaded performance that any differences are overshadowed by the fact you're probably already drawing >300 fps as a worst case anyway.
I know somebody who (independently of TC2) has replaced togl in a source engine game with DXVK, with mixed results. I'd still like to see an implementation though.
I know somebody who (independently of TC2) has replaced togl in a source engine game with DXVK, with mixed results. I'd still like to see an implementation though.
Could you link to it?
I'm still working on the benchmarks but some things I found is that DXVK doesn't handle borderless-windowed mode that well and screen tearing also happens on TC2 but just less noticeable. It's meant to be run with Wine on Linux and maybe why, but I doubt it. I finished the benchmarks for Windows and found that it does run better with DirectX 9+ on both TC2 and TF2 but is very hard to see with the screen tearing. I'm working on making a quick Hackintosh and Linux disk.
Here are the Windows 10 benchmarks. I was having driver troubles with Ubuntu so if someone else could benchmark there please do. I'm still working on the MacOS ones. The benchmarks show that DXVK performs better than DX9 but my GPU is fairly new and has better driver support for it. I'll work on fixing the current bugs with it before I make a pull request. Windows 10 Benchmarks.txt
@higgy999 it's because vulkan calls are way better than direct3D9 ones. Even the opengl version valve use for tf2 linux has better calls than D3D9, valve devs said so.
@higgy999 it's because vulkan calls are way better than direct3D9 ones. Even the opengl version valve use for tf2 linux has better calls than D3D9, valve devs said so.
Not exactly sure what "better calls" even means, but considering that the openGL calls are actually translated from D3D9, I doubt that they are of higher quality (unless you have a link to a quote).
I couldn't find any other posts with my issues when using DXVK with any Source Engine game. Can others test it on Windows with the launch options -noborder -windowed -height
An update to Portal 2 dropped last night adding in DXVK directly into the base game and can be run with the startup command "-vulkan" This is amazing to see as if it's already in a base Source engine game then who says it can't be used in TF2?! Current implementation in Portal 2 has the same issues as when used in TF2 with the lack of support for borderless windowed mode without screen tearing and Steam not hooking into the rendering to say the fps.
The DXVK that Valve is using is either built with DirectX9 and Vulkan in it and can change with the startup command or the DXVK DLL is loaded on startup. The DLL is found in "bin/dxvk_d3d9.dll". It's also custom built as the latest release version doesn't match it's machine code.
I knew this was closed prematurely.
Here are the Windows 10 benchmarks. I was having driver troubles with Ubuntu so if someone else could benchmark there please do. I'm still working on the MacOS ones. The benchmarks show that DXVK performs better than DX9 but my GPU is fairly new and has better driver support for it. I'll work on fixing the current bugs with it before I make a pull request. Windows 10 Benchmarks.txt
How do you set this up?
How do you set this up?
I believe there was a page on the mastercomfig documentation on benchmarking and followed it. One issue was the demo provided there doesn't work with TF2C and I made my own demo with some bots in a game and used that one for the TF2C benchmarks. I wouldn't say these benchmarks are also ligitiment as I'm pretty sure I had a 300 fps cap making kind of look stupid but just from playing around in it, it's very smooth but hitches majorly sometimes. It runs better than DX9 on my GPU but I think that's because of it's way better driver support. If you were asking about MacOS or Ubuntu, I never got around to finishing them and the MacOS one had different specs and it was a whole thing and that's why I never updated this thread.
I mean the dxvk part.
https://github.com/doitsujin/dxvk download the latest release and extract it. Take the 32 bit DLLs and put them into the "Team Fortress 2/bin/" Put all of them in, although I'm pretty sure some could be removed. https://github.com/doitsujin/dxvk#hud Set the environment variables according on what you want to see and try it out!
Is your feature request related to a problem? Please describe. I'm always frustrated when I get less FPS on Windows due to TF2 using DirectX and not OpenGL or Vulkan.
Describe the solution you'd like Add native opengl backend.
Describe alternatives you've considered Add native Vulkan backend.
Additional context Project that inspired that request https://github.com/PazerOP/TF2Vulkan
Also as mentioned in other requests dx11/12 but I still think opengl would be better.