mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 22:00:13 +01:00
Add sqrt() builtin as an IR operation.
Following a discussion in #dri-devel, I think this makes more sense than implementing it as RSQ RCP CMP as Mesa did. The i965 has a hardware sqrt that should work, and AMD is suppposed to be able to implement it as RSQ RCP with an alternate floating point mode so that the 0.0 case is handled like we want.
This commit is contained in:
parent
ddd2e83db2
commit
44d68fd06f
3 changed files with 11 additions and 1 deletions
|
|
@ -84,6 +84,14 @@ generate_rsq(exec_list *instructions,
|
||||||
generate_unop(instructions, declarations, type, ir_unop_rsq);
|
generate_unop(instructions, declarations, type, ir_unop_rsq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
generate_sqrt(exec_list *instructions,
|
||||||
|
ir_variable **declarations,
|
||||||
|
const glsl_type *type)
|
||||||
|
{
|
||||||
|
generate_unop(instructions, declarations, type, ir_unop_sqrt);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
generate_abs(exec_list *instructions,
|
generate_abs(exec_list *instructions,
|
||||||
ir_variable **declarations,
|
ir_variable **declarations,
|
||||||
|
|
@ -227,7 +235,7 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions)
|
||||||
make_gentype_function(symtab, instructions, "log", 1, generate_log);
|
make_gentype_function(symtab, instructions, "log", 1, generate_log);
|
||||||
/* FINISHME: exp2() */
|
/* FINISHME: exp2() */
|
||||||
/* FINISHME: log2() */
|
/* FINISHME: log2() */
|
||||||
/* FINISHME: sqrt() */
|
make_gentype_function(symtab, instructions, "sqrt", 1, generate_sqrt);
|
||||||
make_gentype_function(symtab, instructions, "inversesqrt", 1, generate_rsq);
|
make_gentype_function(symtab, instructions, "inversesqrt", 1, generate_rsq);
|
||||||
make_gentype_function(symtab, instructions, "abs", 1, generate_abs);
|
make_gentype_function(symtab, instructions, "abs", 1, generate_abs);
|
||||||
/* FINISHME: sign() */
|
/* FINISHME: sign() */
|
||||||
|
|
|
||||||
1
ir.h
1
ir.h
|
|
@ -225,6 +225,7 @@ enum ir_expression_operation {
|
||||||
ir_unop_abs,
|
ir_unop_abs,
|
||||||
ir_unop_rcp,
|
ir_unop_rcp,
|
||||||
ir_unop_rsq,
|
ir_unop_rsq,
|
||||||
|
ir_unop_sqrt,
|
||||||
ir_unop_exp,
|
ir_unop_exp,
|
||||||
ir_unop_log,
|
ir_unop_log,
|
||||||
ir_unop_f2i, /**< Float-to-integer conversion. */
|
ir_unop_f2i, /**< Float-to-integer conversion. */
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ void ir_print_visitor::visit(ir_expression *ir)
|
||||||
"abs",
|
"abs",
|
||||||
"rcp",
|
"rcp",
|
||||||
"rsq",
|
"rsq",
|
||||||
|
"sqrt",
|
||||||
"exp",
|
"exp",
|
||||||
"log",
|
"log",
|
||||||
"f2i",
|
"f2i",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue