mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 02:38:04 +02:00
util: Fix warning C4244 'argument' : conversion from 'type1' to 'type2', possible loss of data
Reviewed-By: Jesse Natalie <jenatali@microsoft.com> Reviewed-by: Jesse Natalie <None> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32979>
This commit is contained in:
parent
6a724af20d
commit
4d653c7df9
7 changed files with 24 additions and 24 deletions
|
|
@ -79,13 +79,13 @@ pipe_reference_described(struct pipe_reference *dst,
|
|||
if (dst != src) {
|
||||
/* bump the src.count first */
|
||||
if (src) {
|
||||
ASSERTED int count = p_atomic_inc_return(&src->count);
|
||||
ASSERTED int64_t count = p_atomic_inc_return(&src->count);
|
||||
assert(count != 1); /* src had to be referenced */
|
||||
debug_reference(src, get_desc, 1);
|
||||
}
|
||||
|
||||
if (dst) {
|
||||
int count = p_atomic_dec_return(&dst->count);
|
||||
int64_t count = p_atomic_dec_return(&dst->count);
|
||||
assert(count != -1); /* dst had to be referenced */
|
||||
debug_reference(dst, get_desc, -1);
|
||||
if (!count)
|
||||
|
|
@ -171,7 +171,7 @@ pipe_resource_reference(struct pipe_resource **dst, struct pipe_resource *src)
|
|||
static inline void
|
||||
pipe_drop_resource_references(struct pipe_resource *dst, int num_refs)
|
||||
{
|
||||
int count = p_atomic_add_return(&dst->reference.count, -num_refs);
|
||||
int64_t count = p_atomic_add_return(&dst->reference.count, -num_refs);
|
||||
|
||||
assert(count >= 0);
|
||||
/* Underflows shouldn't happen, but let's be safe. */
|
||||
|
|
@ -282,8 +282,8 @@ pipe_surface_reset(struct pipe_context *ctx, struct pipe_surface* ps,
|
|||
{
|
||||
pipe_resource_reference(&ps->texture, pt);
|
||||
ps->format = pt->format;
|
||||
ps->width = u_minify(pt->width0, level);
|
||||
ps->height = u_minify(pt->height0, level);
|
||||
ps->width = (uint16_t)u_minify(pt->width0, level);
|
||||
ps->height = (uint16_t)u_minify(pt->height0, level);
|
||||
ps->u.tex.level = level;
|
||||
ps->u.tex.first_layer = ps->u.tex.last_layer = layer;
|
||||
ps->context = ctx;
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ util_bitcount64(uint64_t n)
|
|||
#ifdef HAVE___BUILTIN_POPCOUNTLL
|
||||
return __builtin_popcountll(n);
|
||||
#else
|
||||
return util_bitcount(n) + util_bitcount(n >> 32);
|
||||
return util_bitcount((unsigned)n) + util_bitcount((unsigned)(n >> 32));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ u_box_2d_zslice(unsigned x, unsigned y, unsigned z,
|
|||
{
|
||||
box->x = x;
|
||||
box->y = y;
|
||||
box->z = z;
|
||||
box->z = (int16_t)z;
|
||||
box->width = w;
|
||||
box->height = h;
|
||||
box->depth = 1;
|
||||
|
|
@ -72,10 +72,10 @@ u_box_3d(unsigned x, unsigned y, unsigned z,
|
|||
{
|
||||
box->x = x;
|
||||
box->y = y;
|
||||
box->z = z;
|
||||
box->z = (int16_t)z;
|
||||
box->width = w;
|
||||
box->height = h;
|
||||
box->depth = d;
|
||||
box->depth = (int16_t)d;
|
||||
}
|
||||
|
||||
/* Clips @dst to width @w and height @h.
|
||||
|
|
@ -203,10 +203,10 @@ u_box_union_3d(struct pipe_box *dst,
|
|||
|
||||
dst->width = MAX2(a->x + a->width, b->x + b->width) - x;
|
||||
dst->height = MAX2(a->y + a->height, b->y + b->height) - y;
|
||||
dst->depth = MAX2(a->z + a->depth, b->z + b->depth) - z;
|
||||
dst->depth = (int16_t) (MAX2(a->z + a->depth, b->z + b->depth) - z);
|
||||
dst->x = x;
|
||||
dst->y = y;
|
||||
dst->z = z;
|
||||
dst->z = (int16_t)z;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ _mesa_half_is_negative(uint16_t h)
|
|||
struct float16_t {
|
||||
uint16_t bits;
|
||||
float16_t(float f) : bits(_mesa_float_to_half(f)) {}
|
||||
float16_t(double d) : bits(_mesa_float_to_half(d)) {}
|
||||
float16_t(double d) : bits(_mesa_float_to_half((float)d)) {}
|
||||
float16_t(uint16_t raw_bits) : bits(raw_bits) {}
|
||||
static float16_t one() { return float16_t(FP16_ONE); }
|
||||
static float16_t zero() { return float16_t(FP16_ZERO); }
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ simple_mtx_destroy(ASSERTED simple_mtx_t *mtx)
|
|||
static inline void
|
||||
simple_mtx_lock(simple_mtx_t *mtx)
|
||||
{
|
||||
uint32_t c;
|
||||
int64_t c;
|
||||
|
||||
c = p_atomic_cmpxchg(&mtx->val, 0, 1);
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ simple_mtx_lock(simple_mtx_t *mtx)
|
|||
static inline void
|
||||
simple_mtx_unlock(simple_mtx_t *mtx)
|
||||
{
|
||||
uint32_t c;
|
||||
int64_t c;
|
||||
|
||||
HG(ANNOTATE_RWLOCK_RELEASED(mtx, 1));
|
||||
|
||||
|
|
|
|||
|
|
@ -166,17 +166,17 @@ __forceinline short _interlockedadd16(short volatile * _Addend, short _Value)
|
|||
((void) p_atomic_fetch_add((_v), (_i)))
|
||||
|
||||
#define p_atomic_add_return(_v, _i) (\
|
||||
sizeof *(_v) == sizeof(char) ? _interlockedadd8 ((char *) (_v), (_i)) : \
|
||||
sizeof *(_v) == sizeof(short) ? _interlockedadd16((short *) (_v), (_i)) : \
|
||||
sizeof *(_v) == sizeof(long) ? _interlockedadd ((long *) (_v), (_i)) : \
|
||||
sizeof *(_v) == sizeof(__int64) ? _interlockedadd64((__int64 *)(_v), (_i)) : \
|
||||
sizeof *(_v) == sizeof(char) ? _interlockedadd8 ((char *) (_v), (char) (_i)) : \
|
||||
sizeof *(_v) == sizeof(short) ? _interlockedadd16((short *) (_v), (short) (_i)) : \
|
||||
sizeof *(_v) == sizeof(long) ? _interlockedadd ((long *) (_v), (long) (_i)) : \
|
||||
sizeof *(_v) == sizeof(__int64) ? _interlockedadd64((__int64 *)(_v), (__int64) (_i)) : \
|
||||
(assert(!"should not get here"), 0))
|
||||
|
||||
#define p_atomic_fetch_add(_v, _i) (\
|
||||
sizeof *(_v) == sizeof(char) ? _InterlockedExchangeAdd8 ((char *) (_v), (_i)) : \
|
||||
sizeof *(_v) == sizeof(short) ? _InterlockedExchangeAdd16((short *) (_v), (_i)) : \
|
||||
sizeof *(_v) == sizeof(long) ? _InterlockedExchangeAdd ((long *) (_v), (_i)) : \
|
||||
sizeof *(_v) == sizeof(__int64) ? _interlockedexchangeadd64((__int64 *)(_v), (_i)) : \
|
||||
sizeof *(_v) == sizeof(char) ? _InterlockedExchangeAdd8 ((char *) (_v), (char) (_i)) : \
|
||||
sizeof *(_v) == sizeof(short) ? _InterlockedExchangeAdd16((short *) (_v), (short) (_i)) : \
|
||||
sizeof *(_v) == sizeof(long) ? _InterlockedExchangeAdd ((long *) (_v), (long) (_i)) : \
|
||||
sizeof *(_v) == sizeof(__int64) ? _interlockedexchangeadd64((__int64 *)(_v), (__int64) (_i)) : \
|
||||
(assert(!"should not get here"), 0))
|
||||
|
||||
#define p_atomic_cmpxchg(_v, _old, _new) (\
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ util_queue_fence_destroy(struct util_queue_fence *fence)
|
|||
static inline void
|
||||
util_queue_fence_signal(struct util_queue_fence *fence)
|
||||
{
|
||||
uint32_t val = p_atomic_xchg(&fence->val, 0);
|
||||
uint32_t val = (uint32_t)p_atomic_xchg(&fence->val, 0);
|
||||
|
||||
assert(val != 0);
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ util_queue_fence_reset(struct util_queue_fence *fence)
|
|||
#ifdef NDEBUG
|
||||
fence->val = 1;
|
||||
#else
|
||||
uint32_t v = p_atomic_xchg(&fence->val, 1);
|
||||
uint32_t v = (uint32_t)p_atomic_xchg(&fence->val, 1);
|
||||
assert(v == 0);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue