Search Unity

Native GLSL shader performance (vs. CG/HLSL) for mobile & mobile VR

Discussion in 'Shaders' started by DonCornholio, May 12, 2021.

  1. DonCornholio

    DonCornholio

    Joined:
    Feb 27, 2017
    Posts:
    92
    Hi there !

    I was wondering if anyone of you have used GLSL Shaders to have better optimization than going the default CG/HLSL cross compiler route ? Are there real gains to be had or is it just a waste of time and a burden on the workflow ?

    I am developing for mobile VR headsets only at the moment, so getting a 10%+ performance improvement could be worth it for me.

    Also i am looking for a way to quickly test Shaders on Quest / Pico without having to rebuild all the time. If you know a solution please hit me up! I recently checked performance for 2 shader variants and the one with reportedly less instructions actually ran slower, even though it was basically identical except for sampling and masking one less texture array. I still can't wrap my head around this and thought how great it would be to just be able to instantly see performance results on the headset.

    It really would be great to get some insights on your experiences :)
     
    Last edited: May 12, 2021
  2. DonCornholio

    DonCornholio

    Joined:
    Feb 27, 2017
    Posts:
    92
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    I know some people who have claimed that the only way to get optimal shaders on OpenGLES is to hand write them.

    Personally I've never seen a reason to. Sometimes Unity's cross compiler outputs some really bad code, but it's rare. In the days when you were trying to shave 1 or 2 instructions from your shader, and doing so would save you 10% performance ... it was probably worth it. Today optimizing away 1 or 2 instructions might not even change anything depending on where they are in the shader. I personally don't see the point of the hassle.

    The main performance benefit I saw when going to Quest was from avoiding Surface Shaders.
     
    DonCornholio likes this.