ptitSeb / gl4es

GL4ES is a OpenGL 2.1/1.5 to GL ES 2.0/1.1 translation library, with support for Pandora, ODroid, OrangePI, CHIP, Raspberry PI, Android, Emscripten and AmigaOS4.
http://ptitseb.github.io/gl4es/
MIT License
712 stars 160 forks source link

S3tc hardware support #383

Open Sisah2 opened 2 years ago

Sisah2 commented 2 years ago

Hello, please can you subscribe steps/parts of code to disable dxt texture decompression and use extensions for hardware support (i think its really matter of just disabling some code) I got device with GL_EXT_texture_compression_s3tc_srgb GL_EXT_texture_compression_dxt1 GL_ANGLE_texture_compression_dxt3 GL_ANGLE_texture_compression_dxt5 I tried commenting out code in gl4es_glCompressedTexImage2D gl4es_glCompressedTexSubImage2D gl4es_glGetCompressedTexImage And just call their gles variants here (in app im using it seems to call only gl4es_glCompressedTexImage2D from those three) does it need also some changes in texture.c ?

AbduSharif commented 2 years ago

This too is supported on some devices: GL_EXT_texture_compression_s3tc

Sisah2 commented 1 year ago

Currently ram is big problem in openmw on android, textures taking too much of it (i expect they are converted to uncompresed format) enabling this extension where available with fallback to reconpression to some different format will help a lot. LIBGL_SHRINK options make really big diferences in ram usage.

ptitSeb commented 1 year ago

Yeah, I should add support for hardware S3TC extension, that should help on a lot of harware that should support this now.

Sisah2 commented 1 year ago

That would be awesome. Not sure about mali, but xclipse support those angle extensions and snapdragon 8gen2 (not sure about older) have regular GL_EXT_texture_compression_s3tc_srgb and GL_EXT_texture_compression_s3tc.

Sisah2 commented 7 months ago

Actually just revert this check here and dxt textures get loaded. https://github.com/Sisah2/gl4es/blob/b32fcfd2a379c508209a8d16567a56de3883b1df/src/gl/texture_compressed.c#L208 But without mipmaps, i guess it would need to resize those compressed data and upload them manually (or decompress->resize->compress back) any clue on doing this? Need resizeDxtData() function or at least way to compress uncompressed data to dxt.

Sisah2 commented 7 months ago

Ended up with this, it work but use small hack in osg to tell gl4es at which point to generate mipmaps (if(level == bound->max_level)) mostly work, but there were few textures for which it didnt (they request hardware mipmap generation it seems) using bound->mipmap_auto worked for those, which is weird (its not supposed to work with compressed textures right?) Memory is happier, loading times faster, and if not using mipmaps even framerate is much better, but for some reason when mipmaps are used there is basically no framerate gain. https://github.com/Sisah2/gl4es/commit/8b6c0418dabe3410fc53918b66285588cde9a7e7

ptitSeb commented 7 months ago

You could make a PR with this. I see it's optionnal so I'll gladly accept it. Just missing a bit of doc maybe.