[Mesa-dev] [PATCH 5/9] i965/nir: Emit MUL + ADD for MAD on GEN <= 5

Jason Ekstrand jason at jlekstrand.net
Wed Mar 18 21:31:45 PDT 2015


On Wed, Mar 18, 2015 at 8:43 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> On Wednesday, March 18, 2015 11:27:19 PM Connor Abbott wrote:
>> On Wed, Mar 18, 2015 at 11:24 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
>> > On Tuesday, March 17, 2015 07:17:19 PM Jason Ekstrand wrote:
>> >> ---
>> >>  src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 8 +++++++-
>> >>  1 file changed, 7 insertions(+), 1 deletion(-)
>> >>
>> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> >> index 5da8423..41f9ae2 100644
>> >> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> >> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> >> @@ -1234,7 +1234,13 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr)
>> >>        break;
>> >>
>> >>     case nir_op_ffma:
>> >> -      inst = emit(MAD(result, op[2], op[1], op[0]));
>> >> +      if (brw->gen >= 6) {
>> >> +         inst = emit(MAD(result, op[2], op[1], op[0]));
>> >> +      } else {
>> >> +         fs_reg temp = vgrf(glsl_type::float_type);
>> >> +         emit(MUL(temp, op[0], op[1]));
>> >> +         inst = emit(ADD(result, temp, op[2]));
>> >> +      }
>> >>        inst->saturate = instr->dest.saturate;
>> >>        break;
>> >>
>> >>
>> >
>> > I think this is a reasonable plan for now - it's simple and works.
>> > Connor is probably right that we can do better with nir_opt_algebraic,
>> > but I think doing that as a follow-on patch justified by statistics
>> > would be wise.
>>
>> Actually, it seems like we already have a lower_ffma option, so just
>> setting that to true on gen < 6 should be even less code than this...
>
> You make a good point.  Let's do that.

Yeah, I'm ok with that.


More information about the mesa-dev mailing list