[Mesa-dev] [PATCH] nir: add lowering for gl_HelperInvocation
Ilia Mirkin
imirkin at alum.mit.edu
Mon Jun 25 18:48:49 UTC 2018
On Mon, Jun 25, 2018 at 2:38 PM, Rob Clark <robdclark at gmail.com> wrote:
> On Mon, Jun 25, 2018 at 2:29 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
>> 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].
>
> note that for adreno I just have up to 4x samples.. in fact, do any
> mesa drivers support > 32 samples?
>
>> 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.
>>
>
> I didn't try that but I think gl_SampleMaskIn[0] will work as long as
> there isn't sample-rate shading. Blob always does 'covmask & (1 <<
> sampleid)'. But I guess as long as there isn't any GL state that can
> also trigger sample-rate shading (?), I could switch lowering based on
> whether shader reads sample_id, and use the simpler
> gl_SampleMaskIn[0]==0 in the non-sample-rate case...
Reading gl_SampleID (or gl_SamplePosition) automatically triggers
sample-rate shading.
-ilia
More information about the mesa-dev
mailing list