<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 22, 2017 at 12:57 PM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Mon, Nov 13, 2017 at 08:12:46AM -0800, Jason Ekstrand wrote:<br>
> ---<br>
> src/intel/blorp/blorp.c | 1 +<br>
> src/intel/blorp/blorp.h | 7 +++<br>
> src/intel/blorp/blorp_genX_<wbr>exec.h | 77 +++++++++++++++++++++++++++++<br>
> src/intel/blorp/blorp_priv.h | 1 +<br>
> src/intel/vulkan/genX_blorp_<wbr>exec.c | 10 ++++<br>
> src/mesa/drivers/dri/i965/<wbr>genX_blorp_exec.c | 13 +++++<br>
> 6 files changed, 109 insertions(+)<br>
><br>
> diff --git a/src/intel/blorp/blorp.c b/src/intel/blorp/blorp.c<br>
> index 5faba75..8a9d2fd 100644<br>
> --- a/src/intel/blorp/blorp.c<br>
> +++ b/src/intel/blorp/blorp.c<br>
> @@ -100,6 +100,7 @@ brw_blorp_surface_info_init(<wbr>struct blorp_context *blorp,<br>
> }<br>
><br>
> info->clear_color = surf->clear_color;<br>
> + info->clear_color_addr = surf->clear_color_addr;<br>
><br>
> info->view = (struct isl_view) {<br>
> .usage = is_render_target ? ISL_SURF_USAGE_RENDER_TARGET_<wbr>BIT :<br>
> diff --git a/src/intel/blorp/blorp.h b/src/intel/blorp/blorp.h<br>
> index 9716c66..c3077aa 100644<br>
> --- a/src/intel/blorp/blorp.h<br>
> +++ b/src/intel/blorp/blorp.h<br>
> @@ -106,6 +106,13 @@ struct blorp_surf<br>
> enum isl_aux_usage aux_usage;<br>
><br>
> union isl_color_value clear_color;<br>
> +<br>
> + /** If set (bo != NULL), clear_color is ignored and the actual clear color<br>
<br>
</div></div>The first line of the comment should be blank.<span class=""><br></span></blockquote><div><br></div><div>Sure<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> + * this is fetched from this address. On gen7-8, this is all of dword 7 of<br>
</span> ^<br>
Extra word.<br><div><div class="h5"></div></div></blockquote><div><br></div><div>Thanks.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
> + * RENDER_SURFACE_STATE and is the responsibility of the caller to ensure<br>
> + * that it contains a swizzle of RGBA and resource min LOD of 0.<br>
> + */<br>
> + struct blorp_address clear_color_addr;<br>
> };<br>
><br>
> void<br>
> diff --git a/src/intel/blorp/blorp_genX_<wbr>exec.h b/src/intel/blorp/blorp_genX_<wbr>exec.h<br>
> index 5389262..4f88650 100644<br>
> --- a/src/intel/blorp/blorp_genX_<wbr>exec.h<br>
> +++ b/src/intel/blorp/blorp_genX_<wbr>exec.h<br>
> @@ -78,6 +78,11 @@ static void<br>
> blorp_surface_reloc(struct blorp_batch *batch, uint32_t ss_offset,<br>
> struct blorp_address address, uint32_t delta);<br>
><br>
> +#if GEN_GEN >= 7<br>
> +static struct blorp_address<br>
> +blorp_get_surface_base_<wbr>address(struct blorp_batch *batch);<br>
> +#endif<br>
> +<br>
> static void<br>
> blorp_emit_urb_config(struct blorp_batch *batch,<br>
> unsigned vs_entry_size, unsigned sf_entry_size);<br>
> @@ -1202,6 +1207,42 @@ blorp_emit_pipeline(struct blorp_batch *batch,<br>
><br>
> #endif /* GEN_GEN >= 6 */<br>
><br>
> +#if GEN_GEN >= 7 && GEN_GEN <= 10<br>
> +static void<br>
> +blorp_emit_memcpy(struct blorp_batch *batch,<br>
> + struct blorp_address dst,<br>
> + struct blorp_address src,<br>
> + uint32_t size)<br>
> +{<br>
> + assert(size % 4 == 0);<br>
> +<br>
> + for (unsigned dw = 0; dw < size; dw += 4) {<br>
> +#if GEN_GEN >= 8<br>
> + blorp_emit(batch, GENX(MI_COPY_MEM_MEM), cp) {<br>
> + cp.DestinationMemoryAddress = dst;<br>
> + cp.SourceMemoryAddress = src;<br>
> + }<br>
> +#else<br>
> + /* IVB does not have a general purpose register for command streamer<br>
> + * commands. Therefore, we use an alternate temporary register.<br>
> + */<br>
> +#define BLORP_TEMP_REG 0x2440 /* GEN7_3DPRIM_BASE_VERTEX */<br>
> + blorp_emit(batch, GENX(MI_LOAD_REGISTER_MEM), load) {<br>
> + load.RegisterAddress = BLORP_TEMP_REG;<br>
> + load.MemoryAddress = src;<br>
> + }<br>
> + blorp_emit(batch, GENX(MI_STORE_REGISTER_MEM), store) {<br>
> + store.RegisterAddress = BLORP_TEMP_REG;<br>
> + store.MemoryAddress = dst;<br>
> + }<br>
> +#undef BLORP_TEMP_REG<br>
> +#endif<br>
> + dst.offset += 4;<br>
> + src.offset += 4;<br>
> + }<br>
> +}<br>
> +#endif<br>
> +<br>
> static void<br>
> blorp_emit_surface_state(<wbr>struct blorp_batch *batch,<br>
> const struct brw_blorp_surface_info *surface,<br>
> @@ -1259,6 +1300,20 @@ blorp_emit_surface_state(<wbr>struct blorp_batch *batch,<br>
> }<br>
><br>
> blorp_flush_range(batch, state, GENX(RENDER_SURFACE_STATE_<wbr>length) * 4);<br>
> +<br>
> +#if GEN_GEN > 10<br>
> +# error("Implement indirect clear support on gen11+")<br>
> +#elif GEN_GEN >= 7 && GEN_GEN <= 10<br>
<br>
</div></div>Could we move the #if/elif block under the if statement below and use<br>
assert(!str) instead of #error? Otherwise we can't run any tests on<br>
gen11+ until this feature is implemented.<br></blockquote><div><br></div><div>Yeah, I think that's reasonable.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-Nanley<br>
<div><div class="h5"><br>
> + if (surface->clear_color_addr.<wbr>buffer) {<br>
> + struct blorp_address dst_addr = blorp_get_surface_base_<wbr>address(batch);<br>
> + dst_addr.offset += state_offset + isl_dev->ss.clear_value_<wbr>offset;<br>
> + blorp_emit_memcpy(batch, dst_addr, surface->clear_color_addr,<br>
> + isl_dev->ss.clear_value_size);<br>
> + }<br>
> +#else<br>
> + /* Indirect clears are only supported on gen7+ */<br>
> + assert(surface->clear_color_<wbr>addr.buffer == NULL);<br>
> +#endif<br>
> }<br>
><br>
> static void<br>
> @@ -1303,6 +1358,7 @@ blorp_emit_surface_states(<wbr>struct blorp_batch *batch,<br>
> uint32_t bind_offset, surface_offsets[2];<br>
> void *surface_maps[2];<br>
><br>
> + MAYBE_UNUSED bool has_indirect_clear_color = false;<br>
> if (params->use_pre_baked_<wbr>binding_table) {<br>
> bind_offset = params->pre_baked_binding_<wbr>table_offset;<br>
> } else {<br>
> @@ -1316,6 +1372,8 @@ blorp_emit_surface_states(<wbr>struct blorp_batch *batch,<br>
> surface_maps[BLORP_<wbr>RENDERBUFFER_BT_INDEX],<br>
> surface_offsets[BLORP_<wbr>RENDERBUFFER_BT_INDEX],<br>
> params->color_write_disable, true);<br>
> + if (params->dst.clear_color_addr.<wbr>buffer != NULL)<br>
> + has_indirect_clear_color = true;<br>
> } else {<br>
> assert(params->depth.enabled || params->stencil.enabled);<br>
> const struct brw_blorp_surface_info *surface =<br>
> @@ -1329,9 +1387,28 @@ blorp_emit_surface_states(<wbr>struct blorp_batch *batch,<br>
> surface_maps[BLORP_TEXTURE_BT_<wbr>INDEX],<br>
> surface_offsets[BLORP_TEXTURE_<wbr>BT_INDEX],<br>
> NULL, false);<br>
> + if (params->src.clear_color_addr.<wbr>buffer != NULL)<br>
> + has_indirect_clear_color = true;<br>
> }<br>
> }<br>
><br>
> +#if GEN_GEN >= 7 && GEN_GEN <= 10<br>
> + if (has_indirect_clear_color) {<br>
> + /* Updating a surface state object may require that the state cache be<br>
> + * invalidated. From the SKL PRM, Shared Functions -> State -> State<br>
> + * Caching:<br>
> + *<br>
> + * Whenever the RENDER_SURFACE_STATE object in memory pointed to by<br>
> + * the Binding Table Pointer (BTP) and Binding Table Index (BTI) is<br>
> + * modified [...], the L1 state cache must be invalidated to ensure<br>
> + * the new surface or sampler state is fetched from system memory.<br>
> + */<br>
> + blorp_emit(batch, GENX(PIPE_CONTROL), pipe) {<br>
> + pipe.<wbr>StateCacheInvalidationEnable = true;<br>
> + }<br>
> + }<br>
> +#endif<br>
> +<br>
> #if GEN_GEN >= 7<br>
> blorp_emit(batch, GENX(3DSTATE_BINDING_TABLE_<wbr>POINTERS_VS), bt);<br>
> blorp_emit(batch, GENX(3DSTATE_BINDING_TABLE_<wbr>POINTERS_HS), bt);<br>
> diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h<br>
> index d91e436..faa0af1 100644<br>
> --- a/src/intel/blorp/blorp_priv.h<br>
> +++ b/src/intel/blorp/blorp_priv.h<br>
> @@ -56,6 +56,7 @@ struct brw_blorp_surface_info<br>
> enum isl_aux_usage aux_usage;<br>
><br>
> union isl_color_value clear_color;<br>
> + struct blorp_address clear_color_addr;<br>
><br>
> struct isl_view view;<br>
><br>
> diff --git a/src/intel/vulkan/genX_blorp_<wbr>exec.c b/src/intel/vulkan/genX_blorp_<wbr>exec.c<br>
> index f041fc7..817b530 100644<br>
> --- a/src/intel/vulkan/genX_blorp_<wbr>exec.c<br>
> +++ b/src/intel/vulkan/genX_blorp_<wbr>exec.c<br>
> @@ -64,6 +64,16 @@ blorp_surface_reloc(struct blorp_batch *batch, uint32_t ss_offset,<br>
> anv_batch_set_error(&cmd_<wbr>buffer->batch, result);<br>
> }<br>
><br>
> +static struct blorp_address<br>
> +blorp_get_surface_base_<wbr>address(struct blorp_batch *batch)<br>
> +{<br>
> + struct anv_cmd_buffer *cmd_buffer = batch->driver_batch;<br>
> + return (struct blorp_address) {<br>
> + .buffer = &cmd_buffer->device-><a href="http://surface_state_pool.block_pool.bo" rel="noreferrer" target="_blank">surface_<wbr>state_pool.block_pool.bo</a>,<br>
> + .offset = 0,<br>
> + };<br>
> +}<br>
> +<br>
> static void *<br>
> blorp_alloc_dynamic_state(<wbr>struct blorp_batch *batch,<br>
> uint32_t size,<br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>genX_blorp_exec.c b/src/mesa/drivers/dri/i965/<wbr>genX_blorp_exec.c<br>
> index 3c7a7b4..e47db59 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>genX_blorp_exec.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>genX_blorp_exec.c<br>
> @@ -94,6 +94,19 @@ blorp_surface_reloc(struct blorp_batch *batch, uint32_t ss_offset,<br>
> #endif<br>
> }<br>
><br>
> +#if GEN_GEN >= 7<br>
> +static struct blorp_address<br>
> +blorp_get_surface_base_<wbr>address(struct blorp_batch *batch)<br>
> +{<br>
> + assert(batch->blorp->driver_<wbr>ctx == batch->driver_batch);<br>
> + struct brw_context *brw = batch->driver_batch;<br>
> + return (struct blorp_address) {<br>
> + .buffer = brw->batch.state_bo,<br>
> + .offset = 0,<br>
> + };<br>
> +}<br>
> +#endif<br>
> +<br>
> static void *<br>
> blorp_alloc_dynamic_state(<wbr>struct blorp_batch *batch,<br>
> uint32_t size,<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>