mesa: use ffma_weak

Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41165>
This commit is contained in:
Karol Herbst 2026-04-23 16:49:22 +02:00 committed by Marge Bot
parent e1aaaf4ed0
commit f3e8a5adda
7 changed files with 37 additions and 37 deletions

View file

@ -590,7 +590,7 @@ emit_combine(struct texenv_fragment_program *p,
return nir_fdot3(p->b, smear(p->b, tmp0), smear(p->b, tmp1));
case TEXENV_MODE_MODULATE_ADD_ATI:
return nir_fmad_old(p->b, src[0], src[2], src[1]);
return nir_ffma_weak(p->b, src[0], src[2], src[1]);
case TEXENV_MODE_MODULATE_SIGNED_ADD_ATI:
return nir_fadd_imm(p->b,

View file

@ -418,9 +418,9 @@ emit_transpose_matrix_transform_vec4(nir_builder *b,
{
nir_def *result;
result = nir_fmul(b, nir_channel(b, src, 0), mat[0]);
result = nir_fmad_old(b, nir_channel(b, src, 1), mat[1], result);
result = nir_fmad_old(b, nir_channel(b, src, 2), mat[2], result);
result = nir_fmad_old(b, nir_channel(b, src, 3), mat[3], result);
result = nir_ffma_weak(b, nir_channel(b, src, 1), mat[1], result);
result = nir_ffma_weak(b, nir_channel(b, src, 2), mat[2], result);
result = nir_ffma_weak(b, nir_channel(b, src, 3), mat[3], result);
return result;
}
@ -603,10 +603,10 @@ get_scenecolor(struct tnl_program *p, GLuint side)
// rgb: material_emission + material_ambient * lm_ambient
// alpha: material_diffuse.a
return nir_vector_insert_imm(p->b, nir_fmad_old(p->b,
lm_ambient,
material_ambient,
material_emission),
return nir_vector_insert_imm(p->b, nir_ffma_weak(p->b,
lm_ambient,
material_ambient,
material_emission),
nir_channel(p->b,
material_diffuse,
3),
@ -956,7 +956,7 @@ static void build_lighting( struct tnl_program *p )
/* light is attenuated by distance */
lit = emit_lit(p->b, dots);
lit = nir_fmul(p->b, lit, att);
_col0 = nir_fmad_old(p->b, nir_channel(p->b, lit, 0), ambient, _col0);
_col0 = nir_ffma_weak(p->b, nir_channel(p->b, lit, 0), ambient, _col0);
} else if (!p->state->material_shininess_is_zero) {
/* there's a non-zero specular term */
lit = emit_lit(p->b, dots);
@ -967,14 +967,14 @@ static void build_lighting( struct tnl_program *p )
_col0 = nir_fadd(p->b, ambient, _col0);
}
_col0 = nir_fmad_old(p->b, nir_channel(p->b, lit, 1),
diffuse, _col0);
_col0 = nir_ffma_weak(p->b, nir_channel(p->b, lit, 1),
diffuse, _col0);
if (separate)
_col1 = nir_fmad_old(p->b, nir_channel(p->b, lit, 2),
specular, _col1);
_col1 = nir_ffma_weak(p->b, nir_channel(p->b, lit, 2),
specular, _col1);
else
_col0 = nir_fmad_old(p->b, nir_channel(p->b, lit, 2),
specular, _col0);
_col0 = nir_ffma_weak(p->b, nir_channel(p->b, lit, 2),
specular, _col0);
}
/* Back face lighting:
*/
@ -1009,7 +1009,7 @@ static void build_lighting( struct tnl_program *p )
/* light is attenuated by distance */
lit = emit_lit(p->b, dots);
lit = nir_fmul(p->b, lit, att);
_bfc0 = nir_fmad_old(p->b, nir_channel(p->b, lit, 0), ambient, _bfc0);
_bfc0 = nir_ffma_weak(p->b, nir_channel(p->b, lit, 0), ambient, _bfc0);
} else if (!p->state->material_shininess_is_zero) {
/* there's a non-zero specular term */
lit = emit_lit(p->b, dots);
@ -1020,14 +1020,14 @@ static void build_lighting( struct tnl_program *p )
_bfc0 = nir_fadd(p->b, ambient, _bfc0);
}
_bfc0 = nir_fmad_old(p->b, nir_channel(p->b, lit, 1),
diffuse, _bfc0);
_bfc0 = nir_ffma_weak(p->b, nir_channel(p->b, lit, 1),
diffuse, _bfc0);
if (separate)
_bfc1 = nir_fmad_old(p->b, nir_channel(p->b, lit, 2),
specular, _bfc1);
_bfc1 = nir_ffma_weak(p->b, nir_channel(p->b, lit, 2),
specular, _bfc1);
else
_bfc0 = nir_fmad_old(p->b, nir_channel(p->b, lit, 2),
specular, _bfc0);
_bfc0 = nir_ffma_weak(p->b, nir_channel(p->b, lit, 2),
specular, _bfc0);
}
}
}
@ -1080,7 +1080,7 @@ build_reflect_texgen(struct tnl_program *p)
/* 2n.u */
tmp = nir_fadd(p->b, tmp, tmp);
/* (-2n.u)n + u */
return nir_fmad_old(p->b, nir_fneg(p->b, tmp), normal, eye_hat);
return nir_ffma_weak(p->b, nir_fneg(p->b, tmp), normal, eye_hat);
}
@ -1103,7 +1103,7 @@ build_sphere_texgen(struct tnl_program *p)
/* 2n.u */
tmp = nir_fadd(p->b, tmp, tmp);
/* (-2n.u)n + u */
nir_def *r = nir_fmad_old(p->b, nir_fneg(p->b, tmp), normal, eye_hat);
nir_def *r = nir_ffma_weak(p->b, nir_fneg(p->b, tmp), normal, eye_hat);
/* r + 0,0,1 */
tmp = nir_fadd(p->b, r, nir_imm_vec4(p->b, 0.0f, 0.0f, 1.0f, 0.0f));
/* rx^2 + ry^2 + (rz+1)^2 */
@ -1113,7 +1113,7 @@ build_sphere_texgen(struct tnl_program *p)
/* 1/m */
nir_def *inv_m = nir_fmul_imm(p->b, tmp, 0.5f);
/* r/m + 1/2 */
return nir_fmad_old(p->b, r, inv_m, nir_imm_float(p->b, 0.5f));
return nir_ffma_weak(p->b, r, inv_m, nir_imm_float(p->b, 0.5f));
}
static void build_texture_transform( struct tnl_program *p )
@ -1235,9 +1235,9 @@ static void build_atten_pointsize( struct tnl_program *p )
nir_def *dist = nir_fabs(p->b, eye);
/* p1 + dist * (p2 + dist * p3); */
nir_def *factor = nir_fmad_old(p->b, dist, nir_channel(p->b, att, 2),
nir_channel(p->b, att, 1));
factor = nir_fmad_old(p->b, dist, factor, nir_channel(p->b, att, 0));
nir_def *factor = nir_ffma_weak(p->b, dist, nir_channel(p->b, att, 2),
nir_channel(p->b, att, 1));
factor = nir_ffma_weak(p->b, dist, factor, nir_channel(p->b, att, 0));
/* 1 / sqrt(factor) */
factor = nir_frsq(p->b, factor);

