[Mesa-dev] [PATCH 06/18] i965/cs: Add support for the SEND message that terminates a CS thread.
Jordan Justen
jordan.l.justen at intel.com
Tue Apr 14 11:35:29 PDT 2015
On 2015-04-13 23:41:15, Matt Turner wrote:
> On Sat, Mar 14, 2015 at 9:54 PM, Jordan Justen
> <jordan.l.justen at intel.com> wrote:
> > From: Paul Berry <stereotype441 at gmail.com>
> >
> > This message must be sent to the "thread spawner" unit.
> >
> > Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
> > ---
> > src/mesa/drivers/dri/i965/brw_eu.h | 4 +++
> > src/mesa/drivers/dri/i965/brw_eu_emit.c | 46 +++++++++++++++++++++++++++++++++
> > 2 files changed, 50 insertions(+)
> >
> > diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
> > index d9ad5bd..708c216 100644
> > --- a/src/mesa/drivers/dri/i965/brw_eu.h
> > +++ b/src/mesa/drivers/dri/i965/brw_eu.h
> > @@ -349,6 +349,10 @@ brw_jump_scale(const struct brw_context *brw)
> > return 1;
> > }
> >
> > +void brw_cs_terminate(struct brw_compile *p,
> > + unsigned msg_reg_nr,
> > + struct brw_reg src0);
> > +
> > /* If/else/endif. Works by manipulating the execution flags on each
> > * channel.
> > */
> > diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c
> > index 43e5783..9c166a3 100644
> > --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
> > +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
> > @@ -2895,3 +2895,49 @@ void brw_shader_time_add(struct brw_compile *p,
> > 0 /* response length */,
> > false /* header present */);
> > }
> > +
> > +
> > +static void
> > +brw_set_cs_terminate_message(struct brw_context *brw,
> > + struct brw_compile *p,
> > + struct brw_inst *insn)
> > +{
> > + /* Terminate a compute shader by sending a message to the thread spawner.
> > + * Note that even though the thread has a URB resource associated with it,
> > + * we set the "do not dereference URB" bit, because the URB resource is
> > + * managed by the fixed-function unit, so it will free it automatically.
> > + */
> > + brw_set_message_descriptor(p, insn, BRW_SFID_THREAD_SPAWNER,
> > + 1 /* msg_length */,
> > + 0 /* response_length */,
> > + false /* header_present */,
> > + true /* end_of_thread */);
> > + brw_inst_set_ts_opcode(brw, insn, 0); /* Dereference resource */
> > + brw_inst_set_ts_request_type(brw, insn, 0); /* Root thread */
> > + brw_inst_set_ts_resource_select(brw, insn, 1); /* Do not dereference URB */
> > +}
> > +
> > +
> > +/**
> > + * Emit the SEND message to terminate a compute shader.
> > + */
> > +void
> > +brw_cs_terminate(struct brw_compile *p,
> > + unsigned msg_reg_nr,
> > + struct brw_reg src0)
> > +{
> > + struct brw_context *brw = p->brw;
> > + struct brw_inst *insn;
> > +
> > + gen6_resolve_implied_move(p, &src0, msg_reg_nr);
> > + insn = next_insn(p, BRW_OPCODE_SEND);
> > + brw_set_dest(p, insn, brw_null_reg());
> > + brw_set_src0(p, insn, src0);
> > + brw_set_src1(p, insn, brw_imm_d(0));
> > +
> > + if (brw->gen < 6)
> > + brw_inst_set_cond_modifier(brw, insn, msg_reg_nr);
>
> Presumably gen <= 6 can't do compute shaders, so what's going on here
> and in the call to gen6_resolve_implied_move above?
Ken mentioned that I needed to drop the "i965/fs: Don't assign high
regs for CS termination send" patch. This caused me to rework these
patches a bit. In the end, I dropped this patch, and moved this code
to be in the visitor & generator:
http://cgit.freedesktop.org/~jljusten/mesa/commit/?h=cs-27&id=fc0ccf68
http://cgit.freedesktop.org/~jljusten/mesa/commit/?h=cs-27&id=d12ec0e8
Does this look better?
-Jordan
> > +
> > + brw_set_cs_terminate_message(brw, p, insn);
> > + brw_inst_set_mask_control(brw, insn, BRW_MASK_DISABLE);
> > +}
> > --
> > 2.1.4
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list