[TRACKER] iOS rendering bugs related to half_float precision issues #38441
Description
Recently, while investigating a potential batching bug, @lawnjelly traced back rendering issues on an iOS device to the use of half float UVs. When an ArrayMesh is set to use compression, it will use half float (16 bit) formats instead of full float (32 bit). This cuts the size of the mesh in half, but can result in precision issues. The use of half floats is enabled by the extension GL_HALF_FLOAT_OES
which is "available" on all GLES2 devices. I say "available" because iOS register the extension and present it as available, but silently fail when half floats are used in a vertex format. This comment #38318 (comment) presents a partial fix to the problem, but a more robust fix is needed.
I see two avenues to approach this problem:
-
The issues are most obvious when rendering a mesh after having rendered certain GUI primitives. This seems to suggest that mixing half_floats and floats is a problem (e.g. the vertex buffer doesn't like switching between the two formats. This may require us to allocate more buffers to keep things clearly separated.
-
The issue clearly stems from the use of
GL_HALF_FLOAT_OES
, so an obvious (but not necessarily optimal) fix would be to force iOS devices to never use half floats here:
godot/drivers/gles2/rasterizer_storage_gles2.cpp
Lines 5953 to 5958 in 8426ed2
config.support_half_float_vertices = true;
//every platform should support this except web, iOS has issues with their support, so disable
#ifdef JAVASCRIPT_ENABLED
config.support_half_float_vertices = false;
#endif
#ifdef IPHONE_ENABLED
config.support_half_float_vertices = false;
#endif
This solution, while easy, would result in iOS devices never compressing vertex data, which will unnecessarily increase the amount of VRAM used.
The following issues appear to stem from this particular issue and will likely be solved by the fixes above:
-
GLES2 Batching + CPUParticles2D texture + Label = Rendering issue on iOS #38318
-
CPUParticle2D Textures Don't Render on iOS After Screen Reading Shader #38211
The following issues may come from this particular issue and may be solved by the fixes above: