diff options
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util')
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_debug.c | 134 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_debug.h | 6 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_other.c | 80 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_yuv.c | 192 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_zs.c | 160 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_math.h | 171 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_sse.h | 27 |
7 files changed, 182 insertions, 588 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_debug.c b/mesalib/src/gallium/auxiliary/util/u_debug.c index d79f31ea9..2d2d049b2 100644 --- a/mesalib/src/gallium/auxiliary/util/u_debug.c +++ b/mesalib/src/gallium/auxiliary/util/u_debug.c @@ -402,31 +402,28 @@ void debug_print_format(const char *msg, unsigned fmt ) #endif - -static const struct debug_named_value pipe_prim_names[] = { -#ifdef DEBUG - DEBUG_NAMED_VALUE(PIPE_PRIM_POINTS), - DEBUG_NAMED_VALUE(PIPE_PRIM_LINES), - DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_LOOP), - DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP), - DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES), - DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP), - DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_FAN), - DEBUG_NAMED_VALUE(PIPE_PRIM_QUADS), - DEBUG_NAMED_VALUE(PIPE_PRIM_QUAD_STRIP), - DEBUG_NAMED_VALUE(PIPE_PRIM_POLYGON), - DEBUG_NAMED_VALUE(PIPE_PRIM_LINES_ADJACENCY), - DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP_ADJACENCY), - DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES_ADJACENCY), - DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY), -#endif - DEBUG_NAMED_VALUE_END -}; - - -const char *u_prim_name( unsigned prim ) +/** Return string name of given primitive type */ +const char * +u_prim_name(unsigned prim) { - return debug_dump_enum(pipe_prim_names, prim); + static const struct debug_named_value names[] = { + DEBUG_NAMED_VALUE(PIPE_PRIM_POINTS), + DEBUG_NAMED_VALUE(PIPE_PRIM_LINES), + DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_LOOP), + DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP), + DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES), + DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP), + DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_FAN), + DEBUG_NAMED_VALUE(PIPE_PRIM_QUADS), + DEBUG_NAMED_VALUE(PIPE_PRIM_QUAD_STRIP), + DEBUG_NAMED_VALUE(PIPE_PRIM_POLYGON), + DEBUG_NAMED_VALUE(PIPE_PRIM_LINES_ADJACENCY), + DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP_ADJACENCY), + DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES_ADJACENCY), + DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY), + DEBUG_NAMED_VALUE_END + }; + return debug_dump_enum(names, prim); } @@ -722,38 +719,75 @@ error1: void debug_print_transfer_flags(const char *msg, unsigned usage) { -#define FLAG(x) { x, #x } - static const struct { - unsigned bit; - const char *name; - } flags[] = { - FLAG(PIPE_TRANSFER_READ), - FLAG(PIPE_TRANSFER_WRITE), - FLAG(PIPE_TRANSFER_MAP_DIRECTLY), - FLAG(PIPE_TRANSFER_DISCARD_RANGE), - FLAG(PIPE_TRANSFER_DONTBLOCK), - FLAG(PIPE_TRANSFER_UNSYNCHRONIZED), - FLAG(PIPE_TRANSFER_FLUSH_EXPLICIT), - FLAG(PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) + static const struct debug_named_value names[] = { + DEBUG_NAMED_VALUE(PIPE_TRANSFER_READ), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_WRITE), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_MAP_DIRECTLY), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_DISCARD_RANGE), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_DONTBLOCK), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_UNSYNCHRONIZED), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_FLUSH_EXPLICIT), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_PERSISTENT), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_COHERENT), + DEBUG_NAMED_VALUE_END }; - unsigned i; - debug_printf("%s ", msg); + debug_printf("%s: %s\n", msg, debug_dump_flags(names, usage)); +} - for (i = 0; i < Elements(flags); i++) { - if (usage & flags[i].bit) { - debug_printf("%s", flags[i].name); - usage &= ~flags[i].bit; - if (usage) { - debug_printf(" | "); - } - } - } - debug_printf("\n"); -#undef FLAG +/** + * Print PIPE_BIND_x flags with a message. + */ +void +debug_print_bind_flags(const char *msg, unsigned usage) +{ + static const struct debug_named_value names[] = { + DEBUG_NAMED_VALUE(PIPE_BIND_DEPTH_STENCIL), + DEBUG_NAMED_VALUE(PIPE_BIND_RENDER_TARGET), + DEBUG_NAMED_VALUE(PIPE_BIND_BLENDABLE), + DEBUG_NAMED_VALUE(PIPE_BIND_SAMPLER_VIEW), + DEBUG_NAMED_VALUE(PIPE_BIND_VERTEX_BUFFER), + DEBUG_NAMED_VALUE(PIPE_BIND_INDEX_BUFFER), + DEBUG_NAMED_VALUE(PIPE_BIND_CONSTANT_BUFFER), + DEBUG_NAMED_VALUE(PIPE_BIND_DISPLAY_TARGET), + DEBUG_NAMED_VALUE(PIPE_BIND_TRANSFER_WRITE), + DEBUG_NAMED_VALUE(PIPE_BIND_TRANSFER_READ), + DEBUG_NAMED_VALUE(PIPE_BIND_STREAM_OUTPUT), + DEBUG_NAMED_VALUE(PIPE_BIND_CURSOR), + DEBUG_NAMED_VALUE(PIPE_BIND_CUSTOM), + DEBUG_NAMED_VALUE(PIPE_BIND_GLOBAL), + DEBUG_NAMED_VALUE(PIPE_BIND_SHADER_RESOURCE), + DEBUG_NAMED_VALUE(PIPE_BIND_COMPUTE_RESOURCE), + DEBUG_NAMED_VALUE(PIPE_BIND_COMMAND_ARGS_BUFFER), + DEBUG_NAMED_VALUE(PIPE_BIND_SCANOUT), + DEBUG_NAMED_VALUE(PIPE_BIND_SHARED), + DEBUG_NAMED_VALUE(PIPE_BIND_LINEAR), + DEBUG_NAMED_VALUE_END + }; + + debug_printf("%s: %s\n", msg, debug_dump_flags(names, usage)); } +/** + * Print PIPE_USAGE_x enum values with a message. + */ +void +debug_print_usage_enum(const char *msg, unsigned usage) +{ + static const struct debug_named_value names[] = { + DEBUG_NAMED_VALUE(PIPE_USAGE_DEFAULT), + DEBUG_NAMED_VALUE(PIPE_USAGE_IMMUTABLE), + DEBUG_NAMED_VALUE(PIPE_USAGE_DYNAMIC), + DEBUG_NAMED_VALUE(PIPE_USAGE_STREAM), + DEBUG_NAMED_VALUE(PIPE_USAGE_STAGING), + DEBUG_NAMED_VALUE_END + }; + + debug_printf("%s: %s\n", msg, debug_dump_enum(names, usage)); +} + #endif diff --git a/mesalib/src/gallium/auxiliary/util/u_debug.h b/mesalib/src/gallium/auxiliary/util/u_debug.h index 4c22fdfb6..3b2255244 100644 --- a/mesalib/src/gallium/auxiliary/util/u_debug.h +++ b/mesalib/src/gallium/auxiliary/util/u_debug.h @@ -467,6 +467,12 @@ void debug_dump_float_rgba_bmp(const char *filename, void debug_print_transfer_flags(const char *msg, unsigned usage); +void +debug_print_bind_flags(const char *msg, unsigned usage); + +void +debug_print_usage_enum(const char *msg, unsigned usage); + #ifdef __cplusplus } diff --git a/mesalib/src/gallium/auxiliary/util/u_format_other.c b/mesalib/src/gallium/auxiliary/util/u_format_other.c index 85001c14f..20752d469 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_other.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_other.c @@ -42,10 +42,7 @@ util_format_r9g9b9e5_float_unpack_rgba_float(float *dst_row, unsigned dst_stride float *dst = dst_row; const uint8_t *src = src_row; for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*(const uint32_t *)src); rgb9e5_to_float3(value, dst); dst[3] = 1; /* a */ src += 4; @@ -66,10 +63,7 @@ util_format_r9g9b9e5_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride const float *src = src_row; uint8_t *dst = dst_row; for(x = 0; x < width; x += 1) { - uint32_t value = float3_to_rgb9e5(src); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(float3_to_rgb9e5(src)); *(uint32_t *)dst = value; src += 4; dst += 4; @@ -83,10 +77,7 @@ void util_format_r9g9b9e5_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*(const uint32_t *)src); rgb9e5_to_float3(value, dst); dst[3] = 1; /* a */ } @@ -103,10 +94,7 @@ util_format_r9g9b9e5_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_str uint8_t *dst = dst_row; const uint8_t *src = src_row; for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*(const uint32_t *)src); rgb9e5_to_float3(value, p); dst[0] = float_to_ubyte(p[0]); /* r */ dst[1] = float_to_ubyte(p[1]); /* g */ @@ -136,10 +124,7 @@ util_format_r9g9b9e5_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_strid p[0] = ubyte_to_float(src[0]); p[1] = ubyte_to_float(src[1]); p[2] = ubyte_to_float(src[2]); - value = float3_to_rgb9e5(p); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(float3_to_rgb9e5(p)); *(uint32_t *)dst = value; src += 4; dst += 4; @@ -160,10 +145,7 @@ util_format_r11g11b10_float_unpack_rgba_float(float *dst_row, unsigned dst_strid float *dst = dst_row; const uint8_t *src = src_row; for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*(const uint32_t *)src); r11g11b10f_to_float3(value, dst); dst[3] = 1; /* a */ src += 4; @@ -184,10 +166,7 @@ util_format_r11g11b10_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid const float *src = src_row; uint8_t *dst = dst_row; for(x = 0; x < width; x += 1) { - uint32_t value = float3_to_r11g11b10f(src); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(float3_to_r11g11b10f(src)); *(uint32_t *)dst = value; src += 4; dst += 4; @@ -201,10 +180,7 @@ void util_format_r11g11b10_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*(const uint32_t *)src); r11g11b10f_to_float3(value, dst); dst[3] = 1; /* a */ } @@ -221,10 +197,7 @@ util_format_r11g11b10_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st uint8_t *dst = dst_row; const uint8_t *src = src_row; for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*(const uint32_t *)src); r11g11b10f_to_float3(value, p); dst[0] = float_to_ubyte(p[0]); /* r */ dst[1] = float_to_ubyte(p[1]); /* g */ @@ -254,10 +227,7 @@ util_format_r11g11b10_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri p[0] = ubyte_to_float(src[0]); p[1] = ubyte_to_float(src[1]); p[2] = ubyte_to_float(src[2]); - value = float3_to_r11g11b10f(p); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(float3_to_r11g11b10f(p)); *(uint32_t *)dst = value; src += 4; dst += 4; @@ -338,13 +308,9 @@ util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, float *dst = dst_row; const uint16_t *src = (const uint16_t *)src_row; for(x = 0; x < width; x += 1) { - uint16_t value = *src++; + uint16_t value = util_cpu_to_le16(*src++); int16_t r, g; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - r = ((int16_t)(value << 8)) >> 8; g = ((int16_t)(value << 0)) >> 8; @@ -370,13 +336,9 @@ util_format_r8g8bx_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_strid uint8_t *dst = dst_row; const uint16_t *src = (const uint16_t *)src_row; for(x = 0; x < width; x += 1) { - uint16_t value = *src++; + uint16_t value = util_cpu_to_le16(*src++); int16_t r, g; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - r = ((int16_t)(value << 8)) >> 8; g = ((int16_t)(value << 0)) >> 8; @@ -407,11 +369,7 @@ util_format_r8g8bx_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= (uint16_t)(((int8_t)(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ; value |= (uint16_t)((((int8_t)(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - - *dst++ = value; + *dst++ = util_le16_to_cpu(value); src += 4; } @@ -437,11 +395,7 @@ util_format_r8g8bx_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= src[0] >> 1; value |= (src[1] >> 1) << 8; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - - *dst++ = value; + *dst++ = util_le16_to_cpu(value); src += 4; } @@ -455,13 +409,9 @@ void util_format_r8g8bx_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) { - uint16_t value = *(const uint16_t *)src; + uint16_t value = util_cpu_to_le16(*(const uint16_t *)src); int16_t r, g; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - r = ((int16_t)(value << 8)) >> 8; g = ((int16_t)(value << 0)) >> 8; diff --git a/mesalib/src/gallium/auxiliary/util/u_format_yuv.c b/mesalib/src/gallium/auxiliary/util/u_format_yuv.c index 891d99cf6..16ed8af7b 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_yuv.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_yuv.c @@ -52,11 +52,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid float r, g0, g1, b; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); r = ubyte_to_float((value >> 0) & 0xff); g0 = ubyte_to_float((value >> 8) & 0xff); @@ -77,11 +73,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); r = ubyte_to_float((value >> 0) & 0xff); g0 = ubyte_to_float((value >> 8) & 0xff); @@ -114,11 +106,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st uint8_t r, g0, g1, b; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); r = (value >> 0) & 0xff; g0 = (value >> 8) & 0xff; @@ -139,11 +127,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); r = (value >> 0) & 0xff; g0 = (value >> 8) & 0xff; @@ -186,11 +170,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid value |= float_to_ubyte(b) << 16; value |= float_to_ubyte(g1) << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -206,11 +186,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid value |= float_to_ubyte(b) << 16; value |= float_to_ubyte(g1) << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -243,11 +219,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri value |= b << 16; value |= g1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -263,11 +235,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri value |= b << 16; value |= g1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -304,11 +272,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid float r, g0, g1, b; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); g0 = ubyte_to_float((value >> 0) & 0xff); r = ubyte_to_float((value >> 8) & 0xff); @@ -329,11 +293,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); g0 = ubyte_to_float((value >> 0) & 0xff); r = ubyte_to_float((value >> 8) & 0xff); @@ -366,11 +326,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st uint8_t r, g0, g1, b; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); g0 = (value >> 0) & 0xff; r = (value >> 8) & 0xff; @@ -391,11 +347,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); g0 = (value >> 0) & 0xff; r = (value >> 8) & 0xff; @@ -438,11 +390,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid value |= float_to_ubyte(g1) << 16; value |= float_to_ubyte(b) << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -458,11 +406,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid value |= float_to_ubyte(g1) << 16; value |= float_to_ubyte(b) << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -495,11 +439,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri value |= g1 << 16; value |= b << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -515,11 +455,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri value |= g1 << 16; value |= b << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -556,11 +492,7 @@ util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride, uint8_t y0, y1, u, v; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); u = (value >> 0) & 0xff; y0 = (value >> 8) & 0xff; @@ -577,11 +509,7 @@ util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride, } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); u = (value >> 0) & 0xff; y0 = (value >> 8) & 0xff; @@ -612,11 +540,7 @@ util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, uint8_t y0, y1, u, v; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); u = (value >> 0) & 0xff; y0 = (value >> 8) & 0xff; @@ -633,11 +557,7 @@ util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); u = (value >> 0) & 0xff; y0 = (value >> 8) & 0xff; @@ -683,11 +603,7 @@ util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= v << 16; value |= y1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -702,11 +618,7 @@ util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= v << 16; value |= y1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -744,11 +656,7 @@ util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= v << 16; value |= y1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -763,11 +671,7 @@ util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= v << 16; value |= y1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -809,11 +713,7 @@ util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride, uint8_t y0, y1, u, v; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); y0 = (value >> 0) & 0xff; u = (value >> 8) & 0xff; @@ -830,11 +730,7 @@ util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride, } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); y0 = (value >> 0) & 0xff; u = (value >> 8) & 0xff; @@ -865,11 +761,7 @@ util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, uint8_t y0, y1, u, v; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); y0 = (value >> 0) & 0xff; u = (value >> 8) & 0xff; @@ -886,11 +778,7 @@ util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); y0 = (value >> 0) & 0xff; u = (value >> 8) & 0xff; @@ -936,11 +824,7 @@ util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= y1 << 16; value |= v << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -955,11 +839,7 @@ util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= y1 << 16; value |= v << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -997,11 +877,7 @@ util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= y1 << 16; value |= v << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -1016,11 +892,7 @@ util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= y1 << 16; value |= v << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); diff --git a/mesalib/src/gallium/auxiliary/util/u_format_zs.c b/mesalib/src/gallium/auxiliary/util/u_format_zs.c index ed45c52f9..f1ed32f1d 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_zs.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_zs.c @@ -147,10 +147,7 @@ util_format_z16_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, float *dst = dst_row; const uint16_t *src = (const uint16_t *)src_row; for(x = 0; x < width; ++x) { - uint16_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif + uint16_t value = util_cpu_to_le16(*src++); *dst++ = z16_unorm_to_z32_float(value); } src_row += src_stride/sizeof(*src_row); @@ -170,10 +167,7 @@ util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint16_t value; value = z32_float_to_z16_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - *dst++ = value; + *dst++ = util_le16_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -190,10 +184,7 @@ util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, uint32_t *dst = dst_row; const uint16_t *src = (const uint16_t *)src_row; for(x = 0; x < width; ++x) { - uint16_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif + uint16_t value = util_cpu_to_le16(*src++); *dst++ = z16_unorm_to_z32_unorm(value); } src_row += src_stride/sizeof(*src_row); @@ -213,10 +204,7 @@ util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint16_t value; value = z32_unorm_to_z16_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - *dst++ = value; + *dst++ = util_le16_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -233,10 +221,7 @@ util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, float *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z32_unorm_to_z32_float(value); } src_row += src_stride/sizeof(*src_row); @@ -256,10 +241,7 @@ util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint32_t value; value = z32_float_to_z32_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -362,10 +344,7 @@ util_format_z24_unorm_s8_uint_unpack_z_float(float *dst_row, unsigned dst_stride float *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_float(value & 0xffffff); } src_row += src_stride/sizeof(*src_row); @@ -383,16 +362,10 @@ util_format_z24_unorm_s8_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride const float *src = src_row; uint32_t *dst = (uint32_t *)dst_row; for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_le32_to_cpu(*dst); value &= 0xff000000; value |= z32_float_to_z24_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -409,10 +382,7 @@ util_format_z24_unorm_s8_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_s uint32_t *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_unorm(value & 0xffffff); } src_row += src_stride/sizeof(*src_row); @@ -430,16 +400,10 @@ util_format_z24_unorm_s8_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stri const uint32_t *src = src_row; uint32_t *dst = (uint32_t *)dst_row; for(x = 0; x < width; ++x) { - uint32_t value= *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_le32_to_cpu(*dst); value &= 0xff000000; value |= z32_unorm_to_z24_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -456,10 +420,7 @@ util_format_z24_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stri uint8_t *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = value >> 24; } src_row += src_stride/sizeof(*src_row); @@ -477,16 +438,10 @@ util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride const uint8_t *src = src_row; uint32_t *dst = (uint32_t *)dst_row; for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_le32_to_cpu(*dst); value &= 0x00ffffff; value |= *src++ << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -503,10 +458,7 @@ util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride float *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_float(value >> 8); } src_row += src_stride/sizeof(*src_row); @@ -524,16 +476,10 @@ util_format_s8_uint_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride const float *src = src_row; uint32_t *dst = (uint32_t *)dst_row; for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_le32_to_cpu(*dst); value &= 0x000000ff; value |= z32_float_to_z24_unorm(*src++) << 8; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -550,10 +496,7 @@ util_format_s8_uint_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_s uint32_t *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_unorm(value >> 8); } src_row += src_stride/sizeof(*src_row); @@ -571,16 +514,10 @@ util_format_s8_uint_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stri const uint32_t *src = src_row; uint32_t *dst = (uint32_t *)dst_row; for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_le32_to_cpu(*dst); value &= 0x000000ff; value |= *src++ & 0xffffff00; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -597,10 +534,7 @@ util_format_s8_uint_z24_unorm_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stri uint8_t *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = value & 0xff; } src_row += src_stride/sizeof(*src_row); @@ -618,16 +552,10 @@ util_format_s8_uint_z24_unorm_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride const uint8_t *src = src_row; uint32_t *dst = (uint32_t *)dst_row; for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_le32_to_cpu(*dst); value &= 0xffffff00; value |= *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -644,10 +572,7 @@ util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, float *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_float(value & 0xffffff); } src_row += src_stride/sizeof(*src_row); @@ -667,10 +592,7 @@ util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint32_t value; value = z32_float_to_z24_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -687,10 +609,7 @@ util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, uint32_t *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_unorm(value & 0xffffff); } src_row += src_stride/sizeof(*src_row); @@ -710,10 +629,7 @@ util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint32_t value; value = z32_unorm_to_z24_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -730,10 +646,7 @@ util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, float *dst = dst_row; const uint32_t *src = (uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_float(value >> 8); } src_row += src_stride/sizeof(*src_row); @@ -753,10 +666,7 @@ util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint32_t value; value = z32_float_to_z24_unorm(*src++) << 8; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -773,10 +683,7 @@ util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, uint32_t *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_unorm(value >> 8); } src_row += src_stride/sizeof(*src_row); @@ -796,10 +703,7 @@ util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint32_t value; value = z32_unorm_to_z24_unorm(*src++) << 8; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h index d6e83f962..8f62cac66 100644 --- a/mesalib/src/gallium/auxiliary/util/u_math.h +++ b/mesalib/src/gallium/auxiliary/util/u_math.h @@ -41,13 +41,7 @@ #include "pipe/p_compiler.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#include <math.h> +#include "c99_math.h" #include <float.h> #include <stdarg.h> @@ -56,153 +50,15 @@ extern "C" { #endif -#ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 -#endif - - -#if defined(_MSC_VER) - -#if _MSC_VER < 1400 && !defined(__cplusplus) - -static INLINE float cosf( float f ) -{ - return (float) cos( (double) f ); -} - -static INLINE float sinf( float f ) -{ - return (float) sin( (double) f ); -} - -static INLINE float ceilf( float f ) -{ - return (float) ceil( (double) f ); -} - -static INLINE float floorf( float f ) -{ - return (float) floor( (double) f ); -} - -static INLINE float powf( float f, float g ) -{ - return (float) pow( (double) f, (double) g ); -} - -static INLINE float sqrtf( float f ) -{ - return (float) sqrt( (double) f ); -} - -static INLINE float fabsf( float f ) -{ - return (float) fabs( (double) f ); -} - -static INLINE float logf( float f ) -{ - return (float) log( (double) f ); -} - -#else -/* Work-around an extra semi-colon in VS 2005 logf definition */ -#ifdef logf -#undef logf -#define logf(x) ((float)log((double)(x))) -#endif /* logf */ - -#if _MSC_VER < 1800 -#define isfinite(x) _finite((double)(x)) -#define isnan(x) _isnan((double)(x)) -#endif /* _MSC_VER < 1800 */ -#endif /* _MSC_VER < 1400 && !defined(__cplusplus) */ - -#if _MSC_VER < 1800 -static INLINE double log2( double x ) -{ - const double invln2 = 1.442695041; - return log( x ) * invln2; -} - -static INLINE double -round(double x) -{ - return x >= 0.0 ? floor(x + 0.5) : ceil(x - 0.5); -} - -static INLINE float -roundf(float x) -{ - return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f); -} +#ifdef __cplusplus +extern "C" { #endif -#ifndef INFINITY -#define INFINITY (DBL_MAX + DBL_MAX) -#endif -#ifndef NAN -#define NAN (INFINITY - INFINITY) +#ifndef M_SQRT2 +#define M_SQRT2 1.41421356237309504880 #endif -#endif /* _MSC_VER */ - - -#if __STDC_VERSION__ < 199901L && (!defined(__cplusplus) || defined(_MSC_VER)) -static INLINE long int -lrint(double d) -{ - long int rounded = (long int)(d + 0.5); - - if (d - floor(d) == 0.5) { - if (rounded % 2 != 0) - rounded += (d > 0) ? -1 : 1; - } - - return rounded; -} - -static INLINE long int -lrintf(float f) -{ - long int rounded = (long int)(f + 0.5f); - - if (f - floorf(f) == 0.5f) { - if (rounded % 2 != 0) - rounded += (f > 0) ? -1 : 1; - } - - return rounded; -} - -static INLINE long long int -llrint(double d) -{ - long long int rounded = (long long int)(d + 0.5); - - if (d - floor(d) == 0.5) { - if (rounded % 2 != 0) - rounded += (d > 0) ? -1 : 1; - } - - return rounded; -} - -static INLINE long long int -llrintf(float f) -{ - long long int rounded = (long long int)(f + 0.5f); - - if (f - floorf(f) == 0.5f) { - if (rounded % 2 != 0) - rounded += (f > 0) ? -1 : 1; - } - - return rounded; -} -#endif /* C99 */ - #define POW2_TABLE_SIZE_LOG2 9 #define POW2_TABLE_SIZE (1 << POW2_TABLE_SIZE_LOG2) #define POW2_TABLE_OFFSET (POW2_TABLE_SIZE/2) @@ -499,7 +355,7 @@ util_half_inf_sign(int16_t x) #ifndef FFS_DEFINED #define FFS_DEFINED 1 -#if defined(_MSC_VER) && _MSC_VER >= 1300 && (_M_IX86 || _M_AMD64 || _M_IA64) +#if defined(_MSC_VER) && (_M_IX86 || _M_AMD64 || _M_IA64) unsigned char _BitScanForward(unsigned long* Index, unsigned long Mask); #pragma intrinsic(_BitScanForward) static INLINE @@ -541,7 +397,7 @@ unsigned ffs( unsigned u ) static INLINE unsigned util_last_bit(unsigned u) { -#if defined(__GNUC__) +#if defined(HAVE___BUILTIN_CLZ) return u == 0 ? 0 : 32 - __builtin_clz(u); #else unsigned r = 0; @@ -663,7 +519,7 @@ float_to_byte_tex(float f) static INLINE unsigned util_logbase2(unsigned n) { -#if defined(PIPE_CC_GCC) +#if defined(HAVE___BUILTIN_CLZ) return ((sizeof(unsigned) * 8 - 1) - __builtin_clz(n | 1)); #else unsigned pos = 0; @@ -683,7 +539,7 @@ util_logbase2(unsigned n) static INLINE unsigned util_next_power_of_two(unsigned x) { -#if defined(PIPE_CC_GCC) +#if defined(HAVE___BUILTIN_CLZ) if (x <= 1) return 1; @@ -715,7 +571,7 @@ util_next_power_of_two(unsigned x) static INLINE unsigned util_bitcount(unsigned n) { -#if defined(PIPE_CC_GCC) +#if defined(HAVE___BUILTIN_POPCOUNT) return __builtin_popcount(n); #else /* K&R classic bitcount. @@ -724,8 +580,8 @@ util_bitcount(unsigned n) * Requires only one iteration per set bit, instead of * one iteration per bit less than highest set bit. */ - unsigned bits = 0; - for (bits; n; bits++) { + unsigned bits; + for (bits = 0; n; bits++) { n &= n - 1; } return bits; @@ -784,8 +640,7 @@ util_bitreverse(unsigned n) static INLINE uint32_t util_bswap32(uint32_t n) { -/* We need the gcc version checks for non-autoconf build system */ -#if defined(HAVE___BUILTIN_BSWAP32) || (defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 403)) +#if defined(HAVE___BUILTIN_BSWAP32) return __builtin_bswap32(n); #else return (n >> 24) | diff --git a/mesalib/src/gallium/auxiliary/util/u_sse.h b/mesalib/src/gallium/auxiliary/util/u_sse.h index 642f96eb7..d4f51912a 100644 --- a/mesalib/src/gallium/auxiliary/util/u_sse.h +++ b/mesalib/src/gallium/auxiliary/util/u_sse.h @@ -44,33 +44,6 @@ #include <emmintrin.h> -/* MSVC before VC8 does not support the _mm_castxxx_yyy */ -#if defined(_MSC_VER) && _MSC_VER < 1500 - -union __declspec(align(16)) m128_types { - __m128 m128; - __m128i m128i; - __m128d m128d; -}; - -static __inline __m128 -_mm_castsi128_ps(__m128i a) -{ - union m128_types u; - u.m128i = a; - return u.m128; -} - -static __inline __m128i -_mm_castps_si128(__m128 a) -{ - union m128_types u; - u.m128 = a; - return u.m128i; -} - -#endif /* defined(_MSC_VER) && _MSC_VER < 1500 */ - union m128i { __m128i m; ubyte ub[16]; |