[Mesa-dev] [PATCH 2/2] blorp: Embed a wm_prog_data in blorp_prog_data

Pohjolainen, Topi topi.pohjolainen at gmail.com
Wed Feb 1 08:01:31 UTC 2017


On Tue, Jan 31, 2017 at 11:05:28AM -0800, Jason Ekstrand wrote:
> While we're at it, we rename it to remove the brw_ prefix

Nice! Both patches:

Reviewed-by: Topi Pohjolainen <topi.pohjolainen at intel.com>

> 
> Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
> ---
>  src/intel/blorp/blorp.c           | 26 +++++---------
>  src/intel/blorp/blorp_blit.c      |  2 +-
>  src/intel/blorp/blorp_clear.c     |  2 +-
>  src/intel/blorp/blorp_genX_exec.h | 72 +++++++++++++++++++--------------------
>  src/intel/blorp/blorp_priv.h      | 30 ++++------------
>  5 files changed, 52 insertions(+), 80 deletions(-)
> 
> diff --git a/src/intel/blorp/blorp.c b/src/intel/blorp/blorp.c
> index 2f27274..8a90c3b 100644
> --- a/src/intel/blorp/blorp.c
> +++ b/src/intel/blorp/blorp.c
> @@ -145,7 +145,7 @@ const unsigned *
>  brw_blorp_compile_nir_shader(struct blorp_context *blorp, struct nir_shader *nir,
>                               const struct brw_wm_prog_key *wm_key,
>                               bool use_repclear,
> -                             struct brw_blorp_prog_data *prog_data,
> +                             struct blorp_prog_data *prog_data,
>                               unsigned *program_size)
>  {
>     const struct brw_compiler *compiler = blorp->compiler;
> @@ -160,15 +160,14 @@ brw_blorp_compile_nir_shader(struct blorp_context *blorp, struct nir_shader *nir
>     nir->options =
>        compiler->glsl_compiler_options[MESA_SHADER_FRAGMENT].NirOptions;
>  
> -   struct brw_wm_prog_data wm_prog_data;
> -   memset(&wm_prog_data, 0, sizeof(wm_prog_data));
> +   memset(prog_data, 0, sizeof(*prog_data));
>  
> -   wm_prog_data.base.nr_params = 0;
> -   wm_prog_data.base.param = NULL;
> +   prog_data->wm.base.nr_params = 0;
> +   prog_data->wm.base.param = NULL;
>  
>     /* BLORP always just uses the first two binding table entries */
> -   wm_prog_data.binding_table.render_target_start = BLORP_RENDERBUFFER_BT_INDEX;
> -   wm_prog_data.base.binding_table.texture_start = BLORP_TEXTURE_BT_INDEX;
> +   prog_data->wm.binding_table.render_target_start = BLORP_RENDERBUFFER_BT_INDEX;
> +   prog_data->wm.base.binding_table.texture_start = BLORP_TEXTURE_BT_INDEX;
>  
>     nir = brw_preprocess_nir(compiler, nir);
>     nir_remove_dead_variables(nir, nir_var_shader_in);
> @@ -176,21 +175,12 @@ brw_blorp_compile_nir_shader(struct blorp_context *blorp, struct nir_shader *nir
>  
>     const unsigned *program =
>        brw_compile_fs(compiler, blorp->driver_ctx, mem_ctx,
> -                     wm_key, &wm_prog_data, nir,
> +                     wm_key, &prog_data->wm, nir,
>                       NULL, -1, -1, false, use_repclear, program_size, NULL);
>  
> -   /* Copy the relavent bits of wm_prog_data over into the blorp prog data */
> -   prog_data->dispatch_8 = wm_prog_data.dispatch_8;
> -   prog_data->dispatch_16 = wm_prog_data.dispatch_16;
> -   prog_data->first_curbe_grf_0 = wm_prog_data.base.dispatch_grf_start_reg;
> -   prog_data->first_curbe_grf_2 = wm_prog_data.dispatch_grf_start_reg_2;
> -   prog_data->ksp_offset_2 = wm_prog_data.prog_offset_2;
> -   prog_data->persample_msaa_dispatch = wm_prog_data.persample_dispatch;
> -   prog_data->flat_inputs = wm_prog_data.flat_inputs;
> -   prog_data->num_varying_inputs = wm_prog_data.num_varying_inputs;
>     prog_data->inputs_read = nir->info.inputs_read;
>  
> -   assert(wm_prog_data.base.nr_params == 0);
> +   assert(prog_data->wm.base.nr_params == 0);
>  
>     return program;
>  }
> diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c
> index af46389..fc9e737 100644
> --- a/src/intel/blorp/blorp_blit.c
> +++ b/src/intel/blorp/blorp_blit.c
> @@ -1235,7 +1235,7 @@ brw_blorp_get_blit_kernel(struct blorp_context *blorp,
>  
>     const unsigned *program;
>     unsigned program_size;
> -   struct brw_blorp_prog_data prog_data;
> +   struct blorp_prog_data prog_data;
>  
>     /* Try and compile with NIR first.  If that fails, fall back to the old
>      * method of building shaders manually.
> diff --git a/src/intel/blorp/blorp_clear.c b/src/intel/blorp/blorp_clear.c
> index ce9b292..01889b8 100644
> --- a/src/intel/blorp/blorp_clear.c
> +++ b/src/intel/blorp/blorp_clear.c
> @@ -73,7 +73,7 @@ blorp_params_get_clear_kernel(struct blorp_context *blorp,
>     struct brw_wm_prog_key wm_key;
>     brw_blorp_init_wm_prog_key(&wm_key);
>  
> -   struct brw_blorp_prog_data prog_data;
> +   struct blorp_prog_data prog_data;
>     unsigned program_size;
>     const unsigned *program =
>        brw_blorp_compile_nir_shader(blorp, b.shader, &wm_key, use_replicated_data,
> diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h
> index 71beadc..bb665e2 100644
> --- a/src/intel/blorp/blorp_genX_exec.h
> +++ b/src/intel/blorp/blorp_genX_exec.h
> @@ -156,7 +156,7 @@ emit_urb_config(struct blorp_batch *batch,
>      * where 'n' stands for number of varying inputs expressed as vec4s.
>      */
>      const unsigned num_varyings =
> -       params->wm_prog_data ? params->wm_prog_data->num_varying_inputs : 0;
> +       params->wm_prog_data ? params->wm_prog_data->wm.num_varying_inputs : 0;
>      const unsigned total_needed = 16 + 16 + num_varyings * 16;
>  
>     /* The URB size is expressed in units of 64 bytes (512 bits) */
> @@ -191,7 +191,7 @@ blorp_emit_input_varying_data(struct blorp_batch *batch,
>     const unsigned vec4_size_in_bytes = 4 * sizeof(float);
>     const unsigned max_num_varyings =
>        DIV_ROUND_UP(sizeof(params->wm_inputs), vec4_size_in_bytes);
> -   const unsigned num_varyings = params->wm_prog_data->num_varying_inputs;
> +   const unsigned num_varyings = params->wm_prog_data->wm.num_varying_inputs;
>  
>     *size = num_varyings * vec4_size_in_bytes;
>  
> @@ -239,7 +239,7 @@ blorp_emit_vertex_buffers(struct blorp_batch *batch,
>     vb[0].EndAddress.offset += size - 1;
>  #endif
>  
> -   if (params->wm_prog_data && params->wm_prog_data->num_varying_inputs) {
> +   if (params->wm_prog_data && params->wm_prog_data->wm.num_varying_inputs) {
>        blorp_emit_input_varying_data(batch, params,
>                                      &vb[1].BufferStartingAddress, &size);
>        vb[1].VertexBufferIndex = 1;
> @@ -273,7 +273,7 @@ blorp_emit_vertex_elements(struct blorp_batch *batch,
>                             const struct blorp_params *params)
>  {
>     const unsigned num_varyings =
> -      params->wm_prog_data ? params->wm_prog_data->num_varying_inputs : 0;
> +      params->wm_prog_data ? params->wm_prog_data->wm.num_varying_inputs : 0;
>     const unsigned num_elements = 2 + num_varyings;
>  
>     struct GENX(VERTEX_ELEMENT_STATE) ve[num_elements];
> @@ -381,7 +381,7 @@ static void
>  blorp_emit_sf_config(struct blorp_batch *batch,
>                       const struct blorp_params *params)
>  {
> -   const struct brw_blorp_prog_data *prog_data = params->wm_prog_data;
> +   const struct blorp_prog_data *prog_data = params->wm_prog_data;
>  
>     /* 3DSTATE_SF
>      *
> @@ -412,11 +412,11 @@ blorp_emit_sf_config(struct blorp_batch *batch,
>  
>     blorp_emit(batch, GENX(3DSTATE_SBE), sbe) {
>        sbe.VertexURBEntryReadOffset = 1;
> -      sbe.NumberofSFOutputAttributes = prog_data->num_varying_inputs;
> -      sbe.VertexURBEntryReadLength = brw_blorp_get_urb_length(prog_data);
> +      sbe.NumberofSFOutputAttributes = prog_data->wm.num_varying_inputs;
> +      sbe.VertexURBEntryReadLength = blorp_get_urb_length(prog_data);
>        sbe.ForceVertexURBEntryReadLength = true;
>        sbe.ForceVertexURBEntryReadOffset = true;
> -      sbe.ConstantInterpolationEnable = prog_data->flat_inputs;
> +      sbe.ConstantInterpolationEnable = prog_data->wm.flat_inputs;
>  
>  #if GEN_GEN >= 9
>        for (unsigned i = 0; i < 32; i++)
> @@ -441,9 +441,9 @@ blorp_emit_sf_config(struct blorp_batch *batch,
>     blorp_emit(batch, GENX(3DSTATE_SBE), sbe) {
>        sbe.VertexURBEntryReadOffset = 1;
>        if (prog_data) {
> -         sbe.NumberofSFOutputAttributes = prog_data->num_varying_inputs;
> -         sbe.VertexURBEntryReadLength = brw_blorp_get_urb_length(prog_data);
> -         sbe.ConstantInterpolationEnable = prog_data->flat_inputs;
> +         sbe.NumberofSFOutputAttributes = prog_data->wm.num_varying_inputs;
> +         sbe.VertexURBEntryReadLength = blorp_get_urb_length(prog_data);
> +         sbe.ConstantInterpolationEnable = prog_data->wm.flat_inputs;
>        } else {
>           sbe.NumberofSFOutputAttributes = 0;
>           sbe.VertexURBEntryReadLength = 1;
> @@ -461,9 +461,9 @@ blorp_emit_sf_config(struct blorp_batch *batch,
>  
>        sf.VertexURBEntryReadOffset = 1;
>        if (prog_data) {
> -         sf.NumberofSFOutputAttributes = prog_data->num_varying_inputs;
> -         sf.VertexURBEntryReadLength = brw_blorp_get_urb_length(prog_data);
> -         sf.ConstantInterpolationEnable = prog_data->flat_inputs;
> +         sf.NumberofSFOutputAttributes = prog_data->wm.num_varying_inputs;
> +         sf.VertexURBEntryReadLength = blorp_get_urb_length(prog_data);
> +         sf.ConstantInterpolationEnable = prog_data->wm.flat_inputs;
>        } else {
>           sf.NumberofSFOutputAttributes = 0;
>           sf.VertexURBEntryReadLength = 1;
> @@ -477,7 +477,7 @@ static void
>  blorp_emit_ps_config(struct blorp_batch *batch,
>                       const struct blorp_params *params)
>  {
> -   const struct brw_blorp_prog_data *prog_data = params->wm_prog_data;
> +   const struct blorp_prog_data *prog_data = params->wm_prog_data;
>  
>     /* Even when thread dispatch is disabled, max threads (dw5.25:31) must be
>      * nonzero to prevent the GPU from hanging.  While the documentation doesn't
> @@ -501,16 +501,16 @@ blorp_emit_ps_config(struct blorp_batch *batch,
>        }
>  
>        ps.DispatchGRFStartRegisterForConstantSetupData0 =
> -         prog_data->first_curbe_grf_0;
> +         prog_data->wm.base.dispatch_grf_start_reg;
>        ps.DispatchGRFStartRegisterForConstantSetupData2 =
> -         prog_data->first_curbe_grf_2;
> +         prog_data->wm.dispatch_grf_start_reg_2;
>  
> -      ps._8PixelDispatchEnable = prog_data->dispatch_8;
> -      ps._16PixelDispatchEnable = prog_data->dispatch_16;
> +      ps._8PixelDispatchEnable = prog_data->wm.dispatch_8;
> +      ps._16PixelDispatchEnable = prog_data->wm.dispatch_16;
>  
>        ps.KernelStartPointer0 = params->wm_prog_kernel;
>        ps.KernelStartPointer2 =
> -         params->wm_prog_kernel + prog_data->ksp_offset_2;
> +         params->wm_prog_kernel + prog_data->wm.prog_offset_2;
>  
>        /* 3DSTATE_PS expects the number of threads per PSD, which is always 64;
>         * it implicitly scales for different GT levels (which have some # of
> @@ -552,9 +552,9 @@ blorp_emit_ps_config(struct blorp_batch *batch,
>        if (params->src.addr.buffer)
>           psx.PixelShaderKillsPixel = true;
>  
> -      psx.AttributeEnable = prog_data->num_varying_inputs > 0;
> +      psx.AttributeEnable = prog_data->wm.num_varying_inputs > 0;
>  
> -      if (prog_data && prog_data->persample_msaa_dispatch)
> +      if (prog_data && prog_data->wm.persample_dispatch)
>           psx.PixelShaderIsPerSample = true;
>     }
>  
> @@ -586,7 +586,7 @@ blorp_emit_ps_config(struct blorp_batch *batch,
>        if (params->dst.surf.samples > 1) {
>           wm.MultisampleRasterizationMode = MSRASTMODE_ON_PATTERN;
>           wm.MultisampleDispatchMode =
> -            (prog_data && prog_data->persample_msaa_dispatch) ?
> +            (prog_data && prog_data->wm.persample_dispatch) ?
>              MSDISPMODE_PERSAMPLE : MSDISPMODE_PERPIXEL;
>        } else {
>           wm.MultisampleRasterizationMode = MSRASTMODE_OFF_PIXEL;
> @@ -604,18 +604,18 @@ blorp_emit_ps_config(struct blorp_batch *batch,
>  
>        if (prog_data) {
>           ps.DispatchGRFStartRegisterforConstantSetupData0 =
> -            prog_data->first_curbe_grf_0;
> +            prog_data->wm.base.dispatch_grf_start_reg;
>           ps.DispatchGRFStartRegisterforConstantSetupData2 =
> -            prog_data->first_curbe_grf_2;
> +            prog_data->wm.dispatch_grf_start_reg_2;
>  
>           ps.KernelStartPointer0 = params->wm_prog_kernel;
>           ps.KernelStartPointer2 =
> -            params->wm_prog_kernel + prog_data->ksp_offset_2;
> +            params->wm_prog_kernel + prog_data->wm.prog_offset_2;
>  
> -         ps._8PixelDispatchEnable = prog_data->dispatch_8;
> -         ps._16PixelDispatchEnable = prog_data->dispatch_16;
> +         ps._8PixelDispatchEnable = prog_data->wm.dispatch_8;
> +         ps._16PixelDispatchEnable = prog_data->wm.dispatch_16;
>  
> -         ps.AttributeEnable = prog_data->num_varying_inputs > 0;
> +         ps.AttributeEnable = prog_data->wm.num_varying_inputs > 0;
>        } else {
>           /* Gen7 hardware gets angry if we don't enable at least one dispatch
>            * mode, so just enable 16-pixel dispatch if we don't have a program.
> @@ -666,18 +666,18 @@ blorp_emit_ps_config(struct blorp_batch *batch,
>           wm.ThreadDispatchEnable = true;
>  
>           wm.DispatchGRFStartRegisterforConstantSetupData0 =
> -            prog_data->first_curbe_grf_0;
> +            prog_data->wm.base.dispatch_grf_start_reg;
>           wm.DispatchGRFStartRegisterforConstantSetupData2 =
> -            prog_data->first_curbe_grf_2;
> +            prog_data->wm.dispatch_grf_start_reg_2;
>  
>           wm.KernelStartPointer0 = params->wm_prog_kernel;
>           wm.KernelStartPointer2 =
> -            params->wm_prog_kernel + prog_data->ksp_offset_2;
> +            params->wm_prog_kernel + prog_data->wm.prog_offset_2;
>  
> -         wm._8PixelDispatchEnable = prog_data->dispatch_8;
> -         wm._16PixelDispatchEnable = prog_data->dispatch_16;
> +         wm._8PixelDispatchEnable = prog_data->wm.dispatch_8;
> +         wm._16PixelDispatchEnable = prog_data->wm.dispatch_16;
>  
> -         wm.NumberofSFOutputAttributes = prog_data->num_varying_inputs;
> +         wm.NumberofSFOutputAttributes = prog_data->wm.num_varying_inputs;
>        }
>  
>        if (params->src.addr.buffer) {
> @@ -688,7 +688,7 @@ blorp_emit_ps_config(struct blorp_batch *batch,
>        if (params->dst.surf.samples > 1) {
>           wm.MultisampleRasterizationMode = MSRASTMODE_ON_PATTERN;
>           wm.MultisampleDispatchMode =
> -            (prog_data && prog_data->persample_msaa_dispatch) ?
> +            (prog_data && prog_data->wm.persample_dispatch) ?
>              MSDISPMODE_PERSAMPLE : MSDISPMODE_PERPIXEL;
>        } else {
>           wm.MultisampleRasterizationMode = MSRASTMODE_OFF_PIXEL;
> diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h
> index a88d0f8..70cdfbc 100644
> --- a/src/intel/blorp/blorp_priv.h
> +++ b/src/intel/blorp/blorp_priv.h
> @@ -135,33 +135,15 @@ struct brw_blorp_wm_inputs
>     uint32_t pad[1];
>  };
>  
> -struct brw_blorp_prog_data
> +struct blorp_prog_data
>  {
> -   bool dispatch_8;
> -   bool dispatch_16;
> +   struct brw_wm_prog_data wm;
>  
> -   uint8_t first_curbe_grf_0;
> -   uint8_t first_curbe_grf_2;
> -
> -   uint32_t ksp_offset_2;
> -
> -   /**
> -    * True if the WM program should be run in MSDISPMODE_PERSAMPLE with more
> -    * than one sample per pixel.
> -    */
> -   bool persample_msaa_dispatch;
> -
> -   /**
> -    * Mask of which FS inputs are marked flat by the shader source.  This is
> -    * needed for setting up 3DSTATE_SF/SBE.
> -    */
> -   uint32_t flat_inputs;
> -   unsigned num_varying_inputs;
>     uint64_t inputs_read;
>  };
>  
>  static inline unsigned
> -brw_blorp_get_urb_length(const struct brw_blorp_prog_data *prog_data)
> +blorp_get_urb_length(const struct blorp_prog_data *prog_data)
>  {
>     if (prog_data == NULL)
>        return 1;
> @@ -170,7 +152,7 @@ brw_blorp_get_urb_length(const struct brw_blorp_prog_data *prog_data)
>      *
>      * read_length = ceiling((max_source_attr+1)/2)
>      */
> -   return MAX2((prog_data->num_varying_inputs + 1) / 2, 1);
> +   return MAX2((prog_data->wm.num_varying_inputs + 1) / 2, 1);
>  }
>  
>  struct blorp_params
> @@ -190,7 +172,7 @@ struct blorp_params
>     unsigned num_draw_buffers;
>     unsigned num_layers;
>     uint32_t wm_prog_kernel;
> -   struct brw_blorp_prog_data *wm_prog_data;
> +   struct blorp_prog_data *wm_prog_data;
>  };
>  
>  void blorp_params_init(struct blorp_params *params);
> @@ -306,7 +288,7 @@ const unsigned *
>  brw_blorp_compile_nir_shader(struct blorp_context *blorp, struct nir_shader *nir,
>                               const struct brw_wm_prog_key *wm_key,
>                               bool use_repclear,
> -                             struct brw_blorp_prog_data *prog_data,
> +                             struct blorp_prog_data *prog_data,
>                               unsigned *program_size);
>  
>  /** \} */
> -- 
> 2.5.0.400.gff86faf
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list