<p dir="ltr">R-B</p>
<div class="gmail_quote">On Jul 27, 2015 6:12 AM, "Francisco Jerez" <<a href="mailto:currojerez@riseup.net">currojerez@riseup.net</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This cleans up fs_inst::regs_read() slightly by disentangling the<br>
calculation of "components" from the handling of message payload<br>
arguments. This will also simplify the SIMD lowering and logical send<br>
message lowering passes, because it will avoid expressions like<br>
'regs_read * REG_SIZE / component_size' which are not only ugly, they<br>
may be inaccurate because regs_read rounds up the result to the<br>
closest register multiple so they could give incorrect results when<br>
the component size is lower than one register (e.g. uniforms). This<br>
didn't seem to be a problem right now because all such expressions<br>
happen to be dealing with per-channel GRFs only currently, but that's<br>
by no means obvious so better be safe than sorry.<br>
<br>
v2: Split PIXEL_X/Y and LINTERP into separate case blocks.<br>
---<br>
src/mesa/drivers/dri/i965/brw_fs.cpp | 33 +++++++++++++++++++++++----------<br>
src/mesa/drivers/dri/i965/brw_ir_fs.h | 1 +<br>
2 files changed, 24 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
index 2b7ddc9..a620c79 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
@@ -663,10 +663,29 @@ fs_inst::is_partial_write() const<br>
!this->dst.is_contiguous());<br>
}<br>
<br>
+unsigned<br>
+fs_inst::components_read(unsigned i) const<br>
+{<br>
+ switch (opcode) {<br>
+ case FS_OPCODE_LINTERP:<br>
+ if (i == 0)<br>
+ return 2;<br>
+ else<br>
+ return 1;<br>
+<br>
+ case FS_OPCODE_PIXEL_X:<br>
+ case FS_OPCODE_PIXEL_Y:<br>
+ assert(i == 0);<br>
+ return 2;<br>
+<br>
+ default:<br>
+ return 1;<br>
+ }<br>
+}<br>
+<br>
int<br>
fs_inst::regs_read(int arg) const<br>
{<br>
- unsigned components = 1;<br>
switch (opcode) {<br>
case FS_OPCODE_FB_WRITE:<br>
case SHADER_OPCODE_URB_WRITE_SIMD8:<br>
@@ -688,15 +707,8 @@ fs_inst::regs_read(int arg) const<br>
break;<br>
<br>
case FS_OPCODE_LINTERP:<br>
- if (arg == 0)<br>
- return exec_size / 4;<br>
- else<br>
+ if (arg == 1)<br>
return 1;<br>
-<br>
- case FS_OPCODE_PIXEL_X:<br>
- case FS_OPCODE_PIXEL_Y:<br>
- if (arg == 0)<br>
- components = 2;<br>
break;<br>
<br>
case SHADER_OPCODE_LOAD_PAYLOAD:<br>
@@ -720,7 +732,8 @@ fs_inst::regs_read(int arg) const<br>
return 1;<br>
case GRF:<br>
case HW_REG:<br>
- return DIV_ROUND_UP(components * src[arg].component_size(exec_size),<br>
+ return DIV_ROUND_UP(components_read(arg) *<br>
+ src[arg].component_size(exec_size),<br>
REG_SIZE);<br>
case MRF:<br>
unreachable("MRF registers are not allowed as sources");<br>
diff --git a/src/mesa/drivers/dri/i965/brw_ir_fs.h b/src/mesa/drivers/dri/i965/brw_ir_fs.h<br>
index 693357f..97c6f8b 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_ir_fs.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_ir_fs.h<br>
@@ -201,6 +201,7 @@ public:<br>
bool is_send_from_grf() const;<br>
bool is_partial_write() const;<br>
bool is_copy_payload(const brw::simple_allocator &grf_alloc) const;<br>
+ unsigned components_read(unsigned i) const;<br>
int regs_read(int arg) const;<br>
bool can_do_source_mods(const struct brw_device_info *devinfo);<br>
bool has_side_effects() const;<br>
--<br>
2.4.6<br>
<br>
</blockquote></div>