<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 16, 2016 at 9:22 PM, Francisco Jerez <span dir="ltr"><<a href="mailto:currojerez@riseup.net" target="_blank">currojerez@riseup.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This seems cleaner than exposing an implementation detail of<br>
brw_fs_reg_allocate.cpp to the world, and will give the caller control<br>
over the instruction execution flags (e.g. force_writemask_all) that<br>
are applied to the scratch read and write instructions.<br>
---<br>
src/mesa/drivers/dri/i965/brw_fs.h | 4 ---<br>
src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp | 41 ++++++++++++-----------<br>
2 files changed, 21 insertions(+), 24 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h<br>
index bf30d65..53a3557 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs.h<br>
@@ -211,10 +211,6 @@ public:<br>
bool opt_saturate_propagation();<br>
bool opt_cmod_propagation();<br>
bool opt_zero_samples();<br>
- void emit_unspill(bblock_t *block, fs_inst *inst, fs_reg reg,<br>
- uint32_t spill_offset, unsigned count);<br>
- void emit_spill(bblock_t *block, fs_inst *inst, fs_reg reg,<br>
- uint32_t spill_offset, unsigned count);<br>
<br>
void emit_nir_code();<br>
void nir_setup_inputs();<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp<br>
index 2260147..5fc586f 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp<br>
@@ -764,16 +764,17 @@ namespace {<br>
}<br>
}<br>
<br>
-void<br>
-fs_visitor::emit_unspill(bblock_t *block, fs_inst *inst, fs_reg dst,<br>
- uint32_t spill_offset, unsigned count)<br>
+static void<br>
+emit_unspill(const fs_builder &bld, fs_reg dst,<br>
+ uint32_t spill_offset, unsigned count)<br>
{<br>
+ const brw_device_info *devinfo = bld.shader->devinfo;<br>
+ const fs_visitor *v = static_cast<const fs_visitor *>(bld.shader);<br>
unsigned reg_size = 1;<br>
- if (dispatch_width == 16 && count % 2 == 0)<br>
+ if (v->dispatch_width == 16 && count % 2 == 0)<br>
reg_size = 2;<br>
<br>
- const fs_builder ibld = fs_builder(this, block, inst)<br>
- .group(reg_size * 8, 0);<br>
+ const fs_builder ibld = bld.group(reg_size * 8, 0);<br>
<br>
for (unsigned i = 0; i < count / reg_size; i++) {<br>
/* The Gen7 descriptor-based offset is 12 bits of HWORD units. Because<br>
@@ -793,7 +794,7 @@ fs_visitor::emit_unspill(bblock_t *block, fs_inst *inst, fs_reg dst,<br>
unspill_inst->regs_written = reg_size;<br>
<br>
if (!gen7_read) {<br>
- unspill_inst->base_mrf = spill_base_mrf(this);<br>
+ unspill_inst->base_mrf = spill_base_mrf(bld.shader);<br></blockquote><div><br></div><div>This makes the static_cast in spill_base_mrf make a bit more sense<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
unspill_inst->mlen = 1; /* header contains offset */<br>
}<br>
<br>
@@ -802,17 +803,16 @@ fs_visitor::emit_unspill(bblock_t *block, fs_inst *inst, fs_reg dst,<br>
}<br>
}<br>
<br>
-void<br>
-fs_visitor::emit_spill(bblock_t *block, fs_inst *inst, fs_reg src,<br>
- uint32_t spill_offset, unsigned count)<br>
+static void<br>
+emit_spill(const fs_builder &bld, fs_reg src,<br>
+ uint32_t spill_offset, unsigned count)<br>
{<br>
+ const fs_visitor *v = static_cast<const fs_visitor *>(bld.shader);<br>
unsigned reg_size = 1;<br>
- if (dispatch_width == 16 && count % 2 == 0)<br>
+ if (v->dispatch_width == 16 && count % 2 == 0)<br>
reg_size = 2;<br>
<br>
- const fs_builder ibld = fs_builder(this, block, inst)<br>
- .at(block, inst->next)<br>
- .group(reg_size * 8, 0);<br>
+ const fs_builder ibld = bld.group(reg_size * 8, 0);<br>
<br>
for (unsigned i = 0; i < count / reg_size; i++) {<br>
fs_inst *spill_inst =<br>
@@ -820,7 +820,7 @@ fs_visitor::emit_spill(bblock_t *block, fs_inst *inst, fs_reg src,<br>
src.reg_offset += reg_size;<br>
spill_inst->offset = spill_offset + i * reg_size * REG_SIZE;<br>
spill_inst->mlen = 1 + reg_size; /* header, value */<br>
- spill_inst->base_mrf = spill_base_mrf(this);<br>
+ spill_inst->base_mrf = spill_base_mrf(bld.shader);<br>
}<br>
}<br>
<br>
@@ -936,6 +936,8 @@ fs_visitor::spill_reg(int spill_reg)<br>
* could just spill/unspill the GRF being accessed.<br>
*/<br>
foreach_block_and_inst (block, fs_inst, inst, cfg) {<br>
+ const fs_builder ibld = fs_builder(this, block, inst);<br>
+<br>
for (unsigned int i = 0; i < inst->sources; i++) {<br>
if (inst->src[i].file == VGRF &&<br>
inst->src[i].nr == spill_reg) {<br>
@@ -947,8 +949,7 @@ fs_visitor::spill_reg(int spill_reg)<br>
inst->src[i].nr = <a href="http://unspill_dst.nr" rel="noreferrer" target="_blank">unspill_dst.nr</a>;<br>
inst->src[i].reg_offset = 0;<br>
<br>
- emit_unspill(block, inst, unspill_dst, subset_spill_offset,<br>
- regs_read);<br>
+ emit_unspill(ibld, unspill_dst, subset_spill_offset, regs_read);<br>
}<br>
}<br>
<br>
@@ -974,11 +975,11 @@ fs_visitor::spill_reg(int spill_reg)<br>
* since we write back out all of the regs_written().<br>
*/<br>
if (inst->is_partial_write())<br>
- emit_unspill(block, inst, spill_src, subset_spill_offset,<br>
+ emit_unspill(ibld, spill_src, subset_spill_offset,<br>
inst->regs_written);<br>
<br>
- emit_spill(block, inst, spill_src, subset_spill_offset,<br>
- inst->regs_written);<br>
+ emit_spill(<a href="http://ibld.at" rel="noreferrer" target="_blank">ibld.at</a>(block, inst->next), spill_src,<br>
+ subset_spill_offset, inst->regs_written);<br>
}<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.7.3<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">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>
</font></span></blockquote></div><br></div></div>