Optimize shaders from command line


This topic contains 3 replies, has 2 voices, and was last updated by  Joe Davis 3 years, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #31620

    I would like to achieve the same result as the Optimize button in PVRShaderEditor 2.2, but I need to do it from the command line on Windows (because I need to automate it for our asset pipeline). So basically I need a command line tool with no GUI that takes a glsl file and outputs an optimized (not compiled) version of that file. Is there a way of doing this?


    Joe Davis


    Yes – this is possible. The compilers in the “ProfilingCompilers” directory of the SDK are the same command-line tools used by PVRShaderEditor for its profiling data. When you run the compiler with no arguments, it will list the available command-line parameters.

    We also have a package of disassembly GLSL ES compilers available under NDA. To get this package, you should follow these steps:

    1. Signing our NDA: Please follow the instructions listed on our Developer Support portal landing page
    2. Register for the Support portal: Once the NDA is in place, you must then register for our portal. It’s worth noting that a new user name and password will be required (i.e. you can’t login with your forum credentials). If you don’t already have access to the disassembly compiler package from the Downloads page, you should file a ticket to discuss this with us



    Thanks for the suggestion. I tried the compilers but didn’t have any luck getting them to work on Windows. I suspect I am doing something wrong, but I don’t know what. Here is an example of what I did. As you can see there is no output file “out.txt” resulting from the call to the compiler.

    eries5XT.exe D:projectssonnet_20106josborne_HPE-MDORGAN-10D2trunk
    AssetsShadersglslwater_Water_VS_Water.GLSL out.txt -v

    Volume in drive C has no label.
    Volume Serial Number is E221-9811

    Directory of C:PowerVRGraphicsSDKProfilingCompilersGLSLESWindows_x86_32

    02/10/2014 03:05 PM .
    02/10/2014 03:05 PM ..
    10/30/2013 12:26 AM 1,982,976 GLSLESCompiler_Series5.exe
    10/30/2013 12:26 AM 1,993,728 GLSLESCompiler_Series5XT.exe
    10/30/2013 12:26 AM 1,435,136 GLSLESCompiler_Series6.exe
    3 File(s) 5,411,840 bytes
    2 Dir(s) 125,447,626,752 bytes free

    When I call it again with the -prof option I do get an out.prof file that contains profiling information. So I know the compiler is working, it’s just not outputting the results.


    Joe Davis


    Thanks for the clarification. I’ve realised that I misunderstood your original request. The “Optimize” button in PVRShaderEditor runs a built in version of Aras from Unity’s glsl-optimizer tool (available on GitHub here: https://github.com/aras-p/glsl-optimizer). Our command-line tools do not integrate glsl-optimizer, and for this reason there is not a command-line option to optimize shaders.

    When using the optimizer, we recommend checking the emulated cycle count number before and after optimization. There are some corner cases where running the optimizer can make your code slower.

    If you run the command-line compiler without any arguments, it will list the available options. To get the emulated cycle counts, you can use the -perfsim flag. You can use this to automatically verify the shader performance before and after glsl-optimizer runs on it.


Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.