Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 277
Potluck Mittal Avatar asked Dec 03 '22 03:12

Potluck Mittal


1 Answers

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 OpenGL ES 2.0 SDK - used, for example, in Galaxy S II
  • Qualcomm Adreno SDK - used, for example, in Nexus One, HTC Desire, HTC Legend
  • ImgTec PowerVR Insider SDK - used, for example, in Galaxy Nexus, LG Optimus 3D, Galaxy Tab

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.

like image 93
Mārtiņš Možeiko Avatar answered Dec 29 '22 03:12

Mārtiņš Možeiko