[osg-users] How to use osg::ShaderBinary

Julien Valentin julienvalentin51 at gmail.com
Mon Jul 24 08:15:55 PDT 2017


Hi
Shader binary formats are vendor specific.
You can retrieve it by hand with 

Code:
Program::ProgramBinary* Program::PerContextProgram::compileProgramBinary(osg::State& state);


but as it requires a proper context bound so you can't call it from an update callback.
Perhaps recording osg::Programs you wanna bake in a Camera PostDrawCallback can do the trick...
But I think the best way to generate them is offline using vendor sdk tools:

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.

 


qiaokun wrote:
> Hi,
> 
>     I want to know the use of 'osg::ShaderBinary'.
>     'osg:: ShaderBinary' is read from a binary file.
>     I just don't know how to generate a binary shader file.
>     Maybe use an offline shader compiler?
>     I hope someone tell me if it is necessary to use 'osg::ShaderBinary' in case of using a lot of shaders in a big project and how to use it. 
> Thank you!
> 
> Cheers,
> Qiaokun


------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=71311#71311







More information about the osg-users mailing list