<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 23, 2016 at 8:28 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:53AM -0700, Jason Ekstrand wrote:<br>
> ---<br>
>  src/mesa/drivers/dri/i965/<wbr>Makefile.sources  |   15 +-<br>
>  src/mesa/drivers/dri/i965/<wbr>blorp_priv.h      |    2 +-<br>
>  src/mesa/drivers/dri/i965/<wbr>genX_blorp_exec.c | 1113 +-------------------------<br>
>  src/mesa/drivers/dri/i965/<wbr>genX_blorp_exec.h | 1121 +++++++++++++++++++++++++++<br>
>  4 files changed, 1133 insertions(+), 1118 deletions(-)<br>
>  create mode 100644 src/mesa/drivers/dri/i965/<wbr>genX_blorp_exec.h<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>Makefile.sources b/src/mesa/drivers/dri/i965/<wbr>Makefile.sources<br>
> index 5ea7b96..c97486c 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>Makefile.sources<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>Makefile.sources<br>
> @@ -259,16 +259,21 @@ i965_FILES = \<br>
>       intel_upload.c<br>
><br>
>  i965_gen6_FILES = \<br>
> -     genX_blorp_exec.c<br>
> +     genX_blorp_exec.c \<br>
> +     genX_blorp_exec.h<br>
><br>
>  i965_gen7_FILES = \<br>
> -     genX_blorp_exec.c<br>
> +     genX_blorp_exec.c \<br>
> +     genX_blorp_exec.h<br>
><br>
>  i965_gen75_FILES = \<br>
> -     genX_blorp_exec.c<br>
> +     genX_blorp_exec.c \<br>
> +     genX_blorp_exec.h<br>
><br>
>  i965_gen8_FILES = \<br>
> -     genX_blorp_exec.c<br>
> +     genX_blorp_exec.c \<br>
> +     genX_blorp_exec.h<br>
><br>
>  i965_gen9_FILES = \<br>
> -     genX_blorp_exec.c<br>
> +     genX_blorp_exec.c \<br>
> +     genX_blorp_exec.h<br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>blorp_priv.h b/src/mesa/drivers/dri/i965/<wbr>blorp_priv.h<br>
> index 977f54d..9b987a8 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>blorp_priv.h<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>blorp_priv.h<br>
> @@ -141,7 +141,7 @@ struct brw_blorp_prog_data<br>
>      */<br>
>     uint32_t flat_inputs;<br>
>     unsigned num_varying_inputs;<br>
> -   GLbitfield64 inputs_read;<br>
> +   uint64_t inputs_read;<br>
>  };<br>
><br>
>  static inline unsigned<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 8c15b16..e07fa0a 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>
> @@ -29,9 +29,7 @@<br>
>  #include "brw_context.h"<br>
>  #include "brw_state.h"<br>
><br>
> -#include "blorp_priv.h"<br>
> -<br>
> -#include "genxml/gen_macros.h"<br>
> +#include "genX_blorp_exec.h"<br>
><br>
>  static void *<br>
>  blorp_emit_dwords(struct blorp_context *blorp, void *batch, unsigned n)<br>
> @@ -168,1115 +166,6 @@ blorp_emit_3dstate_<wbr>multisample(struct blorp_context *blorp, void *batch,<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 blorp_batch<br>
> -<br>
> -static uint64_t<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(batch->blorp, batch->batch,<br>
> -                              location, address, delta);<br>
> -   }<br>
> -}<br>
> -<br>
> -#include "genxml/genX_pack.h"<br>
> -<br>
> -#define _blorp_cmd_length(cmd) cmd ## _length<br>
> -#define _blorp_cmd_length_bias(cmd) cmd ## _length_bias<br>
> -#define _blorp_cmd_header(cmd) cmd ## _header<br>
> -#define _blorp_cmd_pack(cmd) cmd ## _pack<br>
> -<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.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>
> - * header the space requirement is as follows per vertex (in bytes):<br>
> - *<br>
> - *     Header    Position    Program constants<br>
> - *   +--------+------------+-------<wbr>------------+<br>
> - *   |   16   |     16     |      n x 16       |<br>
> - *   +--------+------------+-------<wbr>------------+<br>
> - *<br>
> - * where 'n' stands for number of varying inputs expressed as vec4s.<br>
> - *<br>
> - * The URB size is in turn expressed in 64 bytes (512 bits).<br>
> - */<br>
> -static inline unsigned<br>
> -gen7_blorp_get_vs_entry_size(<wbr>const struct brw_blorp_params *params)<br>
> -{<br>
> -    const unsigned num_varyings =<br>
> -       params->wm_prog_data ? params->wm_prog_data->num_<wbr>varying_inputs : 0;<br>
> -    const unsigned total_needed = 16 + 16 + num_varyings * 16;<br>
> -<br>
> -   return DIV_ROUND_UP(total_needed, 64);<br>
> -}<br>
> -<br>
> -/* 3DSTATE_URB<br>
> -/* 3DSTATE_URB_VS<br>
> - * 3DSTATE_URB_HS<br>
> - * 3DSTATE_URB_DS<br>
> - * 3DSTATE_URB_GS<br>
> - *<br>
> - * Assign the entire URB to the VS. Even though the VS disabled, URB space<br>
> - * is still needed because the clipper loads the VUE's from the URB. From<br>
> - * the Sandybridge PRM, Volume 2, Part 1, Section 3DSTATE,<br>
> - * Dword 1.15:0 "VS Number of URB Entries":<br>
> - *     This field is always used (even if VS Function Enable is DISABLED).<br>
> - *<br>
> - * The warning below appears in the PRM (Section 3DSTATE_URB), but we can<br>
> - * safely ignore it because this batch contains only one draw call.<br>
> - *     Because of URB corruption caused by allocating a previous GS unit<br>
</div></div>> - *     URB entry to the VS unit, software is required to send a ???GS NULL<br>
> - *     Fence??? (Send URB fence with VS URB size == 1 and GS URB size == 0)<br>
<span class="">> - *     plus a dummy DRAW call before any case where VS will be taking over<br>
> - *     GS URB space.<br>
<br>
</span>You are dropping all the documentation above.<br></blockquote><div><br></div><div>Yes, that was a rebase fail.  I've fixed it locally.<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">
> - *<br>
> - * If the 3DSTATE_URB_VS is emitted, than the others must be also.<br>
> - * From the Ivybridge PRM, Volume 2 Part 1, section 1.7.1 3DSTATE_URB_VS:<br>
> - *<br>
> - *     3DSTATE_URB_HS, 3DSTATE_URB_DS, and 3DSTATE_URB_GS must also be<br>
> - *     programmed in order for the programming of this state to be<br>
> - *     valid.<br>
> - */<br>
> -static void<br>
> -emit_urb_config(struct blorp_batch batch,<br>
> -                const struct brw_blorp_params *params)<br>
> -{<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 blorp_batch batch,<br>
> -                       const struct brw_blorp_params *params,<br>
> -                       struct blorp_address *addr,<br>
> -                       uint32_t *size)<br>
> -{<br>
> -   const float vertices[] = {<br>
> -      /* v0 */ (float)params->x0, (float)params->y1,<br>
> -      /* v1 */ (float)params->x1, (float)params->y1,<br>
> -      /* v2 */ (float)params->x0, (float)params->y0,<br>
> -   };<br>
> -<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 blorp_batch batch,<br>
> -                              const struct brw_blorp_params *params,<br>
> -                              struct blorp_address *addr,<br>
> -                              uint32_t *size)<br>
> -{<br>
> -   const unsigned vec4_size_in_bytes = 4 * sizeof(float);<br>
> -   const unsigned max_num_varyings =<br>
> -      DIV_ROUND_UP(sizeof(params-><wbr>wm_inputs), vec4_size_in_bytes);<br>
> -   const unsigned num_varyings = params->wm_prog_data->num_<wbr>varying_inputs;<br>
> -<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>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>
> -    * the vertex data buffer.<br>
> -    */<br>
> -   for (unsigned i = 0; i < max_num_varyings; i++) {<br>
> -      const gl_varying_slot attr = VARYING_SLOT_VAR0 + i;<br>
> -<br>
> -      if (!(params->wm_prog_data-><wbr>inputs_read & BITFIELD64_BIT(attr)))<br>
> -         continue;<br>
> -<br>
> -      memcpy(inputs, inputs_src + i * 4, vec4_size_in_bytes);<br>
> -<br>
> -      inputs += 4;<br>
> -   }<br>
> -}<br>
> -<br>
> -static void<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>
> -   memset(vb, 0, sizeof(vb));<br>
> -<br>
> -   unsigned num_buffers = 1;<br>
> -<br>
> -   uint32_t 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 = batch.blorp->mocs.vb;<br>
> -#if GEN_GEN >= 7<br>
> -   vb[0].AddressModifyEnable = true;<br>
> -#endif<br>
> -#if GEN_GEN >= 8<br>
> -   vb[0].BufferSize = size;<br>
> -#else<br>
> -   vb[0].BufferAccessType = VERTEXDATA;<br>
> -   vb[0].EndAddress = vb[0].BufferStartingAddress;<br>
> -   vb[0].EndAddress.offset += size - 1;<br>
> -#endif<br>
> -<br>
> -   if (params->wm_prog_data && params->wm_prog_data->num_<wbr>varying_inputs) {<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 = batch.blorp->mocs.vb;<br>
> -#if GEN_GEN >= 7<br>
> -      vb[1].AddressModifyEnable = true;<br>
> -#endif<br>
> -#if GEN_GEN >= 8<br>
> -      vb[1].BufferSize = size;<br>
> -#else<br>
> -      vb[1].BufferAccessType = INSTANCEDATA;<br>
> -      vb[1].EndAddress = vb[1].BufferStartingAddress;<br>
> -      vb[1].EndAddress.offset += size - 1;<br>
> -#endif<br>
> -      num_buffers++;<br>
> -   }<br>
> -<br>
> -   const unsigned num_dwords =<br>
> -      1 + GENX(VERTEX_BUFFER_STATE_<wbr>length) * num_buffers;<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>(&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 blorp_batch batch,<br>
> -                           const struct brw_blorp_params *params)<br>
> -{<br>
> -   const unsigned num_varyings =<br>
> -      params->wm_prog_data ? params->wm_prog_data->num_<wbr>varying_inputs : 0;<br>
> -   const unsigned num_elements = 2 + num_varyings;<br>
> -<br>
> -   struct GENX(VERTEX_ELEMENT_STATE) ve[num_elements];<br>
> -   memset(ve, 0, num_elements * sizeof(*ve));<br>
> -<br>
> -   /* Setup VBO for the rectangle primitive..<br>
> -    *<br>
> -    * A rectangle primitive (3DPRIM_RECTLIST) consists of only three<br>
> -    * vertices. The vertices reside in screen space with DirectX<br>
> -    * coordinates (that is, (0, 0) is the upper left corner).<br>
> -    *<br>
> -    *   v2 ------ implied<br>
> -    *    |        |<br>
> -    *    |        |<br>
> -    *   v0 ----- v1<br>
> -    *<br>
> -    * Since the VS is disabled, the clipper loads each VUE directly from<br>
> -    * the URB. This is controlled by the 3DSTATE_VERTEX_BUFFERS and<br>
> -    * 3DSTATE_VERTEX_ELEMENTS packets below. The VUE contents are as follows:<br>
> -    *   dw0: Reserved, MBZ.<br>
> -    *   dw1: Render Target Array Index. The HiZ op does not use indexed<br>
> -    *        vertices, so set the dword to 0.<br>
> -    *   dw2: Viewport Index. The HiZ op disables viewport mapping and<br>
> -    *        scissoring, so set the dword to 0.<br>
> -    *   dw3: Point Width: The HiZ op does not emit the POINTLIST primitive,<br>
> -    *        so set the dword to 0.<br>
> -    *   dw4: Vertex Position X.<br>
> -    *   dw5: Vertex Position Y.<br>
> -    *   dw6: Vertex Position Z.<br>
> -    *   dw7: Vertex Position W.<br>
> -    *<br>
> -    *   dw8: Flat vertex input 0<br>
> -    *   dw9: Flat vertex input 1<br>
> -    *   ...<br>
> -    *   dwn: Flat vertex input n - 8<br>
> -    *<br>
> -    * For details, see the Sandybridge PRM, Volume 2, Part 1, Section 1.5.1<br>
> -    * "Vertex URB Entry (VUE) Formats".<br>
> -    *<br>
> -    * Only vertex position X and Y are going to be variable, Z is fixed to<br>
> -    * zero and W to one. Header words dw0-3 are all zero. There is no need to<br>
> -    * include the fixed values in the vertex buffer. Vertex fetcher can be<br>
> -    * instructed to fill vertex elements with constant values of one and zero<br>
> -    * instead of reading them from the buffer.<br>
> -    * Flat inputs are program constants that are not interpolated. Moreover<br>
> -    * their values will be the same between vertices.<br>
> -    *<br>
> -    * See the vertex element setup below.<br>
> -    */<br>
> -   ve[0].VertexBufferIndex = 0;<br>
> -   ve[0].Valid = true;<br>
> -   ve[0].SourceElementFormat = ISL_FORMAT_R32G32B32A32_FLOAT;<br>
> -   ve[0].SourceElementOffset = 0;<br>
> -   ve[0].Component0Control = VFCOMP_STORE_0;<br>
> -   ve[0].Component1Control = VFCOMP_STORE_0;<br>
> -   ve[0].Component2Control = VFCOMP_STORE_0;<br>
> -   ve[0].Component3Control = VFCOMP_STORE_0;<br>
> -<br>
> -   ve[1].VertexBufferIndex = 0;<br>
> -   ve[1].Valid = true;<br>
> -   ve[1].SourceElementFormat = ISL_FORMAT_R32G32_FLOAT;<br>
> -   ve[1].SourceElementOffset = 0;<br>
> -   ve[1].Component0Control = VFCOMP_STORE_SRC;<br>
> -   ve[1].Component1Control = VFCOMP_STORE_SRC;<br>
> -   ve[1].Component2Control = VFCOMP_STORE_0;<br>
> -   ve[1].Component3Control = VFCOMP_STORE_1_FP;<br>
> -<br>
> -   for (unsigned i = 0; i < num_varyings; ++i) {<br>
> -      ve[i + 2].VertexBufferIndex = 1;<br>
> -      ve[i + 2].Valid = true;<br>
> -      ve[i + 2].SourceElementFormat = ISL_FORMAT_R32G32B32A32_FLOAT;<br>
> -      ve[i + 2].SourceElementOffset = i * 4 * sizeof(float);<br>
> -      ve[i + 2].Component0Control = VFCOMP_STORE_SRC;<br>
> -      ve[i + 2].Component1Control = VFCOMP_STORE_SRC;<br>
> -      ve[i + 2].Component2Control = VFCOMP_STORE_SRC;<br>
> -      ve[i + 2].Component3Control = VFCOMP_STORE_SRC;<br>
> -   }<br>
> -<br>
> -   const unsigned num_dwords =<br>
> -      1 + GENX(VERTEX_ELEMENT_STATE_<wbr>length) * num_elements;<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)(&batch, dw, &ve[i]);<br>
> -      dw += GENX(VERTEX_ELEMENT_STATE_<wbr>length);<br>
> -   }<br>
> -<br>
> -#if GEN_GEN >= 8<br>
> -   blorp_emit(batch, GENX(3DSTATE_VF_SGVS), sgvs);<br>
> -<br>
> -   for (unsigned i = 0; i < num_elements; i++) {<br>
> -      blorp_emit(batch, GENX(3DSTATE_VF_INSTANCING), vf) {<br>
> -         vf.VertexElementIndex = i;<br>
> -         vf.InstancingEnable = false;<br>
> -      }<br>
> -   }<br>
> -<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 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>
> -<br>
> -   /* 3DSTATE_SF<br>
> -    *<br>
> -    * Disable ViewportTransformEnable (dw2.1)<br>
> -    *<br>
> -    * From the SandyBridge PRM, Volume 2, Part 1, Section 1.3, "3D<br>
> -    * Primitives Overview":<br>
> -    *     RECTLIST: Viewport Mapping must be DISABLED (as is typical with the<br>
> -    *     use of screen- space coordinates).<br>
> -    *<br>
> -    * A solid rectangle must be rendered, so set FrontFaceFillMode (dw2.4:3)<br>
> -    * and BackFaceFillMode (dw2.5:6) to SOLID(0).<br>
> -    *<br>
> -    * From the Sandy Bridge PRM, Volume 2, Part 1, Section<br>
> -    * 6.4.1.1 3DSTATE_SF, Field FrontFaceFillMode:<br>
> -    *     SOLID: Any triangle or rectangle object found to be front-facing<br>
> -    *     is rendered as a solid object. This setting is required when<br>
> -    *     (rendering rectangle (RECTLIST) objects.<br>
> -    */<br>
<br>
</div></div>And all this.<br>
<div><div class="h5"><br>
> -<br>
> -#if GEN_GEN >= 8<br>
> -<br>
> -   blorp_emit(batch, GENX(3DSTATE_SF), sf);<br>
> -<br>
> -   blorp_emit(batch, GENX(3DSTATE_RASTER), raster) {<br>
> -      raster.CullMode = CULLMODE_NONE;<br>
> -   }<br>
> -<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>
> -      sbe.<wbr>ForceVertexURBEntryReadLength = true;<br>
> -      sbe.<wbr>ForceVertexURBEntryReadOffset = true;<br>
> -      sbe.<wbr>ConstantInterpolationEnable = prog_data->flat_inputs;<br>
> -<br>
> -#if GEN_GEN >= 9<br>
> -      for (unsigned i = 0; i < 32; i++)<br>
> -         sbe.<wbr>AttributeActiveComponentFormat<wbr>[i] = ACF_XYZW;<br>
> -#endif<br>
> -   }<br>
> -<br>
> -#elif GEN_GEN >= 7<br>
> -<br>
> -   blorp_emit(batch, GENX(3DSTATE_SF), sf) {<br>
> -      sf.FrontFaceFillMode = FILL_MODE_SOLID;<br>
> -      sf.BackFaceFillMode = FILL_MODE_SOLID;<br>
> -<br>
> -      sf.<wbr>MultisampleRasterizationMode = params->dst.surf.samples > 1 ?<br>
> -         MSRASTMODE_ON_PATTERN : MSRASTMODE_OFF_PIXEL;<br>
> -<br>
> -#if GEN_GEN == 7<br>
> -      sf.DepthBufferSurfaceFormat = params->depth_format;<br>
> -#endif<br>
> -   }<br>
> -<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>
> -         sbe.VertexURBEntryReadLength = brw_blorp_get_urb_length(prog_<wbr>data);<br>
> -         sbe.<wbr>ConstantInterpolationEnable = prog_data->flat_inputs;<br>
> -      } else {<br>
> -         sbe.NumberofSFOutputAttributes = 0;<br>
> -         sbe.VertexURBEntryReadLength = 1;<br>
> -      }<br>
> -   }<br>
> -<br>
> -#else /* GEN_GEN <= 6 */<br>
> -<br>
> -   blorp_emit(batch, GENX(3DSTATE_SF), sf) {<br>
> -      sf.FrontFaceFillMode = FILL_MODE_SOLID;<br>
> -      sf.BackFaceFillMode = FILL_MODE_SOLID;<br>
> -<br>
> -      sf.<wbr>MultisampleRasterizationMode = params->dst.surf.samples > 1 ?<br>
> -         MSRASTMODE_ON_PATTERN : MSRASTMODE_OFF_PIXEL;<br>
> -<br>
> -      sf.VertexURBEntryReadOffset = BRW_SF_URB_ENTRY_READ_OFFSET;<br>
> -      if (prog_data) {<br>
> -         sf.NumberofSFOutputAttributes = prog_data->num_varying_inputs;<br>
> -         sf.VertexURBEntryReadLength = brw_blorp_get_urb_length(prog_<wbr>data);<br>
> -         sf.ConstantInterpolationEnable = prog_data->flat_inputs;<br>
> -      } else {<br>
> -         sf.NumberofSFOutputAttributes = 0;<br>
> -         sf.VertexURBEntryReadLength = 1;<br>
> -      }<br>
> -   }<br>
> -<br>
> -#endif /* GEN_GEN */<br>
> -}<br>
> -<br>
> -static void<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>
> -<br>
> -   /* Even when thread dispatch is disabled, max threads (dw5.25:31) must be<br>
> -    * nonzero to prevent the GPU from hanging.  While the documentation doesn't<br>
> -    * mention this explicitly, it notes that the valid range for the field is<br>
> -    * [1,39] = [2,40] threads, which excludes zero.<br>
> -    *<br>
> -    * To be safe (and to minimize extraneous code) we go ahead and fully<br>
> -    * configure the WM state whether or not there is a WM program.<br>
> -    */<br>
<br>
</div></div>And here.<br>
<div><div class="h5"><br>
> -<br>
> -#if GEN_GEN >= 8<br>
> -<br>
> -   blorp_emit(batch, GENX(3DSTATE_WM), wm);<br>
> -<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>
> -      } else {<br>
> -         ps.BindingTableEntryCount = 1;<br>
> -      }<br>
> -<br>
> -      ps.<wbr>DispatchGRFStartRegisterForCon<wbr>stantSetupData0 =<br>
> -         prog_data->first_curbe_grf_0;<br>
> -      ps.<wbr>DispatchGRFStartRegisterForCon<wbr>stantSetupData2 =<br>
> -         prog_data->first_curbe_grf_2;<br>
> -<br>
> -      ps._8PixelDispatchEnable = prog_data->dispatch_8;<br>
> -      ps._16PixelDispatchEnable = prog_data->dispatch_16;<br>
> -<br>
> -      ps.KernelStartPointer0 = params->wm_prog_kernel;<br>
> -      ps.KernelStartPointer2 =<br>
> -         params->wm_prog_kernel + prog_data->ksp_offset_2;<br>
> -<br>
> -      /* 3DSTATE_PS expects the number of threads per PSD, which is always 64;<br>
> -       * it implicitly scales for different GT levels (which have some # of<br>
> -       * PSDs).<br>
> -       *<br>
> -       * In Gen8 the format is U8-2 whereas in Gen9 it is U8-1.<br>
> -       */<br>
> -      if (GEN_GEN >= 9)<br>
> -         ps.<wbr>MaximumNumberofThreadsPerPSD = 64 - 1;<br>
> -      else<br>
> -         ps.<wbr>MaximumNumberofThreadsPerPSD = 64 - 2;<br>
> -<br>
> -      switch (params->fast_clear_op) {<br>
> -#if GEN_GEN >= 9<br>
> -      case (1 << 6): /* GEN7_PS_RENDER_TARGET_RESOLVE_<wbr>ENABLE */<br>
> -         ps.RenderTargetResolveType = RESOLVE_PARTIAL;<br>
> -         break;<br>
> -      case (3 << 6): /* GEN9_PS_RENDER_TARGET_RESOLVE_<wbr>FULL */<br>
> -         ps.RenderTargetResolveType = RESOLVE_FULL;<br>
> -         break;<br>
> -#else<br>
> -      case (1 << 6): /* GEN7_PS_RENDER_TARGET_RESOLVE_<wbr>ENABLE */<br>
> -         ps.RenderTargetResolveEnable = true;<br>
> -         break;<br>
> -#endif<br>
> -      case (1 << 8): /* GEN7_PS_RENDER_TARGET_FAST_<wbr>CLEAR_ENABLE */<br>
> -         ps.RenderTargetFastClearEnable = true;<br>
> -         break;<br>
> -      }<br>
> -   }<br>
> -<br>
> -   blorp_emit(batch, GENX(3DSTATE_PS_EXTRA), psx) {<br>
> -      psx.PixelShaderValid = true;<br>
> -<br>
> -      if (params->src.addr.buffer)<br>
> -         psx.PixelShaderKillsPixel = true;<br>
> -<br>
> -      psx.AttributeEnable = prog_data->num_varying_inputs > 0;<br>
> -<br>
> -      if (prog_data && prog_data->persample_msaa_<wbr>dispatch)<br>
> -         psx.PixelShaderIsPerSample = true;<br>
> -   }<br>
> -<br>
> -#elif GEN_GEN >= 7<br>
> -<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>
> -         break;<br>
> -      case GEN6_HIZ_OP_DEPTH_RESOLVE:<br>
> -         wm.DepthBufferResolveEnable = true;<br>
> -         break;<br>
> -      case GEN6_HIZ_OP_HIZ_RESOLVE:<br>
> -         wm.<wbr>HierarchicalDepthBufferResolve<wbr>Enable = true;<br>
> -         break;<br>
> -      case GEN6_HIZ_OP_NONE:<br>
> -         break;<br>
> -      default:<br>
> -         unreachable("not reached");<br>
> -      }<br>
> -<br>
> -      if (prog_data)<br>
> -         wm.ThreadDispatchEnable = true;<br>
> -<br>
> -      if (params->src.addr.buffer)<br>
> -         wm.PixelShaderKillPixel = true;<br>
> -<br>
> -      if (params->dst.surf.samples > 1) {<br>
> -         wm.<wbr>MultisampleRasterizationMode = MSRASTMODE_ON_PATTERN;<br>
> -         wm.MultisampleDispatchMode =<br>
> -            (prog_data && prog_data->persample_msaa_<wbr>dispatch) ?<br>
> -            MSDISPMODE_PERSAMPLE : MSDISPMODE_PERPIXEL;<br>
> -      } else {<br>
> -         wm.<wbr>MultisampleRasterizationMode = MSRASTMODE_OFF_PIXEL;<br>
> -         wm.MultisampleDispatchMode = MSDISPMODE_PERSAMPLE;<br>
> -      }<br>
> -   }<br>
> -<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>
> -#endif<br>
> -<br>
> -      if (prog_data) {<br>
> -         ps.<wbr>DispatchGRFStartRegisterforCon<wbr>stantSetupData0 =<br>
> -            prog_data->first_curbe_grf_0;<br>
> -         ps.<wbr>DispatchGRFStartRegisterforCon<wbr>stantSetupData2 =<br>
> -            prog_data->first_curbe_grf_2;<br>
> -<br>
> -         ps.KernelStartPointer0 = params->wm_prog_kernel;<br>
> -         ps.KernelStartPointer2 =<br>
> -            params->wm_prog_kernel + prog_data->ksp_offset_2;<br>
> -<br>
> -         ps._8PixelDispatchEnable = prog_data->dispatch_8;<br>
> -         ps._16PixelDispatchEnable = prog_data->dispatch_16;<br>
> -<br>
> -         ps.AttributeEnable = prog_data->num_varying_inputs > 0;<br>
> -      } else {<br>
> -         /* Gen7 hardware gets angry if we don't enable at least one dispatch<br>
> -          * mode, so just enable 16-pixel dispatch if we don't have a program.<br>
> -          */<br>
> -         ps._16PixelDispatchEnable = true;<br>
> -      }<br>
> -<br>
> -      if (params->src.addr.buffer)<br>
> -         ps.SamplerCount = 1; /* Up to 4 samplers */<br>
> -<br>
> -      switch (params->fast_clear_op) {<br>
> -      case (1 << 6): /* GEN7_PS_RENDER_TARGET_RESOLVE_<wbr>ENABLE */<br>
> -         ps.RenderTargetResolveEnable = true;<br>
> -         break;<br>
> -      case (1 << 8): /* GEN7_PS_RENDER_TARGET_FAST_<wbr>CLEAR_ENABLE */<br>
> -         ps.RenderTargetFastClearEnable = true;<br>
> -         break;<br>
> -      }<br>
> -   }<br>
> -<br>
> -#else /* GEN_GEN <= 6 */<br>
> -<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>
> -         wm.DepthBufferClear = true;<br>
> -         break;<br>
> -      case GEN6_HIZ_OP_DEPTH_RESOLVE:<br>
> -         wm.DepthBufferResolveEnable = true;<br>
> -         break;<br>
> -      case GEN6_HIZ_OP_HIZ_RESOLVE:<br>
> -         wm.<wbr>HierarchicalDepthBufferResolve<wbr>Enable = true;<br>
> -         break;<br>
> -      case GEN6_HIZ_OP_NONE:<br>
> -         break;<br>
> -      default:<br>
> -         unreachable("not reached");<br>
> -      }<br>
> -<br>
> -      if (prog_data) {<br>
> -         wm.ThreadDispatchEnable = true;<br>
> -<br>
> -         wm.<wbr>DispatchGRFStartRegisterforCon<wbr>stantSetupData0 =<br>
> -            prog_data->first_curbe_grf_0;<br>
> -         wm.<wbr>DispatchGRFStartRegisterforCon<wbr>stantSetupData2 =<br>
> -            prog_data->first_curbe_grf_2;<br>
> -<br>
> -         wm.KernelStartPointer0 = params->wm_prog_kernel;<br>
> -         wm.KernelStartPointer2 =<br>
> -            params->wm_prog_kernel + prog_data->ksp_offset_2;<br>
> -<br>
> -         wm._8PixelDispatchEnable = prog_data->dispatch_8;<br>
> -         wm._16PixelDispatchEnable = prog_data->dispatch_16;<br>
> -<br>
> -         wm.NumberofSFOutputAttributes = prog_data->num_varying_inputs;<br>
> -      }<br>
> -<br>
> -      if (params->src.addr.buffer) {<br>
> -         wm.SamplerCount = 1; /* Up to 4 samplers */<br>
> -         wm.PixelShaderKillPixel = true; /* TODO: temporarily smash on */<br>
> -      }<br>
> -<br>
> -      if (params->dst.surf.samples > 1) {<br>
> -         wm.<wbr>MultisampleRasterizationMode = MSRASTMODE_ON_PATTERN;<br>
> -         wm.MultisampleDispatchMode =<br>
> -            (prog_data && prog_data->persample_msaa_<wbr>dispatch) ?<br>
> -            MSDISPMODE_PERSAMPLE : MSDISPMODE_PERPIXEL;<br>
> -      } else {<br>
> -         wm.<wbr>MultisampleRasterizationMode = MSRASTMODE_OFF_PIXEL;<br>
> -         wm.MultisampleDispatchMode = MSDISPMODE_PERSAMPLE;<br>
> -      }<br>
> -   }<br>
> -<br>
> -#endif /* GEN_GEN */<br>
> -}<br>
> -<br>
> -<br>
> -static void<br>
> -blorp_emit_depth_stencil_<wbr>config(struct blorp_batch batch,<br>
> -                                const struct brw_blorp_params *params)<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(batch, GENX(3DSTATE_DEPTH_BUFFER), db) {<br>
> -      switch (params->depth.surf.dim) {<br>
> -      case ISL_SURF_DIM_1D:<br>
> -         db.SurfaceType = SURFTYPE_1D;<br>
> -         break;<br>
> -      case ISL_SURF_DIM_2D:<br>
> -         db.SurfaceType = SURFTYPE_2D;<br>
> -         break;<br>
> -      case ISL_SURF_DIM_3D:<br>
> -         db.SurfaceType = SURFTYPE_3D;<br>
> -         break;<br>
> -      }<br>
> -<br>
> -      db.SurfaceFormat = params->depth_format;<br>
> -<br>
> -#if GEN_GEN >= 7<br>
> -      db.DepthWriteEnable = true;<br>
> -#endif<br>
> -<br>
> -#if GEN_GEN <= 6<br>
> -      db.TiledSurface = true;<br>
> -      db.TileWalk = TILEWALK_YMAJOR;<br>
> -      db.MIPMapLayoutMode = MIPLAYOUT_BELOW;<br>
> -      db.SeparateStencilBufferEnable = true;<br>
> -#endif<br>
> -<br>
> -      db.<wbr>HierarchicalDepthBufferEnable = true;<br>
> -<br>
> -      db.Width = params->depth.surf.logical_<wbr>level0_px.width - 1;<br>
> -      db.Height = params->depth.surf.logical_<wbr>level0_px.height - 1;<br>
> -      db.RenderTargetViewExtent = db.Depth =<br>
> -         MAX2(params->depth.surf.<wbr>logical_level0_px.depth,<br>
> -              params->depth.surf.logical_<wbr>level0_px.array_len) - 1;<br>
> -<br>
> -      db.LOD = params->depth.view.base_level;<br>
> -      db.MinimumArrayElement = params->depth.view.base_array_<wbr>layer;<br>
> -<br>
> -      db.SurfacePitch = params->depth.surf.row_pitch - 1;<br>
> -      db.SurfaceBaseAddress = params->depth.addr;<br>
> -      db.DepthBufferMOCS = mocs;<br>
> -   }<br>
> -<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(batch, GENX(3DSTATE_STENCIL_BUFFER), sb);<br>
> -}<br>
> -<br>
> -static uint32_t<br>
> -blorp_emit_blend_state(struct blorp_batch batch,<br>
> -                       const struct brw_blorp_params *params)<br>
> -{<br>
> -   struct GENX(BLEND_STATE) blend;<br>
> -   memset(&blend, 0, sizeof(blend));<br>
> -<br>
> -   for (unsigned i = 0; i < params->num_draw_buffers; ++i) {<br>
> -      blend.Entry[i].<wbr>PreBlendColorClampEnable = true;<br>
> -      blend.Entry[i].<wbr>PostBlendColorClampEnable = true;<br>
> -      blend.Entry[i].ColorClampRange = COLORCLAMP_RTFORMAT;<br>
> -<br>
> -      blend.Entry[i].WriteDisableRed = params->color_write_disable[0]<wbr>;<br>
> -      blend.Entry[i].<wbr>WriteDisableGreen = params->color_write_disable[1]<wbr>;<br>
> -      blend.Entry[i].<wbr>WriteDisableBlue = params->color_write_disable[2]<wbr>;<br>
> -      blend.Entry[i].<wbr>WriteDisableAlpha = params->color_write_disable[3]<wbr>;<br>
> -   }<br>
> -<br>
> -   uint32_t offset;<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(batch, GENX(3DSTATE_BLEND_STATE_<wbr>POINTERS), sp) {<br>
> -      sp.BlendStatePointer = offset;<br>
> -#if GEN_GEN >= 8<br>
> -      sp.BlendStatePointerValid = true;<br>
> -#endif<br>
> -   }<br>
> -#endif<br>
> -<br>
> -#if GEN_GEN >= 8<br>
> -   blorp_emit(batch, GENX(3DSTATE_PS_BLEND), ps_blend) {<br>
> -      ps_blend.HasWriteableRT = true;<br>
> -   }<br>
> -#endif<br>
> -<br>
> -   return offset;<br>
> -}<br>
> -<br>
> -static uint32_t<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>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(batch, GENX(3DSTATE_CC_STATE_<wbr>POINTERS), sp) {<br>
> -      sp.ColorCalcStatePointer = offset;<br>
> -#if GEN_GEN >= 8<br>
> -      sp.ColorCalcStatePointerValid = true;<br>
> -#endif<br>
> -   }<br>
> -#endif<br>
> -<br>
> -   return offset;<br>
> -}<br>
> -<br>
> -static uint32_t<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(batch, GENX(3DSTATE_WM_DEPTH_STENCIL)<wbr>, ds);<br>
> -   return 0;<br>
> -<br>
> -#else /* GEN_GEN <= 7 */<br>
> -<br>
> -   /* See the following sections of the Sandy Bridge PRM, Volume 1, Part2:<br>
> -    *   - 7.5.3.1 Depth Buffer Clear<br>
> -    *   - 7.5.3.2 Depth Buffer Resolve<br>
> -    *   - 7.5.3.3 Hierarchical Depth Buffer Resolve<br>
> -    */<br>
> -   struct GENX(DEPTH_STENCIL_STATE) ds = {<br>
> -      .DepthBufferWriteEnable = true,<br>
> -   };<br>
> -<br>
> -   if (params->hiz_op == GEN6_HIZ_OP_DEPTH_RESOLVE) {<br>
> -      ds.DepthTestEnable = true;<br>
> -      ds.DepthTestFunction = COMPAREFUNCTION_NEVER;<br>
> -   }<br>
> -<br>
> -   uint32_t offset;<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(batch, GENX(3DSTATE_DEPTH_STENCIL_<wbr>STATE_POINTERS), sp) {<br>
> -      sp.PointertoDEPTH_STENCIL_<wbr>STATE = offset;<br>
> -   }<br>
> -#endif<br>
> -<br>
> -   return offset;<br>
> -<br>
> -#endif /* GEN_GEN */<br>
> -}<br>
> -<br>
> -struct surface_state_info {<br>
> -   unsigned num_dwords;<br>
> -   unsigned ss_align; /* Required alignment of RENDER_SURFACE_STATE in bytes */<br>
> -   unsigned reloc_dw;<br>
> -   unsigned aux_reloc_dw;<br>
> -};<br>
> -<br>
> -static const struct surface_state_info surface_state_infos[] = {<br>
> -   [6] = {6,  32, 1,  0},<br>
> -   [7] = {8,  32, 1,  6},<br>
> -   [8] = {13, 64, 8,  10},<br>
> -   [9] = {16, 64, 8,  10},<br>
> -};<br>
> -<br>
> -static void<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[GEN_GEN];<br>
> -<br>
> -   struct isl_surf surf = surface->surf;<br>
> -<br>
> -   if (surf.dim == ISL_SURF_DIM_1D &&<br>
> -       surf.dim_layout == ISL_DIM_LAYOUT_GEN4_2D) {<br>
> -      assert(surf.logical_level0_px.<wbr>height == 1);<br>
> -      surf.dim = ISL_SURF_DIM_2D;<br>
> -   }<br>
> -<br>
> -   /* Blorp doesn't support HiZ in any of the blit or slow-clear paths */<br>
> -   enum isl_aux_usage aux_usage = surface->aux_usage;<br>
> -   if (aux_usage == ISL_AUX_USAGE_HIZ)<br>
> -      aux_usage = ISL_AUX_USAGE_NONE;<br>
> -<br>
> -   const uint32_t mocs = is_render_target ? blorp->mocs.rb : blorp->mocs.tex;<br>
> -<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(blorp, state_offset + ss_info.reloc_dw * 4,<br>
> -                       surface->addr, 0);<br>
> -<br>
> -   if (aux_usage != ISL_AUX_USAGE_NONE) {<br>
> -      /* On gen7 and prior, the bottom 12 bits of the MCS base address are<br>
> -       * used to store other information.  This should be ok, however, because<br>
> -       * surface buffer addresses are always 4K page alinged.<br>
> -       */<br>
> -      assert((surface->aux_addr.<wbr>offset & 0xfff) == 0);<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 blorp_batch batch,<br>
> -                          const struct brw_blorp_params *params)<br>
> -{<br>
> -   uint32_t bind_offset, *bind_map;<br>
> -   void *surface_maps[2];<br>
> -<br>
> -   const unsigned ss_size = GENX(RENDER_SURFACE_STATE_<wbr>length) * 4;<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>batch.blorp, num_surfaces, ss_size, ss_align,<br>
> -                             &bind_offset, &bind_map, surface_maps);<br>
> -<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(<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(batch, GENX(3DSTATE_BINDING_TABLE_<wbr>POINTERS_PS), bt) {<br>
> -      bt.PointertoPSBindingTable = bind_offset;<br>
> -   }<br>
> -#else<br>
> -   blorp_emit(batch, GENX(3DSTATE_BINDING_TABLE_<wbr>POINTERS), bt) {<br>
> -      bt.PSBindingTableChange = true;<br>
> -      bt.PointertoPSBindingTable = bind_offset;<br>
> -   }<br>
> -#endif<br>
> -}<br>
> -<br>
> -static void<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>
> -      .MipModeFilter = MIPFILTER_NONE,<br>
> -      .MagModeFilter = MAPFILTER_LINEAR,<br>
> -      .MinModeFilter = MAPFILTER_LINEAR,<br>
> -      .MinLOD = 0,<br>
> -      .MaxLOD = 0,<br>
> -      .TCXAddressControlMode = TCM_CLAMP,<br>
> -      .TCYAddressControlMode = TCM_CLAMP,<br>
> -      .TCZAddressControlMode = TCM_CLAMP,<br>
> -      .MaximumAnisotropy = RATIO21,<br>
> -      .<wbr>RAddressMinFilterRoundingEnabl<wbr>e = true,<br>
> -      .<wbr>RAddressMagFilterRoundingEnabl<wbr>e = true,<br>
> -      .<wbr>VAddressMinFilterRoundingEnabl<wbr>e = true,<br>
> -      .<wbr>VAddressMagFilterRoundingEnabl<wbr>e = true,<br>
> -      .<wbr>UAddressMinFilterRoundingEnabl<wbr>e = true,<br>
> -      .<wbr>UAddressMagFilterRoundingEnabl<wbr>e = true,<br>
> -      .NonnormalizedCoordinateEnable = true,<br>
> -   };<br>
> -<br>
> -   uint32_t offset;<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(batch, GENX(3DSTATE_SAMPLER_STATE_<wbr>POINTERS_PS), ssp) {<br>
> -      ssp.PointertoPSSamplerState = offset;<br>
> -   }<br>
> -#else<br>
> -   blorp_emit(batch, GENX(3DSTATE_SAMPLER_STATE_<wbr>POINTERS), ssp) {<br>
> -      ssp.VSSamplerStateChange = true;<br>
> -      ssp.GSSamplerStateChange = true;<br>
> -      ssp.PSSamplerStateChange = true;<br>
> -      ssp.PointertoPSSamplerState = offset;<br>
> -   }<br>
> -#endif<br>
> -}<br>
> -<br>
> -/* 3DSTATE_VIEWPORT_STATE_<wbr>POINTERS */<br>
> -static void<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>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)(&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(batch, GENX(3DSTATE_VIEWPORT_STATE_<wbr>POINTERS_CC), vsp) {<br>
> -      vsp.CCViewportPointer = cc_vp_offset;<br>
> -   }<br>
> -#else<br>
> -   blorp_emit(batch, GENX(3DSTATE_VIEWPORT_STATE_<wbr>POINTERS), vsp) {<br>
> -      vsp.CCViewportStateChange = true;<br>
> -      vsp.PointertoCC_VIEWPORT = cc_vp_offset;<br>
> -   }<br>
> -#endif<br>
> -}<br>
> -<br>
> -<br>
> -/**<br>
> - * \brief Execute a blit or render pass operation.<br>
> - *<br>
> - * To execute the operation, this function manually constructs and emits a<br>
> - * batch to draw a rectangle primitive. The batchbuffer is flushed before<br>
> - * constructing and after emitting the batch.<br>
> - *<br>
> - * This function alters no GL state.<br>
> - */<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>
> -   uint32_t blend_state_offset = 0;<br>
> -   uint32_t color_calc_state_offset = 0;<br>
> -   uint32_t depth_stencil_state_offset;<br>
> -<br>
> -   blorp_emit_vertex_buffers(<wbr>batch, params);<br>
> -   blorp_emit_vertex_elements(<wbr>batch, params);<br>
> -<br>
> -   emit_urb_config(batch, params);<br>
> -<br>
> -   if (params->wm_prog_data) {<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(batch, params);<br>
> -<br>
> -#if GEN_GEN <= 6<br>
> -   /* 3DSTATE_CC_STATE_POINTERS<br>
> -    *<br>
> -    * The pointer offsets are relative to<br>
> -    * CMD_STATE_BASE_ADDRESS.<wbr>DynamicStateBaseAddress.<br>
> -    *<br>
> -    * The HiZ op doesn't use BLEND_STATE or COLOR_CALC_STATE.<br>
<br>
</div></div>Here also.<br>
<div><div class="h5"><br>
> -    *<br>
> -    * The dynamic state emit helpers emit their own STATE_POINTERS packets on<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(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>
> -      cc.PointertoBLEND_STATE = blend_state_offset;<br>
> -      cc.PointertoCOLOR_CALC_STATE = color_calc_state_offset;<br>
> -      cc.PointertoDEPTH_STENCIL_<wbr>STATE = depth_stencil_state_offset;<br>
> -   }<br>
> -#else<br>
> -   (void)blend_state_offset;<br>
> -   (void)color_calc_state_offset;<br>
> -   (void)depth_stencil_state_<wbr>offset;<br>
> -#endif<br>
> -<br>
> -   blorp_emit(batch, GENX(3DSTATE_CONSTANT_VS), vs);<br>
> -#if GEN_GEN >= 7<br>
> -   blorp_emit(batch, GENX(3DSTATE_CONSTANT_HS), hs);<br>
> -   blorp_emit(batch, GENX(3DSTATE_CONSTANT_DS), DS);<br>
> -#endif<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(<wbr>batch, params);<br>
> -<br>
> -   if (params->src.addr.buffer)<br>
> -      blorp_emit_sampler_state(<wbr>batch, params);<br>
> -<br>
> -   blorp_emit_3dstate_<wbr>multisample(batch.blorp, batch.batch,<br>
> -                                  params->dst.surf.samples);<br>
> -<br>
> -   blorp_emit(batch, GENX(3DSTATE_SAMPLE_MASK), mask) {<br>
> -      mask.SampleMask = (1 << params->dst.surf.samples) - 1;<br>
> -   }<br>
> -<br>
> -   /* From the BSpec, 3D Pipeline > Geometry > Vertex Shader > State,<br>
> -    * 3DSTATE_VS, Dword 5.0 "VS Function Enable":<br>
> -    *<br>
> -    *   [DevSNB] A pipeline flush must be programmed prior to a<br>
> -    *   3DSTATE_VS command that causes the VS Function Enable to<br>
> -    *   toggle. Pipeline flush can be executed by sending a PIPE_CONTROL<br>
> -    *   command with CS stall bit set and a post sync operation.<br>
> -    *<br>
> -    * We've already done one at the start of the BLORP operation.<br>
<br>
</div></div>And here.<br>
<br>
> -    */<br>
<div><div class="h5">> -   blorp_emit(batch, GENX(3DSTATE_VS), vs);<br>
> -#if GEN_GEN >= 7<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(batch, GENX(3DSTATE_GS), gs);<br>
> -<br>
> -   blorp_emit(batch, GENX(3DSTATE_CLIP), clip) {<br>
> -      clip.PerspectiveDivideDisable = true;<br>
> -   }<br>
> -<br>
> -   blorp_emit_sf_config(batch, params);<br>
> -   blorp_emit_ps_config(batch, params);<br>
> -<br>
> -   blorp_emit_viewport_state(<wbr>batch, params);<br>
> -<br>
> -   if (params->depth.addr.buffer) {<br>
> -      blorp_emit_depth_stencil_<wbr>config(batch, params);<br>
> -   } else {<br>
> -      blorp_emit(batch, GENX(3DSTATE_DEPTH_BUFFER), db) {<br>
> -         db.SurfaceType = SURFTYPE_NULL;<br>
> -         db.SurfaceFormat = D32_FLOAT;<br>
> -      }<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>
> -    *<br>
> -    * From the Sandybridge PRM, Volume 2, Part 1, Section 3DSTATE_CLEAR_PARAMS:<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>
</div></div>And finally here. Otherwise it looks that code is just moved.<br>
<br>
I would keep the documentation, and with that:<br>
<br>
Reviewed-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br>
<div><div class="h5"><br>
> -    */<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(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(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>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>genX_blorp_exec.h b/src/mesa/drivers/dri/i965/<wbr>genX_blorp_exec.h<br>
> new file mode 100644<br>
> index 0000000..02a0397<br>
> --- /dev/null<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>genX_blorp_exec.h<br>
> @@ -0,0 +1,1121 @@<br>
> +/*<br>
> + * Copyright © 2016 Intel Corporation<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice (including the next<br>
> + * paragraph) shall be included in all copies or substantial portions of the<br>
> + * Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
> + * IN THE SOFTWARE.<br>
> + */<br>
> +<br>
> +#include "blorp_priv.h"<br>
> +#include "brw_device_info.h"<br>
> +#include "intel_aub.h"<br>
> +<br>
> +/**<br>
> + * This file provides the blorp pipeline setup and execution functionality.<br>
> + * It defines the following function:<br>
> + *<br>
> + * static void<br>
> + * blorp_exec(struct blorp_context *blorp, void *batch_data,<br>
> + *            const struct brw_blorp_params *params);<br>
> + *<br>
> + * It is the job of whoever includes this header to wrap this in something<br>
> + * to get an externally visible symbol.<br>
> + *<br>
> + * In order for the blorp_exec function to work, the driver must provide<br>
> + * implementations of the following static helper functions.<br>
> + */<br>
> +<br>
> +static void *<br>
> +blorp_emit_dwords(struct blorp_context *blorp, void *batch, unsigned n);<br>
> +<br>
> +static uint64_t<br>
> +blorp_emit_reloc(struct blorp_context *blorp, void *batch,<br>
> +                 void *location, struct blorp_address address, uint32_t delta);<br>
> +<br>
> +static void *<br>
> +blorp_alloc_dynamic_state(<wbr>struct blorp_context *blorp,<br>
> +                          enum aub_state_struct_type type,<br>
> +                          uint32_t size,<br>
> +                          uint32_t alignment,<br>
> +                          uint32_t *offset);<br>
> +static void *<br>
> +blorp_alloc_vertex_buffer(<wbr>struct blorp_context *blorp, uint32_t size,<br>
> +                          struct blorp_address *addr);<br>
> +<br>
> +static void<br>
> +blorp_alloc_binding_table(<wbr>struct blorp_context *blorp, unsigned num_entries,<br>
> +                          unsigned state_size, unsigned state_alignment,<br>
> +                          uint32_t *bt_offset, uint32_t **bt_map,<br>
> +                          void **surface_maps);<br>
> +static void<br>
> +blorp_surface_reloc(struct blorp_context *blorp, uint32_t ss_offset,<br>
> +                    struct blorp_address address, uint32_t delta);<br>
> +<br>
> +static void<br>
> +blorp_emit_urb_config(struct blorp_context *blorp, void *batch,<br>
> +                      unsigned vs_entry_size);<br>
> +static void<br>
> +blorp_emit_3dstate_<wbr>multisample(struct blorp_context *blorp, void *batch,<br>
> +                               unsigned samples);<br>
> +<br>
> +/***** BEGIN blorp_exec implementation ******/<br>
> +<br>
> +#include "genxml/gen_macros.h"<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 blorp_batch<br>
> +<br>
> +static uint64_t<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(batch->blorp, batch->batch,<br>
> +                              location, address, delta);<br>
> +   }<br>
> +}<br>
> +<br>
> +#include "genxml/genX_pack.h"<br>
> +<br>
> +#define _blorp_cmd_length(cmd) cmd ## _length<br>
> +#define _blorp_cmd_length_bias(cmd) cmd ## _length_bias<br>
> +#define _blorp_cmd_header(cmd) cmd ## _header<br>
> +#define _blorp_cmd_pack(cmd) cmd ## _pack<br>
> +<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.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>
> + * header the space requirement is as follows per vertex (in bytes):<br>
> + *<br>
> + *     Header    Position    Program constants<br>
> + *   +--------+------------+-------<wbr>------------+<br>
> + *   |   16   |     16     |      n x 16       |<br>
> + *   +--------+------------+-------<wbr>------------+<br>
> + *<br>
> + * where 'n' stands for number of varying inputs expressed as vec4s.<br>
> + *<br>
> + * The URB size is in turn expressed in 64 bytes (512 bits).<br>
> + */<br>
> +static inline unsigned<br>
> +gen7_blorp_get_vs_entry_size(<wbr>const struct brw_blorp_params *params)<br>
> +{<br>
> +    const unsigned num_varyings =<br>
> +       params->wm_prog_data ? params->wm_prog_data->num_<wbr>varying_inputs : 0;<br>
> +    const unsigned total_needed = 16 + 16 + num_varyings * 16;<br>
> +<br>
> +   return DIV_ROUND_UP(total_needed, 64);<br>
> +}<br>
> +<br>
> +/* 3DSTATE_URB_VS<br>
> + * 3DSTATE_URB_HS<br>
> + * 3DSTATE_URB_DS<br>
> + * 3DSTATE_URB_GS<br>
> + *<br>
> + * If the 3DSTATE_URB_VS is emitted, than the others must be also.<br>
> + * From the Ivybridge PRM, Volume 2 Part 1, section 1.7.1 3DSTATE_URB_VS:<br>
> + *<br>
> + *     3DSTATE_URB_HS, 3DSTATE_URB_DS, and 3DSTATE_URB_GS must also be<br>
> + *     programmed in order for the programming of this state to be<br>
> + *     valid.<br>
> + */<br>
> +static void<br>
> +emit_urb_config(struct blorp_batch batch,<br>
> +                const struct brw_blorp_params *params)<br>
> +{<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 blorp_batch batch,<br>
> +                       const struct brw_blorp_params *params,<br>
> +                       struct blorp_address *addr,<br>
> +                       uint32_t *size)<br>
> +{<br>
> +   const float vertices[] = {<br>
> +      /* v0 */ (float)params->x0, (float)params->y1,<br>
> +      /* v1 */ (float)params->x1, (float)params->y1,<br>
> +      /* v2 */ (float)params->x0, (float)params->y0,<br>
> +   };<br>
> +<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 blorp_batch batch,<br>
> +                              const struct brw_blorp_params *params,<br>
> +                              struct blorp_address *addr,<br>
> +                              uint32_t *size)<br>
> +{<br>
> +   const unsigned vec4_size_in_bytes = 4 * sizeof(float);<br>
> +   const unsigned max_num_varyings =<br>
> +      DIV_ROUND_UP(sizeof(params-><wbr>wm_inputs), vec4_size_in_bytes);<br>
> +   const unsigned num_varyings = params->wm_prog_data->num_<wbr>varying_inputs;<br>
> +<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>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>
> +    * the vertex data buffer.<br>
> +    */<br>
> +   for (unsigned i = 0; i < max_num_varyings; i++) {<br>
> +      const gl_varying_slot attr = VARYING_SLOT_VAR0 + i;<br>
> +<br>
> +      if (!(params->wm_prog_data-><wbr>inputs_read & BITFIELD64_BIT(attr)))<br>
> +         continue;<br>
> +<br>
> +      memcpy(inputs, inputs_src + i * 4, vec4_size_in_bytes);<br>
> +<br>
> +      inputs += 4;<br>
> +   }<br>
> +}<br>
> +<br>
> +static void<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>
> +   memset(vb, 0, sizeof(vb));<br>
> +<br>
> +   unsigned num_buffers = 1;<br>
> +<br>
> +   uint32_t 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 = batch.blorp->mocs.vb;<br>
> +#if GEN_GEN >= 7<br>
> +   vb[0].AddressModifyEnable = true;<br>
> +#endif<br>
> +#if GEN_GEN >= 8<br>
> +   vb[0].BufferSize = size;<br>
> +#else<br>
> +   vb[0].BufferAccessType = VERTEXDATA;<br>
> +   vb[0].EndAddress = vb[0].BufferStartingAddress;<br>
> +   vb[0].EndAddress.offset += size - 1;<br>
> +#endif<br>
> +<br>
> +   if (params->wm_prog_data && params->wm_prog_data->num_<wbr>varying_inputs) {<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 = batch.blorp->mocs.vb;<br>
> +#if GEN_GEN >= 7<br>
> +      vb[1].AddressModifyEnable = true;<br>
> +#endif<br>
> +#if GEN_GEN >= 8<br>
> +      vb[1].BufferSize = size;<br>
> +#else<br>
> +      vb[1].BufferAccessType = INSTANCEDATA;<br>
> +      vb[1].EndAddress = vb[1].BufferStartingAddress;<br>
> +      vb[1].EndAddress.offset += size - 1;<br>
> +#endif<br>
> +      num_buffers++;<br>
> +   }<br>
> +<br>
> +   const unsigned num_dwords =<br>
> +      1 + GENX(VERTEX_BUFFER_STATE_<wbr>length) * num_buffers;<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>(&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 blorp_batch batch,<br>
> +                           const struct brw_blorp_params *params)<br>
> +{<br>
> +   const unsigned num_varyings =<br>
> +      params->wm_prog_data ? params->wm_prog_data->num_<wbr>varying_inputs : 0;<br>
> +   const unsigned num_elements = 2 + num_varyings;<br>
> +<br>
> +   struct GENX(VERTEX_ELEMENT_STATE) ve[num_elements];<br>
> +   memset(ve, 0, num_elements * sizeof(*ve));<br>
> +<br>
> +   /* Setup VBO for the rectangle primitive..<br>
> +    *<br>
> +    * A rectangle primitive (3DPRIM_RECTLIST) consists of only three<br>
> +    * vertices. The vertices reside in screen space with DirectX<br>
> +    * coordinates (that is, (0, 0) is the upper left corner).<br>
> +    *<br>
> +    *   v2 ------ implied<br>
> +    *    |        |<br>
> +    *    |        |<br>
> +    *   v0 ----- v1<br>
> +    *<br>
> +    * Since the VS is disabled, the clipper loads each VUE directly from<br>
> +    * the URB. This is controlled by the 3DSTATE_VERTEX_BUFFERS and<br>
> +    * 3DSTATE_VERTEX_ELEMENTS packets below. The VUE contents are as follows:<br>
> +    *   dw0: Reserved, MBZ.<br>
> +    *   dw1: Render Target Array Index. The HiZ op does not use indexed<br>
> +    *        vertices, so set the dword to 0.<br>
> +    *   dw2: Viewport Index. The HiZ op disables viewport mapping and<br>
> +    *        scissoring, so set the dword to 0.<br>
> +    *   dw3: Point Width: The HiZ op does not emit the POINTLIST primitive,<br>
> +    *        so set the dword to 0.<br>
> +    *   dw4: Vertex Position X.<br>
> +    *   dw5: Vertex Position Y.<br>
> +    *   dw6: Vertex Position Z.<br>
> +    *   dw7: Vertex Position W.<br>
> +    *<br>
> +    *   dw8: Flat vertex input 0<br>
> +    *   dw9: Flat vertex input 1<br>
> +    *   ...<br>
> +    *   dwn: Flat vertex input n - 8<br>
> +    *<br>
> +    * For details, see the Sandybridge PRM, Volume 2, Part 1, Section 1.5.1<br>
> +    * "Vertex URB Entry (VUE) Formats".<br>
> +    *<br>
> +    * Only vertex position X and Y are going to be variable, Z is fixed to<br>
> +    * zero and W to one. Header words dw0-3 are all zero. There is no need to<br>
> +    * include the fixed values in the vertex buffer. Vertex fetcher can be<br>
> +    * instructed to fill vertex elements with constant values of one and zero<br>
> +    * instead of reading them from the buffer.<br>
> +    * Flat inputs are program constants that are not interpolated. Moreover<br>
> +    * their values will be the same between vertices.<br>
> +    *<br>
> +    * See the vertex element setup below.<br>
> +    */<br>
> +   ve[0].VertexBufferIndex = 0;<br>
> +   ve[0].Valid = true;<br>
> +   ve[0].SourceElementFormat = ISL_FORMAT_R32G32B32A32_FLOAT;<br>
> +   ve[0].SourceElementOffset = 0;<br>
> +   ve[0].Component0Control = VFCOMP_STORE_0;<br>
> +   ve[0].Component1Control = VFCOMP_STORE_0;<br>
> +   ve[0].Component2Control = VFCOMP_STORE_0;<br>
> +   ve[0].Component3Control = VFCOMP_STORE_0;<br>
> +<br>
> +   ve[1].VertexBufferIndex = 0;<br>
> +   ve[1].Valid = true;<br>
> +   ve[1].SourceElementFormat = ISL_FORMAT_R32G32_FLOAT;<br>
> +   ve[1].SourceElementOffset = 0;<br>
> +   ve[1].Component0Control = VFCOMP_STORE_SRC;<br>
> +   ve[1].Component1Control = VFCOMP_STORE_SRC;<br>
> +   ve[1].Component2Control = VFCOMP_STORE_0;<br>
> +   ve[1].Component3Control = VFCOMP_STORE_1_FP;<br>
> +<br>
> +   for (unsigned i = 0; i < num_varyings; ++i) {<br>
> +      ve[i + 2].VertexBufferIndex = 1;<br>
> +      ve[i + 2].Valid = true;<br>
> +      ve[i + 2].SourceElementFormat = ISL_FORMAT_R32G32B32A32_FLOAT;<br>
> +      ve[i + 2].SourceElementOffset = i * 4 * sizeof(float);<br>
> +      ve[i + 2].Component0Control = VFCOMP_STORE_SRC;<br>
> +      ve[i + 2].Component1Control = VFCOMP_STORE_SRC;<br>
> +      ve[i + 2].Component2Control = VFCOMP_STORE_SRC;<br>
> +      ve[i + 2].Component3Control = VFCOMP_STORE_SRC;<br>
> +   }<br>
> +<br>
> +   const unsigned num_dwords =<br>
> +      1 + GENX(VERTEX_ELEMENT_STATE_<wbr>length) * num_elements;<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)(&batch, dw, &ve[i]);<br>
> +      dw += GENX(VERTEX_ELEMENT_STATE_<wbr>length);<br>
> +   }<br>
> +<br>
> +#if GEN_GEN >= 8<br>
> +   blorp_emit(batch, GENX(3DSTATE_VF_SGVS), sgvs);<br>
> +<br>
> +   for (unsigned i = 0; i < num_elements; i++) {<br>
> +      blorp_emit(batch, GENX(3DSTATE_VF_INSTANCING), vf) {<br>
> +         vf.VertexElementIndex = i;<br>
> +         vf.InstancingEnable = false;<br>
> +      }<br>
> +   }<br>
> +<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 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>
> +<br>
> +#if GEN_GEN >= 8<br>
> +<br>
> +   blorp_emit(batch, GENX(3DSTATE_SF), sf);<br>
> +<br>
> +   blorp_emit(batch, GENX(3DSTATE_RASTER), raster) {<br>
> +      raster.CullMode = CULLMODE_NONE;<br>
> +   }<br>
> +<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>
> +      sbe.<wbr>ForceVertexURBEntryReadLength = true;<br>
> +      sbe.<wbr>ForceVertexURBEntryReadOffset = true;<br>
> +      sbe.<wbr>ConstantInterpolationEnable = prog_data->flat_inputs;<br>
> +<br>
> +#if GEN_GEN >= 9<br>
> +      for (unsigned i = 0; i < 32; i++)<br>
> +         sbe.<wbr>AttributeActiveComponentFormat<wbr>[i] = ACF_XYZW;<br>
> +#endif<br>
> +   }<br>
> +<br>
> +#elif GEN_GEN >= 7<br>
> +<br>
> +   blorp_emit(batch, GENX(3DSTATE_SF), sf) {<br>
> +      sf.FrontFaceFillMode = FILL_MODE_SOLID;<br>
> +      sf.BackFaceFillMode = FILL_MODE_SOLID;<br>
> +<br>
> +      sf.<wbr>MultisampleRasterizationMode = params->dst.surf.samples > 1 ?<br>
> +         MSRASTMODE_ON_PATTERN : MSRASTMODE_OFF_PIXEL;<br>
> +<br>
> +#if GEN_GEN == 7<br>
> +      sf.DepthBufferSurfaceFormat = params->depth_format;<br>
> +#endif<br>
> +   }<br>
> +<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>
> +         sbe.VertexURBEntryReadLength = brw_blorp_get_urb_length(prog_<wbr>data);<br>
> +         sbe.<wbr>ConstantInterpolationEnable = prog_data->flat_inputs;<br>
> +      } else {<br>
> +         sbe.NumberofSFOutputAttributes = 0;<br>
> +         sbe.VertexURBEntryReadLength = 1;<br>
> +      }<br>
> +   }<br>
> +<br>
> +#else /* GEN_GEN <= 6 */<br>
> +<br>
> +   blorp_emit(batch, GENX(3DSTATE_SF), sf) {<br>
> +      sf.FrontFaceFillMode = FILL_MODE_SOLID;<br>
> +      sf.BackFaceFillMode = FILL_MODE_SOLID;<br>
> +<br>
> +      sf.<wbr>MultisampleRasterizationMode = params->dst.surf.samples > 1 ?<br>
> +         MSRASTMODE_ON_PATTERN : MSRASTMODE_OFF_PIXEL;<br>
> +<br>
> +      sf.VertexURBEntryReadOffset = BRW_SF_URB_ENTRY_READ_OFFSET;<br>
> +      if (prog_data) {<br>
> +         sf.NumberofSFOutputAttributes = prog_data->num_varying_inputs;<br>
> +         sf.VertexURBEntryReadLength = brw_blorp_get_urb_length(prog_<wbr>data);<br>
> +         sf.ConstantInterpolationEnable = prog_data->flat_inputs;<br>
> +      } else {<br>
> +         sf.NumberofSFOutputAttributes = 0;<br>
> +         sf.VertexURBEntryReadLength = 1;<br>
> +      }<br>
> +   }<br>
> +<br>
> +#endif /* GEN_GEN */<br>
> +}<br>
> +<br>
> +static void<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>
> +<br>
> +#if GEN_GEN >= 8<br>
> +<br>
> +   blorp_emit(batch, GENX(3DSTATE_WM), wm);<br>
> +<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>
> +      } else {<br>
> +         ps.BindingTableEntryCount = 1;<br>
> +      }<br>
> +<br>
> +      ps.<wbr>DispatchGRFStartRegisterForCon<wbr>stantSetupData0 =<br>
> +         prog_data->first_curbe_grf_0;<br>
> +      ps.<wbr>DispatchGRFStartRegisterForCon<wbr>stantSetupData2 =<br>
> +         prog_data->first_curbe_grf_2;<br>
> +<br>
> +      ps._8PixelDispatchEnable = prog_data->dispatch_8;<br>
> +      ps._16PixelDispatchEnable = prog_data->dispatch_16;<br>
> +<br>
> +      ps.KernelStartPointer0 = params->wm_prog_kernel;<br>
> +      ps.KernelStartPointer2 =<br>
> +         params->wm_prog_kernel + prog_data->ksp_offset_2;<br>
> +<br>
> +      /* 3DSTATE_PS expects the number of threads per PSD, which is always 64;<br>
> +       * it implicitly scales for different GT levels (which have some # of<br>
> +       * PSDs).<br>
> +       *<br>
> +       * In Gen8 the format is U8-2 whereas in Gen9 it is U8-1.<br>
> +       */<br>
> +      if (GEN_GEN >= 9)<br>
> +         ps.<wbr>MaximumNumberofThreadsPerPSD = 64 - 1;<br>
> +      else<br>
> +         ps.<wbr>MaximumNumberofThreadsPerPSD = 64 - 2;<br>
> +<br>
> +      switch (params->fast_clear_op) {<br>
> +#if GEN_GEN >= 9<br>
> +      case (1 << 6): /* GEN7_PS_RENDER_TARGET_RESOLVE_<wbr>ENABLE */<br>
> +         ps.RenderTargetResolveType = RESOLVE_PARTIAL;<br>
> +         break;<br>
> +      case (3 << 6): /* GEN9_PS_RENDER_TARGET_RESOLVE_<wbr>FULL */<br>
> +         ps.RenderTargetResolveType = RESOLVE_FULL;<br>
> +         break;<br>
> +#else<br>
> +      case (1 << 6): /* GEN7_PS_RENDER_TARGET_RESOLVE_<wbr>ENABLE */<br>
> +         ps.RenderTargetResolveEnable = true;<br>
> +         break;<br>
> +#endif<br>
> +      case (1 << 8): /* GEN7_PS_RENDER_TARGET_FAST_<wbr>CLEAR_ENABLE */<br>
> +         ps.RenderTargetFastClearEnable = true;<br>
> +         break;<br>
> +      }<br>
> +   }<br>
> +<br>
> +   blorp_emit(batch, GENX(3DSTATE_PS_EXTRA), psx) {<br>
> +      psx.PixelShaderValid = true;<br>
> +<br>
> +      if (params->src.addr.buffer)<br>
> +         psx.PixelShaderKillsPixel = true;<br>
> +<br>
> +      psx.AttributeEnable = prog_data->num_varying_inputs > 0;<br>
> +<br>
> +      if (prog_data && prog_data->persample_msaa_<wbr>dispatch)<br>
> +         psx.PixelShaderIsPerSample = true;<br>
> +   }<br>
> +<br>
> +#elif GEN_GEN >= 7<br>
> +<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>
> +         break;<br>
> +      case GEN6_HIZ_OP_DEPTH_RESOLVE:<br>
> +         wm.DepthBufferResolveEnable = true;<br>
> +         break;<br>
> +      case GEN6_HIZ_OP_HIZ_RESOLVE:<br>
> +         wm.<wbr>HierarchicalDepthBufferResolve<wbr>Enable = true;<br>
> +         break;<br>
> +      case GEN6_HIZ_OP_NONE:<br>
> +         break;<br>
> +      default:<br>
> +         unreachable("not reached");<br>
> +      }<br>
> +<br>
> +      if (prog_data)<br>
> +         wm.ThreadDispatchEnable = true;<br>
> +<br>
> +      if (params->src.addr.buffer)<br>
> +         wm.PixelShaderKillPixel = true;<br>
> +<br>
> +      if (params->dst.surf.samples > 1) {<br>
> +         wm.<wbr>MultisampleRasterizationMode = MSRASTMODE_ON_PATTERN;<br>
> +         wm.MultisampleDispatchMode =<br>
> +            (prog_data && prog_data->persample_msaa_<wbr>dispatch) ?<br>
> +            MSDISPMODE_PERSAMPLE : MSDISPMODE_PERPIXEL;<br>
> +      } else {<br>
> +         wm.<wbr>MultisampleRasterizationMode = MSRASTMODE_OFF_PIXEL;<br>
> +         wm.MultisampleDispatchMode = MSDISPMODE_PERSAMPLE;<br>
> +      }<br>
> +   }<br>
> +<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>
> +#endif<br>
> +<br>
> +      if (prog_data) {<br>
> +         ps.<wbr>DispatchGRFStartRegisterforCon<wbr>stantSetupData0 =<br>
> +            prog_data->first_curbe_grf_0;<br>
> +         ps.<wbr>DispatchGRFStartRegisterforCon<wbr>stantSetupData2 =<br>
> +            prog_data->first_curbe_grf_2;<br>
> +<br>
> +         ps.KernelStartPointer0 = params->wm_prog_kernel;<br>
> +         ps.KernelStartPointer2 =<br>
> +            params->wm_prog_kernel + prog_data->ksp_offset_2;<br>
> +<br>
> +         ps._8PixelDispatchEnable = prog_data->dispatch_8;<br>
> +         ps._16PixelDispatchEnable = prog_data->dispatch_16;<br>
> +<br>
> +         ps.AttributeEnable = prog_data->num_varying_inputs > 0;<br>
> +      } else {<br>
> +         /* Gen7 hardware gets angry if we don't enable at least one dispatch<br>
> +          * mode, so just enable 16-pixel dispatch if we don't have a program.<br>
> +          */<br>
> +         ps._16PixelDispatchEnable = true;<br>
> +      }<br>
> +<br>
> +      if (params->src.addr.buffer)<br>
> +         ps.SamplerCount = 1; /* Up to 4 samplers */<br>
> +<br>
> +      switch (params->fast_clear_op) {<br>
> +      case (1 << 6): /* GEN7_PS_RENDER_TARGET_RESOLVE_<wbr>ENABLE */<br>
> +         ps.RenderTargetResolveEnable = true;<br>
> +         break;<br>
> +      case (1 << 8): /* GEN7_PS_RENDER_TARGET_FAST_<wbr>CLEAR_ENABLE */<br>
> +         ps.RenderTargetFastClearEnable = true;<br>
> +         break;<br>
> +      }<br>
> +   }<br>
> +<br>
> +#else /* GEN_GEN <= 6 */<br>
> +<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>
> +         wm.DepthBufferClear = true;<br>
> +         break;<br>
> +      case GEN6_HIZ_OP_DEPTH_RESOLVE:<br>
> +         wm.DepthBufferResolveEnable = true;<br>
> +         break;<br>
> +      case GEN6_HIZ_OP_HIZ_RESOLVE:<br>
> +         wm.<wbr>HierarchicalDepthBufferResolve<wbr>Enable = true;<br>
> +         break;<br>
> +      case GEN6_HIZ_OP_NONE:<br>
> +         break;<br>
> +      default:<br>
> +         unreachable("not reached");<br>
> +      }<br>
> +<br>
> +      if (prog_data) {<br>
> +         wm.ThreadDispatchEnable = true;<br>
> +<br>
> +         wm.<wbr>DispatchGRFStartRegisterforCon<wbr>stantSetupData0 =<br>
> +            prog_data->first_curbe_grf_0;<br>
> +         wm.<wbr>DispatchGRFStartRegisterforCon<wbr>stantSetupData2 =<br>
> +            prog_data->first_curbe_grf_2;<br>
> +<br>
> +         wm.KernelStartPointer0 = params->wm_prog_kernel;<br>
> +         wm.KernelStartPointer2 =<br>
> +            params->wm_prog_kernel + prog_data->ksp_offset_2;<br>
> +<br>
> +         wm._8PixelDispatchEnable = prog_data->dispatch_8;<br>
> +         wm._16PixelDispatchEnable = prog_data->dispatch_16;<br>
> +<br>
> +         wm.NumberofSFOutputAttributes = prog_data->num_varying_inputs;<br>
> +      }<br>
> +<br>
> +      if (params->src.addr.buffer) {<br>
> +         wm.SamplerCount = 1; /* Up to 4 samplers */<br>
> +         wm.PixelShaderKillPixel = true; /* TODO: temporarily smash on */<br>
> +      }<br>
> +<br>
> +      if (params->dst.surf.samples > 1) {<br>
> +         wm.<wbr>MultisampleRasterizationMode = MSRASTMODE_ON_PATTERN;<br>
> +         wm.MultisampleDispatchMode =<br>
> +            (prog_data && prog_data->persample_msaa_<wbr>dispatch) ?<br>
> +            MSDISPMODE_PERSAMPLE : MSDISPMODE_PERPIXEL;<br>
> +      } else {<br>
> +         wm.<wbr>MultisampleRasterizationMode = MSRASTMODE_OFF_PIXEL;<br>
> +         wm.MultisampleDispatchMode = MSDISPMODE_PERSAMPLE;<br>
> +      }<br>
> +   }<br>
> +<br>
> +#endif /* GEN_GEN */<br>
> +}<br>
> +<br>
> +<br>
> +static void<br>
> +blorp_emit_depth_stencil_<wbr>config(struct blorp_batch batch,<br>
> +                                const struct brw_blorp_params *params)<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(batch, GENX(3DSTATE_DEPTH_BUFFER), db) {<br>
> +      switch (params->depth.surf.dim) {<br>
> +      case ISL_SURF_DIM_1D:<br>
> +         db.SurfaceType = SURFTYPE_1D;<br>
> +         break;<br>
> +      case ISL_SURF_DIM_2D:<br>
> +         db.SurfaceType = SURFTYPE_2D;<br>
> +         break;<br>
> +      case ISL_SURF_DIM_3D:<br>
> +         db.SurfaceType = SURFTYPE_3D;<br>
> +         break;<br>
> +      }<br>
> +<br>
> +      db.SurfaceFormat = params->depth_format;<br>
> +<br>
> +#if GEN_GEN >= 7<br>
> +      db.DepthWriteEnable = true;<br>
> +#endif<br>
> +<br>
> +#if GEN_GEN <= 6<br>
> +      db.TiledSurface = true;<br>
> +      db.TileWalk = TILEWALK_YMAJOR;<br>
> +      db.MIPMapLayoutMode = MIPLAYOUT_BELOW;<br>
> +      db.SeparateStencilBufferEnable = true;<br>
> +#endif<br>
> +<br>
> +      db.<wbr>HierarchicalDepthBufferEnable = true;<br>
> +<br>
> +      db.Width = params->depth.surf.logical_<wbr>level0_px.width - 1;<br>
> +      db.Height = params->depth.surf.logical_<wbr>level0_px.height - 1;<br>
> +      db.RenderTargetViewExtent = db.Depth =<br>
> +         MAX2(params->depth.surf.<wbr>logical_level0_px.depth,<br>
> +              params->depth.surf.logical_<wbr>level0_px.array_len) - 1;<br>
> +<br>
> +      db.LOD = params->depth.view.base_level;<br>
> +      db.MinimumArrayElement = params->depth.view.base_array_<wbr>layer;<br>
> +<br>
> +      db.SurfacePitch = params->depth.surf.row_pitch - 1;<br>
> +      db.SurfaceBaseAddress = params->depth.addr;<br>
> +      db.DepthBufferMOCS = mocs;<br>
> +   }<br>
> +<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(batch, GENX(3DSTATE_STENCIL_BUFFER), sb);<br>
> +}<br>
> +<br>
> +static uint32_t<br>
> +blorp_emit_blend_state(struct blorp_batch batch,<br>
> +                       const struct brw_blorp_params *params)<br>
> +{<br>
> +   struct GENX(BLEND_STATE) blend;<br>
> +   memset(&blend, 0, sizeof(blend));<br>
> +<br>
> +   for (unsigned i = 0; i < params->num_draw_buffers; ++i) {<br>
> +      blend.Entry[i].<wbr>PreBlendColorClampEnable = true;<br>
> +      blend.Entry[i].<wbr>PostBlendColorClampEnable = true;<br>
> +      blend.Entry[i].ColorClampRange = COLORCLAMP_RTFORMAT;<br>
> +<br>
> +      blend.Entry[i].WriteDisableRed = params->color_write_disable[0]<wbr>;<br>
> +      blend.Entry[i].<wbr>WriteDisableGreen = params->color_write_disable[1]<wbr>;<br>
> +      blend.Entry[i].<wbr>WriteDisableBlue = params->color_write_disable[2]<wbr>;<br>
> +      blend.Entry[i].<wbr>WriteDisableAlpha = params->color_write_disable[3]<wbr>;<br>
> +   }<br>
> +<br>
> +   uint32_t offset;<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(batch, GENX(3DSTATE_BLEND_STATE_<wbr>POINTERS), sp) {<br>
> +      sp.BlendStatePointer = offset;<br>
> +#if GEN_GEN >= 8<br>
> +      sp.BlendStatePointerValid = true;<br>
> +#endif<br>
> +   }<br>
> +#endif<br>
> +<br>
> +#if GEN_GEN >= 8<br>
> +   blorp_emit(batch, GENX(3DSTATE_PS_BLEND), ps_blend) {<br>
> +      ps_blend.HasWriteableRT = true;<br>
> +   }<br>
> +#endif<br>
> +<br>
> +   return offset;<br>
> +}<br>
> +<br>
> +static uint32_t<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>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(batch, GENX(3DSTATE_CC_STATE_<wbr>POINTERS), sp) {<br>
> +      sp.ColorCalcStatePointer = offset;<br>
> +#if GEN_GEN >= 8<br>
> +      sp.ColorCalcStatePointerValid = true;<br>
> +#endif<br>
> +   }<br>
> +#endif<br>
> +<br>
> +   return offset;<br>
> +}<br>
> +<br>
> +static uint32_t<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(batch, GENX(3DSTATE_WM_DEPTH_STENCIL)<wbr>, ds);<br>
> +   return 0;<br>
> +<br>
> +#else /* GEN_GEN <= 7 */<br>
> +<br>
> +   /* See the following sections of the Sandy Bridge PRM, Volume 1, Part2:<br>
> +    *   - 7.5.3.1 Depth Buffer Clear<br>
> +    *   - 7.5.3.2 Depth Buffer Resolve<br>
> +    *   - 7.5.3.3 Hierarchical Depth Buffer Resolve<br>
> +    */<br>
> +   struct GENX(DEPTH_STENCIL_STATE) ds = {<br>
> +      .DepthBufferWriteEnable = true,<br>
> +   };<br>
> +<br>
> +   if (params->hiz_op == GEN6_HIZ_OP_DEPTH_RESOLVE) {<br>
> +      ds.DepthTestEnable = true;<br>
> +      ds.DepthTestFunction = COMPAREFUNCTION_NEVER;<br>
> +   }<br>
> +<br>
> +   uint32_t offset;<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(batch, GENX(3DSTATE_DEPTH_STENCIL_<wbr>STATE_POINTERS), sp) {<br>
> +      sp.PointertoDEPTH_STENCIL_<wbr>STATE = offset;<br>
> +   }<br>
> +#endif<br>
> +<br>
> +   return offset;<br>
> +<br>
> +#endif /* GEN_GEN */<br>
> +}<br>
> +<br>
> +struct surface_state_info {<br>
> +   unsigned num_dwords;<br>
> +   unsigned ss_align; /* Required alignment of RENDER_SURFACE_STATE in bytes */<br>
> +   unsigned reloc_dw;<br>
> +   unsigned aux_reloc_dw;<br>
> +};<br>
> +<br>
> +static const struct surface_state_info surface_state_infos[] = {<br>
> +   [6] = {6,  32, 1,  0},<br>
> +   [7] = {8,  32, 1,  6},<br>
> +   [8] = {13, 64, 8,  10},<br>
> +   [9] = {16, 64, 8,  10},<br>
> +};<br>
> +<br>
> +static void<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[GEN_GEN];<br>
> +<br>
> +   struct isl_surf surf = surface->surf;<br>
> +<br>
> +   if (surf.dim == ISL_SURF_DIM_1D &&<br>
> +       surf.dim_layout == ISL_DIM_LAYOUT_GEN4_2D) {<br>
> +      assert(surf.logical_level0_px.<wbr>height == 1);<br>
> +      surf.dim = ISL_SURF_DIM_2D;<br>
> +   }<br>
> +<br>
> +   /* Blorp doesn't support HiZ in any of the blit or slow-clear paths */<br>
> +   enum isl_aux_usage aux_usage = surface->aux_usage;<br>
> +   if (aux_usage == ISL_AUX_USAGE_HIZ)<br>
> +      aux_usage = ISL_AUX_USAGE_NONE;<br>
> +<br>
> +   const uint32_t mocs = is_render_target ? blorp->mocs.rb : blorp->mocs.tex;<br>
> +<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(blorp, state_offset + ss_info.reloc_dw * 4,<br>
> +                       surface->addr, 0);<br>
> +<br>
> +   if (aux_usage != ISL_AUX_USAGE_NONE) {<br>
> +      /* On gen7 and prior, the bottom 12 bits of the MCS base address are<br>
> +       * used to store other information.  This should be ok, however, because<br>
> +       * surface buffer addresses are always 4K page alinged.<br>
> +       */<br>
> +      assert((surface->aux_addr.<wbr>offset & 0xfff) == 0);<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 blorp_batch batch,<br>
> +                          const struct brw_blorp_params *params)<br>
> +{<br>
> +   uint32_t bind_offset, *bind_map;<br>
> +   void *surface_maps[2];<br>
> +<br>
> +   const unsigned ss_size = GENX(RENDER_SURFACE_STATE_<wbr>length) * 4;<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>batch.blorp, num_surfaces, ss_size, ss_align,<br>
> +                             &bind_offset, &bind_map, surface_maps);<br>
> +<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(<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(batch, GENX(3DSTATE_BINDING_TABLE_<wbr>POINTERS_PS), bt) {<br>
> +      bt.PointertoPSBindingTable = bind_offset;<br>
> +   }<br>
> +#else<br>
> +   blorp_emit(batch, GENX(3DSTATE_BINDING_TABLE_<wbr>POINTERS), bt) {<br>
> +      bt.PSBindingTableChange = true;<br>
> +      bt.PointertoPSBindingTable = bind_offset;<br>
> +   }<br>
> +#endif<br>
> +}<br>
> +<br>
> +static void<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>
> +      .MipModeFilter = MIPFILTER_NONE,<br>
> +      .MagModeFilter = MAPFILTER_LINEAR,<br>
> +      .MinModeFilter = MAPFILTER_LINEAR,<br>
> +      .MinLOD = 0,<br>
> +      .MaxLOD = 0,<br>
> +      .TCXAddressControlMode = TCM_CLAMP,<br>
> +      .TCYAddressControlMode = TCM_CLAMP,<br>
> +      .TCZAddressControlMode = TCM_CLAMP,<br>
> +      .MaximumAnisotropy = RATIO21,<br>
> +      .<wbr>RAddressMinFilterRoundingEnabl<wbr>e = true,<br>
> +      .<wbr>RAddressMagFilterRoundingEnabl<wbr>e = true,<br>
> +      .<wbr>VAddressMinFilterRoundingEnabl<wbr>e = true,<br>
> +      .<wbr>VAddressMagFilterRoundingEnabl<wbr>e = true,<br>
> +      .<wbr>UAddressMinFilterRoundingEnabl<wbr>e = true,<br>
> +      .<wbr>UAddressMagFilterRoundingEnabl<wbr>e = true,<br>
> +      .NonnormalizedCoordinateEnable = true,<br>
> +   };<br>
> +<br>
> +   uint32_t offset;<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(batch, GENX(3DSTATE_SAMPLER_STATE_<wbr>POINTERS_PS), ssp) {<br>
> +      ssp.PointertoPSSamplerState = offset;<br>
> +   }<br>
> +#else<br>
> +   blorp_emit(batch, GENX(3DSTATE_SAMPLER_STATE_<wbr>POINTERS), ssp) {<br>
> +      ssp.VSSamplerStateChange = true;<br>
> +      ssp.GSSamplerStateChange = true;<br>
> +      ssp.PSSamplerStateChange = true;<br>
> +      ssp.PointertoPSSamplerState = offset;<br>
> +   }<br>
> +#endif<br>
> +}<br>
> +<br>
> +/* 3DSTATE_VIEWPORT_STATE_<wbr>POINTERS */<br>
> +static void<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>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)(&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(batch, GENX(3DSTATE_VIEWPORT_STATE_<wbr>POINTERS_CC), vsp) {<br>
> +      vsp.CCViewportPointer = cc_vp_offset;<br>
> +   }<br>
> +#else<br>
> +   blorp_emit(batch, GENX(3DSTATE_VIEWPORT_STATE_<wbr>POINTERS), vsp) {<br>
> +      vsp.CCViewportStateChange = true;<br>
> +      vsp.PointertoCC_VIEWPORT = cc_vp_offset;<br>
> +   }<br>
> +#endif<br>
> +}<br>
> +<br>
> +<br>
> +/**<br>
> + * \brief Execute a blit or render pass operation.<br>
> + *<br>
> + * To execute the operation, this function manually constructs and emits a<br>
> + * batch to draw a rectangle primitive. The batchbuffer is flushed before<br>
> + * constructing and after emitting the batch.<br>
> + *<br>
> + * This function alters no GL state.<br>
> + */<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>
> +   uint32_t blend_state_offset = 0;<br>
> +   uint32_t color_calc_state_offset = 0;<br>
> +   uint32_t depth_stencil_state_offset;<br>
> +<br>
> +   blorp_emit_vertex_buffers(<wbr>batch, params);<br>
> +   blorp_emit_vertex_elements(<wbr>batch, params);<br>
> +<br>
> +   emit_urb_config(batch, params);<br>
> +<br>
> +   if (params->wm_prog_data) {<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(batch, params);<br>
> +<br>
> +#if GEN_GEN <= 6<br>
> +   /* The dynamic state emit helpers emit their own STATE_POINTERS packets on<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(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>
> +      cc.PointertoBLEND_STATE = blend_state_offset;<br>
> +      cc.PointertoCOLOR_CALC_STATE = color_calc_state_offset;<br>
> +      cc.PointertoDEPTH_STENCIL_<wbr>STATE = depth_stencil_state_offset;<br>
> +   }<br>
> +#else<br>
> +   (void)blend_state_offset;<br>
> +   (void)color_calc_state_offset;<br>
> +   (void)depth_stencil_state_<wbr>offset;<br>
> +#endif<br>
> +<br>
> +   blorp_emit(batch, GENX(3DSTATE_CONSTANT_VS), vs);<br>
> +#if GEN_GEN >= 7<br>
> +   blorp_emit(batch, GENX(3DSTATE_CONSTANT_HS), hs);<br>
> +   blorp_emit(batch, GENX(3DSTATE_CONSTANT_DS), DS);<br>
> +#endif<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(<wbr>batch, params);<br>
> +<br>
> +   if (params->src.addr.buffer)<br>
> +      blorp_emit_sampler_state(<wbr>batch, params);<br>
> +<br>
> +   blorp_emit_3dstate_<wbr>multisample(batch.blorp, batch.batch,<br>
> +                                  params->dst.surf.samples);<br>
> +<br>
> +   blorp_emit(batch, GENX(3DSTATE_SAMPLE_MASK), mask) {<br>
> +      mask.SampleMask = (1 << params->dst.surf.samples) - 1;<br>
> +   }<br>
> +<br>
> +   blorp_emit(batch, GENX(3DSTATE_VS), vs);<br>
> +#if GEN_GEN >= 7<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(batch, GENX(3DSTATE_GS), gs);<br>
> +<br>
> +   blorp_emit(batch, GENX(3DSTATE_CLIP), clip) {<br>
> +      clip.PerspectiveDivideDisable = true;<br>
> +   }<br>
> +<br>
> +   blorp_emit_sf_config(batch, params);<br>
> +   blorp_emit_ps_config(batch, params);<br>
> +<br>
> +   blorp_emit_viewport_state(<wbr>batch, params);<br>
> +<br>
> +   if (params->depth.addr.buffer) {<br>
> +      blorp_emit_depth_stencil_<wbr>config(batch, params);<br>
> +   } else {<br>
> +      blorp_emit(batch, GENX(3DSTATE_DEPTH_BUFFER), db) {<br>
> +         db.SurfaceType = SURFTYPE_NULL;<br>
> +         db.SurfaceFormat = D32_FLOAT;<br>
> +      }<br>
> +      blorp_emit(batch, GENX(3DSTATE_HIER_DEPTH_<wbr>BUFFER), hiz);<br>
> +      blorp_emit(batch, GENX(3DSTATE_STENCIL_BUFFER), sb);<br>
> +   }<br>
> +<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(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(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>
> 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>