<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 28, 2016 at 12:11 PM, Pohjolainen, Topi <span dir="ltr"><<a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@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 Sat, Oct 22, 2016 at 10:50:50AM -0700, Jason Ekstrand wrote:<br>
> ---<br>
>  src/intel/blorp/blorp.h       |  11 +++<br>
>  src/intel/blorp/blorp_clear.c | 162 ++++++++++++++++++++++++++++++<wbr>+++++++++++-<br>
>  src/intel/blorp/blorp_priv.h  |   1 +<br>
>  3 files changed, 172 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/src/intel/blorp/blorp.h b/src/intel/blorp/blorp.h<br>
> index 0c64d13..8a761ce 100644<br>
> --- a/src/intel/blorp/blorp.h<br>
> +++ b/src/intel/blorp/blorp.h<br>
> @@ -156,6 +156,17 @@ blorp_clear_depth_stencil(<wbr>struct blorp_batch *batch,<br>
>                            uint8_t stencil_mask, uint8_t stencil_value);<br>
><br>
>  void<br>
> +blorp_clear_attachments(<wbr>struct blorp_batch *batch,<br>
> +                        uint32_t color_surface_state,<br>
> +                        enum isl_format depth_format,<br>
> +                        uint32_t num_samples,<br>
> +                        uint32_t start_layer, uint32_t num_layers,<br>
> +                        uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,<br>
> +                        bool clear_color, union isl_color_value color_value,<br>
> +                        bool clear_depth, float depth_value,<br>
> +                        uint8_t stencil_mask, uint8_t stencil_value);<br>
> +<br>
> +void<br>
>  blorp_ccs_resolve(struct blorp_batch *batch,<br>
>                    struct blorp_surf *surf, enum isl_format format);<br>
><br>
> diff --git a/src/intel/blorp/blorp_clear.<wbr>c b/src/intel/blorp/blorp_clear.<wbr>c<br>
> index 3d752ac..2287f59 100644<br>
> --- a/src/intel/blorp/blorp_clear.<wbr>c<br>
> +++ b/src/intel/blorp/blorp_clear.<wbr>c<br>
> @@ -87,6 +87,94 @@ blorp_params_get_clear_kernel(<wbr>struct blorp_context *blorp,<br>
>     ralloc_free(mem_ctx);<br>
>  }<br>
><br>
> +struct layer_offset_vs_key {<br>
> +   enum blorp_shader_type shader_type;<br>
> +   unsigned num_inputs;<br>
> +};<br>
> +<br>
<br>
</div></div>I'm assuming we need this because we are re-using the surface state from<br>
other pass and therefore cannot set the base layer in the surface state? If<br>
so it would be nice to have a comment here.<br></blockquote><div><br></div><div>Done.<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">
> +static void<br>
> +blorp_params_get_layer_<wbr>offset_vs(struct blorp_context *blorp,<br>
> +                                 struct blorp_params *params)<br>
> +{<br>
> +   struct layer_offset_vs_key blorp_key = {<br>
> +      .shader_type = BLORP_SHADER_TYPE_LAYER_<wbr>OFFSET_VS,<br>
> +   };<br>
> +<br>
> +   if (params->wm_prog_data)<br>
> +      blorp_key.num_inputs = params->wm_prog_data->num_<wbr>varying_inputs;<br>
> +<br>
> +   if (blorp->lookup_shader(blorp, &blorp_key, sizeof(blorp_key),<br>
> +                            &params->vs_prog_kernel, &params->vs_prog_data))<br>
> +      return;<br>
> +<br>
> +   void *mem_ctx = ralloc_context(NULL);<br>
> +<br>
> +   nir_builder b;<br>
> +   nir_builder_init_simple_<wbr>shader(&b, mem_ctx, MESA_SHADER_VERTEX, NULL);<br>
> +   b.shader-><a href="http://info.name" rel="noreferrer" target="_blank">info.name</a> = ralloc_strdup(b.shader, "BLORP-layer-offset-vs");<br>
> +<br>
> +   const struct glsl_type *uvec4_type = glsl_vector_type(GLSL_TYPE_<wbr>UINT, 4);<br>
> +<br>
> +   /*<br>
> +    * First we deal with the header which has instance and base instance<br>
> +    */<br>
<br>
</div></div>Fits as oneline comment.<br>
<span class=""><br>
> +   nir_variable *a_header = nir_variable_create(b.shader, nir_var_shader_in,<br>
> +                                                uvec4_type, "header");<br>
> +   a_header->data.location = VERT_ATTRIB_GENERIC0;<br>
> +<br>
> +   nir_variable *v_layer = nir_variable_create(b.shader, nir_var_shader_out,<br>
> +                                               glsl_int_type(), "layer_id");<br>
> +   v_layer->data.location = VARYING_SLOT_LAYER;<br>
> +<br>
> +   /* Compute the layer id */<br>
> +   nir_ssa_def *header = nir_load_var(&b, a_header);<br>
> +   nir_ssa_def *base_layer = nir_channel(&b, header, 0);<br>
> +   nir_ssa_def *instance = nir_channel(&b, header, 1);<br>
> +   nir_store_var(&b, v_layer, nir_iadd(&b, instance, base_layer), 0x1);<br>
> +<br>
> +   /*<br>
> +    * Then we copy the vertex from the next slot to VARYING_SLOT_POS<br>
> +    */<br>
<br>
</span>Same here.<br>
<span class=""><br>
> +   nir_variable *a_vertex = nir_variable_create(b.shader, nir_var_shader_in,<br>
> +                                                glsl_vec4_type(), "a_vertex");<br>
> +   a_vertex->data.location = VERT_ATTRIB_GENERIC1;<br>
> +<br>
> +   nir_variable *v_pos = nir_variable_create(b.shader, nir_var_shader_out,<br>
> +                                             glsl_vec4_type(), "v_pos");<br>
> +   v_pos->data.location = VARYING_SLOT_POS;<br>
> +<br>
> +   nir_copy_var(&b, v_pos, a_vertex);<br>
> +<br>
> +   /*<br>
> +    * Then we copy everything else<br>
> +    */<br>
<br>
</span>And here.<br>
<div><div class="h5"><br>
> +   for (unsigned i = 0; i < blorp_key.num_inputs; i++) {<br>
> +      nir_variable *a_in = nir_variable_create(b.shader, nir_var_shader_in,<br>
> +                                               uvec4_type, "input");<br>
> +      a_in->data.location = VERT_ATTRIB_GENERIC2 + i;<br>
> +<br>
> +      nir_variable *v_out = nir_variable_create(b.shader, nir_var_shader_out,<br>
> +                                                uvec4_type, "output");<br>
> +      v_out->data.location = VARYING_SLOT_VAR0 + i;<br>
> +<br>
> +      nir_copy_var(&b, v_out, a_in);<br>
> +   }<br>
> +<br>
> +   struct brw_vs_prog_data vs_prog_data;<br>
> +   memset(&vs_prog_data, 0, sizeof(vs_prog_data));<br>
> +<br>
> +   unsigned program_size;<br>
> +   const unsigned *program =<br>
> +      blorp_compile_vs(blorp, mem_ctx, b.shader, &vs_prog_data, &program_size);<br>
> +<br>
> +   blorp->upload_shader(blorp, &blorp_key, sizeof(blorp_key),<br>
> +                        program, program_size,<br>
> +                        &vs_prog_data, sizeof(vs_prog_data),<br>
> +                        &params->vs_prog_kernel, &params->vs_prog_data);<br>
> +<br>
> +   ralloc_free(mem_ctx);<br>
> +}<br>
> +<br>
>  /* The x0, y0, x1, and y1 parameters must already be populated with the render<br>
>   * area of the framebuffer to be cleared.<br>
>   */<br>
> @@ -224,7 +312,7 @@ blorp_fast_clear(struct blorp_batch *batch,<br>
>     params.x1 = x1;<br>
>     params.y1 = y1;<br>
><br>
> -   memset(&params.wm_inputs, 0xff, 4*sizeof(float));<br>
> +   memset(&params.wm_inputs.<wbr>clear_color, 0xff, 4*sizeof(float));<br>
>     params.fast_clear_op = BLORP_FAST_CLEAR_OP_CLEAR;<br>
><br>
>     get_fast_clear_rect(batch-><wbr>blorp->isl_dev, surf->aux_surf,<br>
> @@ -262,7 +350,7 @@ blorp_clear(struct blorp_batch *batch,<br>
>        format = ISL_FORMAT_R32_UINT;<br>
>     }<br>
><br>
> -   memcpy(&params.wm_inputs, clear_color.f32, sizeof(float) * 4);<br>
> +   memcpy(&params.wm_inputs.<wbr>clear_color, clear_color.f32, sizeof(float) * 4);<br>
><br>
>     bool use_simd16_replicated_data = true;<br>
><br>
> @@ -381,6 +469,76 @@ blorp_clear_depth_stencil(<wbr>struct blorp_batch *batch,<br>
>     }<br>
>  }<br>
><br>
> +/** Clear active color/depth/stencili attachments<br>
> + *<br>
> + * This function performs a clear operation on the currently bound<br>
> + * color/depth/stencil attachments.  It is assumed that any information passed<br>
> + * in here is valid, consistent, and in-bounds relative to the currently<br>
> + * attached depth/stencil.  The color_surface_state parameter is the 32-bit<br>
> + * offset relative to surface state base address where the surface state for<br>
> + * the desired color attachment is.  If clear_color is false,<br>
> + * color_surface_state must point to a valid null surface that matches the<br>
> + * currently bound depth and stencil.<br>
> + */<br>
> +void<br>
> +blorp_clear_attachments(<wbr>struct blorp_batch *batch,<br>
> +                        uint32_t binding_table_offset,<br>
<br>
</div></div>Prototype has this named 'color_surface_state' same as the comment above.<br></blockquote><div><br></div><div>Good catch!  I've updated both to binding_table_offset and made the comment make sense in that context.<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">
> +                        enum isl_format depth_format,<br>
> +                        uint32_t num_samples,<br>
> +                        uint32_t start_layer, uint32_t num_layers,<br>
> +                        uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,<br>
> +                        bool clear_color, union isl_color_value color_value,<br>
> +                        bool clear_depth, float depth_value,<br>
> +                        uint8_t stencil_mask, uint8_t stencil_value)<br>
> +{<br>
> +   struct blorp_params params;<br>
> +   blorp_params_init(&params);<br>
> +<br>
> +   assert(batch->flags & BLORP_BATCH_NO_EMIT_DEPTH_<wbr>STENCIL);<br>
> +<br>
> +   params.x0 = x0;<br>
> +   params.y0 = y0;<br>
> +   params.x1 = x1;<br>
> +   params.y1 = y1;<br>
> +<br>
> +   params.use_pre_baked_binding_<wbr>table = true;<br>
> +   params.pre_baked_binding_<wbr>table_offset = binding_table_offset;<br>
> +<br>
> +   params.num_layers = num_layers;<br>
> +   params.num_samples = num_samples;<br>
> +<br>
> +   if (clear_color) {<br>
> +      params.dst.enabled = true;<br>
> +<br>
> +      memcpy(&params.wm_inputs.<wbr>clear_color, color_value.f32, sizeof(float) * 4);<br>
> +<br>
> +      /* Unfortunately, without knowing whether or not our destination surface<br>
> +       * is tiled or not, we have to assume it may be linear.  This means no<br>
> +       * SIMD16_REPDATA for us. :-(<br>
> +       */<br>
> +      blorp_params_get_clear_kernel(<wbr>batch->blorp, &params, false);<br>
> +   }<br>
> +<br>
> +   if (clear_depth) {<br>
> +      params.depth.enabled = true;<br>
> +<br>
> +      params.z = depth_value;<br>
> +      params.depth_format = isl_format_get_depth_format(<wbr>depth_format, false);<br>
> +   }<br>
> +<br>
> +   if (stencil_mask) {<br>
> +      params.stencil.enabled = true;<br>
> +<br>
> +      params.stencil_mask = stencil_mask;<br>
> +      params.stencil_ref = stencil_value;<br>
> +   }<br>
> +<br>
> +   blorp_params_get_layer_offset_<wbr>vs(batch->blorp, &params);<br>
> +   params.vs_inputs.base_layer = start_layer;<br>
> +<br>
> +   batch->blorp->exec(batch, &params);<br>
> +}<br>
> +<br>
>  void<br>
>  blorp_ccs_resolve(struct blorp_batch *batch,<br>
>                    struct blorp_surf *surf, enum isl_format format)<br>
> diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h<br>
> index 31e7aae..300bd9d 100644<br>
> --- a/src/intel/blorp/blorp_priv.h<br>
> +++ b/src/intel/blorp/blorp_priv.h<br>
> @@ -232,6 +232,7 @@ void blorp_params_init(struct blorp_params *params);<br>
>  enum blorp_shader_type {<br>
>     BLORP_SHADER_TYPE_BLIT,<br>
>     BLORP_SHADER_TYPE_CLEAR,<br>
> +   BLORP_SHADER_TYPE_LAYER_<wbr>OFFSET_VS,<br>
>  };<br>
><br>
>  struct brw_blorp_blit_prog_key<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>