Search Unity

Too many math instructions for SM2.0

Discussion in 'Shaders' started by b7r, Aug 30, 2015.

  1. b7r

    b7r

    Joined:
    May 6, 2014
    Posts:
    1
    Hi,

    today I tried writing a simple Mandelbrot and Julia Shader. That worked but on the platform Windows Phone I got an error. I read that it only supports SM2.0. But with SM2.0 I got following error:

    Shader error in 'Custom/Julia': Too many math instructions for SM2.0 (67 needed, max is 64). Try #pragma target 3.0 at line 54 (on d3d11_9x)​

    Do you know any workaround for this problem? With only 64 Math instructions I can’t get really far.


    Greetings

    Johannes
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There really isn't a workaround unless you can do your shader in some form of multi-pass or multi-buffer form (ie: write out the first set of calculations to a texture, then use that as the input in a second shader).

    That said, your only 3 instructions off - you'll likely be able to shave that off..
     
  3. jistyles

    jistyles

    Joined:
    Nov 6, 2013
    Posts:
    34
    Only solution is to optimise or multipass it.

    It's a vector based unit, so abuse that first, then rearrange for assembly op's to aid the rather clumsy compiler. Even stupid stuff eg, MAD explicitly where possible...
    This: A = (B*C) + D;
    Not this: A = D + B*C;
    I know that looks like a bathtub full of retard, but when shaving cycles it's always worth doing this first.
     
    levlaj likes this.