2 Replies Latest reply on Nov 26, 2008 2:57 PM by DavideBarranca

    Array use

    DavideBarranca Level 1
      Dear all,
      I'd like to be clarified about arrays (only within PixelBender, I don't have to import stuff in Flash).
      Reading the doc, are allowed:
      quote:

      Constant-size arrays of floats declared as kernel parameters.
      Constant-size arrays of floats declared as kernel dependents.
      NOTE: Pixel Bender 1.0 supports only arrays of floats, and the array size is a compile-time constant.


      It's only the array size that must be fixed, right? If I write a simple
      parameter float sky[10];
      and then, within the evaluatePixel() I try to assign values to the array components, I got the error message:
      'assign' : l-value required "sky" (can't modify a parameter).
      On the other hand, if I declare an array as a dependent, I must then evaluateDependents() and assign all the values, so then it's read only.
      My question is: is there a way (current PixelBender version) to declare a fixed size array and then be able to fill it with values from within the evaluatePixel()?
      Thanks in advance,

      Davide Barranca
      Bologna, Italy
        • 1. Re: Array use
          AIF Bob Level 3
          quote:

          My question is: is there a way (current PixelBender version) to declare a fixed size array and then be able to fill it with values from within the evaluatePixel()?


          The quick answer to your question is "no, there is no way to do that".

          The longer answer, and the explanation for why the documentation is accurate (although not necessarily clear) is that at present arrays are only allowed to be parameters or dependents, and all parameters and dependents are read only within evaluatePixel. There is no way to declare an array as a local variable within evaluatePixel, so there is no way to get write access to an array within evaluatePixel.

          This all came about in the first place because some older GPUs do not handle arrays well.

          If you want an array where all of your accesses into that array are constants you can fake it by declaring a series of scalar variables like this:

          float w0;
          float w1;
          float w2;
          float w3;
          etc...

          I know that this only solves one limited case though and is far from ideal.

          We are also unhappy about our current array handling and looking into ways of improving it.


          • 2. Re: Array use
            DavideBarranca Level 1
            Thanks for your answer Kevin, looking forward to see extended support in next versions :-)
            Kind regards,

            Davide