<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 26, 2016 at 8:46 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">The Gen5+ sampler message payload construction code steps through the<br>
coordinate and derivative components by induction like 'coordinate =<br>
offset(coordinate, bld, 1)', the problem is that while doing that it<br>
may step one past the end of the coordinate vector causing an<br>
assertion failure in offset() if it happens to be a (single component)<br>
immediate. Right now coordinates and derivatives are typically passed<br>
as actual registers but that will no longer be the case when we start<br>
propagating constants into logical messages.<br>
<br>
Instead express coordinate components in closed form like<br>
'offset(coordinate, bld, i)' -- The end result seems slightly more<br>
readable that way and it allows passing the coordinate and derivative<br>
registers by const reference instead of by value, so it seems like a<br>
clean-up in its own right.<br></blockquote><div><br></div><div>Thank you!!! This is way better than the way it was before.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
src/mesa/drivers/dri/i965/brw_fs.cpp | 62 +++++++++++++++---------------------<br>
1 file changed, 25 insertions(+), 37 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 31ebbe3..e05977b 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
@@ -4022,9 +4022,9 @@ lower_sampler_logical_send_gen4(const fs_builder &bld, fs_inst *inst, opcode op,<br>
<br>
static void<br>
lower_sampler_logical_send_gen5(const fs_builder &bld, fs_inst *inst, opcode op,<br>
- fs_reg coordinate,<br>
+ const fs_reg &coordinate,<br>
const fs_reg &shadow_c,<br>
- fs_reg lod, fs_reg lod2,<br>
+ const fs_reg &lod, const fs_reg &lod2,<br>
const fs_reg &sample_index,<br>
const fs_reg &surface,<br>
const fs_reg &sampler,<br>
@@ -4044,10 +4044,10 @@ lower_sampler_logical_send_gen5(const fs_builder &bld, fs_inst *inst, opcode op,<br>
message.nr--;<br>
}<br>
<br>
- for (unsigned i = 0; i < coord_components; i++) {<br>
- bld.MOV(retype(offset(msg_coords, bld, i), coordinate.type), coordinate);<br>
- coordinate = offset(coordinate, bld, 1);<br>
- }<br>
+ for (unsigned i = 0; i < coord_components; i++)<br>
+ bld.MOV(retype(offset(msg_coords, bld, i), coordinate.type),<br>
+ offset(coordinate, bld, i));<br>
+<br>
fs_reg msg_end = offset(msg_coords, bld, coord_components);<br>
fs_reg msg_lod = offset(msg_coords, bld, 4);<br>
<br>
@@ -4076,12 +4076,10 @@ lower_sampler_logical_send_gen5(const fs_builder &bld, fs_inst *inst, opcode op,<br>
*/<br>
msg_end = msg_lod;<br>
for (unsigned i = 0; i < grad_components; i++) {<br>
- bld.MOV(msg_end, lod);<br>
- lod = offset(lod, bld, 1);<br>
+ bld.MOV(msg_end, offset(lod, bld, i));<br>
msg_end = offset(msg_end, bld, 1);<br>
<br>
- bld.MOV(msg_end, lod2);<br>
- lod2 = offset(lod2, bld, 1);<br>
+ bld.MOV(msg_end, offset(lod2, bld, i));<br>
msg_end = offset(msg_end, bld, 1);<br>
}<br>
break;<br>
@@ -4131,14 +4129,14 @@ is_high_sampler(const struct brw_device_info *devinfo, const fs_reg &sampler)<br>
<br>
static void<br>
lower_sampler_logical_send_gen7(const fs_builder &bld, fs_inst *inst, opcode op,<br>
- fs_reg coordinate,<br>
+ const fs_reg &coordinate,<br>
const fs_reg &shadow_c,<br>
- fs_reg lod, fs_reg lod2,<br>
+ fs_reg lod, const fs_reg &lod2,<br>
const fs_reg &sample_index,<br>
const fs_reg &mcs,<br>
const fs_reg &surface,<br>
const fs_reg &sampler,<br>
- fs_reg offset_value,<br>
+ const fs_reg &offset_value,<br>
unsigned coord_components,<br>
unsigned grad_components)<br>
{<br>
@@ -4210,21 +4208,15 @@ lower_sampler_logical_send_gen7(const fs_builder &bld, fs_inst *inst, opcode op,<br>
* [hdr], [ref], x, dPdx.x, dPdy.x, y, dPdx.y, dPdy.y, z, dPdx.z, dPdy.z<br>
*/<br>
for (unsigned i = 0; i < coord_components; i++) {<br>
- bld.MOV(sources[length], coordinate);<br>
- coordinate = offset(coordinate, bld, 1);<br>
+ bld.MOV(sources[length], offset(coordinate, bld, i));<br>
length++;<br>
<br>
/* For cube map array, the coordinate is (u,v,r,ai) but there are<br>
* only derivatives for (u, v, r).<br>
*/<br>
if (i < grad_components) {<br>
- bld.MOV(sources[length], lod);<br>
- lod = offset(lod, bld, 1);<br>
- length++;<br>
-<br>
- bld.MOV(sources[length], lod2);<br>
- lod2 = offset(lod2, bld, 1);<br>
- length++;<br>
+ bld.MOV(sources[length++], offset(lod, bld, i));<br>
+ bld.MOV(sources[length++], offset(lod2, bld, i));<br>
}<br>
}<br>
<br>
@@ -4239,13 +4231,12 @@ lower_sampler_logical_send_gen7(const fs_builder &bld, fs_inst *inst, opcode op,<br>
* On Gen9 they are u, v, lod, r<br>
*/<br>
bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D), coordinate);<br>
- coordinate = offset(coordinate, bld, 1);<br>
length++;<br>
<br>
if (devinfo->gen >= 9) {<br>
if (coord_components >= 2) {<br>
- bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D), coordinate);<br>
- coordinate = offset(coordinate, bld, 1);<br>
+ bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D),<br>
+ offset(coordinate, bld, 1));<br>
}<br>
length++;<br>
}<br>
@@ -4254,8 +4245,8 @@ lower_sampler_logical_send_gen7(const fs_builder &bld, fs_inst *inst, opcode op,<br>
length++;<br>
<br>
for (unsigned i = devinfo->gen >= 9 ? 2 : 1; i < coord_components; i++) {<br>
- bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D), coordinate);<br>
- coordinate = offset(coordinate, bld, 1);<br>
+ bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D),<br>
+ offset(coordinate, bld, i));<br>
length++;<br>
}<br>
<br>
@@ -4293,8 +4284,8 @@ lower_sampler_logical_send_gen7(const fs_builder &bld, fs_inst *inst, opcode op,<br>
* texture coordinates.<br>
*/<br>
for (unsigned i = 0; i < coord_components; i++) {<br>
- bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D), coordinate);<br>
- coordinate = offset(coordinate, bld, 1);<br>
+ bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D),<br>
+ offset(coordinate, bld, i));<br>
length++;<br>
}<br>
<br>
@@ -4306,20 +4297,18 @@ lower_sampler_logical_send_gen7(const fs_builder &bld, fs_inst *inst, opcode op,<br>
<br>
/* More crazy intermixing */<br>
for (unsigned i = 0; i < 2; i++) { /* u, v */<br>
- bld.MOV(sources[length], coordinate);<br>
- coordinate = offset(coordinate, bld, 1);<br>
+ bld.MOV(sources[length], offset(coordinate, bld, i));<br>
length++;<br></blockquote><div><br></div><div>Might be good to build the length++ into the bld.MOV while you're here. Same for the ones below. If you don't want the churn, I can write a follow-on easily enough.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
<br>
for (unsigned i = 0; i < 2; i++) { /* offu, offv */<br>
- bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D), offset_value);<br>
- offset_value = offset(offset_value, bld, 1);<br>
+ bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D),<br>
+ offset(offset_value, bld, i));<br>
length++;<br>
}<br>
<br>
if (coord_components == 3) { /* r if present */<br>
- bld.MOV(sources[length], coordinate);<br>
- coordinate = offset(coordinate, bld, 1);<br>
+ bld.MOV(sources[length], offset(coordinate, bld, 2));<br>
length++;<br>
}<br>
<br>
@@ -4332,8 +4321,7 @@ lower_sampler_logical_send_gen7(const fs_builder &bld, fs_inst *inst, opcode op,<br>
/* Set up the coordinate (except for cases where it was done above) */<br>
if (!coordinate_done) {<br>
for (unsigned i = 0; i < coord_components; i++) {<br>
- bld.MOV(sources[length], coordinate);<br>
- coordinate = offset(coordinate, bld, 1);<br>
+ bld.MOV(sources[length], offset(coordinate, bld, i));<br>
length++;<br>
}<br>
}<br>
<span class="HOEnZb"><font color="#888888">--<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>