Potluck Mittal
Potluck Mittal

Reputation: 83

Android glShaderBinary

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.

Upvotes: 4

Views: 4777

Answers (1)

Mārtiņš Možeiko
Mārtiņš Možeiko

Reputation: 12927

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.

Upvotes: 17

Related Questions