<div dir="ltr">On 15 September 2013 00:10, Francisco Jerez <span dir="ltr"><<a href="mailto:currojerez@riseup.net" target="_blank">currojerez@riseup.net</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">And add Gen7 implementation.<br>
---<br>
 src/mesa/drivers/dri/i965/brw_context.h           |  7 +++++<br>
 src/mesa/drivers/dri/i965/gen7_wm_surface_state.c | 35 +++++++++++++++++++----<br>
 2 files changed, 37 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h<br>
index 108e98c..3003d15 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_context.h<br>
@@ -895,6 +895,13 @@ struct brw_context<br>
                                      uint32_t *out_offset,<br>
                                       bool dword_pitch);<br>
<br>
+      void (*create_raw_surface)(struct brw_context *brw,<br>
+                                 drm_intel_bo *bo,<br>
+                                 uint32_t offset,<br>
+                                 uint32_t size,<br>
+                                 uint32_t *out_offset,<br>
+                                 bool rw);<br>
+<br>
       /** Upload a SAMPLER_STATE table. */<br>
       void (*upload_sampler_state_table)(struct brw_context *brw,<br>
                                          struct gl_program *prog,<br>
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c<br>
index 8f95abe..8b86387 100644<br>
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c<br>
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c<br>
@@ -232,7 +232,8 @@ gen7_emit_buffer_surface_state(struct brw_context *brw,<br>
                                unsigned surface_format,<br>
                                unsigned buffer_size,<br>
                                unsigned pitch,<br>
-                               unsigned mocs)<br>
+                               unsigned mocs,<br>
+                               bool rw)<br>
 {<br>
    uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,<br>
                                     8 * 4, 32, out_offset);<br>
@@ -251,7 +252,8 @@ gen7_emit_buffer_surface_state(struct brw_context *brw,<br>
<br>
    /* Emit relocation to surface contents */<br>
    drm_intel_bo_emit_reloc(brw-><a href="http://batch.bo" target="_blank">batch.bo</a>, *out_offset + 4,<br>
-                           bo, buffer_offset, I915_GEM_DOMAIN_SAMPLER, 0);<br>
+                           bo, buffer_offset, I915_GEM_DOMAIN_SAMPLER,<br>
+                           (rw ? I915_GEM_DOMAIN_SAMPLER : 0));<br>
<br>
    gen7_check_surface_setup(surf, false /* is_render_target */);<br>
 }<br>
@@ -348,7 +350,8 @@ gen7_update_buffer_texture_surface(struct gl_context *ctx,<br>
                                   surface_format,<br>
                                   w,<br>
                                   texel_size,<br>
-                                  0 /* mocs */);<br>
+                                  0 /* mocs */,<br>
+                                  false /* rw */);<br>
 }<br>
<br>
 static void<br>
@@ -429,7 +432,27 @@ gen7_create_constant_surface(struct brw_context *brw,<br>
                                   BRW_SURFACEFORMAT_R32G32B32A32_FLOAT,<br>
                                   elements - 1,<br>
                                   stride,<br>
-                                  0 /* mocs */);<br>
+                                  0 /* mocs */,<br>
+                                  false /* rw */);<br>
+}<br>
+<br>
+/**<br>
+ * Create a raw surface for untyped R/W access.<br>
+ */<br>
+static void<br>
+gen7_create_raw_surface(struct brw_context *brw, drm_intel_bo *bo,<br>
+                        uint32_t offset, uint32_t size,<br>
+                        uint32_t *out_offset, bool rw)<br>
+{<br>
+   gen7_emit_buffer_surface_state(brw,<br>
+                                  out_offset,<br>
+                                  bo,<br>
+                                  offset,<br>
+                                  BRW_SURFACEFORMAT_RAW,<br>
+                                  size - 1,<br></blockquote><div><br></div><div>Note: if you land this patch after Ken's "i965: Fix off by one errors in texture buffer size calculations.", I believe this will need to be just "size", not "size - 1".<br>
<br></div><div>In any case, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+                                  1,<br>
+                                  0 /* mocs */,<br>
+                                  true /* rw */);<br>
 }<br>
<br>
 /**<br>
@@ -445,7 +468,8 @@ gen7_create_shader_time_surface(struct brw_context *brw, uint32_t *out_offset)<br>
                                   BRW_SURFACEFORMAT_RAW,<br>
                                   brw->shader_time.bo->size - 1,<br>
                                   1,<br>
-                                  0 /* mocs */);<br>
+                                  0 /* mocs */,<br>
+                                  true /* rw */);<br>
 }<br>
<br>
 static void<br>
@@ -570,4 +594,5 @@ gen7_init_vtable_surface_functions(struct brw_context *brw)<br>
    brw->vtbl.update_null_renderbuffer_surface =<br>
       gen7_update_null_renderbuffer_surface;<br>
    brw->vtbl.create_constant_surface = gen7_create_constant_surface;<br>
+   brw->vtbl.create_raw_surface = gen7_create_raw_surface;<br>
 }<br>
<span><font color="#888888">--<br>
1.8.3.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>