multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.38k stars 424 forks source link

Upgrade to DX11 #1061

Closed ghost closed 4 years ago

ghost commented 5 years ago

Is your feature request related to a problem? Please describe. I was working on atlases features to improve rendering performance when you have too many objects on screen. After almost achieving it, it turns out that it required more work than I expected to actually benefit from the feature. I also had to implement fastman92 limit adjuster to increase the ID limits, and since it was modifying too much GTA code, I realized that I'll be spending the next few months fixing bugs from the limit adjuster alone. Not only that, the atlases stuff will also eat more RAM since the unwrapped texture might be a lot bigger than the actual ones.

Describe the solution you'd like The alternative solution is to upgrade to DX11. There's a project called "RenderHook." They successfully upgraded GTA SA to DX11 with little to no issues. It is opensource, and I'm thinking of implementing it.

Additional context I talked to Dutchman, and it seems that we have a lot of players who run GTA on low-end PCs. They might not be able to run DX11. We'll keep DX9 for backwards compatibility as an option in settings.

Moreover, I'm not going to start working on this immediately. I'm going to take a long break for 1 year. Till then, we can discuss the problems we might face later.

Renderhook: https://github.com/petrgeorgievsky/gtaRenderHook

https://www.youtube.com/watch?v=Ttokgk46GYA

Einheit-101 commented 5 years ago

But in which way should DX11 improve performance? What should Dx11 do?

ffsPLASMA commented 5 years ago

Wouldn't it be a better way to approach overall performance by assigning multi threading to the application?

ghost commented 5 years ago

Wouldn't it be a better way to approach overall performance by assigning multi threading to the application?

Multi-threading would be nice, but we really don't need that. We don't have access to the sourcecode of GTA, and it might introduce impossible-to-fix bugs.

But in which way should DX11 improve performance? What should Dx11 do?

In DX9, if a model is using 10 textures, then it will result in at least 10+ draw calls for that model. DX11 will reduce it to a single draw call. There are also other hidden costs that come with DX9, they've been improved in DX11.

ArranTuna commented 5 years ago

Wouldn't it be a better way to approach overall performance by assigning multi threading to the application?

The DX11 mod called RenderHook actually seems to allow GTA SA to use more than 1 core as when testing it my process was using 35% CPU on a quad core so I'm guessing the DX11 stuff is in it's own thread. I was able to get almost double the single player FPS using the mod when some graphic features were reduced (mainly reducing "cascade count" from 4 to 1)

jushar commented 5 years ago

They might not be able to run DX11.

Actually, I'm not sure about that. Win7 is now the minimum requirement and even if the graphics card doesn't support DX11 features, we can use DX11 with old feature levels:

I suggest before we implement a backwards compatibility mode, we collect some stats on the maximum available feature levels.

ghost commented 5 years ago

Actually, I'm not sure about that. Win7 is now the minimum requirement and even if the graphics card doesn't support DX11 features, we can use DX11 with old feature I see. We can do that. It will save us time.

I suggest before we implement a backwards compatibility mode, we collect some stats on the maximum available feature levels.

I see. We can do that. It will save us time. Collecting stats is probably the best way to find out what we should do.

The DX11 mod called RenderHook actually seems to allow GTA SA to use more than 1 core as when testing it my process was using 35% CPU on a quad core so I'm guessing the DX11 stuff is in it's own thread.

I don't think RenderHook is fully using the multi-threading features of DX11. It has to be DX11 API running its own thread behind the scenes.

ArranTuna commented 5 years ago

If you need stats, I can help with that, I already have a script on CIT if you do /userstats the clipboard will be filled with information gathered from players like what screen resolutions are being used.

You could also add any new things you need checking to https://wiki.multitheftauto.com/wiki/DxGetStatus as this function already has many values and I imagine some of them would be things you'd find useful to know like "VideoCardPSVersion"

If some of those that are already in dxGetStatus are useful let me know and I'll add them now to my /userstats and I'll post the results here.

jushar commented 5 years ago

@ArranTuna Thank you for that, but the maximum value for returned for VideoCardPSVersion is 3.0 with DirectX 9 whereas newer DirectX versions start with 4.0 and go up to 5.x.

Luckily, there are MTA-wide stats on the graphics card model which we can use to create a list of supported feature levels. I'll probably do that in the next few days and post the result here later.

d1stru3t0r commented 4 years ago

I talked to Dutchman, and it seems that we have a lot of players who run GTA on low-end PCs. They might not be able to run DX11. We'll keep DX9 for backwards compatibility as an option in settings.

Let's be honest, I don't think 1% has a non DX11 GPU. Most of the players are playing FFS/Battle Royale/RP which needs already a good GPU. I don't think we will lose anything using DX11, i just see this as a very HUGE win in every case. Even Vista supports DX11, so even old players could benefit. Also, even if you have LOW end GPU, DX11 would highly benefit it even for them. Noone is playing on Intel GMA 3100 anymore :)

Staff note: please enter a quote appropiately next time, fixed ; )

Dutchman101 commented 4 years ago

Noone is playing on Intel GMA 3100 anymore

MTA is a case apart, they really are playing with hardware from that era.

We are not going to let down this part of our playerbase (those playing with old hardware that can run GTA SA) because it's a significant group, it's common knownledge that a good chunk of MTA's playerbase comes from development countries that are running really dated PC's.

So, in accordance with the feedback in this issue so far, we want to do our homework: collect stats and find out what is supported by which percentage, find out if we can simply use feature levels, or if we need to use a fallback on DX9. The devs will make an informed decision based on that, and not on speculation or on the opinion that those still using dated hardware do not matter.

ghost commented 4 years ago

Without upgrading MTA to DX11, other streaming features will not give the result we want. It's a lot of work for one person, I'm already busy with work, and I don't think I'll enough free time to get it done in this year. Maybe next year, sorry. If anybody wants to work on this, I'm ready to help them.