[Mesa-dev] [PATCH 09/25] intel/blorp: Make the number of samples an explicit parameter

Jason Ekstrand jason at jlekstrand.net
Sat Oct 22 17:50:40 UTC 2016


Previously, we always inferred it from params->dst which meant that
references to params->dst were scattered all throughout the state upload
code.
---
 src/intel/blorp/blorp.c           |  1 +
 src/intel/blorp/blorp_blit.c      |  2 ++
 src/intel/blorp/blorp_clear.c     |  7 +++++++
 src/intel/blorp/blorp_genX_exec.h | 16 +++++++---------
 src/intel/blorp/blorp_priv.h      |  1 +
 5 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/intel/blorp/blorp.c b/src/intel/blorp/blorp.c
index 08afffe..ecea07e 100644
--- a/src/intel/blorp/blorp.c
+++ b/src/intel/blorp/blorp.c
@@ -141,6 +141,7 @@ void
 blorp_params_init(struct blorp_params *params)
 {
    memset(params, 0, sizeof(*params));
+   params->num_samples = 1;
    params->num_draw_buffers = 1;
    params->num_layers = 1;
 }
diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c
index 0c3ee72..37b6dd7 100644
--- a/src/intel/blorp/blorp_blit.c
+++ b/src/intel/blorp/blorp_blit.c
@@ -1611,6 +1611,8 @@ do_blorp_blit(struct blorp_batch *batch,
       wm_prog_key->persample_msaa_dispatch = true;
    }
 
