[Mesa-dev] [PATCH 1/4] i965: Virtualize emit_buffer_surface_state().

Kenneth Graunke kenneth at whitecape.org
Fri Nov 1 20:23:11 PDT 2013


This entails adding "mocs" and "rw" parameters to the Gen4-5 version.
I made it actually pay attention to the rw flag (even though it is
always false), but mocs is always ignored.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_context.h           |  9 +++++++++
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c  | 14 ++++++++++----
 src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |  1 +
 3 files changed, 20 insertions(+), 4 deletions(-)

I was rebasing Broadwell code today and realized I hadn't finished my
emit_buffer_surface_state rework.  This cuts a bit more duplication,
which is nice since I'm about to add Gen8+ variants.

No Piglit regressions on Ivybridge.

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index bec4d6b..e146efa 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -989,6 +989,15 @@ struct brw_context
                                  uint32_t size,
                                  uint32_t *out_offset,
                                  bool rw);
+      void (*emit_buffer_surface_state)(struct brw_context *brw,
+                                        uint32_t *out_offset,
+                                        drm_intel_bo *bo,
+                                        unsigned buffer_offset,
+                                        unsigned surface_format,
+                                        unsigned buffer_size,
+                                        unsigned pitch,
+                                        unsigned mocs,
+                                        bool rw);
 
       /** Upload a SAMPLER_STATE table. */
       void (*upload_sampler_state_table)(struct brw_context *brw,
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 46871c7..5d43a0d 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -197,7 +197,9 @@ gen4_emit_buffer_surface_state(struct brw_context *brw,
                                unsigned buffer_offset,
                                unsigned surface_format,
                                unsigned buffer_size,
-                               unsigned pitch)
+                               unsigned pitch,
+                               unsigned mocs,
+                               bool rw)
 {
    uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
                                     6 * 4, 32, out_offset);
@@ -219,7 +221,8 @@ gen4_emit_buffer_surface_state(struct brw_context *brw,
    if (bo) {
       drm_intel_bo_emit_reloc(brw->batch.bo, *out_offset + 4,
                               bo, buffer_offset,
-                              I915_GEM_DOMAIN_SAMPLER, 0);
+                              I915_GEM_DOMAIN_SAMPLER,
+                              (rw ? I915_GEM_DOMAIN_SAMPLER : 0));
    }
 }
 
@@ -252,7 +255,9 @@ brw_update_buffer_texture_surface(struct gl_context *ctx,
                                   tObj->BufferOffset,
                                   brw_format,
                                   size / texel_size,
-                                  texel_size);
+                                  texel_size,
+                                  0,
+                                  false);
 }
 
 static void
@@ -329,7 +334,7 @@ brw_create_constant_surface(struct brw_context *brw,
 
    gen4_emit_buffer_surface_state(brw, out_offset, bo, offset,
                                   BRW_SURFACEFORMAT_R32G32B32A32_FLOAT,
-                                  elements, stride);
+                                  elements, stride, 0, false);
 }
 
 /**
@@ -927,4 +932,5 @@ gen4_init_vtable_surface_functions(struct brw_context *brw)
    brw->vtbl.update_null_renderbuffer_surface =
       brw_update_null_renderbuffer_surface;
    brw->vtbl.create_constant_surface = brw_create_constant_surface;
+   brw->vtbl.emit_buffer_surface_state = gen4_emit_buffer_surface_state;
 }
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index ed7565f..2a42e32 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -615,4 +615,5 @@ gen7_init_vtable_surface_functions(struct brw_context *brw)
       gen7_update_null_renderbuffer_surface;
    brw->vtbl.create_constant_surface = gen7_create_constant_surface;
    brw->vtbl.create_raw_surface = gen7_create_raw_surface;
+   brw->vtbl.emit_buffer_surface_state = gen7_emit_buffer_surface_state;
 }
-- 
1.8.3.2



More information about the mesa-dev mailing list