[Mesa-stable] [Mesa-dev] [PATCH] glsl: Lower variable indexing of system value arrays; treat like inputs.

Ilia Mirkin imirkin at alum.mit.edu
Mon Apr 4 17:30:37 UTC 2016


On Mon, Apr 4, 2016 at 1:22 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> On Monday, April 4, 2016 12:05:20 PM PDT Ilia Mirkin wrote:
>> For those (few, I'm sure) of us who are exceedingly lazy, what [glsl
>> ir] code ends up getting generated as a result of this?
>>
>> int temp;
>> if (zero == 0) temp = gl_SampleMaskIn[0]
>> else leave temp undefined?
>
> Running my new samplemaskin-indirect Piglit test, it appears to create:
>
> (assign (x) (var_ref dereference_array_value)
>             (array_ref (var_ref gl_SampleMaskIn) (constant uint (0))))
>
> a.k.a.
>
>    temp = gl_SampleMaskIn[0];
>
> For arrays of size <= 4, lower_variable_index_to_cond_assign() creates
> if-ladders that try array indexes sequentially.  It also unconditionally
> reads the first element.
>
> So, if there were 64 samples, the array size would be [2], and it would
> generate:
>
>     temp = gl_SampleMaskIn[0]
>     if (index == 1)
>         temp = gl_SampleMaskIn[1];
>
> This seems optimal.

I like it! Esp since I'm fairly sure > 32x MSAA is not supported on
many levels in mesa (not to mention hw).

It appears that you're reusing EmitNoIndirectInput, however I'm fairly
sure that both nvc0 and radeonsi end up with that set to false:

      options->EmitNoIndirectInput =
         !screen->get_shader_param(screen, sh,
                                   PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR);

src/gallium/drivers/nouveau/nvc0/nvc0_screen.c:   case
PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR:
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c-      return shader !=
PIPE_SHADER_FRAGMENT || class_3d < GM107_3D_CLASS;

[and it's only false for GM107 frag shaders because I need to spend
some time figuring out how the new IPA instructions behave differently
wrt this]

src/gallium/drivers/radeonsi/si_pipe.c: case
PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR:
src/gallium/drivers/radeonsi/si_pipe.c-         return shader !=
PIPE_SHADER_GEOMETRY;

etc.

I would recommend just always returning true for system values, or
perhaps only for the gl_SampleMaskIn system value.

  -ilia


More information about the mesa-stable mailing list