mesa: tidy up renderbuffer RefCount initialisation
[mesa.git] / src / mesa / main / format_utils.h
index 00ec7774dd26d36670582cd10471b1a7601ab268..378997b38b29324226aca68825731274986f0cc2 100644 (file)
@@ -34,6 +34,7 @@
 #include "imports.h"
 #include "macros.h"
 #include "util/rounding.h"
+#include "util/half_float.h"
 
 extern const mesa_array_format RGBA32_FLOAT;
 extern const mesa_array_format RGBA8_UBYTE;
@@ -99,7 +100,7 @@ _mesa_unorm_to_unorm(unsigned x, unsigned src_bits, unsigned dst_bits)
 {
    if (src_bits < dst_bits) {
       return EXTEND_NORMALIZED_INT(x, src_bits, dst_bits);
-   } else {
+   } else if (src_bits > dst_bits) {
       unsigned src_half = (1 << (src_bits - 1)) - 1;
 
       if (src_bits + dst_bits > sizeof(x) * 8) {
@@ -109,6 +110,8 @@ _mesa_unorm_to_unorm(unsigned x, unsigned src_bits, unsigned dst_bits)
       } else {
          return (x * MAX_UINT(dst_bits) + src_half) / MAX_UINT(src_bits);
       }
+   } else {
+      return x;
    }
 }