   Spline in HLSL
  I implemented a spline solver which is used for recalculating image and change luminance and contrast inside shader.My solution is to calculate nature cubic spline coefficients (defined by maximun 4 points)in application, the coefficients will be transfered into pixel shader as matrix.In pixel shader I recalculate pixel color according to those parameters.The problem is when I run it in the latest card, it works fine.but I tried on ATI radeon x1400 which is not that old, it becomes really slow, and I think the shader code looks not expensive, and wonder which part makes it slow, or is there is any other cheaper solution.Thank you in advance and sorry for my poor english, if you dont understand my description.Code:   // Color border problem, can be ignored   thePixel.rgb = clamp(thePixel.rgb, 0.0001, 0.9999);   // Calculate index which indicate which polynomial is used to calculate pixel color   int3 curveIndex = int3((thePixel.rgb - 0.5) * 4) + 1; // x coordinate of Points which define the spline   float4 curvX = {0, 0.25, 0.75, 1.0}; // calculate r g b, according to the coefficient which calculate in the application   float factor = (thePixel.r- curvX[curveIndex.r]);   thePixel.r = Coefficient[0][curveIndex.r] +  Coefficient[1][curveIndex.r] * factor +Coefficient[2][curveIndex.r] * pow(factor,2) +Coefficient[3][curveIndex.r] * pow(factor,3); factor = (thePixel.g- curvX[curveIndex.g]);   thePixel.g = Coefficient[0][curveIndex.g] + Coefficient[1][curveIndex.g] * factor +   Coefficient[2][curveIndex.g] * pow(factor,2)+   Coefficient[3][curveIndex.g] * pow(factor,3);  factor = (thePixel.b- curvX[curveIndex.b]); thePixel.b = Coefficient[0][curveIndex.b] + Coefficient[1][curveIndex.b] * factor+   Coefficient[2][curveIndex.b] * pow(factor,2)+   Coefficient[3][curveIndex.b] * pow(factor,3);
  cross post:* http://www.gamedev.net/community/forums/topic.asp?topic_id=534702* http://www.gamedev.net/community/forums/topic.asp?topic_id=534700   ;  Your problem is mainly down to the array lookups based on the pixel colour. To do that in HLSL it needs to do a series of comparisons - look at the number of cmp instructions in the assembly output from fxc.One possible solution is to use a small texture instead of an array.You may find the ATI GPU Shader Analyzer helpful for performance testing.   