+   params->num_samples = params->dst.surf.samples;
+
    if (params->src.tile_x_sa || params->src.tile_y_sa) {
       assert(wm_prog_key->need_src_offset);
       surf_get_intratile_offset_px(&params->src,
diff --git a/src/intel/blorp/blorp_clear.c b/src/intel/blorp/blorp_clear.c
index 8ecfaa3..0920049 100644
--- a/src/intel/blorp/blorp_clear.c
+++ b/src/intel/blorp/blorp_clear.c
@@ -234,6 +234,7 @@ blorp_fast_clear(struct blorp_batch *batch,
 
    brw_blorp_surface_info_init(batch->blorp, &params.dst, surf, level,
                                start_layer, format, true);
+   params.num_samples = params.dst.surf.samples;
 
    batch->blorp->exec(batch, &params);
 }
@@ -293,6 +294,8 @@ blorp_clear(struct blorp_batch *batch,
                                   start_layer, format, true);
       params.dst.view.swizzle = swizzle;
 
+      params.num_samples = params.dst.surf.samples;
+
       /* We may be restricted on the number of layers we can bind at any one
        * time.  In particular, Sandy Bridge has a maximum number of layers of
        * 512 but a maximum 3D texture size is much larger.
@@ -338,6 +341,8 @@ blorp_clear_depth_stencil(struct blorp_batch *batch,
             params.stencil.surf.logical_level0_px;
          params.dst.view = params.depth.view;
 
+         params.num_samples = params.stencil.surf.samples;
+
          /* We may be restricted on the number of layers we can bind at any
           * one time.  In particular, Sandy Bridge has a maximum number of
           * layers of 512 but a maximum 3D texture size is much larger.
@@ -359,6 +364,8 @@ blorp_clear_depth_stencil(struct blorp_batch *batch,
             params.depth.surf.logical_level0_px;
          params.dst.view = params.depth.view;
 
+         params.num_samples = params.depth.surf.samples;
+
          /* We may be restricted on the number of layers we can bind at any
           * one time.  In particular, Sandy Bridge has a maximum number of
           * layers of 512 but a maximum 3D texture size is much larger.
diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h
index d455714..1e99349 100644
--- a/src/intel/blorp/blorp_genX_exec.h
+++ b/src/intel/blorp/blorp_genX_exec.h
@@ -455,7 +455,7 @@ blorp_emit_sf_config(struct blorp_batch *batch,
       sf.FrontFaceFillMode = FILL_MODE_SOLID;
       sf.BackFaceFillMode = FILL_MODE_SOLID;
 
-      sf.MultisampleRasterizationMode = params->dst.surf.samples > 1 ?
+      sf.MultisampleRasterizationMode = params->num_samples > 1 ?
          MSRASTMODE_ON_PATTERN : MSRASTMODE_OFF_PIXEL;
 
 #if GEN_GEN == 7
@@ -481,7 +481,7 @@ blorp_emit_sf_config(struct blorp_batch *batch,
       sf.FrontFaceFillMode = FILL_MODE_SOLID;
       sf.BackFaceFillMode = FILL_MODE_SOLID;
 
-      sf.MultisampleRasterizationMode = params->dst.surf.samples > 1 ?
+      sf.MultisampleRasterizationMode = params->num_samples > 1 ?
          MSRASTMODE_ON_PATTERN : MSRASTMODE_OFF_PIXEL;
 
       sf.VertexURBEntryReadOffset = 1;
@@ -609,7 +609,7 @@ blorp_emit_ps_config(struct blorp_batch *batch,
       if (params->src.enabled)
          wm.PixelShaderKillPixel = true;
 
-      if (params->dst.surf.samples > 1) {
+      if (params->num_samples > 1) {
          wm.MultisampleRasterizationMode = MSRASTMODE_ON_PATTERN;
          wm.MultisampleDispatchMode =
             (prog_data && prog_data->persample_msaa_dispatch) ?
@@ -711,7 +711,7 @@ blorp_emit_ps_config(struct blorp_batch *batch,
          wm.PixelShaderKillPixel = true; /* TODO: temporarily smash on */
       }
 
-      if (params->dst.surf.samples > 1) {
+      if (params->num_samples > 1) {
          wm.MultisampleRasterizationMode = MSRASTMODE_ON_PATTERN;
          wm.MultisampleDispatchMode =
             (prog_data && prog_data->persample_msaa_dispatch) ?
@@ -1159,10 +1159,8 @@ static void
 blorp_emit_3dstate_multisample(struct blorp_batch *batch,
                                const struct blorp_params *params)
 {
-   const unsigned samples = params->dst.surf.samples;
-
    blorp_emit(batch, GENX(3DSTATE_MULTISAMPLE), ms) {
-      ms.NumberofMultisamples       = __builtin_ffs(samples) - 1;
+      ms.NumberofMultisamples       = __builtin_ffs(params->num_samples) - 1;
 
 #if GEN_GEN >= 8
       /* The PRM says that this bit is valid only for DX9:
@@ -1175,7 +1173,7 @@ blorp_emit_3dstate_multisample(struct blorp_batch *batch,
 #elif GEN_GEN >= 7
       ms.PixelLocation              = PIXLOC_CENTER;
 
-      switch (samples) {
+      switch (params->num_samples) {
       case 1:
          GEN_SAMPLE_POS_1X(ms.Sample);
          break;
@@ -1297,7 +1295,7 @@ blorp_exec(struct blorp_batch *batch, const struct blorp_params *params)
    blorp_emit_3dstate_multisample(batch, params);
 
    blorp_emit(batch, GENX(3DSTATE_SAMPLE_MASK), mask) {
-      mask.SampleMask = (1 << params->dst.surf.samples) - 1;
+      mask.SampleMask = (1 << params->num_samples) - 1;
    }
 
    /* From the BSpec, 3D Pipeline > Geometry > Vertex Shader > State,
diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h
index 1fbedce..4266f13 100644
--- a/src/intel/blorp/blorp_priv.h
+++ b/src/intel/blorp/blorp_priv.h
@@ -194,6 +194,7 @@ struct blorp_params
    enum blorp_fast_clear_op fast_clear_op;
    bool color_write_disable[4];
    struct brw_blorp_wm_inputs wm_inputs;
+   unsigned num_samples;
    unsigned num_draw_buffers;
    unsigned num_layers;
    uint32_t wm_prog_kernel;
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list