in0finite / SanAndreasUnity

Open source reimplementation of GTA San Andreas game engine in Unity
https://discord.gg/p6jjud5
MIT License
2.1k stars 348 forks source link

Improve Android Compatibility and speed + ChromeOS support #137

Closed smitdylan2001 closed 1 year ago

smitdylan2001 commented 1 year ago

Improved Android Speed by using IL2CPP by default, with 64 bit (and ChromeOS) support. This is the new Google Play standard, so it should be similar in an open source project.

Also added GPU skinning, graphics jobs, prebake collision meshes and optimize mesh data for better performance and faster load times

in0finite commented 1 year ago

You can't just switch to IL2CPP and think it will work. It needs to be heavily tested, because IL2CPP is known to introduce some bugs. And anyway, Mono is used on Standalone platforms, so I would stick with it.

prebake collision meshes - this won't change anything since we don't have collision meshes in the project

optimize mesh data - also won't change anything since we don't have meshes in the project

GPU skinning, graphics jobs - for this I am not sure if it matters, and I don't know exactly the meaning of these, so I wouldn't change them

smitdylan2001 commented 1 year ago

Thanks for the feedback! Got it. GPU skinning will run skinned meshes transformations on the GPU instead of the CPU, which almost always is faster. Graphics jobs will generate draw calls using the job system, which will put less stress on the main thread and rendering thread.

Feel free to close the PR

in0finite commented 1 year ago

GPU skinning makes sense.

As for draw calls and graphics jobs, currently the bottleneck in rendering is the Built-in rendering pipeline (which has terrible batching). So the improvement for rendering will be done by switching to HDRP (high definition rendering pipeline) which can use SRP batcher. This can bring massive improvement (up to several times faster) and graphics jobs will probably have no impact.

Anyway, since none of the proposed changes would bring anything significant to the project, I would close this PR.

smitdylan2001 commented 1 year ago

GPU skinning makes sense.

As for draw calls and graphics jobs, currently the bottleneck in rendering is the Built-in rendering pipeline (which has terrible batching). So the improvement for rendering will be done by switching to HDRP (high definition rendering pipeline) which can use SRP batcher. This can bring massive improvement (up to several times faster) and graphics jobs will probably have no impact.

Anyway, since none of the proposed changes would bring anything significant to the project, I would close this PR.

Why would you use the HDRP? That definitely is not faster and you'll loose android compatibility (and other platforms as well). URP would be great however

in0finite commented 1 year ago

Why would you use the HDRP?

For better visual quality. It should be faster if batching is turned on. If compatibility is an issue, we can use URP for other platforms.

smitdylan2001 commented 1 year ago

Compatibility definitely is an issue with the hdrp. And the shaders of the hdrp are quite heavy as well, so I am not too sure if performance will be better by much. It will probably with the urp is batching is one of the issues. URP also can look great

DannyWebbie commented 1 year ago

HDRP as a default seems a bit of an overkill for the assets users are most likely going to be using and the hardware some of the people interested in this project are running, as HDRP only supports compute enabled hardware (OpenGL and OpenGL ES would be dropped). Based on some complaints I've seen on Unity forums, supporting both URP and HDRP is probably not exactly trivial either.

For what it's worth, I also believe switching to IL2CPP as the default is a good idea to maintain portability on that front.

smitdylan2001 commented 1 year ago

HDRP as a default seems a bit of an overkill for the assets users are most likely going to be using and the hardware some of the people interested in this project are running, as HDRP only supports compute enabled hardware (OpenGL and OpenGL ES would be dropped). Based on some complaints I've seen on Unity forums, supporting both URP and HDRP is probably not exactly trivial either.

For what it's worth, I also believe switching to IL2CPP as the default is a good idea to maintain portability on that front.

Agreed with both points. Note that hdrp isn't just about API support. Android for example isn't supported with any API, not even vulkan (still scratching my head about why not). Not sure about ios.

Il2CPP indeed can make big CPU performance gains. Stuff that isn't supported by it will simply run the C# code, so unless there is a major bug it shouldn't affect compatibility

in0finite commented 1 year ago

Ok, so let's agree on the key points: