Aloshi / EmulationStation

A flexible emulator front-end supporting keyboardless navigation and custom system themes.
MIT License
2.08k stars 905 forks source link

[Issue] Font Display Letters partially corrupted. #913

Open Langerz82 opened 3 months ago

Langerz82 commented 3 months ago

Version: Somewhat modified ES - https://github.com/EmuELEC/emuelec-emulationstation Built with OPENGLES 2.0.

Child Issue: https://github.com/EmuELEC/EmuELEC/issues/878

When the user plays a game, and ES halts upon resume some of the font letters have pixel corruption around some of the sides.

I've isolated it down to this function: void Font::getTextureForNewGlyph(const Vector2i& glyphSize, FontTexture*& tex_out, Vector2i& cursor_out) https://github.com/Aloshi/EmulationStation/blob/master/es-core/src/resources/Font.cpp#L324

If Texture Cacheing is disabled, the fonts display perfectly, but I think it also cause a memory-leak lool as my system crashed.

By making the pixel spacing between cache texture fonts = 2, it minimizes the amount of corruption but its still present. https://github.com/Aloshi/EmulationStation/blob/master/es-core/src/resources/Font.cpp#L276 https://github.com/Aloshi/EmulationStation/blob/master/es-core/src/resources/Font.cpp#L288

I'm at a loss how to fix the issue, and hopefully the ES team can shed some light on how to fix this issue. Thanks guys, I hope the report is detailed enough.

Langerz82 commented 3 months ago

Think I worked it out: When it creates the texture here: https://github.com/EmuELEC/emuelec-emulationstation/blob/EmuELEC/es-core/src/renderers/Renderer_GLES20.cpp#L631C31-L631C44

For GLES20: passing nullptr into the data does not actually initialise all the data to empty, resulting in leftover artifacts. By creating memory and setting it all to 0xFF for luminance alpha, and 0x0 for just alpha, it nows displays fontface lettering correct. https://github.com/EmuELEC/emuelec-emulationstation/blob/EmuELEC/es-core/src/renderers/Renderer_GLES20.cpp#L669C4-L669C94 https://github.com/EmuELEC/emuelec-emulationstation/blob/EmuELEC/es-core/src/renderers/Renderer_GLES20.cpp#L683

Here is my solution in EmuELEC's emulationstation, but I'm sure you can incorporate it for a proper fix in your code: https://github.com/EmuELEC/emuelec-emulationstation/pull/100/files <-- edit: updated link.