View file

@ -231,7 +231,7 @@ emit_arith_inst(struct st_translate *t,
return nir_fmul(t->b, src[0], src[1]);
case GL_MAD_ATI:
return nir_ffma_old(t->b, src[0], src[1], src[2]);
return nir_ffma_weak(t->b, src[0], src[1], src[2]);
case GL_LERP_ATI:
return nir_flrp(t->b, src[2], src[1], src[0]);

View file

@ -186,7 +186,7 @@ get_intersection(nir_builder *b, nir_def *v1, nir_def *v2,
nir_def *d1, nir_def *d2)
{
nir_def *factor = nir_fdiv(b, d1, nir_fsub(b, d1, d2));
return nir_fmad_old(b, nir_fsub(b, v2, v1), factor, v1);
return nir_ffma_weak(b, nir_fsub(b, v2, v1), factor, v1);
}
#define begin_for_loop(name, max) \
@ -382,7 +382,7 @@ get_window_space_depth(nir_builder *b, nir_def *v, nir_def **trans)
nir_def *d = nir_bcsel(b, c, nir_imm_float(b, -1), nir_fdiv(b, z, w));
/* map [-1, 1] to [near, far] set by glDepthRange(near, far) */
return nir_fmad_old(b, trans[0], d, trans[1]);
return nir_ffma_weak(b, trans[0], d, trans[1]);
}
static void

View file

@ -114,7 +114,7 @@ lower_color(nir_builder *b, lower_drawpixels_state *state, nir_intrinsic_instr *
/* Apply the scale and bias. */
if (state->options->scale_and_bias) {
/* MAD def, def, scale, bias; */
def = nir_ffma_old(b, def, get_scale(b, state), get_bias(b, state));
def = nir_ffma_weak(b, def, get_scale(b, state), get_bias(b, state));
}
if (state->options->pixel_maps) {

View file

@ -41,9 +41,9 @@ fog_result(nir_builder *b, nir_def *color, enum gl_fog_mode fog_mode,
* gl_MesaFogParamsOptimized gives us (-1 / (end - start)) and
* (end / (end - start)) so we can generate a single MAD.
*/
f = nir_fmad_old(b, fogc,
nir_channel(b, params, 0),
nir_channel(b, params, 1));
f = nir_ffma_weak(b, fogc,
nir_channel(b, params, 0),
nir_channel(b, params, 1));
break;
case FOG_EXP:
/* f = e^(-(density * fogcoord))
@ -74,7 +74,7 @@ fog_result(nir_builder *b, nir_def *color, enum gl_fog_mode fog_mode,
/* Not using flrp because we may end up lowering fog after driver lowering
* that meant to remove all lrps.
*/
return nir_fmad_old(b, color, f, nir_fmul(b, fog_color, nir_fsub_imm(b, 1.0, f)));
return nir_ffma_weak(b, color, f, nir_fmul(b, fog_color, nir_fsub_imm(b, 1.0, f)));
}
struct lower_fog_state {

View file

@ -41,7 +41,7 @@ st_nir_lower_position_invariant(struct nir_shader *s,
result = nir_fmul(&b, mvp[0], nir_channel(&b, in_pos, 0));
for (int i = 1; i < 4; i++)
result = nir_fmad_old(&b, mvp[i], nir_channel(&b, in_pos, i), result);
result = nir_ffma_weak(&b, mvp[i], nir_channel(&b, in_pos, i), result);
nir_store_output(&b, result, nir_imm_int(&b, 0),
.io_semantics.location = VARYING_SLOT_POS);