st/mesa/glsl/nir/i965: make use of new gl_shader_program_data in gl_shader_program
[mesa.git] / src / mesa / main / pack.c
index fb642b85be88b5b32f01044d762fe6b0353e8df3..89faf5154436fbd55aa728f7e2894153318e2298 100644 (file)
@@ -43,7 +43,6 @@
 
 
 #include "glheader.h"
-#include "colormac.h"
 #include "enums.h"
 #include "image.h"
 #include "imports.h"
@@ -470,7 +469,7 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
 static inline GLuint
 clamp_float_to_uint(GLfloat f)
 {
-   return f < 0.0F ? 0 : F_TO_I(f);
+   return f < 0.0F ? 0 : _mesa_lroundevenf(f);
 }
 
 
@@ -478,7 +477,7 @@ static inline GLuint
 clamp_half_to_uint(GLhalfARB h)
 {
    GLfloat f = _mesa_half_to_float(h);
-   return f < 0.0F ? 0 : F_TO_I(f);
+   return f < 0.0F ? 0 : _mesa_lroundevenf(f);
 }
 
 
@@ -1074,6 +1073,21 @@ _mesa_pack_depth_span( struct gl_context *ctx, GLuint n, GLvoid *dest,
          }
       }
       break;
+   case GL_UNSIGNED_INT_24_8:
+      {
+         const GLdouble scale = (GLdouble) 0xffffff;
+         GLuint *dst = (GLuint *) dest;
+         GLuint i;
+         for (i = 0; i < n; i++) {
+            GLuint z = (GLuint) (depthSpan[i] * scale);
+            assert(z <= 0xffffff);
+            dst[i] = (z << 8);
+         }
+         if (dstPacking->SwapBytes) {
+            _mesa_swap4( (GLuint *) dst, n );
+         }
+         break;
+      }
    case GL_UNSIGNED_INT:
       {
          GLuint *dst = (GLuint *) dest;
@@ -1124,7 +1138,8 @@ _mesa_pack_depth_span( struct gl_context *ctx, GLuint n, GLvoid *dest,
       }
       break;
    default:
-      _mesa_problem(ctx, "bad type in _mesa_pack_depth_span");
+      _mesa_problem(ctx, "bad type in _mesa_pack_depth_span (%s)",
+                    _mesa_enum_to_string(dstType));
    }
 
    free(depthCopy);