<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 23, 2016 at 8:33 AM, 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 Fri, Aug 19, 2016 at 09:55:52AM -0700, Jason Ekstrand wrote:<br>
> This gets rid of brw_context throughout the core of the state setup code.<br>
> ---<br>
>  src/mesa/drivers/dri/i965/<wbr>genX_blorp_exec.c | 332 +++++++++++++++-------------<br>
>  1 file changed, 182 insertions(+), 150 deletions(-)<br>
><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 288e384..8c15b16 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>
> @@ -34,8 +34,11 @@<br>
>  #include "genxml/gen_macros.h"<br>
><br>
>  static void *<br>
> -blorp_emit_dwords(struct brw_context *brw, unsigned n)<br>
> +blorp_emit_dwords(struct blorp_context *blorp, void *batch, unsigned n)<br>
>  {<br>
> +   assert(blorp->driver_ctx == batch);<br>
> +   struct brw_context *brw = batch;<br>
> +<br>
>     intel_batchbuffer_begin(brw, n, RENDER_RING);<br>
>     uint32_t *map = brw->batch.map_next;<br>
>     brw->batch.map_next += n;<br>
> @@ -44,9 +47,12 @@ blorp_emit_dwords(struct brw_context *brw, unsigned n)<br>
>  }<br>
><br>
>  static uint64_t<br>
> -blorp_emit_reloc(struct brw_context *brw, void *location,<br>
> -                 struct blorp_address address, uint32_t delta)<br>
> +blorp_emit_reloc(struct blorp_context *blorp, void *batch,<br>
> +                 void *location, struct blorp_address address, uint32_t delta)<br>
>  {<br>
> +   assert(blorp->driver_ctx == batch);<br>
> +   struct brw_context *brw = batch;<br>
> +<br>
>     uint32_t offset = (char *)location - (char *)brw->batch.map;<br>
>     if (brw->gen >= 8) {<br>
>        return intel_batchbuffer_reloc64(brw, address.buffer, offset,<br>
> @@ -62,9 +68,11 @@ blorp_emit_reloc(struct brw_context *brw, void *location,<br>
>  }<br>
><br>
>  static void<br>
> -blorp_surface_reloc(struct brw_context *brw, uint32_t ss_offset,<br>
> +blorp_surface_reloc(struct blorp_context *blorp, uint32_t ss_offset,<br>
>                      struct blorp_address address, uint32_t delta)<br>
>  {<br>
> +   struct brw_context *brw = blorp->driver_ctx;<br>
> +<br>
>     drm_intel_bo_emit_reloc(brw-><a href="http://batch.bo" rel="noreferrer" target="_blank">b<wbr>atch.bo</a>, ss_offset,<br>
>                             address.buffer, address.offset + delta,<br>
>                             address.read_domains, address.write_domain);<br>
> @@ -129,8 +137,12 @@ blorp_alloc_vertex_buffer(<wbr>struct blorp_context *blorp, uint32_t size,<br>
>  }<br>
><br>
>  static void<br>
> -blorp_emit_urb_config(struct brw_context *brw, unsigned vs_entry_size)<br>
> +blorp_emit_urb_config(struct blorp_context *blorp, void *batch,<br>
> +                      unsigned vs_entry_size)<br>
>  {<br>
> +   assert(blorp->driver_ctx == batch);<br>
> +   struct brw_context *brw = batch;<br>
> +<br>
>  #if GEN_GEN >= 7<br>
>     if (!(brw->ctx.NewDriverState & (BRW_NEW_CONTEXT | BRW_NEW_URB_SIZE)) &&<br>
>         brw->urb.vsize >= vs_entry_size)<br>
> @@ -145,26 +157,34 @@ blorp_emit_urb_config(struct brw_context *brw, unsigned vs_entry_size)<br>
>  }<br>
><br>
>  static void<br>
> -blorp_emit_3dstate_<wbr>multisample(struct brw_context *brw, unsigned samples)<br>
> +blorp_emit_3dstate_<wbr>multisample(struct blorp_context *blorp, void *batch,<br>
> +                               unsigned samples)<br>
>  {<br>
> +   assert(blorp->driver_ctx == batch);<br>
>  #if GEN_GEN >= 8<br>
> -   gen8_emit_3dstate_multisample(<wbr>brw, samples);<br>
> +   gen8_emit_3dstate_multisample(<wbr>batch, samples);<br>
>  #else<br>
> -   gen6_emit_3dstate_multisample(<wbr>brw, samples);<br>
> +   gen6_emit_3dstate_multisample(<wbr>batch, samples);<br>
>  #endif<br>
>  }<br>
><br>
> +struct blorp_batch {<br>
> +   struct blorp_context *blorp;<br>
> +   void *batch;<br>
> +};<br>
> +<br>
>  #define __gen_address_type struct blorp_address<br>
> -#define __gen_user_data struct brw_context<br>
> +#define __gen_user_data struct blorp_batch<br>
><br>
>  static uint64_t<br>
> -__gen_combine_address(struct brw_context *brw, void *location,<br>
> +__gen_combine_address(struct blorp_batch *batch, void *location,<br>
>                        struct blorp_address address, uint32_t delta)<br>
>  {<br>
>     if (address.buffer == NULL) {<br>
>        return address.offset + delta;<br>
>     } else {<br>
> -      return blorp_emit_reloc(brw, location, address, delta);<br>
> +      return blorp_emit_reloc(batch->blorp, batch->batch,<br>
> +                              location, address, delta);<br>
>     }<br>
>  }<br>
><br>
> @@ -175,21 +195,22 @@ __gen_combine_address(struct brw_context *brw, void *location,<br>
>  #define _blorp_cmd_header(cmd) cmd ## _header<br>
>  #define _blorp_cmd_pack(cmd) cmd ## _pack<br>
><br>
> -#define blorp_emit(brw, cmd, name)                                \<br>
> -   for (struct cmd name = { _blorp_cmd_header(cmd) },             \<br>
> -        *_dst = blorp_emit_dwords(brw, _blorp_cmd_length(cmd));   \<br>
> -        __builtin_expect(_dst != NULL, 1);                        \<br>
> -        _blorp_cmd_pack(cmd)(brw, (void *)_dst, &name),           \<br>
> +#define blorp_emit(batch, cmd, name)                        \<br>
> +   for (struct cmd name = { _blorp_cmd_header(cmd) },       \<br>
> +        *_dst = blorp_emit_dwords(batch.blorp, batch.batch, \<br>
> +                                  _blorp_cmd_length(cmd));  \<br>
> +        __builtin_expect(_dst != NULL, 1);                  \<br>
> +        _blorp_cmd_pack(cmd)(&batch, (void *)_dst, &name),   \<br>
>          _dst = NULL)<br>
><br>
> -#define blorp_emitn(batch, cmd, n) ({                    \<br>
> -      uint32_t *_dw = blorp_emit_dwords(batch, n);       \<br>
> -      struct cmd template = {                            \<br>
> -         _blorp_cmd_header(cmd),                         \<br>
> -         .DWordLength = n - _blorp_cmd_length_bias(cmd), \<br>
> -      };                                                 \<br>
> -      _blorp_cmd_pack(cmd)(batch, _dw, &template);       \<br>
> -      _dw + 1; /* Array starts at dw[1] */               \<br>
> +#define blorp_emitn(batch, cmd, n) ({                                   \<br>
> +      uint32_t *_dw = blorp_emit_dwords(batch.blorp, batch.batch, n);   \<br>
> +      struct cmd template = {                                           \<br>
> +         _blorp_cmd_header(cmd),                                        \<br>
> +         .DWordLength = n - _blorp_cmd_length_bias(cmd),                \<br>
> +      };                                                                \<br>
> +      _blorp_cmd_pack(cmd)(&batch, _dw, &template);                     \<br>
> +      _dw + 1; /* Array starts at dw[1] */                              \<br>
>     })<br>
><br>
>  /* Once vertex fetcher has written full VUE entries with complete<br>
> @@ -242,14 +263,15 @@ gen7_blorp_get_vs_entry_size(<wbr>const struct brw_blorp_params *params)<br>
>   *     valid.<br>
>   */<br>
>  static void<br>
> -emit_urb_config(struct brw_context *brw,<br>
> +emit_urb_config(struct blorp_batch batch,<br>
>                  const struct brw_blorp_params *params)<br>
>  {<br>
> -   blorp_emit_urb_config(brw, gen7_blorp_get_vs_entry_size(<wbr>params));<br>
> +   blorp_emit_urb_config(batch.<wbr>blorp, batch.batch,<br>
> +                         gen7_blorp_get_vs_entry_size(<wbr>params));<br>
>  }<br>
><br>
>  static void<br>
> -blorp_emit_vertex_data(struct brw_context *brw,<br>
> +blorp_emit_vertex_data(struct blorp_batch batch,<br>
>                         const struct brw_blorp_params *params,<br>
>                         struct blorp_address *addr,<br>
>                         uint32_t *size)<br>
> @@ -260,13 +282,13 @@ blorp_emit_vertex_data(struct brw_context *brw,<br>
>        /* v2 */ (float)params->x0, (float)params->y0,<br>
>     };<br>
><br>
> -   void *data = blorp_alloc_vertex_buffer(&<wbr>brw->blorp, sizeof(vertices), addr);<br>
> +   void *data = blorp_alloc_vertex_buffer(<wbr>batch.blorp, sizeof(vertices), addr);<br>
>     memcpy(data, vertices, sizeof(vertices));<br>
>     *size = sizeof(vertices);<br>
>  }<br>
><br>
>  static void<br>
> -blorp_emit_input_varying_<wbr>data(struct brw_context *brw,<br>
> +blorp_emit_input_varying_<wbr>data(struct blorp_batch batch,<br>
>                                const struct brw_blorp_params *params,<br>
>                                struct blorp_address *addr,<br>
>                                uint32_t *size)<br>
> @@ -279,7 +301,7 @@ blorp_emit_input_varying_data(<wbr>struct brw_context *brw,<br>
>     *size = num_varyings * vec4_size_in_bytes;<br>
><br>
>     const float *const inputs_src = (const float *)&params->wm_inputs;<br>
> -   float *inputs = blorp_alloc_vertex_buffer(&<wbr>brw->blorp, *size, addr);<br>
> +   float *inputs = blorp_alloc_vertex_buffer(<wbr>batch.blorp, *size, addr);<br>
><br>
>     /* Walk over the attribute slots, determine if the attribute is used by<br>
>      * the program and when necessary copy the values from the input storage to<br>
> @@ -298,7 +320,7 @@ blorp_emit_input_varying_data(<wbr>struct brw_context *brw,<br>
>  }<br>
><br>
>  static void<br>
> -blorp_emit_vertex_buffers(<wbr>struct brw_context *brw,<br>
> +blorp_emit_vertex_buffers(<wbr>struct blorp_batch batch,<br>
>                            const struct brw_blorp_params *params)<br>
>  {<br>
>     struct GENX(VERTEX_BUFFER_STATE) vb[2];<br>
> @@ -307,10 +329,10 @@ blorp_emit_vertex_buffers(<wbr>struct brw_context *brw,<br>
>     unsigned num_buffers = 1;<br>
><br>
>     uint32_t size;<br>
> -   blorp_emit_vertex_data(brw, params, &vb[0].BufferStartingAddress, &size);<br>
> +   blorp_emit_vertex_data(batch, params, &vb[0].BufferStartingAddress, &size);<br>
>     vb[0].VertexBufferIndex = 0;<br>
>     vb[0].BufferPitch = 2 * sizeof(float);<br>
> -   vb[0].VertexBufferMOCS = brw->blorp.mocs.vb;<br>
> +   vb[0].VertexBufferMOCS = batch.blorp->mocs.vb;<br>
>  #if GEN_GEN >= 7<br>
>     vb[0].AddressModifyEnable = true;<br>
>  #endif<br>
> @@ -323,11 +345,11 @@ blorp_emit_vertex_buffers(<wbr>struct brw_context *brw,<br>
>  #endif<br>
><br>
>     if (params->wm_prog_data && params->wm_prog_data->num_<wbr>varying_inputs) {<br>
> -      blorp_emit_input_varying_data(<wbr>brw, params,<br>
> +      blorp_emit_input_varying_data(<wbr>batch, params,<br>
>                                      &vb[1].BufferStartingAddress, &size);<br>
>        vb[1].VertexBufferIndex = 1;<br>
>        vb[1].BufferPitch = 0;<br>
> -      vb[1].VertexBufferMOCS = brw->blorp.mocs.vb;<br>
> +      vb[1].VertexBufferMOCS = batch.blorp->mocs.vb;<br>
>  #if GEN_GEN >= 7<br>
>        vb[1].AddressModifyEnable = true;<br>
>  #endif<br>
> @@ -343,16 +365,16 @@ blorp_emit_vertex_buffers(<wbr>struct brw_context *brw,<br>
><br>
>     const unsigned num_dwords =<br>
>        1 + GENX(VERTEX_BUFFER_STATE_<wbr>length) * num_buffers;<br>
> -   uint32_t *dw = blorp_emitn(brw, GENX(3DSTATE_VERTEX_BUFFERS), num_dwords);<br>
> +   uint32_t *dw = blorp_emitn(batch, GENX(3DSTATE_VERTEX_BUFFERS), num_dwords);<br>
><br>
>     for (unsigned i = 0; i < num_buffers; i++) {<br>
> -      GENX(VERTEX_BUFFER_STATE_pack)<wbr>(brw, dw, &vb[i]);<br>
> +      GENX(VERTEX_BUFFER_STATE_pack)<wbr>(&batch, dw, &vb[i]);<br>
>        dw += GENX(VERTEX_BUFFER_STATE_<wbr>length);<br>
>     }<br>
>  }<br>
><br>
>  static void<br>
> -blorp_emit_vertex_elements(<wbr>struct brw_context *brw,<br>
> +blorp_emit_vertex_elements(<wbr>struct blorp_batch batch,<br>
>                             const struct brw_blorp_params *params)<br>
>  {<br>
>     const unsigned num_varyings =<br>
> @@ -437,31 +459,31 @@ blorp_emit_vertex_elements(<wbr>struct brw_context *brw,<br>
><br>
>     const unsigned num_dwords =<br>
>        1 + GENX(VERTEX_ELEMENT_STATE_<wbr>length) * num_elements;<br>
> -   uint32_t *dw = blorp_emitn(brw, GENX(3DSTATE_VERTEX_ELEMENTS), num_dwords);<br>
> +   uint32_t *dw = blorp_emitn(batch, GENX(3DSTATE_VERTEX_ELEMENTS), num_dwords);<br>
><br>
>     for (unsigned i = 0; i < num_elements; i++) {<br>
> -      GENX(VERTEX_ELEMENT_STATE_<wbr>pack)(brw, dw, &ve[i]);<br>
> +      GENX(VERTEX_ELEMENT_STATE_<wbr>pack)(&batch, dw, &ve[i]);<br>
>        dw += GENX(VERTEX_ELEMENT_STATE_<wbr>length);<br>
>     }<br>
><br>
>  #if GEN_GEN >= 8<br>
> -   blorp_emit(brw, GENX(3DSTATE_VF_SGVS), sgvs);<br>
> +   blorp_emit(batch, GENX(3DSTATE_VF_SGVS), sgvs);<br>
><br>
>     for (unsigned i = 0; i < num_elements; i++) {<br>
> -      blorp_emit(brw, GENX(3DSTATE_VF_INSTANCING), vf) {<br>
> +      blorp_emit(batch, GENX(3DSTATE_VF_INSTANCING), vf) {<br>
>           vf.VertexElementIndex = i;<br>
>           vf.InstancingEnable = false;<br>
>        }<br>
>     }<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_VF_TOPOLOGY), topo) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_VF_TOPOLOGY), topo) {<br>
>        topo.PrimitiveTopologyType = _3DPRIM_RECTLIST;<br>
>     }<br>
>  #endif<br>
>  }<br>
><br>
>  static void<br>
> -blorp_emit_sf_config(struct brw_context *brw,<br>
> +blorp_emit_sf_config(struct blorp_batch batch,<br>
>                       const struct brw_blorp_params *params)<br>
>  {<br>
>     const struct brw_blorp_prog_data *prog_data = params->wm_prog_data;<br>
> @@ -487,13 +509,13 @@ blorp_emit_sf_config(struct brw_context *brw,<br>
><br>
>  #if GEN_GEN >= 8<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_SF), sf);<br>
> +   blorp_emit(batch, GENX(3DSTATE_SF), sf);<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_RASTER), raster) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_RASTER), raster) {<br>
>        raster.CullMode = CULLMODE_NONE;<br>
>     }<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_SBE), sbe) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_SBE), sbe) {<br>
>        sbe.VertexURBEntryReadOffset = BRW_SF_URB_ENTRY_READ_OFFSET;<br>
>        sbe.NumberofSFOutputAttributes = prog_data->num_varying_inputs;<br>
>        sbe.VertexURBEntryReadLength = brw_blorp_get_urb_length(prog_<wbr>data);<br>
> @@ -509,7 +531,7 @@ blorp_emit_sf_config(struct brw_context *brw,<br>
><br>
>  #elif GEN_GEN >= 7<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_SF), sf) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_SF), sf) {<br>
>        sf.FrontFaceFillMode = FILL_MODE_SOLID;<br>
>        sf.BackFaceFillMode = FILL_MODE_SOLID;<br>
><br>
> @@ -521,7 +543,7 @@ blorp_emit_sf_config(struct brw_context *brw,<br>
>  #endif<br>
>     }<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_SBE), sbe) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_SBE), sbe) {<br>
>        sbe.VertexURBEntryReadOffset = BRW_SF_URB_ENTRY_READ_OFFSET;<br>
>        if (prog_data) {<br>
>           sbe.NumberofSFOutputAttributes = prog_data->num_varying_inputs;<br>
> @@ -535,7 +557,7 @@ blorp_emit_sf_config(struct brw_context *brw,<br>
><br>
>  #else /* GEN_GEN <= 6 */<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_SF), sf) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_SF), sf) {<br>
>        sf.FrontFaceFillMode = FILL_MODE_SOLID;<br>
>        sf.BackFaceFillMode = FILL_MODE_SOLID;<br>
><br>
> @@ -557,7 +579,7 @@ blorp_emit_sf_config(struct brw_context *brw,<br>
>  }<br>
><br>
>  static void<br>
> -blorp_emit_ps_config(struct brw_context *brw,<br>
> +blorp_emit_ps_config(struct blorp_batch batch,<br>
>                       const struct brw_blorp_params *params)<br>
>  {<br>
>     const struct brw_blorp_prog_data *prog_data = params->wm_prog_data;<br>
> @@ -573,9 +595,9 @@ blorp_emit_ps_config(struct brw_context *brw,<br>
><br>
>  #if GEN_GEN >= 8<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_WM), wm);<br>
> +   blorp_emit(batch, GENX(3DSTATE_WM), wm);<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_PS), ps) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_PS), ps) {<br>
>        if (params->src.addr.buffer) {<br>
>           ps.SamplerCount = 1; /* Up to 4 samplers */<br>
>           ps.BindingTableEntryCount = 2;<br>
> @@ -625,7 +647,7 @@ blorp_emit_ps_config(struct brw_context *brw,<br>
>        }<br>
>     }<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_PS_EXTRA), psx) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_PS_EXTRA), psx) {<br>
>        psx.PixelShaderValid = true;<br>
><br>
>        if (params->src.addr.buffer)<br>
> @@ -639,7 +661,7 @@ blorp_emit_ps_config(struct brw_context *brw,<br>
><br>
>  #elif GEN_GEN >= 7<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_WM), wm) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_WM), wm) {<br>
>        switch (params->hiz_op) {<br>
>        case GEN6_HIZ_OP_DEPTH_CLEAR:<br>
>           wm.DepthBufferClear = true;<br>
> @@ -673,8 +695,8 @@ blorp_emit_ps_config(struct brw_context *brw,<br>
>        }<br>
>     }<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_PS), ps) {<br>
> -      ps.MaximumNumberofThreads = brw->max_wm_threads - 1;<br>
> +   blorp_emit(batch, GENX(3DSTATE_PS), ps) {<br>
> +      ps.MaximumNumberofThreads = batch.blorp->isl_dev->info-><wbr>max_wm_threads - 1;<br>
><br>
>  #if GEN_IS_HASWELL<br>
>        ps.SampleMask = 1;<br>
> @@ -716,8 +738,8 @@ blorp_emit_ps_config(struct brw_context *brw,<br>
><br>
>  #else /* GEN_GEN <= 6 */<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_WM), wm) {<br>
> -      wm.MaximumNumberofThreads = brw->max_wm_threads - 1;<br>
> +   blorp_emit(batch, GENX(3DSTATE_WM), wm) {<br>
> +      wm.MaximumNumberofThreads = batch.blorp->isl_dev->info-><wbr>max_wm_threads - 1;<br>
><br>
>        switch (params->hiz_op) {<br>
>        case GEN6_HIZ_OP_DEPTH_CLEAR:<br>
> @@ -774,18 +796,16 @@ blorp_emit_ps_config(struct brw_context *brw,<br>
><br>
><br>
>  static void<br>
> -blorp_emit_depth_stencil_<wbr>config(struct brw_context *brw,<br>
> +blorp_emit_depth_stencil_<wbr>config(struct blorp_batch batch,<br>
>                                  const struct brw_blorp_params *params)<br>
>  {<br>
> -   brw_emit_depth_stall_flushes(<wbr>brw);<br>
> -<br>
>  #if GEN_GEN >= 7<br>
>     const uint32_t mocs = 1; /* GEN7_MOCS_L3 */<br>
>  #else<br>
>     const uint32_t mocs = 0;<br>
>  #endif<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_DEPTH_BUFFER), db) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_DEPTH_BUFFER), db) {<br>
>        switch (params->depth.surf.dim) {<br>
>        case ISL_SURF_DIM_1D:<br>
>           db.SurfaceType = SURFTYPE_1D;<br>
> @@ -827,17 +847,17 @@ blorp_emit_depth_stencil_<wbr>config(struct brw_context *brw,<br>
>        db.DepthBufferMOCS = mocs;<br>
>     }<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_HIER_DEPTH_<wbr>BUFFER), hiz) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_HIER_DEPTH_<wbr>BUFFER), hiz) {<br>
>        hiz.SurfacePitch = params->depth.aux_surf.row_<wbr>pitch - 1;<br>
>        hiz.SurfaceBaseAddress = params->depth.aux_addr;<br>
>        hiz.<wbr>HierarchicalDepthBufferMOCS = mocs;<br>
>     }<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_STENCIL_BUFFER), sb);<br>
> +   blorp_emit(batch, GENX(3DSTATE_STENCIL_BUFFER), sb);<br>
>  }<br>
><br>
>  static uint32_t<br>
> -blorp_emit_blend_state(struct brw_context *brw,<br>
> +blorp_emit_blend_state(struct blorp_batch batch,<br>
>                         const struct brw_blorp_params *params)<br>
>  {<br>
>     struct GENX(BLEND_STATE) blend;<br>
> @@ -855,14 +875,14 @@ blorp_emit_blend_state(struct brw_context *brw,<br>
>     }<br>
><br>
>     uint32_t offset;<br>
> -   void *state = blorp_alloc_dynamic_state(&<wbr>brw->blorp,<br>
> +   void *state = blorp_alloc_dynamic_state(<wbr>batch.blorp,<br>
>                                             AUB_TRACE_BLEND_STATE,<br>
>                                             GENX(BLEND_STATE_length) * 4,<br>
>                                             64, &offset);<br>
>     GENX(BLEND_STATE_pack)(NULL, state, &blend);<br>
><br>
>  #if GEN_GEN >= 7<br>
> -   blorp_emit(brw, GENX(3DSTATE_BLEND_STATE_<wbr>POINTERS), sp) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_BLEND_STATE_<wbr>POINTERS), sp) {<br>
>        sp.BlendStatePointer = offset;<br>
>  #if GEN_GEN >= 8<br>
>        sp.BlendStatePointerValid = true;<br>
> @@ -871,7 +891,7 @@ blorp_emit_blend_state(struct brw_context *brw,<br>
>  #endif<br>
><br>
>  #if GEN_GEN >= 8<br>
> -   blorp_emit(brw, GENX(3DSTATE_PS_BLEND), ps_blend) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_PS_BLEND), ps_blend) {<br>
>        ps_blend.HasWriteableRT = true;<br>
>     }<br>
>  #endif<br>
> @@ -880,18 +900,18 @@ blorp_emit_blend_state(struct brw_context *brw,<br>
>  }<br>
><br>
>  static uint32_t<br>
> -blorp_emit_color_calc_state(<wbr>struct brw_context *brw,<br>
> +blorp_emit_color_calc_state(<wbr>struct blorp_batch batch,<br>
>                              const struct brw_blorp_params *params)<br>
>  {<br>
>     uint32_t offset;<br>
> -   void *state = blorp_alloc_dynamic_state(&<wbr>brw->blorp,<br>
> +   void *state = blorp_alloc_dynamic_state(<wbr>batch.blorp,<br>
>                                             AUB_TRACE_CC_STATE,<br>
>                                             GENX(COLOR_CALC_STATE_length) * 4,<br>
>                                             64, &offset);<br>
>     memset(state, 0, GENX(COLOR_CALC_STATE_length) * 4);<br>
><br>
>  #if GEN_GEN >= 7<br>
> -   blorp_emit(brw, GENX(3DSTATE_CC_STATE_<wbr>POINTERS), sp) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_CC_STATE_<wbr>POINTERS), sp) {<br>
>        sp.ColorCalcStatePointer = offset;<br>
>  #if GEN_GEN >= 8<br>
>        sp.ColorCalcStatePointerValid = true;<br>
> @@ -903,13 +923,13 @@ blorp_emit_color_calc_state(<wbr>struct brw_context *brw,<br>
>  }<br>
><br>
>  static uint32_t<br>
> -blorp_emit_depth_stencil_<wbr>state(struct brw_context *brw,<br>
> +blorp_emit_depth_stencil_<wbr>state(struct blorp_batch batch,<br>
>                                 const struct brw_blorp_params *params)<br>
>  {<br>
>  #if GEN_GEN >= 8<br>
><br>
>     /* On gen8+, DEPTH_STENCIL state is simply an instruction */<br>
> -   blorp_emit(brw, GENX(3DSTATE_WM_DEPTH_STENCIL)<wbr>, ds);<br>
> +   blorp_emit(batch, GENX(3DSTATE_WM_DEPTH_STENCIL)<wbr>, ds);<br>
>     return 0;<br>
><br>
>  #else /* GEN_GEN <= 7 */<br>
> @@ -929,14 +949,14 @@ blorp_emit_depth_stencil_<wbr>state(struct brw_context *brw,<br>
>     }<br>
><br>
>     uint32_t offset;<br>
> -   void *state = blorp_alloc_dynamic_state(&<wbr>brw->blorp,<br>
> +   void *state = blorp_alloc_dynamic_state(<wbr>batch.blorp,<br>
>                                             AUB_TRACE_DEPTH_STENCIL_STATE,<br>
>                                             GENX(DEPTH_STENCIL_STATE_<wbr>length) * 4,<br>
>                                             64, &offset);<br>
>     GENX(DEPTH_STENCIL_STATE_pack)<wbr>(NULL, state, &ds);<br>
><br>
>  #if GEN_GEN >= 7<br>
> -   blorp_emit(brw, GENX(3DSTATE_DEPTH_STENCIL_<wbr>STATE_POINTERS), sp) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_DEPTH_STENCIL_<wbr>STATE_POINTERS), sp) {<br>
>        sp.PointertoDEPTH_STENCIL_<wbr>STATE = offset;<br>
>     }<br>
>  #endif<br>
> @@ -961,12 +981,12 @@ static const struct surface_state_info surface_state_infos[] = {<br>
>  };<br>
><br>
>  static void<br>
> -blorp_emit_surface_state(<wbr>struct brw_context *brw,<br>
> +blorp_emit_surface_state(<wbr>struct blorp_context *blorp,<br>
>                           const struct brw_blorp_surface_info *surface,<br>
>                           uint32_t *state, uint32_t state_offset,<br>
>                           bool is_render_target)<br>
>  {<br>
> -   const struct surface_state_info ss_info = surface_state_infos[brw->gen];<br>
> +   const struct surface_state_info ss_info = surface_state_infos[GEN_GEN];<br>
><br>
>     struct isl_surf surf = surface->surf;<br>
><br>
> @@ -981,17 +1001,16 @@ blorp_emit_surface_state(<wbr>struct brw_context *brw,<br>
>     if (aux_usage == ISL_AUX_USAGE_HIZ)<br>
>        aux_usage = ISL_AUX_USAGE_NONE;<br>
><br>
> -   const uint32_t mocs =<br>
> -      is_render_target ? brw->blorp.mocs.rb : brw->blorp.mocs.tex;<br>
> +   const uint32_t mocs = is_render_target ? blorp->mocs.rb : blorp->mocs.tex;<br>
><br>
> -   isl_surf_fill_state(&brw->isl_<wbr>dev, state,<br>
> +   isl_surf_fill_state(blorp-><wbr>isl_dev, state,<br>
>                         .surf = &surf, .view = &surface->view,<br>
>                         .aux_surf = &surface->aux_surf, .aux_usage = aux_usage,<br>
>                         .mocs = mocs, .clear_color = surface->clear_color,<br>
>                         .x_offset_sa = surface->tile_x_sa,<br>
>                         .y_offset_sa = surface->tile_y_sa);<br>
><br>
> -   blorp_surface_reloc(brw, state_offset + ss_info.reloc_dw * 4,<br>
> +   blorp_surface_reloc(blorp, state_offset + ss_info.reloc_dw * 4,<br>
>                         surface->addr, 0);<br>
><br>
>     if (aux_usage != ISL_AUX_USAGE_NONE) {<br>
> @@ -1000,13 +1019,13 @@ blorp_emit_surface_state(<wbr>struct brw_context *brw,<br>
>         * surface buffer addresses are always 4K page alinged.<br>
>         */<br>
>        assert((surface->aux_addr.<wbr>offset & 0xfff) == 0);<br>
> -      blorp_surface_reloc(brw, state_offset + ss_info.aux_reloc_dw * 4,<br>
> +      blorp_surface_reloc(blorp, state_offset + ss_info.aux_reloc_dw * 4,<br>
>                            surface->aux_addr, state[ss_info.aux_reloc_dw]);<br>
>     }<br>
>  }<br>
><br>
>  static void<br>
> -blorp_emit_surface_states(<wbr>struct brw_context *brw,<br>
> +blorp_emit_surface_states(<wbr>struct blorp_batch batch,<br>
>                            const struct brw_blorp_params *params)<br>
>  {<br>
>     uint32_t bind_offset, *bind_map;<br>
> @@ -1016,24 +1035,24 @@ blorp_emit_surface_states(<wbr>struct brw_context *brw,<br>
>     const unsigned ss_align = GENX(RENDER_SURFACE_STATE_<wbr>length) > 8 ? 64 : 32;<br>
><br>
>     unsigned num_surfaces = 1 + (params->src.addr.buffer != NULL);<br>
> -   blorp_alloc_binding_table(&<wbr>brw->blorp, num_surfaces, ss_size, ss_align,<br>
> +   blorp_alloc_binding_table(<wbr>batch.blorp, num_surfaces, ss_size, ss_align,<br>
>                               &bind_offset, &bind_map, surface_maps);<br>
><br>
> -   blorp_emit_surface_state(brw, &params->dst,<br>
> +   blorp_emit_surface_state(<wbr>batch.blorp, &params->dst,<br>
>                              surface_maps[BLORP_<wbr>RENDERBUFFER_BT_INDEX],<br>
>                              bind_map[BLORP_RENDERBUFFER_<wbr>BT_INDEX], true);<br>
>     if (params->src.addr.buffer) {<br>
> -      blorp_emit_surface_state(brw, &params->src,<br>
> +      blorp_emit_surface_state(<wbr>batch.blorp, &params->src,<br>
>                                 surface_maps[BLORP_TEXTURE_BT_<wbr>INDEX],<br>
>                                 bind_map[BLORP_TEXTURE_BT_<wbr>INDEX], false);<br>
>     }<br>
><br>
>  #if GEN_GEN >= 7<br>
> -   blorp_emit(brw, GENX(3DSTATE_BINDING_TABLE_<wbr>POINTERS_PS), bt) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_BINDING_TABLE_<wbr>POINTERS_PS), bt) {<br>
>        bt.PointertoPSBindingTable = bind_offset;<br>
>     }<br>
>  #else<br>
> -   blorp_emit(brw, GENX(3DSTATE_BINDING_TABLE_<wbr>POINTERS), bt) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_BINDING_TABLE_<wbr>POINTERS), bt) {<br>
>        bt.PSBindingTableChange = true;<br>
>        bt.PointertoPSBindingTable = bind_offset;<br>
>     }<br>
> @@ -1041,7 +1060,7 @@ blorp_emit_surface_states(<wbr>struct brw_context *brw,<br>
>  }<br>
><br>
>  static void<br>
> -blorp_emit_sampler_state(<wbr>struct brw_context *brw,<br>
> +blorp_emit_sampler_state(<wbr>struct blorp_batch batch,<br>
>                           const struct brw_blorp_params *params)<br>
>  {<br>
>     struct GENX(SAMPLER_STATE) sampler = {<br>
> @@ -1064,18 +1083,18 @@ blorp_emit_sampler_state(<wbr>struct brw_context *brw,<br>
>     };<br>
><br>
>     uint32_t offset;<br>
> -   void *state = blorp_alloc_dynamic_state(&<wbr>brw->blorp,<br>
> +   void *state = blorp_alloc_dynamic_state(<wbr>batch.blorp,<br>
>                                             AUB_TRACE_SAMPLER_STATE,<br>
>                                             GENX(SAMPLER_STATE_length) * 4,<br>
>                                             32, &offset);<br>
>     GENX(SAMPLER_STATE_pack)(NULL, state, &sampler);<br>
><br>
>  #if GEN_GEN >= 7<br>
> -   blorp_emit(brw, GENX(3DSTATE_SAMPLER_STATE_<wbr>POINTERS_PS), ssp) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_SAMPLER_STATE_<wbr>POINTERS_PS), ssp) {<br>
>        ssp.PointertoPSSamplerState = offset;<br>
>     }<br>
>  #else<br>
> -   blorp_emit(brw, GENX(3DSTATE_SAMPLER_STATE_<wbr>POINTERS), ssp) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_SAMPLER_STATE_<wbr>POINTERS), ssp) {<br>
>        ssp.VSSamplerStateChange = true;<br>
>        ssp.GSSamplerStateChange = true;<br>
>        ssp.PSSamplerStateChange = true;<br>
> @@ -1086,28 +1105,28 @@ blorp_emit_sampler_state(<wbr>struct brw_context *brw,<br>
><br>
>  /* 3DSTATE_VIEWPORT_STATE_<wbr>POINTERS */<br>
>  static void<br>
> -blorp_emit_viewport_state(<wbr>struct brw_context *brw,<br>
> +blorp_emit_viewport_state(<wbr>struct blorp_batch batch,<br>
>                            const struct brw_blorp_params *params)<br>
>  {<br>
>     uint32_t cc_vp_offset;<br>
><br>
> -   void *state = blorp_alloc_dynamic_state(&<wbr>brw->blorp,<br>
> +   void *state = blorp_alloc_dynamic_state(<wbr>batch.blorp,<br>
>                                             AUB_TRACE_CC_VP_STATE,<br>
>                                             GENX(CC_VIEWPORT_length) * 4, 32,<br>
>                                             &cc_vp_offset);<br>
><br>
> -   GENX(CC_VIEWPORT_pack)(brw, state,<br>
> +   GENX(CC_VIEWPORT_pack)(&batch, state,<br>
>        &(struct GENX(CC_VIEWPORT)) {<br>
>           .MinimumDepth = 0.0,<br>
>           .MaximumDepth = 1.0,<br>
>        });<br>
><br>
>  #if GEN_GEN >= 7<br>
> -   blorp_emit(brw, GENX(3DSTATE_VIEWPORT_STATE_<wbr>POINTERS_CC), vsp) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_VIEWPORT_STATE_<wbr>POINTERS_CC), vsp) {<br>
>        vsp.CCViewportPointer = cc_vp_offset;<br>
>     }<br>
>  #else<br>
> -   blorp_emit(brw, GENX(3DSTATE_VIEWPORT_STATE_<wbr>POINTERS), vsp) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_VIEWPORT_STATE_<wbr>POINTERS), vsp) {<br>
>        vsp.CCViewportStateChange = true;<br>
>        vsp.PointertoCC_VIEWPORT = cc_vp_offset;<br>
>     }<br>
> @@ -1124,35 +1143,29 @@ blorp_emit_viewport_state(<wbr>struct brw_context *brw,<br>
>   *<br>
>   * This function alters no GL state.<br>
>   */<br>
> -void<br>
> -genX(blorp_exec)(struct brw_context *brw,<br>
> -                 const struct brw_blorp_params *params)<br>
> +static void<br>
> +blorp_exec(struct blorp_context *blorp, void *batch_data,<br>
> +           const struct brw_blorp_params *params)<br>
>  {<br>
> +   struct blorp_batch batch = {<br>
> +      .blorp = blorp,<br>
> +      .batch = batch_data,<br>
> +   };<br>
> +<br>
<br>
</div></div>I was sort of expecting the callers to provide an instance of blorp_batch<br>
instead of separate blorp_context and void*. Not a big deal though.<br></blockquote><div><br></div><div>I had already wrote a patch on the series that made that change and I like it better.  I've rebased and squashed it in (that was a pain).<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I read half-way through more carefully and skimmed the rest. I don't think<br>
this would even compile if you had an obvious mistake somewhere. So:<br>
<br>
Reviewed-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br></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">
>     uint32_t blend_state_offset = 0;<br>
>     uint32_t color_calc_state_offset = 0;<br>
>     uint32_t depth_stencil_state_offset;<br>
><br>
> -#if GEN_GEN == 6<br>
> -   /* Emit workaround flushes when we switch from drawing to blorping. */<br>
> -   brw_emit_post_sync_nonzero_<wbr>flush(brw);<br>
> -#endif<br>
> -<br>
> -   brw_upload_state_base_address(<wbr>brw);<br>
> -<br>
> -#if GEN_GEN >= 8<br>
> -   gen7_l3_state.emit(brw);<br>
> -#endif<br>
> -<br>
> -   blorp_emit_vertex_buffers(brw, params);<br>
> -   blorp_emit_vertex_elements(<wbr>brw, params);<br>
> +   blorp_emit_vertex_buffers(<wbr>batch, params);<br>
> +   blorp_emit_vertex_elements(<wbr>batch, params);<br>
><br>
> -   emit_urb_config(brw, params);<br>
> +   emit_urb_config(batch, params);<br>
><br>
>     if (params->wm_prog_data) {<br>
> -      blend_state_offset = blorp_emit_blend_state(brw, params);<br>
> -      color_calc_state_offset = blorp_emit_color_calc_state(<wbr>brw, params);<br>
> +      blend_state_offset = blorp_emit_blend_state(batch, params);<br>
> +      color_calc_state_offset = blorp_emit_color_calc_state(<wbr>batch, params);<br>
>     }<br>
> -   depth_stencil_state_offset = blorp_emit_depth_stencil_<wbr>state(brw, params);<br>
> +   depth_stencil_state_offset = blorp_emit_depth_stencil_<wbr>state(batch, params);<br>
><br>
>  #if GEN_GEN <= 6<br>
>     /* 3DSTATE_CC_STATE_POINTERS<br>
> @@ -1166,7 +1179,7 @@ genX(blorp_exec)(struct brw_context *brw,<br>
>      * gen7+.  However, on gen6 and earlier, they're all lumpped together in<br>
>      * one CC_STATE_POINTERS packet so we have to emit that here.<br>
>      */<br>
> -   blorp_emit(brw, GENX(3DSTATE_CC_STATE_<wbr>POINTERS), cc) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_CC_STATE_<wbr>POINTERS), cc) {<br>
>        cc.BLEND_STATEChange = true;<br>
>        cc.COLOR_CALC_STATEChange = true;<br>
>        cc.DEPTH_STENCIL_STATEChange = true;<br>
> @@ -1180,26 +1193,24 @@ genX(blorp_exec)(struct brw_context *brw,<br>
>     (void)depth_stencil_state_<wbr>offset;<br>
>  #endif<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_CONSTANT_VS), vs);<br>
> +   blorp_emit(batch, GENX(3DSTATE_CONSTANT_VS), vs);<br>
>  #if GEN_GEN >= 7<br>
> -   blorp_emit(brw, GENX(3DSTATE_CONSTANT_HS), hs);<br>
> -   blorp_emit(brw, GENX(3DSTATE_CONSTANT_DS), DS);<br>
> +   blorp_emit(batch, GENX(3DSTATE_CONSTANT_HS), hs);<br>
> +   blorp_emit(batch, GENX(3DSTATE_CONSTANT_DS), DS);<br>
>  #endif<br>
> -   blorp_emit(brw, GENX(3DSTATE_CONSTANT_GS), gs);<br>
> -   blorp_emit(brw, GENX(3DSTATE_CONSTANT_PS), ps);<br>
> -<br>
> -   if (brw->use_resource_streamer)<br>
> -      gen7_disable_hw_binding_<wbr>tables(brw);<br>
> +   blorp_emit(batch, GENX(3DSTATE_CONSTANT_GS), gs);<br>
> +   blorp_emit(batch, GENX(3DSTATE_CONSTANT_PS), ps);<br>
><br>
>     if (params->wm_prog_data)<br>
> -      blorp_emit_surface_states(brw, params);<br>
> +      blorp_emit_surface_states(<wbr>batch, params);<br>
><br>
>     if (params->src.addr.buffer)<br>
> -      blorp_emit_sampler_state(brw, params);<br>
> +      blorp_emit_sampler_state(<wbr>batch, params);<br>
><br>
> -   blorp_emit_3dstate_<wbr>multisample(brw, params->dst.surf.samples);<br>
> +   blorp_emit_3dstate_<wbr>multisample(batch.blorp, batch.batch,<br>
> +                                  params->dst.surf.samples);<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_SAMPLE_MASK), mask) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_SAMPLE_MASK), mask) {<br>
>        mask.SampleMask = (1 << params->dst.surf.samples) - 1;<br>
>     }<br>
><br>
> @@ -1213,35 +1224,33 @@ genX(blorp_exec)(struct brw_context *brw,<br>
>      *<br>
>      * We've already done one at the start of the BLORP operation.<br>
>      */<br>
> -   blorp_emit(brw, GENX(3DSTATE_VS), vs);<br>
> +   blorp_emit(batch, GENX(3DSTATE_VS), vs);<br>
>  #if GEN_GEN >= 7<br>
> -   blorp_emit(brw, GENX(3DSTATE_HS), hs);<br>
> -   blorp_emit(brw, GENX(3DSTATE_TE), te);<br>
> -   blorp_emit(brw, GENX(3DSTATE_DS), DS);<br>
> -   blorp_emit(brw, GENX(3DSTATE_STREAMOUT), so);<br>
> +   blorp_emit(batch, GENX(3DSTATE_HS), hs);<br>
> +   blorp_emit(batch, GENX(3DSTATE_TE), te);<br>
> +   blorp_emit(batch, GENX(3DSTATE_DS), DS);<br>
> +   blorp_emit(batch, GENX(3DSTATE_STREAMOUT), so);<br>
>  #endif<br>
> -   blorp_emit(brw, GENX(3DSTATE_GS), gs);<br>
> +   blorp_emit(batch, GENX(3DSTATE_GS), gs);<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_CLIP), clip) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_CLIP), clip) {<br>
>        clip.PerspectiveDivideDisable = true;<br>
>     }<br>
><br>
> -   blorp_emit_sf_config(brw, params);<br>
> -   blorp_emit_ps_config(brw, params);<br>
> +   blorp_emit_sf_config(batch, params);<br>
> +   blorp_emit_ps_config(batch, params);<br>
><br>
> -   blorp_emit_viewport_state(brw, params);<br>
> +   blorp_emit_viewport_state(<wbr>batch, params);<br>
><br>
>     if (params->depth.addr.buffer) {<br>
> -      blorp_emit_depth_stencil_<wbr>config(brw, params);<br>
> +      blorp_emit_depth_stencil_<wbr>config(batch, params);<br>
>     } else {<br>
> -      brw_emit_depth_stall_flushes(<wbr>brw);<br>
> -<br>
> -      blorp_emit(brw, GENX(3DSTATE_DEPTH_BUFFER), db) {<br>
> +      blorp_emit(batch, GENX(3DSTATE_DEPTH_BUFFER), db) {<br>
>           db.SurfaceType = SURFTYPE_NULL;<br>
>           db.SurfaceFormat = D32_FLOAT;<br>
>        }<br>
> -      blorp_emit(brw, GENX(3DSTATE_HIER_DEPTH_<wbr>BUFFER), hiz);<br>
> -      blorp_emit(brw, GENX(3DSTATE_STENCIL_BUFFER), sb);<br>
> +      blorp_emit(batch, GENX(3DSTATE_HIER_DEPTH_<wbr>BUFFER), hiz);<br>
> +      blorp_emit(batch, GENX(3DSTATE_STENCIL_BUFFER), sb);<br>
>     }<br>
><br>
>     /* 3DSTATE_CLEAR_PARAMS<br>
> @@ -1250,20 +1259,43 @@ genX(blorp_exec)(struct brw_context *brw,<br>
>      *   [DevSNB] 3DSTATE_CLEAR_PARAMS packet must follow the DEPTH_BUFFER_STATE<br>
>      *   packet when HiZ is enabled and the DEPTH_BUFFER_STATE changes.<br>
>      */<br>
> -   blorp_emit(brw, GENX(3DSTATE_CLEAR_PARAMS), clear) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_CLEAR_PARAMS), clear) {<br>
>        clear.DepthClearValueValid = true;<br>
>        clear.DepthClearValue = params->depth.clear_color.u32[<wbr>0];<br>
>     }<br>
><br>
> -   blorp_emit(brw, GENX(3DSTATE_DRAWING_<wbr>RECTANGLE), rect) {<br>
> +   blorp_emit(batch, GENX(3DSTATE_DRAWING_<wbr>RECTANGLE), rect) {<br>
>        rect.<wbr>ClippedDrawingRectangleXMax = MAX2(params->x1, params->x0) - 1;<br>
>        rect.<wbr>ClippedDrawingRectangleYMax = MAX2(params->y1, params->y0) - 1;<br>
>     }<br>
><br>
> -   blorp_emit(brw, GENX(3DPRIMITIVE), prim) {<br>
> +   blorp_emit(batch, GENX(3DPRIMITIVE), prim) {<br>
>        prim.VertexAccessType = SEQUENTIAL;<br>
>        prim.PrimitiveTopologyType = _3DPRIM_RECTLIST;<br>
>        prim.VertexCountPerInstance = 3;<br>
>        prim.InstanceCount = params->num_layers;<br>
>     }<br>
>  }<br>
> +<br>
> +void<br>
> +genX(blorp_exec)(struct brw_context *brw,<br>
> +                 const struct brw_blorp_params *params)<br>
> +{<br>
> +#if GEN_GEN == 6<br>
> +   /* Emit workaround flushes when we switch from drawing to blorping. */<br>
> +   brw_emit_post_sync_nonzero_<wbr>flush(brw);<br>
> +#endif<br>
> +<br>
> +   brw_upload_state_base_address(<wbr>brw);<br>
> +<br>
> +#if GEN_GEN >= 8<br>
> +   gen7_l3_state.emit(brw);<br>
> +#endif<br>
> +<br>
> +   if (brw->use_resource_streamer)<br>
> +      gen7_disable_hw_binding_<wbr>tables(brw);<br>
> +<br>
> +   brw_emit_depth_stall_flushes(<wbr>brw);<br>
> +<br>
> +   blorp_exec(&brw->blorp, brw, params);<br>
> +}<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>