<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 11, 2018 at 3:59 PM, Roland Scheidegger <span dir="ltr"><<a href="mailto:sroland@vmware.com" target="_blank">sroland@vmware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Am 12.06.2018 um 00:32 schrieb Jason Ekstrand:<br>
> On Wed, Jun 6, 2018 at 7:43 AM, Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a><br>
</span><span class="">> <mailto:<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>>> wrote:<br>
> <br>
>     Signed-off-by: Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a><br>
</span>>     <mailto:<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>>><br>
<span class="">>     ---<br>
>     I can't say for sure that this will work on all drivers, but it is<br>
>     what the blob driver does, and it seems to make deqp happy.  I could<br>
>     move this to it's own pass inside ir3, but that seemed like overkill<br>
> <br>
>      src/compiler/nir/nir.h                      | 10 ++++++++++<br>
>      src/compiler/nir/nir_lower_<wbr>system_values.c  | 17 +++++++++++++++++<br>
>      src/gallium/drivers/<wbr>freedreno/ir3/ir3_nir.c |  1 +<br>
>      3 files changed, 28 insertions(+)<br>
> <br>
>     diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
>     index 073ab4e82ea..de3d55d83af 100644<br>
>     --- a/src/compiler/nir/nir.h<br>
>     +++ b/src/compiler/nir/nir.h<br>
>     @@ -1963,6 +1963,16 @@ typedef struct nir_shader_compiler_options {<br>
>          */<br>
>         bool lower_base_vertex;<br>
> <br>
>     +   /**<br>
>     +    * If enabled, gl_HelperInvocation will be lowered as:<br>
>     +    *<br>
>     +    *   !((1 << gl_SampleID) & gl_SampleMaskIN[0]))<br>
> <br>
> <br>
> This only works for multi-sampling.  What about the single-sampled case?<br>
</span>It doesn't make sense to me for msaa neither.<br>
gl_SampleID forces per-sample execution, which clearly isn't what you<br>
want.</blockquote><div><br></div><div>Yes, we do not want gl_HelperInvocation to force per-sample shading.  It doesn't mean we can't lower to it, it just means that the back-end needs to be very careful that it decides whether or not to execute per-sample before it does this lowering.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Plus, gl_SampleMaskIN is specified to only contain bits for the<br>
current shader invocation, so for msaa with forced per-sample execution<br>
that would only contain the single bit corresponding to gl_SampleID<br>
anyway (that is my interpretation at least - I know hw sample mask<br>
inputs will probably always contains all the bits from rasterization,<br>
regardless of gl_SampleID), so the "1 << gl_SampleID &" part will do<br>
nothing at all.</blockquote><div><br></div><div>I think it also relies on gl_SampleMaskIN to give 0 for helper invocations.  This is likely true but I don't know how well-defined all this is in the world of helper invocations.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">So I think that part is more about lowering the hw<br>
rasterization sample mask to gl_SampleMaskIN rather than lowering to<br>
gl_HelperInvocation.<br>
But yes, !gl_SampleMaskIN should give gl_HelperInvocation - I think all<br>
hw can give you raster sample mask even without msaa but I'm not<br>
entirely sure if it's guaranteed to work in GL with single sampling<br>
(similar for sample id, which should just be stuck at 0).<br></blockquote><div><br></div><div>The GL spec doesn't seem to say.  It does say that gl_SampleID is guaranteed to be 0 for single-sampled but it says nothing about gl_SampleMaskIN.</div><div><br></div><div>--Jason<br></div></div><br></div></div>