Forums - Shader Binaries in OpenGL

5 posts / 0 new
Last post
Shader Binaries in OpenGL
lion
Join Date: 29 Apr 20
Posts: 3
Posted: Fri, 2020-10-09 15:15

 

Hi,

 

I need to have shader binaries pre-built for Adreno GPUs for OpenGL ES.

With Mali I can use pre-compile the shaders with a compiler, but I understand Adreno SDK does not provide a shader compiler, so the only option is to generate those binaries on a running system.

What are the rules for reusing these?

Do I need to generate them per Android version? Per GPU model? Etc.

Is there any documentation on this topic?

 

Thanks.

 

  • Up0
  • Down0
Carlos Dominguez Moderator
Join Date: 27 Jul 15
Location: San Diego
Posts: 110
Posted: Fri, 2020-10-09 18:16

Hi Leo,

The binaries compiled should be considered device specific. Even though they may run in other phones, with variations of GLES runtime, Android version, driver, etc. it's not recommended to assume otherwise.

The typical workflow for this involves:

  1. Compiling the shaders the first time at runtime on device
  2. Use glGetProgramBinary (https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glGetProgram...) to extract the shader binary and store locally
  3. On subsequent runs use the binaries generated with glProgramBinary. 

It's worth noting that when using glProgramBinary you should always error check in case something happened such as binaries did not load correctly, got deleted somehow, etc.

I hope this helps!

Cheers,
Carlos

  • Up0
  • Down0
lion
Join Date: 29 Apr 20
Posts: 3
Posted: Tue, 2020-10-13 00:27

 

Hi Carlos,

Thanks a lot for your reply, although it feels a bit dissapointing.

 

I wanted to ask a quick question: 

Do you think it would be very difficult for Qualcomm to do more or less what the rest of the industry does, including platforms like DirectX, Metal and Mali? They all support offline compilation.

I'd say it's more or less extract the compiler code shipped in drivers out to an offline compiler, and package something to suport this... more or less? 

I also think this is something many would like to see.

 

To be honest, it's too bad the workflow we'd really like is crippled because a major supplier, Qualcomm, doesn't provide the software everybody else has.

Also, the alternative to move over to Vulkan is not an option because half the Android devices out there still rely on GL only. Correct?

 

Thanks again.

 

  • Up1
  • Down0
Carlos Dominguez Moderator
Join Date: 27 Jul 15
Location: San Diego
Posts: 110
Posted: Tue, 2020-10-13 09:36

Hi Leo,

I understand the dissapointment although this workflow is not Qualcomm specific and in line with the OpenGL ES standard. In OpenGL ES offline compilers tend to be used mostly for static analysis and not meant for runtime execution of binaries. This is the case with Mali as well and they propose the same workflow I described above: https://developer.arm.com/documentation/101863/0702/Introduction/Binary-...

Quote from their guide: "Most compiled shader binaries are specific to a single pairing of GPU hardware version and driver version, so reliance on binary-only shader distribution is not recommended."

Cheers,

Carlos

  • Up0
  • Down0
lion
Join Date: 29 Apr 20
Posts: 3
Posted: Tue, 2020-10-13 22:53

Well that's too bad, the dissapointment is double now.  

Thanks.

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.