[Mesa-dev] [PATCH 08/22] intel/blorp: Add an "enabled" bit to surface_info

Jason Ekstrand jason at jlekstrand.net
Sat Oct 8 04:41:06 UTC 2016


This gives a slightly smarter way to check whether or not a particular
surface exists than looking at the address.

Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
---
 src/intel/blorp/blorp.c           |  2 ++
 src/intel/blorp/blorp_genX_exec.h | 30 +++++++++++++++---------------
 src/intel/blorp/blorp_priv.h      |  2 ++
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/src/intel/blorp/blorp.c b/src/intel/blorp/blorp.c
index 1c8fd55..91513a0 100644
--- a/src/intel/blorp/blorp.c
+++ b/src/intel/blorp/blorp.c
@@ -64,6 +64,8 @@ brw_blorp_surface_info_init(struct blorp_context *blorp,
                             unsigned int level, unsigned int layer,
                             enum isl_format format, bool is_render_target)
 {
+   info->enabled = true;
+
    if (format == ISL_FORMAT_UNSUPPORTED)
       format = surf->surf->format;
 
diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h
index d72965e..737194a 100644
--- a/src/intel/blorp/blorp_genX_exec.h
+++ b/src/intel/blorp/blorp_genX_exec.h
@@ -510,7 +510,7 @@ blorp_emit_ps_config(struct blorp_batch *batch,
    blorp_emit(batch, GENX(3DSTATE_WM), wm);
 
    blorp_emit(batch, GENX(3DSTATE_PS), ps) {
-      if (params->src.addr.buffer) {
+      if (params->src.enabled) {
          ps.SamplerCount = 1; /* Up to 4 samplers */
          ps.BindingTableEntryCount = 2;
       } else {
@@ -566,7 +566,7 @@ blorp_emit_ps_config(struct blorp_batch *batch,
    blorp_emit(batch, GENX(3DSTATE_PS_EXTRA), psx) {
       psx.PixelShaderValid = true;
 
-      if (params->src.addr.buffer)
+      if (params->src.enabled)
          psx.PixelShaderKillsPixel = true;
 
       psx.AttributeEnable = prog_data->num_varying_inputs > 0;
@@ -597,7 +597,7 @@ blorp_emit_ps_config(struct blorp_batch *batch,
       if (prog_data)
          wm.ThreadDispatchEnable = true;
 
-      if (params->src.addr.buffer)
+      if (params->src.enabled)
          wm.PixelShaderKillPixel = true;
 
       if (params->dst.surf.samples > 1) {
@@ -640,7 +640,7 @@ blorp_emit_ps_config(struct blorp_batch *batch,
          ps._16PixelDispatchEnable = true;
       }
 
-      if (params->src.addr.buffer)
+      if (params->src.enabled)
          ps.SamplerCount = 1; /* Up to 4 samplers */
 
       switch (params->fast_clear_op) {
@@ -697,7 +697,7 @@ blorp_emit_ps_config(struct blorp_batch *batch,
          wm.NumberofSFOutputAttributes = prog_data->num_varying_inputs;
       }
 
-      if (params->src.addr.buffer) {
+      if (params->src.enabled) {
          wm.SamplerCount = 1; /* Up to 4 samplers */
          wm.PixelShaderKillPixel = true; /* TODO: temporarily smash on */
       }
@@ -734,15 +734,15 @@ blorp_emit_depth_stencil_config(struct blorp_batch *batch,
 
    blorp_emit(batch, GENX(3DSTATE_DEPTH_BUFFER), db) {
 #if GEN_GEN >= 7
-      db.DepthWriteEnable = params->depth.addr.buffer != NULL;
-      db.StencilWriteEnable = params->stencil.addr.buffer != NULL;
+      db.DepthWriteEnable = params->depth.enabled;
+      db.StencilWriteEnable = params->stencil.enabled;
 #endif
 
 #if GEN_GEN <= 6
       db.SeparateStencilBufferEnable = true;
 #endif
 
-      if (params->depth.addr.buffer) {
+      if (params->depth.enabled) {
          db.SurfaceType = isl_to_gen_surf_dim[params->depth.surf.dim];
          db.SurfaceFormat = params->depth_format;
 
@@ -767,7 +767,7 @@ blorp_emit_depth_stencil_config(struct blorp_batch *batch,
          db.SurfacePitch = params->depth.surf.row_pitch - 1;
          db.SurfaceBaseAddress = params->depth.addr;
          db.DepthBufferMOCS = mocs;
-      } else if (params->stencil.addr.buffer) {
+      } else if (params->stencil.enabled) {
          db.SurfaceFormat = D32_FLOAT;
 
          db.SurfaceType = isl_to_gen_surf_dim[params->stencil.surf.dim];
@@ -794,7 +794,7 @@ blorp_emit_depth_stencil_config(struct blorp_batch *batch,
    }
 
    blorp_emit(batch, GENX(3DSTATE_STENCIL_BUFFER), sb) {
-      if (params->stencil.addr.buffer) {
+      if (params->stencil.enabled) {
 #if GEN_GEN >= 8 || GEN_IS_HASWELL
          sb.StencilBufferEnable = true;
 #endif
@@ -904,7 +904,7 @@ blorp_emit_depth_stencil_state(struct blorp_batch *batch,
    struct GENX(DEPTH_STENCIL_STATE) ds = { 0 };
 #endif
 
-   if (params->depth.addr.buffer) {
+   if (params->depth.enabled) {
       ds.DepthBufferWriteEnable = true;
 
       switch (params->hiz_op) {
@@ -930,7 +930,7 @@ blorp_emit_depth_stencil_state(struct blorp_batch *batch,
       }
    }
 
-   if (params->stencil.addr.buffer) {
+   if (params->stencil.enabled) {
       ds.StencilBufferWriteEnable = true;
       ds.StencilTestEnable = true;
       ds.DoubleSidedStencilEnable = false;
@@ -1033,14 +1033,14 @@ blorp_emit_surface_states(struct blorp_batch *batch,
    const unsigned ss_size = GENX(RENDER_SURFACE_STATE_length) * 4;
    const unsigned ss_align = GENX(RENDER_SURFACE_STATE_length) > 8 ? 64 : 32;
 
-   unsigned num_surfaces = 1 + (params->src.addr.buffer != NULL);
+   unsigned num_surfaces = 1 + params->src.enabled;
    blorp_alloc_binding_table(batch, num_surfaces, ss_size, ss_align,
                              &bind_offset, surface_offsets, surface_maps);
 
    blorp_emit_surface_state(batch, &params->dst,
                             surface_maps[BLORP_RENDERBUFFER_BT_INDEX],
                             surface_offsets[BLORP_RENDERBUFFER_BT_INDEX], true);
-   if (params->src.addr.buffer) {
+   if (params->src.enabled) {
       blorp_emit_surface_state(batch, &params->src,
                                surface_maps[BLORP_TEXTURE_BT_INDEX],
                                surface_offsets[BLORP_TEXTURE_BT_INDEX], false);
@@ -1238,7 +1238,7 @@ blorp_exec(struct blorp_batch *batch, const struct blorp_params *params)
    if (params->wm_prog_data)
       blorp_emit_surface_states(batch, params);
 
-   if (params->src.addr.buffer)
+   if (params->src.enabled)
       blorp_emit_sampler_state(batch, params);
 
    blorp_emit_3dstate_multisample(batch, params);
diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h
index e9f0124..70a7fcf 100644
--- a/src/intel/blorp/blorp_priv.h
+++ b/src/intel/blorp/blorp_priv.h
@@ -52,6 +52,8 @@ enum blorp_fast_clear_op {
 
 struct brw_blorp_surface_info
 {
+   bool enabled;
+
    struct isl_surf surf;
    struct blorp_address addr;
 
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list