godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
86.79k stars 19.42k forks source link

3.3>... : Software Skinner doesn't work when skinning a non-triangle mesh on Mali GPUs #81470

Open ahopness opened 10 months ago

ahopness commented 10 months ago

Godot version

v3.5.2.stable.official [170ba337a]

System information

Tested on: Mali-G68 MC4, Mali-G71, Mali-G52 MC1, Adreno 642L & PowerVR Rogue GE8322

Issue description

In my game, i use a wireframe art style, so i transform some meshes into wireframes using a script. One type of these meshes are static scenario parts, which render ok on all mobile devices, another type is characters, skinned models, which just refused to show up on certain phones.

Upon futher inspections, i discovered that this bug was only happening on Mali gpus, which would be ok, and i'd just forget about it, if they wouldn't be the most used gpus on the market rn (and for some reason, all samsung currently phones use them, wild). The Debugger would throw me this error each time i called surface modifying function on the ArrayMesh Class (e.g. _add_surface_fromarrays, _surfaceremove, _surface_setmaterial) specifically on phones with Mali GPUs: image

Upon even further inspections, i discorvered that Software Skinning is turn on by default on mobile - because the performance of GPU skinning isn't great overall - and when i turned it off, via disabling software_skinning_fallbackin the ProjectSettings, characters where showing up normally.

Steps to reproduce

  1. Grab any skinned model
  2. Add a script to it with the following code:

    func _ready():
    var a = mesh.surface_get_arrays(0)
    var m = mesh.surface_get_material(0)
    
    mesh.surface_remove(0)
    
    mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, a)
    
    mesh.surface_set_material(0, m)
  3. Export to android and run on any phone with a Mali GPU
  4. Go back to the editor, under the ProjectSettings, turn rendering/quality/skinning/software_skinning_fallback off
  5. Test again

Minimal reproduction project

N/A

ahopness commented 10 months ago

Btw, i don't think this is related to #43217 in any way because im using neither blend shapes nor gles3

darksylinc commented 10 months ago

Mali HW GPUs doesn't natively support wireframe rendering and must be emulated by the OpenGL driver (and in Vulkan, we have to do the emulation ourselves).

It's extremely likely that the Mali driver is just broken.

You can try getting in touch with ARM.

ahopness commented 10 months ago

but this seemed like an issue with the sofware skinning, since skinning the mesh in the gpu works fine (on gles2 and android). are you sure this is an issue with Mali's drivers?

lawnjelly commented 9 months ago

The software skinning only appears to support triangles, the wireframe is probably trying to use lines primitive. Maybe the software skinning fallback is only being used on Mali GPUs.

You can test this hypothesis with project_settings/rendering/quality/skinning/force_software_skinning and seeing if you get the same problem on other hardware.

If so this is likely a documentation issue.

You can solve it as you say by turning off software skinning fallback, but be aware that GPU skinning may not work on all mobile platforms.

Also be aware that using wireframe using GL_LINES in any production (especially non desktop) project is a little risky afaik because driver support can be patchy / slow (if you google for this, you may find alternative ways of drawing wireframe with shaders etc).