Why batch profile shaders?

Imagination’s PowerVR DevTech team has a brand new tool that will help you accelerate development work for any application dealing with shaders, especially high-demanding mobile games. Joe Davis is here to give you a brief description on what the tool does, how you should use it and why he put everything together in a small, simple script.

Many regular users of our PowerVR Graphics SDK already leverage PVRUniSCoEditor for individual shader profiling, but this can become cumbersome when dealing with a huge number of shaders in complex graphics applications such as games, navigation and UI. Wouldn’t it be great if the SDK included a tool that made large scale shader profiling easier? Fortunately, the SDK already includes a great tool that can be used for this purpose.

The GLSL profiling compilers in the SDK are used by PVRUniSCoEditor to retrieve the per-line and entire shader stats. This information is ideal when prototyping shaders to understand their cost without having to execute and benchmark them on target hardware, but it’s only given for the currently selected shader. Conveniently, the compilers are command-line tools and they either write out profiling information to a file or to print it to the console (depending on the profiling mode), so it’s very easy to write a script that can batch process shaders and collect profiling information for them all.

To ease developer support, we’ve written a Perl script called GLSLShaderAnalyzer that does exactly this. The user can point the script to the directory that contains the SGX GLSL ES compilers (535, 540 & 543) and to the vertex and fragment shaders that need to be processed (text files with .vsh and .fsh extensions, respectfully), and then run the script to write profiling information to .csv files. We’ve chosen to write to .csv files as they can be opened in a spread sheet tool, such as Excel, to analyse the data or can be parsed and used as input to a custom analysis tool. A .csv file will be created for each combination of SGX compiler and shader type. For example, the default configuration will create 6 .csv files – a vertex and fragment .csv for each of the available compilers (535, 540 and 543).

Before we go any further, we are issuing the following disclaimer: this was done by a Perl newbie, there are some Perl module dependencies (if you don’t already have the modules, a warning will be given and you can download them with CPAN) and the script is only written to use the Windows 32 bit compilers. Also, we’ve put some checks in to prevent it exploding, but the script doesn’t check the validity of paths that are given as arguments (which isn’t too much of a problem, as long as the parameters are correct).

How does batch profiling for shaders work?

If the Perl script is executed without any arguments, it will display a short manual that describes the parameters that can be given:

No arguments have been specified

The following commands can be used




-sgxCore=all|535|540|543 Default: all

-profileMode=all||profile|perfsim Default: perfsim

-compilerDir=<somePath> must be set

The bare minimum argument that needs to be set is the “-compilerDir” path. If only this is set, “-inDir” and “-outDir” are assumed to be the current directory and the other parameters use the default options that are listed.

“perfsim” is the default “-profileMode” option as this profiling information comes from a GPU simulation path in the compiler. The “profile” stats come from an earlier stage in the compiler that allows per-line estimates to be calculated, but this is before the compiler optimizes the shader so the actual total number of cycles to execute the shader (as given by the “perfsim” flag) may be lower than this.

Once the script has completed, you will have a bunch of .csv files that contain profiling information for all of the shaders that have been processed. As there are separate .csv files for each SGX GPU it’s easy to, for example, compare the output of a USSE1 based GPU – such as an SGX540 – against the output of the SGX543 USSE2 compiler.

Final thoughts

One of the great things about this script is that you can give it any GLSL ES .fsh and .vsh files as input. This means that in addition to using this script for shaders in your project that may already be .fsh and/or .vsh files, you can also use it to process shaders that have been dumped by PVRTrace (can be done with the “File->Save->Save Shaders” option) or you can write another script to convert from GLSL ES shaders in your favourite game engine into .fsh and .vsh files that can then be batch profiled.

The profiling shader compilers are just one of many excellent tools in the PowerVR Insider SDK that can be scripted or integrated into your own tool chains. We hope this post has given you a few ideas for the best way to incorporate these components into your OpenGL ES development process!

Come back to our blog regularly for more developments on our PowerVR Graphics SDK and follow our @ImaginationTech and @PowerVRInsider Twitter accounts for the latest news on all things PowerVR mobile graphics.

Leave a Comment

Search by Tag

Search for posts by tag.

Search by Author

Search for posts by one of our authors.

Featured posts
Popular posts

Blog Contact

If you have any enquiries regarding any of our blog posts, please contact:

United Kingdom

Tel: +44 (0)1923 260 511

Related blog articles

The ultimate embedded GPUs for the latest applications

Introducing PowerVR Series9XEP, Series9XMP, and Series9XTP As Benjamin Franklin once said, only three things in life are certain: death, taxes and the ongoing rapid advancement of GPUs for embedded applications*. Proving his point, this week, Imagination has once again pushed

Opinion: the balance between edge and cloud.

Simon Forrest explains how embedded chips can meet the challenge of delivering true local AI processing. GPUs and NNAs are rapidly becoming essential elements for AI on the edge. As companies begin to harness the potential of using neural networks

DJI Mavic 2 closed

Partner interview series: DJI – flying high

DJI is a name now synonymous with drones, thanks to an estimated 74% market share across consumer, professional and enterprise markets. In the second of our ‘quick chat’ interview series, we speak to we talk to Charlie Sun, R&D Director at DJI to find

PowerVR Series2NX collects another award at China tech summit

Following success at other award ceremonies this year, PowerVR’s Series2NX neural network accelerator has picked up another gong. This time, the panel of judges at the ASPENCORE Global Electronic Achievement Awards Annual EDA/IP award ceremony deemed it to be the most

Stay up-to-date with Imagination

Sign up to receive the latest news and product updates from Imagination straight to your inbox.

  • This field is for validation purposes and should be left unchanged.