mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
mesa: Simplify ptn_log() a bit
Using fdiv lets us drop the fneg. nir_opt_algebraic will re-optimize this if the driver implements fdiv using fmul and frcp. Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23089>
This commit is contained in:
parent
2198eedd04
commit
5b835f1a08
1 changed files with 2 additions and 3 deletions
|
|
@ -308,7 +308,7 @@ ptn_exp(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src)
|
|||
|
||||
/* LOG - Approximate Logarithm Base 2
|
||||
* dst.x = \lfloor\log_2{|src.x|}\rfloor
|
||||
* dst.y = |src.x| * 2^{-\lfloor\log_2{|src.x|}\rfloor}}
|
||||
* dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}}
|
||||
* dst.z = \log_2{|src.x|}
|
||||
* dst.w = 1.0
|
||||
*/
|
||||
|
|
@ -321,8 +321,7 @@ ptn_log(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src)
|
|||
|
||||
ptn_move_dest_masked(b, dest, floor_log2, WRITEMASK_X);
|
||||
ptn_move_dest_masked(b, dest,
|
||||
nir_fmul(b, abs_srcx,
|
||||
nir_fexp2(b, nir_fneg(b, floor_log2))),
|
||||
nir_fdiv(b, abs_srcx, nir_fexp2(b, floor_log2)),
|
||||
WRITEMASK_Y);
|
||||
ptn_move_dest_masked(b, dest, log2, WRITEMASK_Z);
|
||||
ptn_move_dest_masked(b, dest, nir_imm_float(b, 1.0), WRITEMASK_W);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue