<div dir="ltr"><div>I must say, I don't really like this patch. It seems like it's just trying to let you avoid writing two reloc functions which should, by and large, be no-ops for iris. That said, the way blorp does surface relocs is really annoying because it forces the reloc function to write in the value. Unfortunately, untangling this would require passing a reloc function pointer into isl_surf_fill_state. Maybe it's time we did that? On the other hand, future drivers are going to be softpin-only so I'm a bit hesitant to add more interface for relocations. Bah!</div><div><br></div><div>In the end, I do think I agree with Jordan in not liking the #ifdef. Maybe we can just force all drivers to define all three functions and anv/i965 can make blorp_use_address() function a no-op. Would that be reasonable?</div><div><br></div><div>--Jason<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 29, 2018 at 2:24 AM Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Drivers using softpin do not need (or have) relocations. The old<br>
relocation interface is somewhat awkward and limiting.<br>
<br>
In particular, brw_surface_reloc assumes that all SURFACE_STATEs will<br>
exist in a single buffer, and only provides ss_offset. The driver is<br>
supposed to implicitly know about this buffer, in order to offset from<br>
a CPU map of that buffer to write the value. With softpin, we can put<br>
SURFACE_STATEs in any buffer we like, as long as it's within 4GB of<br>
Surface State Base Address. So, this model breaks down.<br>
<br>
Drivers can now #define BLORP_USE_SOFTPIN and define a simpler<br>
blorp_use_pinned_bo() helper, which adds the buffer to the validation<br>
list for the current batch, and returns the (statically assigned,<br>
unchanging) address for the buffer.<br>
<br>
The upcoming Iris driver will use this interface.<br>
---<br>
src/intel/blorp/blorp_genX_exec.h | 36 +++++++++++++++++++++++++++----<br>
1 file changed, 32 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h<br>
index 20f30c7116d..f18de3dc6ce 100644<br>
--- a/src/intel/blorp/blorp_genX_exec.h<br>
+++ b/src/intel/blorp/blorp_genX_exec.h<br>
@@ -47,10 +47,27 @@<br>
static void *<br>
blorp_emit_dwords(struct blorp_batch *batch, unsigned n);<br>
<br>
+#ifdef BLORP_USE_SOFTPIN<br>
+static uint64_t<br>
+blorp_use_pinned_bo(struct blorp_batch *batch, struct blorp_address addr);<br>
+<br>
+/* Wrappers to avoid #ifdefs everywhere */<br>
+#define blorp_emit_reloc _blorp_combine_address<br>
+static inline void<br>
+blorp_surface_reloc(struct blorp_batch *batch, uint32_t ss_offset,<br>
+ struct blorp_address address, uint32_t delta)<br>
+{<br>
+}<br>
+#else<br>
static uint64_t<br>
blorp_emit_reloc(struct blorp_batch *batch,<br>
void *location, struct blorp_address address, uint32_t delta);<br>
<br>
+static void<br>
+blorp_surface_reloc(struct blorp_batch *batch, uint32_t ss_offset,<br>
+ struct blorp_address address, uint32_t delta);<br>
+#endif<br>
+<br>
static void *<br>
blorp_alloc_dynamic_state(struct blorp_batch *batch,<br>
uint32_t size,<br>
@@ -78,10 +95,6 @@ blorp_alloc_binding_table(struct blorp_batch *batch, unsigned num_entries,<br>
static void<br>
blorp_flush_range(struct blorp_batch *batch, void *start, size_t size);<br>
<br>
-static void<br>
-blorp_surface_reloc(struct blorp_batch *batch, uint32_t ss_offset,<br>
- struct blorp_address address, uint32_t delta);<br>
-<br>
#if GEN_GEN >= 7 && GEN_GEN < 10<br>
static struct blorp_address<br>
blorp_get_surface_base_address(struct blorp_batch *batch);<br>
@@ -104,15 +117,23 @@ _blorp_combine_address(struct blorp_batch *batch, void *location,<br>
if (address.buffer == NULL) {<br>
return address.offset + delta;<br>
} else {<br>
+#ifdef BLORP_USE_SOFTPIN<br>
+ return blorp_use_pinned_bo(batch, address) + delta;<br>
+#else<br>
return blorp_emit_reloc(batch, location, address, delta);<br>
+#endif<br>
}<br>
}<br>
<br>
static uint64_t<br>
KSP(struct blorp_batch *batch, struct blorp_address address)<br>
{<br>
+#ifdef BLORP_USE_SOFTPIN<br>
+ return blorp_use_pinned_bo(batch, address);<br>
+#else<br>
assert(address.buffer == NULL);<br>
return address.offset;<br>
+#endif<br>
}<br>
<br>
#define __gen_address_type struct blorp_address<br>
@@ -1370,6 +1391,13 @@ blorp_emit_surface_state(struct blorp_batch *batch,<br>
isl_surf_fill_state(batch->blorp->isl_dev, state,<br>
.surf = &surf, .view = &surface->view,<br>
.aux_surf = &surface->aux_surf, .aux_usage = aux_usage,<br>
+#ifdef BLORP_USE_SOFTPIN<br>
+ .address = blorp_use_pinned_bo(batch, surface->addr),<br>
+ .aux_address = aux_usage != ISL_AUX_USAGE_NONE ?<br>
+ blorp_use_pinned_bo(batch, surface->aux_addr) : 0,<br>
+ .clear_address = !use_clear_address ? 0 :<br>
+ blorp_use_pinned_bo(batch, surface->clear_color_addr),<br>
+#endif<br>
.mocs = surface->addr.mocs,<br>
.clear_color = surface->clear_color,<br>
.use_clear_address = use_clear_address,<br>
-- <br>
2.19.1<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="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>