[Mesa-dev] [PATCH v2 10/20] i965/cs: Add generator support for CS_OPCODE_CS_TERMINATE
Kenneth Graunke
kenneth at whitecape.org
Mon Apr 27 15:15:57 PDT 2015
On Friday, April 24, 2015 04:33:02 PM Jordan Justen wrote:
> v2:
> * Don't rely on brw_eu* to generate the send instruction. We now
> generate the send here, and drop the "i965/cs: Add support for the
> SEND message that terminates a CS thread" brw_eu* patch.
>
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> ---
> src/mesa/drivers/dri/i965/brw_fs.h | 1 +
> src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 35 ++++++++++++++++++++++++++
> 2 files changed, 36 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
> index b1e65cd..8a71ac7 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.h
> +++ b/src/mesa/drivers/dri/i965/brw_fs.h
> @@ -556,6 +556,7 @@ private:
> GLuint nr);
> void generate_fb_write(fs_inst *inst, struct brw_reg payload);
> void generate_urb_write(fs_inst *inst, struct brw_reg payload);
> + void generate_cs_terminate(fs_inst *inst, struct brw_reg payload);
> void generate_blorp_fb_write(fs_inst *inst);
> void generate_linterp(fs_inst *inst, struct brw_reg dst,
> struct brw_reg *src);
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
> index b88dc8e..114f938 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
> @@ -370,6 +370,37 @@ fs_generator::generate_urb_write(fs_inst *inst, struct brw_reg payload)
> }
>
> void
> +fs_generator::generate_cs_terminate(fs_inst *inst, struct brw_reg payload)
> +{
> + struct brw_inst *insn;
> +
> + insn = brw_next_insn(p, BRW_OPCODE_SEND);
> +
> + brw_set_dest(p, insn, brw_null_reg());
> + brw_set_src0(p, insn, payload);
> + brw_set_src1(p, insn, brw_imm_d(0));
> +
> + /* Terminate a compute shader by sending a message to the thread spawner.
> + */
> + brw_inst_set_sfid(devinfo, insn, BRW_SFID_THREAD_SPAWNER);
> + brw_inst_set_mlen(devinfo, insn, 1);
> + brw_inst_set_rlen(devinfo, insn, 0);
> + brw_inst_set_eot(devinfo, insn, inst->eot);
> + brw_inst_set_header_present(devinfo, insn, false);
> +
> + brw_inst_set_ts_opcode(devinfo, insn, 0); /* Dereference resource */
> + brw_inst_set_ts_request_type(devinfo, insn, 0); /* Root thread */
> +
> + /* 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_inst_set_ts_resource_select(devinfo, insn, 1); /* Do not dereference URB */
> +
> + brw_inst_set_mask_control(devinfo, insn, BRW_MASK_DISABLE);
> +}
> +
> +void
> fs_generator::generate_blorp_fb_write(fs_inst *inst)
> {
> brw_fb_WRITE(p,
> @@ -2073,6 +2104,10 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width)
> GEN7_PIXEL_INTERPOLATOR_LOC_PER_SLOT_OFFSET);
> break;
>
> + case CS_OPCODE_CS_TERMINATE:
> + generate_cs_terminate(inst, src[0]);
> + break;
> +
Weird whitespace here.
I don't know how the media pipeline works, particularly, so I'm just
assuming that root threads are correct, and your URB management choices
are correct. You've looked into it a lot so I trust you on that :)
I did verify that "header present" MBZ for all thread spawner messages,
and g0 is just considered to be the message payload. (It looked a bit
funky at first, but makes sense I guess...)
The code looks reasonable, so
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
> default:
> unreachable("Unsupported opcode");
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150427/15f9e255/attachment.sig>
More information about the mesa-dev
mailing list