mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 17:48:10 +02:00
gallium: Fix a bunch of undefined left-shifts in u_format_*
Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
4b17311e52
commit
2e9aef4651
4 changed files with 59 additions and 59 deletions
|
|
@ -579,7 +579,7 @@ def generate_pack_kernel(format, src_channel, src_native_type):
|
|||
if shift + dst_channel.size < depth:
|
||||
value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1)
|
||||
if shift:
|
||||
value = '(%s) << %u' % (value, shift)
|
||||
value = '(uint32_t)(%s) << %u' % (value, shift)
|
||||
if dst_channel.type == SIGNED:
|
||||
# Cast to unsigned
|
||||
value = '(uint%u_t)(%s) ' % (depth, value)
|
||||
|
|
|
|||
|
|
@ -165,10 +165,10 @@ util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
|
|||
g1 = src[5];
|
||||
b = 0.5f*(src[2] + src[6]);
|
||||
|
||||
value = float_to_ubyte(r);
|
||||
value |= float_to_ubyte(g0) << 8;
|
||||
value |= float_to_ubyte(b) << 16;
|
||||
value |= float_to_ubyte(g1) << 24;
|
||||
value = (uint32_t)float_to_ubyte(r);
|
||||
value |= (uint32_t)float_to_ubyte(g0) << 8;
|
||||
value |= (uint32_t)float_to_ubyte(b) << 16;
|
||||
value |= (uint32_t)float_to_ubyte(g1) << 24;
|
||||
|
||||
*dst++ = util_le32_to_cpu(value);
|
||||
|
||||
|
|
@ -181,10 +181,10 @@ util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
|
|||
g1 = 0;
|
||||
b = src[2];
|
||||
|
||||
value = float_to_ubyte(r);
|
||||
value |= float_to_ubyte(g0) << 8;
|
||||
value |= float_to_ubyte(b) << 16;
|
||||
value |= float_to_ubyte(g1) << 24;
|
||||
value = (uint32_t)float_to_ubyte(r);
|
||||
value |= (uint32_t)float_to_ubyte(g0) << 8;
|
||||
value |= (uint32_t)float_to_ubyte(b) << 16;
|
||||
value |= (uint32_t)float_to_ubyte(g1) << 24;
|
||||
|
||||
*dst = util_le32_to_cpu(value);
|
||||
}
|
||||
|
|
@ -215,9 +215,9 @@ util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
|
|||
b = (src[2] + src[6] + 1) >> 1;
|
||||
|
||||
value = r;
|
||||
value |= g0 << 8;
|
||||
value |= b << 16;
|
||||
value |= g1 << 24;
|
||||
value |= (uint32_t)g0 << 8;
|
||||
value |= (uint32_t)b << 16;
|
||||
value |= (uint32_t)g1 << 24;
|
||||
|
||||
*dst++ = util_le32_to_cpu(value);
|
||||
|
||||
|
|
@ -231,9 +231,9 @@ util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
|
|||
b = src[2];
|
||||
|
||||
value = r;
|
||||
value |= g0 << 8;
|
||||
value |= b << 16;
|
||||
value |= g1 << 24;
|
||||
value |= (uint32_t)g0 << 8;
|
||||
value |= (uint32_t)b << 16;
|
||||
value |= (uint32_t)g1 << 24;
|
||||
|
||||
*dst = util_le32_to_cpu(value);
|
||||
}
|
||||
|
|
@ -385,10 +385,10 @@ util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
|
|||
g1 = src[5];
|
||||
b = 0.5f*(src[2] + src[6]);
|
||||
|
||||
value = float_to_ubyte(g0);
|
||||
value |= float_to_ubyte(r) << 8;
|
||||
value |= float_to_ubyte(g1) << 16;
|
||||
value |= float_to_ubyte(b) << 24;
|
||||
value = (uint32_t)float_to_ubyte(g0);
|
||||
value |= (uint32_t)float_to_ubyte(r) << 8;
|
||||
value |= (uint32_t)float_to_ubyte(g1) << 16;
|
||||
value |= (uint32_t)float_to_ubyte(b) << 24;
|
||||
|
||||
*dst++ = util_le32_to_cpu(value);
|
||||
|
||||
|
|
@ -401,10 +401,10 @@ util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
|
|||
g1 = 0;
|
||||
b = src[2];
|
||||
|
||||
value = float_to_ubyte(g0);
|
||||
value |= float_to_ubyte(r) << 8;
|
||||
value |= float_to_ubyte(g1) << 16;
|
||||
value |= float_to_ubyte(b) << 24;
|
||||
value = (uint32_t)float_to_ubyte(g0);
|
||||
value |= (uint32_t)float_to_ubyte(r) << 8;
|
||||
value |= (uint32_t)float_to_ubyte(g1) << 16;
|
||||
value |= (uint32_t)float_to_ubyte(b) << 24;
|
||||
|
||||
*dst = util_le32_to_cpu(value);
|
||||
}
|
||||
|
|
@ -435,9 +435,9 @@ util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
|
|||
b = (src[2] + src[6] + 1) >> 1;
|
||||
|
||||
value = g0;
|
||||
value |= r << 8;
|
||||
value |= g1 << 16;
|
||||
value |= b << 24;
|
||||
value |= (uint32_t)r << 8;
|
||||
value |= (uint32_t)g1 << 16;
|
||||
value |= (uint32_t)b << 24;
|
||||
|
||||
*dst++ = util_le32_to_cpu(value);
|
||||
|
||||
|
|
@ -451,9 +451,9 @@ util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
|
|||
b = src[2];
|
||||
|
||||
value = g0;
|
||||
value |= r << 8;
|
||||
value |= g1 << 16;
|
||||
value |= b << 24;
|
||||
value |= (uint32_t)r << 8;
|
||||
value |= (uint32_t)g1 << 16;
|
||||
value |= (uint32_t)b << 24;
|
||||
|
||||
*dst = util_le32_to_cpu(value);
|
||||
}
|
||||
|
|
@ -599,9 +599,9 @@ util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
|
|||
v = (v0 + v1 + 1) >> 1;
|
||||
|
||||
value = u;
|
||||
value |= y0 << 8;
|
||||
value |= v << 16;
|
||||
value |= y1 << 24;
|
||||
value |= (uint32_t)y0 << 8;
|
||||
value |= (uint32_t)v << 16;
|
||||
value |= (uint32_t)y1 << 24;
|
||||
|
||||
*dst++ = util_le32_to_cpu(value);
|
||||
|
||||
|
|
@ -614,9 +614,9 @@ util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
|
|||
y1 = 0;
|
||||
|
||||
value = u;
|
||||
value |= y0 << 8;
|
||||
value |= v << 16;
|
||||
value |= y1 << 24;
|
||||
value |= (uint32_t)y0 << 8;
|
||||
value |= (uint32_t)v << 16;
|
||||
value |= (uint32_t)y1 << 24;
|
||||
|
||||
*dst = util_le32_to_cpu(value);
|
||||
}
|
||||
|
|
@ -652,9 +652,9 @@ util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
|
|||
v = (v0 + v1 + 1) >> 1;
|
||||
|
||||
value = u;
|
||||
value |= y0 << 8;
|
||||
value |= v << 16;
|
||||
value |= y1 << 24;
|
||||
value |= (uint32_t)y0 << 8;
|
||||
value |= (uint32_t)v << 16;
|
||||
value |= (uint32_t)y1 << 24;
|
||||
|
||||
*dst++ = util_le32_to_cpu(value);
|
||||
|
||||
|
|
@ -667,9 +667,9 @@ util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
|
|||
y1 = 0;
|
||||
|
||||
value = u;
|
||||
value |= y0 << 8;
|
||||
value |= v << 16;
|
||||
value |= y1 << 24;
|
||||
value |= (uint32_t)y0 << 8;
|
||||
value |= (uint32_t)v << 16;
|
||||
value |= (uint32_t)y1 << 24;
|
||||
|
||||
*dst = util_le32_to_cpu(value);
|
||||
}
|
||||
|
|
@ -820,9 +820,9 @@ util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
|
|||
v = (v0 + v1 + 1) >> 1;
|
||||
|
||||
value = y0;
|
||||
value |= u << 8;
|
||||
value |= y1 << 16;
|
||||
value |= v << 24;
|
||||
value |= (uint32_t)u << 8;
|
||||
value |= (uint32_t)y1 << 16;
|
||||
value |= (uint32_t)v << 24;
|
||||
|
||||
*dst++ = util_le32_to_cpu(value);
|
||||
|
||||
|
|
@ -835,9 +835,9 @@ util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
|
|||
y1 = 0;
|
||||
|
||||
value = y0;
|
||||
value |= u << 8;
|
||||
value |= y1 << 16;
|
||||
value |= v << 24;
|
||||
value |= (uint32_t)u << 8;
|
||||
value |= (uint32_t)y1 << 16;
|
||||
value |= (uint32_t)v << 24;
|
||||
|
||||
*dst = util_le32_to_cpu(value);
|
||||
}
|
||||
|
|
@ -873,9 +873,9 @@ util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
|
|||
v = (v0 + v1 + 1) >> 1;
|
||||
|
||||
value = y0;
|
||||
value |= u << 8;
|
||||
value |= y1 << 16;
|
||||
value |= v << 24;
|
||||
value |= (uint32_t)u << 8;
|
||||
value |= (uint32_t)y1 << 16;
|
||||
value |= (uint32_t)v << 24;
|
||||
|
||||
*dst++ = util_le32_to_cpu(value);
|
||||
|
||||
|
|
@ -888,9 +888,9 @@ util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
|
|||
y1 = 0;
|
||||
|
||||
value = y0;
|
||||
value |= u << 8;
|
||||
value |= y1 << 16;
|
||||
value |= v << 24;
|
||||
value |= (uint32_t)u << 8;
|
||||
value |= (uint32_t)y1 << 16;
|
||||
value |= (uint32_t)v << 24;
|
||||
|
||||
*dst = util_le32_to_cpu(value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ static inline uint32_t
|
|||
z16_unorm_to_z32_unorm(uint16_t z)
|
||||
{
|
||||
/* z * 0xffffffff / 0xffff */
|
||||
return (z << 16) | z;
|
||||
return ((uint32_t)z << 16) | z;
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
|
|
@ -439,7 +439,7 @@ util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride
|
|||
for(x = 0; x < width; ++x) {
|
||||
uint32_t value = util_le32_to_cpu(*dst);
|
||||
value &= 0x00ffffff;
|
||||
value |= *src++ << 24;
|
||||
value |= (uint32_t)*src++ << 24;
|
||||
*dst++ = util_cpu_to_le32(value);
|
||||
}
|
||||
dst_row += dst_stride/sizeof(*dst_row);
|
||||
|
|
@ -459,7 +459,7 @@ util_format_z24_unorm_s8_uint_pack_separate(uint8_t *dst_row, unsigned dst_strid
|
|||
const uint8_t *s_src = s_src_row;
|
||||
uint32_t *dst = (uint32_t *)dst_row;
|
||||
for (x = 0; x < width; ++x) {
|
||||
*dst++ = (*z_src++ & 0x00ffffff) | (*s_src++ << 24);
|
||||
*dst++ = (*z_src++ & 0x00ffffff) | ((uint32_t)*s_src++ << 24);
|
||||
}
|
||||
dst_row += dst_stride / sizeof(*dst_row);
|
||||
z_src_row += z_src_stride / sizeof(*z_src_row);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ static void dxt135_decode_imageblock ( const GLubyte *img_block_src,
|
|||
const GLushort color0 = img_block_src[0] | (img_block_src[1] << 8);
|
||||
const GLushort color1 = img_block_src[2] | (img_block_src[3] << 8);
|
||||
const GLuint bits = img_block_src[4] | (img_block_src[5] << 8) |
|
||||
(img_block_src[6] << 16) | (img_block_src[7] << 24);
|
||||
(img_block_src[6] << 16) | ((GLuint)img_block_src[7] << 24);
|
||||
/* What about big/little endian? */
|
||||
GLubyte bit_pos = 2 * (j * 4 + i) ;
|
||||
GLubyte code = (GLubyte) ((bits >> bit_pos) & 3);
|
||||
|
|
@ -430,7 +430,7 @@ static void storedxtencodedblock( GLubyte *blkaddr, GLubyte srccolors[4][4][4],
|
|||
}
|
||||
}
|
||||
testerror += pixerrorbest;
|
||||
bits |= enc << (2 * (j * 4 + i));
|
||||
bits |= (uint32_t)enc << (2 * (j * 4 + i));
|
||||
}
|
||||
}
|
||||
/* some hw might disagree but actually decoding should always use 4-color encoding
|
||||
|
|
@ -470,7 +470,7 @@ static void storedxtencodedblock( GLubyte *blkaddr, GLubyte srccolors[4][4][4],
|
|||
}
|
||||
}
|
||||
testerror2 += pixerrorbest;
|
||||
bits2 |= enc << (2 * (j * 4 + i));
|
||||
bits2 |= (uint32_t)enc << (2 * (j * 4 + i));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue