<p dir="ltr"><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 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 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 mask<br>
> > is used<br>
> >> to determine which slots are read into the destination GRF register (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 Group<br>
> > selects<br>
> >> which 8 bits of this field are used. For untyped SIMD8 messages, the low<br>
> > 8 bits<br>
> >> of this field are used." Furthermore, "The message header for the 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 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 the<br>
> > correct<br>
> >> thing for the header. I believe one of the goals of using SIMD8 VS was to<br>
> > get as<br>
> >> much code reuse as possible, and so I chose the latter. Since the VS 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 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.</p>
<p dir="ltr">Good enough for me.  With the control flow change below,</p>
<p dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>></p>
<p dir="ltr">> >> Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=87258">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 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 this<br>
> > would make it more clear that the header stuff is only for vertex 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">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">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>