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.

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

British Engineering Excellence Award

PowerVR Vision & AI design team collect another award

We’re delighted that the design team for our PowerVR Series2NX Neural Network Accelerator (NNA) has been honoured with a prestigious British Engineering Excellence Award (BEEA). The BEEAs were established in 2009 to demonstrate the high calibre of engineering design and innovation in the

Series8XT AR/VR Banner

Imagination Technologies: the ray tracing pioneers

After a period out of the spotlight, ray tracing technology has recently come back into focus, taking up a lot of column inches in the tech press. The primary reason is because graphics cards for the PC gaming market have

Amazon Fire Stick 4K pic

Amazon Lights up its Fire TV Stick 4K with PowerVR

Amazon, the internet shopping giant, announced earlier this week the latest version of its media streaming device, the Fire TV Stick 4K. First released in 2016, the Fire TV stick brings catch-up streaming services to any TV with an HDMI

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.
Contact Us

Contact Us