8 Replies Latest reply on May 19, 2011 10:25 PM by Christian Lett

    Strange CPU-vs-GPU Problem with Generated PB Kernel

    Christian Lett Level 3

      Hi,

       

      This is odd - As part of a larger graph I'm trying to generate a simple boxed hirizontal grid. Here's the code distilled into a kernel:

       

      <languageVersion : 1.0;>

      kernel gridTest

      <   namespace : "Your Namespace";

          vendor : "Your Vendor";

          version : 1;

      >

      {

          output float4 dst;

             

          parameter float2 gridBounds <

              defaultValue: float2(200.0, 200.0);

          >;

         

          dependent float gridSpacing;

         

          const float3 LINE_COLOUR = float3(0.5, 0.25, 0.0);

         

          region generated() {

              return region(float4(0.0, 0.0, gridBounds.x + 1.0, gridBounds.y + 1.0));

          }

         

          void evaluateDependents() {

              gridSpacing = gridBounds.y / 10.0;

          }

         

          void evaluatePixel() {

              float2 coordFloored = floor(outCoord());

             

              if(mod(coordFloored.y, gridSpacing) < 1.0 || coordFloored.x == 0.0 || coordFloored.x == floor(gridBounds.x))

                  dst.rgb = LINE_COLOUR * 0.8;

             

              // Hilight bottom, middle and top grid lines

              if(mod(coordFloored.y, gridSpacing * 5.0) < 1.0)

                  dst.rgb += LINE_COLOUR * 0.75;

             

              dst.a = 1.0;

          }

      }

       

      Run in GPU mode, it's fine. Run in CPU mode and I get a vertical grid line every few pixels. It's coming from the "coordFloored.x == 0.0" part but I can't figure out why. It's like the outCoord() is reverting to zero every few pixels across. I only spotted it once I ran it in AE, as it runs on the CPU.

       

      I guess I'm either doing something wrong I just can't see, or it's a bug.

       

      Any ideas? It's driving me crazy!

       

      Thanks,

       

      Christian