5 Replies Latest reply: Mar 25, 2011 9:46 AM by EcIipse RSS

    Registers limit in Pixel Bender 3D?

    EcIipse Community Member

      I'm trying to do a shader that does skeletal animation (vertex skinning) using a PixelBender3D, my code looks like this:

       

      parameter float4x4 WorldViewProjection;
      parameter float4x4 Bones[32];

       

      input vertex float4 Position       < id : "PB3D_POSITION";           >;
      input vertex float4 Normals        < id : "PB3D_NORMAL";             >;
      input vertex float4 UV               < id : "PB3D_TEXTURE_COORDS";     >;
      input vertex float4 BlendWeight     < id : "PB3D_WEIGHT";              >;
      input vertex float4 BlendID         < id : "PB3D_BONE_INDEX";         >;

      output float4 vertexClipPosition;

       

      void evaluateVertex()
      {
      // Blend between the weighted bone matrices.
      float4x4 skinTransform;

      int4 iBlendID = int4(BlendID);
      skinTransform += BlendWeight[0]*Bones[iBlendID[0]];
      skinTransform += BlendWeight[1]*Bones[iBlendID[1]];
      skinTransform += BlendWeight[2]*Bones[iBlendID[2]];
      skinTransform += BlendWeight[3]*Bones[iBlendID[3]];

       

      vertexClipPosition = Position * skinTransform;
      vertexClipPosition *= WorldViewProjection;
      }

      Compiles fine but running it I receive an exception that says: Register allocator has run out of registers.
      This is not a very complex shader, it's very usual stuff in HLSL\CG\GLSL, and basically every graphics card around can handle something like that.
      What kind of limitations in register number has this current version of PixelBender3D? Will newer versions improve on it? Is it a problem of PB3D or if I try to do it in Agal (I still need to learn that) I'll hit the same problem? Am I doing something wrong?

        • 1. Re: Registers limit in Pixel Bender 3D?
          EcIipse Community Member

          Seems like there's a limit of 128 constant registers for vertex shaders, but that's not the case, even if I put Bones[5] I still get that error... :-(

           

          Looks like PixelBender3D is currently less powerful than the old Pixel Shaders 1.1, or maybe the generated code by PB3D uses a lot of instruction registers somehow? Is there a way to make a skinned mesh with a good number of bones in Molehill?

          • 2. Re: Registers limit in Pixel Bender 3D?
            AIF Bob Community Member

            There's a limit of 128 constant registers, however I think the limit you're running into is the limit on temporary registers in the code. Unfortunately some of the hardware we support only allows for 8 temporary registers so that's the limit we have for AGAL and Pixel Bender 3D.

             

            As things currently stand, you might be able to do better by programming directly in AGAL, however that's because you might be able to do better hand optimizations than we're currently doing in the compiler, rather than because the limits are any different. We are very aware that we need to improve the optimization in the compiler and we're working on that.

             

            Bob

            • 3. Re: Registers limit in Pixel Bender 3D?
              EcIipse Community Member

              thanks!

              In that code as far I know I'm using only 5 temporary registers, 4 for the skinTransform matrix and one for iBlendID, doesn't it work that way?

              • 4. Re: Registers limit in Pixel Bender 3D?
                AIF Bob Community Member

                Mapping variables in the high level PB code to the low level registers is an arcane art. I'll take a look at this though and see what we can do.

                 

                Bob

                • 5. Re: Registers limit in Pixel Bender 3D?
                  EcIipse Community Member

                  great :-) I've spent the morning learning Agal and now I'm rewriting the shader with it. Of course, in the long run, Pixel Bender 3D can be a much better choice to do more complex shaders