[Mesa-dev] [PATCH] nir: add lowering for gl_HelperInvocation

Ilia Mirkin imirkin at alum.mit.edu
Mon Jun 25 18:29:10 UTC 2018


On Mon, Jun 25, 2018 at 2:23 PM, Ian Romanick <idr at freedesktop.org> wrote:
> On 06/19/2018 08:24 AM, Rob Clark wrote:
>> v2: reword comment about lower_helper_invocations to be more clear
>>     that it might not work on all hardware
>> v3: add special variant of load_sample_id which does not imply per-
>>     sample shading
>>
>> Signed-off-by: Rob Clark <robdclark at gmail.com>
>> ---
>> Yeah, new intrinsic name is a bit funny sounding, but I couldn't
>> think of anything better.
>>
>>  src/compiler/nir/nir.h                          | 12 ++++++++++++
>>  src/compiler/nir/nir_intrinsics.py              |  3 +++
>>  src/compiler/nir/nir_lower_system_values.c      | 17 +++++++++++++++++
>>  .../drivers/freedreno/ir3/ir3_compiler_nir.c    |  1 +
>>  src/gallium/drivers/freedreno/ir3/ir3_nir.c     |  1 +
>>  5 files changed, 34 insertions(+)
>>
>> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
>> index 2d620454796..cb9a4af64cf 100644
>> --- a/src/compiler/nir/nir.h
>> +++ b/src/compiler/nir/nir.h
>> @@ -1981,6 +1981,18 @@ typedef struct nir_shader_compiler_options {
>>      */
>>     bool lower_base_vertex;
>>
>> +   /**
>> +    * If enabled, gl_HelperInvocation will be lowered as:
>> +    *
>> +    *   !((1 << sample_id) & sample_mask_in))
>
> I recently encountered something related to this.  Issue #22 of the
> GL_ARB_shader_image_load_store spec suggests using (gl_SampleMaskIn[0]
> == 0) to detect a helper invocation.  There's a note that
> implementations that support > 32 samples will also need to check
> gl_SampleMaskIn[1].  Did you try that?  It should generate less code.
>
> See also piglit commit c89439fcaba7259b25d090df43a6bf2aac6483d7.

Based on what I've seen of adreno, that sysval is likely actually not
gl_SampleMaskIn, but rather a full pixel coverage mask. This only
matters with sample-rate shading which I don't think Rob has
investigated yet.

I think gl_SampleMaskIn[0] == 0 should work in the general case, but I
suspect that freedreno will have to implement gl_SampleMaskIn as
covmask & (1 << sampleid) for sample-rate shading.

Cheers,

  -ilia


More information about the mesa-dev mailing list