Commit 1aac47db authored by Matt Turner's avatar Matt Turner Committed by Marge Bot

Revert F16C series (MR 6774)

This reverts commit 4fb2eddf.
This reverts commit 7a1deb16.
This reverts commit 2b6a1723.
This reverts commit 5af81393.
This reverts commit 87900afe.

A couple of problems were discovered after this series was merged that
cause breakage in different configurations:

   (1) It seems that using -mf16c also enables AVX, leading to SIGILL on
   platforms that do not support AVX.
   (2) Since clang only warns about unknown flags, and as I understand
   it Meson's handling in cc.has_argument() is broken, the F16C code is
   wrongly enabled when clang is used, even for example on ARM, leading
   to a compilation error.

Closes: #3583Reviewed-by: Eric Anholt's avatarEric Anholt <eric@anholt.net>
Reviewed-by: Rob Clark's avatarRob Clark <robdclark@chromium.org>
Part-of: <!6969>
parent 4a0164ed
Pipeline #208610 passed with stages
in 26 minutes and 16 seconds
......@@ -738,6 +738,7 @@ spec/arb_sparse_buffer/commit: skip
spec/arb_sparse_buffer/minmax: skip
spec/arb_tessellation_shader/arb_tessellation_shader-immediate-mode-draw-patches: skip
spec/arb_texture_buffer_object/negative-unsupported: skip
spec/arb_texture_compression_bptc/bptc-float-modes: fail
spec/arb_texture_cube_map/copyteximage cube samples=16: skip
spec/arb_texture_cube_map/copyteximage cube samples=2: skip
spec/arb_texture_cube_map/copyteximage cube samples=32: skip
......@@ -1655,8 +1656,8 @@ wgl/wgl-sanity: skip
summary:
name: results
---- --------
pass: 23075
fail: 197
pass: 23074
fail: 198
crash: 0
skip: 1433
timeout: 0
......
......@@ -1111,19 +1111,6 @@ else
sse41_args = []
endif
if cc.has_argument('-mf16c') and cpp.has_argument('-mf16c')
pre_args += '-DUSE_F16C'
c_args += '-mf16c'
cpp_args += '-mf16c'
# GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but
# that's not guaranteed (not sure if this also applies to -mf16c)
if host_machine.cpu_family() == 'x86'
c_args += '-mstackrealign'
cpp_args += '-mstackrealign'
endif
endif
# Check for GCC style atomics
dep_atomic = null_dep
......
......@@ -29,7 +29,7 @@
#include "vk_util.h"
#include "util/half_float.h"
#include "util/u_half.h"
#include "util/format_srgb.h"
#include "util/format_r11g11b10f.h"
#include "util/format_rgb9e5.h"
......@@ -1079,7 +1079,7 @@ bool radv_format_pack_clear_color(VkFormat format,
if (channel->size == 32) {
memcpy(&v, &value->float32[c], 4);
} else if(channel->size == 16) {
v = _mesa_float_to_float16_rtz(value->float32[c]);
v = util_float_to_half_rtz(value->float32[c]);
} else {
fprintf(stderr, "failed to fast clear for unhandled float size in format %d\n", format);
return false;
......
......@@ -24,8 +24,7 @@
#include "freedreno_layout.h"
#include "fd_layout_test.h"
#include "adreno_common.xml.h"
#include "util/half_float.h"
#include "util/u_math.h"
#include "util/u_half.h"
#include "a5xx.xml.h"
#include <stdio.h>
......
......@@ -25,8 +25,7 @@
* Rob Clark <robclark@freedesktop.org>
*/
#include "util/half_float.h"
#include "util/u_math.h"
#include "util/u_half.h"
#include "adreno_common.xml.h"
#include "adreno_pm4.xml.h"
#include "a2xx.xml.h"
......
......@@ -27,8 +27,7 @@
#ifndef FD5_PERFCNTR_H_
#define FD5_PERFCNTR_H_
#include "util/half_float.h"
#include "util/u_math.h"
#include "util/u_half.h"
#include "adreno_common.xml.h"
#include "a5xx.xml.h"
......
......@@ -27,8 +27,7 @@
#ifndef FD6_PERFCNTR_H_
#define FD6_PERFCNTR_H_
#include "util/half_float.h"
#include "util/u_math.h"
#include "util/u_half.h"
#include "adreno_common.xml.h"
#include "adreno_pm4.xml.h"
#include "a6xx.xml.h"
......
......@@ -27,8 +27,6 @@
#ifndef FREEDRENO_PERFCNTR_H_
#define FREEDRENO_PERFCNTR_H_
#include "util/macros.h"
/*
* Mapping very closely to the AMD_performance_monitor extension, adreno has
* groups of performance counters where each group has N counters, which can
......
......@@ -78,7 +78,7 @@ class Field(object):
val = "fui(%s)" % var_name
elif self.type == "float" and self.high - self.low == 15:
type = "float"
val = "_mesa_float_to_half(%s)" % var_name
val = "util_float_to_half(%s)" % var_name
elif self.type in [ "address", "waddress" ]:
type = "uint64_t"
val = var_name
......
......@@ -201,7 +201,7 @@ static void printtypeinfo (struct rnntypeinfo *ti, struct rnnbitfield *bf,
if (width == 32)
fprintf(dst, "fui(val)");
else if (width == 16)
fprintf(dst, "_mesa_float_to_half(val)");
fprintf(dst, "util_float_to_half(val)");
else
assert(!"invalid float size");
} else {
......
......@@ -14,7 +14,7 @@
#include "util/format_r11g11b10f.h"
#include "util/format_rgb9e5.h"
#include "util/format_srgb.h"
#include "util/half_float.h"
#include "util/u_half.h"
static uint32_t
tu_pack_float32_for_unorm(float val, int bits)
......@@ -122,7 +122,7 @@ r2d_clear_value(struct tu_cs *cs, VkFormat format, const VkClearValue *val)
else
clear_value[i] = tu_pack_float32_for_unorm(linear, 8);
} else if (ifmt == R2D_FLOAT16) {
clear_value[i] = _mesa_float_to_half(val->color.float32[i]);
clear_value[i] = util_float_to_half(val->color.float32[i]);
} else {
assert(ifmt == R2D_FLOAT32 || ifmt == R2D_INT32 ||
ifmt == R2D_INT16 || ifmt == R2D_INT8);
......
......@@ -248,6 +248,7 @@ C_SOURCES := \
util/u_framebuffer.h \
util/u_gen_mipmap.c \
util/u_gen_mipmap.h \
util/u_half.h \
util/u_handle_table.c \
util/u_handle_table.h \
util/u_hash_table.c \
......
......@@ -37,7 +37,7 @@
#include "util/u_debug.h"
#include "util/u_math.h"
#include "util/half_float.h"
#include "util/u_half.h"
#include "lp_bld_type.h"
#include "lp_bld_const.h"
......@@ -257,7 +257,7 @@ lp_build_one(struct gallivm_state *gallivm, struct lp_type type)
elem_type = lp_build_elem_type(gallivm, type);
if(type.floating && type.width == 16)
elems[0] = LLVMConstInt(elem_type, _mesa_float_to_half(1.0f), 0);
elems[0] = LLVMConstInt(elem_type, util_float_to_half(1.0f), 0);
else if(type.floating)
elems[0] = LLVMConstReal(elem_type, 1.0);
else if(type.fixed)
......@@ -304,7 +304,7 @@ lp_build_const_elem(struct gallivm_state *gallivm,
LLVMValueRef elem;
if(type.floating && type.width == 16) {
elem = LLVMConstInt(elem_type, _mesa_float_to_half((float)val), 0);
elem = LLVMConstInt(elem_type, util_float_to_half((float)val), 0);
} else if(type.floating) {
elem = LLVMConstReal(elem_type, val);
}
......
......@@ -63,7 +63,7 @@
#include "util/u_debug.h"
#include "util/u_math.h"
#include "util/half_float.h"
#include "util/u_half.h"
#include "util/u_cpu_detect.h"
#include "lp_bld_type.h"
......@@ -204,8 +204,8 @@ lp_build_float_to_half(struct gallivm_state *gallivm,
unsigned i;
LLVMTypeRef func_type = LLVMFunctionType(i16t, &f32t, 1, 0);
LLVMValueRef func = lp_build_const_int_pointer(gallivm, func_to_pointer((func_pointer)_mesa_float_to_half));
func = LLVMBuildBitCast(builder, func, LLVMPointerType(func_type, 0), "_mesa_float_to_half");
LLVMValueRef func = lp_build_const_int_pointer(gallivm, func_to_pointer((func_pointer)util_float_to_half));
func = LLVMBuildBitCast(builder, func, LLVMPointerType(func_type, 0), "util_float_to_half");
for (i = 0; i < length; ++i) {
LLVMValueRef index = LLVMConstInt(i32t, i, 0);
......
......@@ -264,6 +264,7 @@ files_libgallium = files(
'util/u_framebuffer.h',
'util/u_gen_mipmap.c',
'util/u_gen_mipmap.h',
'util/u_half.h',
'util/u_handle_table.c',
'util/u_handle_table.h',
'util/u_hash_table.c',
......
......@@ -58,7 +58,7 @@
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
#include "tgsi_exec.h"
#include "util/half_float.h"
#include "util/u_half.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#include "util/rounding.h"
......@@ -3325,8 +3325,8 @@ exec_pk2h(struct tgsi_exec_machine *mach,
fetch_source(mach, &arg[0], &inst->Src[0], TGSI_CHAN_X, TGSI_EXEC_DATA_FLOAT);
fetch_source(mach, &arg[1], &inst->Src[0], TGSI_CHAN_Y, TGSI_EXEC_DATA_FLOAT);
for (chan = 0; chan < TGSI_QUAD_SIZE; chan++) {
dst.u[chan] = _mesa_float_to_half(arg[0].f[chan]) |
(_mesa_float_to_half(arg[1].f[chan]) << 16);
dst.u[chan] = util_float_to_half(arg[0].f[chan]) |
(util_float_to_half(arg[1].f[chan]) << 16);
}
for (chan = 0; chan < TGSI_NUM_CHANNELS; chan++) {
if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
......@@ -3344,8 +3344,8 @@ exec_up2h(struct tgsi_exec_machine *mach,
fetch_source(mach, &arg, &inst->Src[0], TGSI_CHAN_X, TGSI_EXEC_DATA_UINT);
for (chan = 0; chan < TGSI_QUAD_SIZE; chan++) {
dst[0].f[chan] = _mesa_half_to_float(arg.u[chan] & 0xffff);
dst[1].f[chan] = _mesa_half_to_float(arg.u[chan] >> 16);
dst[0].f[chan] = util_half_to_float(arg.u[chan] & 0xffff);
dst[1].f[chan] = util_half_to_float(arg.u[chan] >> 16);
}
for (chan = 0; chan < TGSI_NUM_CHANNELS; chan++) {
if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
......
......@@ -32,7 +32,7 @@
#include "util/u_memory.h"
#include "util/format/u_format.h"
#include "util/half_float.h"
#include "util/u_half.h"
#include "util/u_math.h"
#include "pipe/p_state.h"
#include "translate.h"
......@@ -110,7 +110,7 @@ emit_##NAME(const void *attrib, void *ptr) \
#define TO_64_FLOAT(x) ((double) x)
#define TO_32_FLOAT(x) (x)
#define TO_16_FLOAT(x) _mesa_float_to_half(x)
#define TO_16_FLOAT(x) util_float_to_half(x)
#define TO_8_USCALED(x) ((unsigned char) x)
#define TO_16_USCALED(x) ((unsigned short) x)
......
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef U_HALF_H
#define U_HALF_H
#include "pipe/p_compiler.h"
#include "util/u_math.h"
#include "util/half_float.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* References for float <-> half conversions
*
* http://fgiesen.wordpress.com/2012/03/28/half-to-float-done-quic/
* https://gist.github.com/2156668
* https://gist.github.com/2144712
*/
static inline uint16_t
util_float_to_half(float f)
{
return _mesa_float_to_half(f);
}
static inline uint16_t
util_float_to_half_rtz(float f)
{
uint32_t sign_mask = 0x80000000;
uint32_t round_mask = ~0xfff;
uint32_t f32inf = 0xff << 23;
uint32_t f16inf = 0x1f << 23;
uint32_t sign;
union fi magic;
union fi f32;
uint16_t f16;
magic.ui = 0xf << 23;
f32.f = f;
/* Sign */
sign = f32.ui & sign_mask;
f32.ui ^= sign;
if (f32.ui == f32inf) {
/* Inf */
f16 = 0x7c00;
} else if (f32.ui > f32inf) {
/* NaN */
f16 = 0x7e00;
} else {
/* Number */
f32.ui &= round_mask;
f32.f *= magic.f;
f32.ui -= round_mask;
/*
* XXX: The magic mul relies on denorms being available, otherwise
* all f16 denorms get flushed to zero - hence when this is used
* for tgsi_exec in softpipe we won't get f16 denorms.
*/
/*
* Clamp to max finite value if overflowed.
* OpenGL has completely undefined rounding behavior for float to
* half-float conversions, and this matches what is mandated for float
* to fp11/fp10, which recommend round-to-nearest-finite too.
* (d3d10 is deeply unhappy about flushing such values to infinity, and
* while it also mandates round-to-zero it doesn't care nearly as much
* about that.)
*/
if (f32.ui > f16inf)
f32.ui = f16inf - 1;
f16 = f32.ui >> 13;
}
/* Sign */
f16 |= sign >> 16;
return f16;
}
static inline float
util_half_to_float(uint16_t f16)
{
union fi infnan;
union fi magic;
union fi f32;
infnan.ui = 0x8f << 23;
infnan.f = 65536.0f;
magic.ui = 0xef << 23;
/* Exponent / Mantissa */
f32.ui = (f16 & 0x7fff) << 13;
/* Adjust */
f32.f *= magic.f;
/* XXX: The magic mul relies on denorms being available */
/* Inf / NaN */
if (f32.f >= infnan.f)
f32.ui |= 0xff << 23;
/* Sign */
f32.ui |= (uint32_t)(f16 & 0x8000) << 16;
return f32.f;
}
#ifdef __cplusplus
}
#endif
#endif /* U_HALF_H */
......@@ -32,7 +32,7 @@
#include "hw/common.xml.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
#include "util/half_float.h"
#include "util/u_half.h"
void *
etna_blend_state_create(struct pipe_context *pctx,
......@@ -180,11 +180,11 @@ etna_update_blend_color(struct etna_context *ctx)
VIVS_PE_ALPHA_BLEND_COLOR_A(etna_cfloat_to_uint8(cs->color[3]));
cs->PE_ALPHA_COLOR_EXT0 =
VIVS_PE_ALPHA_COLOR_EXT0_B(_mesa_float_to_half(cs->color[rb_swap ? 2 : 0])) |
VIVS_PE_ALPHA_COLOR_EXT0_G(_mesa_float_to_half(cs->color[1]));
VIVS_PE_ALPHA_COLOR_EXT0_B(util_float_to_half(cs->color[rb_swap ? 2 : 0])) |
VIVS_PE_ALPHA_COLOR_EXT0_G(util_float_to_half(cs->color[1]));
cs->PE_ALPHA_COLOR_EXT1 =
VIVS_PE_ALPHA_COLOR_EXT1_R(_mesa_float_to_half(cs->color[rb_swap ? 0 : 2])) |
VIVS_PE_ALPHA_COLOR_EXT1_A(_mesa_float_to_half(cs->color[3]));
VIVS_PE_ALPHA_COLOR_EXT1_R(util_float_to_half(cs->color[rb_swap ? 0 : 2])) |
VIVS_PE_ALPHA_COLOR_EXT1_A(util_float_to_half(cs->color[3]));
return true;
}
......@@ -42,7 +42,7 @@
#include "compiler/nir/nir_builder.h"
#include "tgsi/tgsi_strings.h"
#include "util/half_float.h"
#include "util/u_half.h"
static bool
etna_alu_to_scalar_filter_cb(const nir_instr *instr, const void *data)
......
......@@ -34,7 +34,7 @@
#include "hw/isa.xml.h"
#include "util/u_math.h"
#include "util/half_float.h"
#include "util/u_half.h"
struct instr {
/* dword0: */
......@@ -379,7 +379,7 @@ print_src(struct etna_inst_src *src, bool sep)
printf("%d", src->imm_val);
break;
case 3: /* 16-bit */
printf("%f/%.5X", _mesa_half_to_float(src->imm_val), src->imm_val);
printf("%f/%.5X", util_half_to_float(src->imm_val), src->imm_val);
break;
}
} else {
......
......@@ -29,7 +29,7 @@
#include "etnaviv_context.h"
#include "etnaviv_screen.h"
#include "etnaviv_translate.h"
#include "util/half_float.h"
#include "util/u_half.h"
#include "util/u_memory.h"
#include "hw/common.xml.h"
......@@ -98,7 +98,7 @@ etna_zsa_state_create(struct pipe_context *pctx,
uint32_t extra_reference = 0;
if (VIV_FEATURE(screen, chipMinorFeatures1, HALF_FLOAT))
extra_reference = _mesa_float_to_half(SATURATE(so->alpha.ref_value));
extra_reference = util_float_to_half(SATURATE(so->alpha.ref_value));
cs->PE_STENCIL_CONFIG_EXT =
VIVS_PE_STENCIL_CONFIG_EXT_EXTRA_ALPHA_REF(extra_reference);
......
......@@ -276,8 +276,8 @@ setup_border_colors(struct fd_texture_stateobj *tex, struct bcolor_entry *entrie
float f_s = CLAMP(f, -1, 1);
e->fp32[c] = fui(f);
e->fp16[c] = _mesa_float_to_half(f);
e->srgb[c] = _mesa_float_to_half(f_u);
e->fp16[c] = util_float_to_half(f);
e->srgb[c] = util_float_to_half(f_u);
e->ui16[c] = f_u * 0xffff;
e->si16[c] = f_s * 0x7fff;
e->ui8[c] = f_u * 0xff;
......
......@@ -183,8 +183,8 @@ setup_border_colors(struct fd_texture_stateobj *tex, struct bcolor_entry *entrie
float f_s = CLAMP(f, -1, 1);
e->fp32[c] = fui(f);
e->fp16[c] = _mesa_float_to_half(f);
e->srgb[c] = _mesa_float_to_half(f_u);
e->fp16[c] = util_float_to_half(f);
e->srgb[c] = util_float_to_half(f_u);
e->ui16[c] = f_u * 0xffff;
e->si16[c] = f_s * 0x7fff;
e->ui8[c] = f_u * 0xff;
......
......@@ -167,7 +167,7 @@ fd_setup_border_colors(struct fd_texture_stateobj *tex, void *ptr,
} else {
bcolor32[desc->swizzle[j]] = fui(sampler->border_color.f[j]);
bcolor[desc->swizzle[j]] =
_mesa_float_to_half(sampler->border_color.f[j]);
util_float_to_half(sampler->border_color.f[j]);
}
}
}
......
......@@ -34,7 +34,7 @@
#include "pipe/p_state.h"
#include "util/u_debug.h"
#include "util/u_math.h"
#include "util/half_float.h"
#include "util/u_half.h"
#include "util/u_dynarray.h"
#include "util/u_pack_color.h"
......
......@@ -23,7 +23,7 @@
*/
#include "util/ralloc.h"
#include "util/half_float.h"
#include "util/u_half.h"
#include "util/bitscan.h"
#include "ppir.h"
......@@ -568,7 +568,7 @@ static void ppir_codegen_encode_store_temp(ppir_node *node, void *code)
static void ppir_codegen_encode_const(ppir_const *constant, uint16_t *code)
{
for (int i = 0; i < constant->num; i++)
code[i] = _mesa_float_to_half(constant->value[i].f);
code[i] = util_float_to_half(constant->value[i].f);
}
static void ppir_codegen_encode_discard(ppir_node *node, void *code)
......
......@@ -24,7 +24,7 @@
*
*/
#include "util/half_float.h"
#include "util/u_half.h"
#include "ppir.h"
#include "codegen.h"
......@@ -174,7 +174,7 @@ print_const(unsigned const_num, uint16_t *val)
{
printf("const%u", const_num);
for (unsigned i = 0; i < 4; i++)
printf(" %f", _mesa_half_to_float(val[i]));
printf(" %f", util_half_to_float(val[i]));
}
static void
......
......@@ -25,7 +25,7 @@
#include "util/format/u_format.h"
#include "util/u_debug.h"
#include "util/half_float.h"
#include "util/u_half.h"
#include "util/u_helpers.h"
#include "util/u_inlines.h"
#include "util/u_pack_color.h"
......@@ -898,7 +898,7 @@ lima_update_pp_uniform(struct lima_context *ctx)
lima_ctx_buff_alloc(ctx, lima_ctx_buff_pp_uniform_array, 4);
for (int i = 0; i < const_buff_size; i++)
fp16_const_buff[i] = _mesa_float_to_half(const_buff[i]);
fp16_const_buff[i] = util_float_to_half(const_buff[i]);
*array = lima_ctx_buff_va(ctx, lima_ctx_buff_pp_uniform);
......
......@@ -25,7 +25,7 @@
#include "util/format/u_format.h"
#include "util/u_math.h"
#include "util/half_float.h"
#include "util/u_half.h"
#include "nv_object.xml.h"
#include "nv30/nv30-40_3d.xml.h"
......@@ -182,11 +182,11 @@ nv30_validate_blend_colour(struct nv30_context *nv30)
case PIPE_FORMAT_R16G16B16A16_FLOAT:
case PIPE_FORMAT_R32G32B32A32_FLOAT:
BEGIN_NV04(push, NV30_3D(BLEND_COLOR), 1);
PUSH_DATA (push, (_mesa_float_to_half(rgba[0]) << 0) |
(_mesa_float_to_half(rgba[1]) << 16));
PUSH_DATA (push, (util_float_to_half(rgba[0]) << 0) |
(util_float_to_half(rgba[1]) << 16));
BEGIN_NV04(push, SUBC_3D(0x037c), 1);
PUSH_DATA (push, (_mesa_float_to_half(rgba[2]) << 0) |
(_mesa_float_to_half(rgba[3]) << 16));
PUSH_DATA (push, (util_float_to_half(rgba[2]) << 0) |
(util_float_to_half(rgba[3]) << 16));
break;
default:
break;
......
......@@ -26,7 +26,7 @@
#include "r300_reg.h"
#include "util/format/u_format.h"
#include "util/half_float.h"
#include "util/u_half.h"
#include "util/u_pack_color.h"
#include "util/u_surface.h"
......
......@@ -24,7 +24,7 @@
#include "draw/draw_context.h"
#include "util/u_framebuffer.h"
#include "util/half_float.h"
#include "util/u_half.h"