Similar to this question but for Android:
Android GLES20 supports a method glShaderBinary, which, based on this gles documentation will load precompiled shader binaries. However, I'm unable to find any way to actually precompile any binaries. When I call GLES20.glGetIntegerv
with the parameter name GLES20.GL_NUM_SHADER_BINARY_FORMATS
, though, it does indicate (at least on the device I am testing on) that there is one available shader binary format. I just don't know how to actually use it.
Binary shader formats are vendor specific. For each different vendor there is different mechanism to compile shaders to binary. So to support most Android devices, you'll need to either to compile your shaders for specific vendor offline, or do it online (using GL_OES_get_program binary extension) and of course also provide glsl source as fallback.
Here are list of OpenGL ES 2.0 SDK from some popular GPU vendors. It either includes offline GLSL shader compiler, or documentation about binary GLSL shaders :
ARM Mali provides malisc
executable that can compile shaders in command line on your host.
Qualcomm Adreno actually allows to get binary of GLSL shader at runtime using glGetProgramBinaryOES
, but not offline. At least so says the docs in Adreno SDK.
PowerVR SDK also states that its GPU allows to get binary of GLSL shader during runtime using glGetProgramBinaryOES
.
glGetProgramBinaryOES
function comes from GL_OES_get_program_binary extension.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With