mesa: added _mesa_scale_and_bias_depth_uint()
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 29 Apr 2008 18:51:06 +0000 (12:51 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 29 Apr 2008 18:51:06 +0000 (12:51 -0600)
src/mesa/main/pixel.c
src/mesa/main/pixel.h

index eb4fd6e..0e9915d 100644 (file)
@@ -1341,6 +1341,21 @@ _mesa_scale_and_bias_depth(const GLcontext *ctx, GLuint n,
 }
 
 
+void
+_mesa_scale_and_bias_depth_uint(const GLcontext *ctx, GLuint n,
+                                GLuint depthValues[])
+{
+   const GLdouble max = (double) 0xffffffff;
+   const GLdouble scale = ctx->Pixel.DepthScale;
+   const GLdouble bias = ctx->Pixel.DepthBias * max;
+   GLuint i;
+   for (i = 0; i < n; i++) {
+      GLdouble d = (GLdouble) depthValues[i] * scale + bias;
+      d = CLAMP(d, 0.0, max);
+      depthValues[i] = (GLuint) d;
+   }
+}
+
 
 /**********************************************************************/
 /*****                    State Management                        *****/
index 09155cf..3ba5b66 100644 (file)
@@ -116,6 +116,9 @@ extern void
 _mesa_scale_and_bias_depth(const GLcontext *ctx, GLuint n,
                            GLfloat depthValues[]);
 
+extern void
+_mesa_scale_and_bias_depth_uint(const GLcontext *ctx, GLuint n,
+                                GLuint depthValues[]);
 
 extern void 
 _mesa_update_pixel( GLcontext *ctx, GLuint newstate );