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

Vertex shader FPS drop #675

Open Icensow opened 5 years ago

Icensow commented 5 years ago

Describe the bug A vertex shader applied only to certain ped (using targetElement argument) also handles vertices of all streamed peds that have a texture with same name and it causes FPS drop. Removing the shader from the texture doesn't resolve it. Destroying the shader also gives no results.

To reproduce

  1. Spawn
  2. Start shader_bug.zip
  3. Input command "dropfps"
  4. See FPS drop
  5. Input command "tryfix" (removes the shader)
  6. See no difference

Expected behaviour No FPS drop (the shader should handle only the vertices of target element) or at least removing shader should fix it.

Screenshots mta-screen_2018-10-29_13-16-28 mta-screen_2018-10-29_13-16-39

Version Multi Theft Auto v1.5.6-release-14664.4

Additional context Video show the issue: https://www.youtube.com/watch?v=5FpgHOrnxLc

ccw808 commented 5 years ago

Caused by two linked issues: 1) Slow down when applying vertex shaders to peds: Reason is because GTA uses GPU vertex shaders for fast ped animation. Applying an MTA vertex shader forces GTA to switch to a (slower) software method for ped animation.

2) Still slow after removing vertex shader: Reason is because GTA is still using software method for existing ped models. It will switch back eventually, but there is currently no reliable method for forcing it. Unloading the DFF + delay + reloading the DFF multiple times can sometimes help.

Commit which enable ped vertex shaders: 0a6db563 Switching GTA between GPU/software animation is done in CRenderWareSA::SetGTAVertexShadersEnabled

Einheit-101 commented 4 years ago

Isnt it theoretically possible to draw Peds/Players without applied shaders with the GPU method and draw everything else with the slow software method? This way we could optimize our resources by removing shaders from far away / offscreen Peds or only apply shaders to a limited amount of them and Performance can increase dramatically!