<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 16, 2015 at 10:28 AM, Ben Widawsky <span dir="ltr"><<a href="mailto:ben@bwidawsk.net" target="_blank">ben@bwidawsk.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Mon, Feb 16, 2015 at 09:24:34AM -0800, Jason Ekstrand wrote:<br>
> On Feb 16, 2015 7:46 AM, "Francisco Jerez" <<a href="mailto:currojerez@riseup.net">currojerez@riseup.net</a>> wrote:<br>
> ><br>
> > Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> writes:<br>
> ><br>
> > > On Feb 15, 2015 11:55 PM, "Ben Widawsky" <<a href="mailto:benjamin.widawsky@intel.com">benjamin.widawsky@intel.com</a>><br>
> > > wrote:<br>
> > >><br>
> > >> The short version: we need to set bits in R0.7 which provide a mask to<br>
> be<br>
> > > used<br>
> > >> for PS kill samples/pixels. Since the VS has no such concept, we just<br>
> > > need to<br>
> > >> set all 1.<br>
> > >><br>
> > >> The longer version...<br>
> > >> Execution for SIMD8 atomics is defined as follows:<br>
> > >> SIMD8: The low 8 bits of the execution mask are ANDed with 8 bits of<br>
> the<br>
> > >> Pixel/Sample Mask from the message header. For the typed messages, the<br>
> > > Slot<br>
> > >> Group in the message descriptor selects either the low or high 8 bits.<br>
> > > For the<br>
> > >> untyped messages, the low 8 bits are always selected. The resulting<br>
> mask<br>
> > > is used<br>
> > >> to determine which slots are read into the destination GRF register<br>
> (for<br>
> > > read),<br>
> > >> or which slots are written to the surface (for write). If the header is<br>
> > > not<br>
> > >> present, only the low 8 bits of the execution mask are used.<br>
> > >><br>
> > >> The message header for untyped messages is defined in R0.7 "This field<br>
> > > contains<br>
> > >> the 16-bit pixel/sample mask to be used for SIMD16 and SIMD8 messages.<br>
> > > All 16<br>
> > >> bits are used for SIMD16 messages.  For typed SIMD8 messages, Slot<br>
> Group<br>
> > > selects<br>
> > >> which 8 bits of this field are used. For untyped SIMD8 messages, the<br>
> low<br>
> > > 8 bits<br>
> > >> of this field are used." Furthermore, "The message header for the<br>
> untyped<br>
> > >> messages only needs to be delivered for pixel shader threads, where the<br>
> > >> execution mask may indicate pixels/samples that are enabled only due to<br>
> > >> derivative (LOD) calculations, but the corresponding slot on the<br>
> surface<br>
> > > must<br>
> > >> not be accessed." We're not using a pixel shader here, but AFAICT, this<br>
> > > mask is<br>
> > >> used for all stages.<br>
> > >><br>
> > >> This leaves two options, Remove the header, or make the VS code emit<br>
> the<br>
> > > correct<br>
> > >> thing for the header. I believe one of the goals of using SIMD8 VS was<br>
> to<br>
> > > get as<br>
> > >> much code reuse as possible, and so I chose the latter. Since the VS<br>
> has<br>
> > > no such<br>
> > >> thing as kill instructions, the mask is derived simple as all 1's.<br>
> > ><br>
> > > Hm. This seems a little fishy. Don't we still have an execution mask for<br>
> > > vertex shaders?  The second half of the if copies that into the bit<br>
> field.<br>
> > ><br>
> ><br>
> > That's fine.  The execution mask is part of the side-band information<br>
> > sent together with the message payload to the data port. It's implicitly<br>
> > ANDed with the sample mask sent in the header to compute the actual set<br>
> > of channels that execute the atomic operation.  What the "second half of<br>
> > the if" copies is not the execution mask but the sample mask used to<br>
> > identify helper invocations of the fragment shader executed to<br>
> > approximate derivatives which are required not to have side effects.<br>
><br>
> Good enough for me.  With the control flow change below,<br>
><br>
> Reviewed-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>><br>
><br>
<br>
</div></div>Hi. Thanks for asking this, it reminded me that I should throw a comment in the<br>
code as well - it took me a few hours to track down all the relevant parts of<br>
the docs, and this commit message is a bit dense (and that was after several<br>
hours to roughly figure out what was going on).<br></blockquote><div><br></div><div>Yeah, I like comments in code better than in commit messages.  That way you see it when you read it rather than having to do git archeology.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks to the both of you. I will make the requested change.<br>
<div class="HOEnZb"><div class="h5"><br>
> > >> Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=87258" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=87258</a><br>
> > >> Cc: Kristian Høgsberg <<a href="mailto:krh@bitplanet.net">krh@bitplanet.net</a>><br>
> > >> Signed-off-by: Ben Widawsky <<a href="mailto:ben@bwidawsk.net">ben@bwidawsk.net</a>><br>
> > >> ---<br>
> > >>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 3 +++<br>
> > >>  1 file changed, 3 insertions(+)<br>
> > >><br>
> > >> diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
> > > b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
> > >> index 2a36d94..c20289f 100644<br>
> > >> --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
> > >> +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
> > >> @@ -2994,6 +2994,9 @@ fs_visitor::emit_untyped_atomic(unsigned<br>
> atomic_op,<br>
> > > unsigned surf_index,<br>
> > >>     if (uses_kill) {<br>
> > >>        emit(MOV(component(sources[0], 7), brw_flag_reg(0, 1)))<br>
> > >>           ->force_writemask_all = true;<br>
> > >> +   } else if (stage == MESA_SHADER_VERTEX) {<br>
> > >> +      emit(MOV(component(sources[0], 7),<br>
> > >> +               brw_imm_ud(0xff)))->force_writemask_all = true;<br>
> > >>     } else {<br>
> > >>        emit(MOV(component(sources[0], 7),<br>
> > >>                 retype(brw_vec1_grf(1, 7), BRW_REGISTER_TYPE_UD));<br>
> > ><br>
> > > Also would you mind rearranging the logic a bit here.  Something like<br>
> this<br>
> > > would make it more clear that the header stuff is only for vertex<br>
> shaders:<br>
> > ><br>
> > > If (fragment) {<br>
> > >    If (uses_kill) {<br>
> > >    } else {<br>
> > >    }<br>
> > > } else {<br>
> > >    // vertex stuff<br>
> > > }<br>
> > ><br>
> ><br>
> > Agreed, I had the same thought when I reviewed this but didn't care<br>
> > enough to complain. :)<br>
> ><br>
> > >> --<br>
> > >> 2.3.0<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="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
> > > _______________________________________________<br>
> > > mesa-dev mailing list<br>
> > > <a href="mailto:mesa-dev@lists.freedesktop.org">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>
</div></div></blockquote></div><br></div></div>