[Mesa-dev] [PATCH 2/2] anv/pipeline: don't pass constant view index in multiview

Jason Ekstrand jason at jlekstrand.net
Tue Feb 27 20:13:52 UTC 2018


On Tue, Feb 27, 2018 at 11:46 AM, Caio Marcelo de Oliveira Filho <
caio.oliveira at intel.com> wrote:

> If view mask has only one bit set, view index is effectively a
> constant, so doesn't need to be passed to the next stages, just always
> set it.
>
> Part of this was in the original patch that added
> anv_nir_lower_multiview.c but disabled.
> ---
>  src/intel/vulkan/anv_nir_lower_multiview.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_nir_lower_multiview.c
> b/src/intel/vulkan/anv_nir_lower_multiview.c
> index d2aefdee62..365a70d757 100644
> --- a/src/intel/vulkan/anv_nir_lower_multiview.c
> +++ b/src/intel/vulkan/anv_nir_lower_multiview.c
> @@ -72,7 +72,8 @@ build_view_index(struct lower_multiview_state *state)
>        b->cursor = nir_before_block(nir_start_block(b->impl));
>
>        assert(state->view_mask != 0);
> -      if (0 && _mesa_bitcount(state->view_mask) == 1) {
> +      if (_mesa_bitcount(state->view_mask) == 1) {
>

Yes, I think it's probably safe to turn this on now.  Originally, I had it
commented out because I was afraid of not getting enough test coverage.
For all I know, we still aren't getting enough test coverage but I think
we've proven by now that the calculations below work.


> +         /* Set the view index directly. */
>           state->view_index = nir_imm_int(b, ffs(state->view_mask) - 1);
>        } else if (state->builder.shader->info.stage ==
> MESA_SHADER_VERTEX) {
>           /* We only support 16 viewports */
> @@ -210,11 +211,15 @@ anv_nir_lower_multiview(nir_shader *shader,
> uint32_t view_mask)
>        assert(view_index->parent_instr->block ==
> nir_start_block(entrypoint));
>        b->cursor = nir_after_instr(view_index->parent_instr);
>
> -      nir_variable *view_index_out =
> -         nir_variable_create(shader, nir_var_shader_out,
> -                             glsl_int_type(), "view index");
> -      view_index_out->data.location = VARYING_SLOT_VIEW_INDEX;
> -      nir_store_var(b, view_index_out, view_index, 0x1);
> +      /* Unless there is only one possible view index (that would be set
> +       * directly), pass it to the next stage. */
>

With multi-line comments, we usually put the "*/" on its own line.


> +      if (_mesa_bitcount(state.view_mask) != 1) {
> +         nir_variable *view_index_out =
> +            nir_variable_create(shader, nir_var_shader_out,
> +                                glsl_int_type(), "view index");
> +         view_index_out->data.location = VARYING_SLOT_VIEW_INDEX;
> +         nir_store_var(b, view_index_out, view_index, 0x1);
> +      }
>
>        nir_variable *layer_id_out =
>           nir_variable_create(shader, nir_var_shader_out,
> --
> 2.16.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180227/6c6e37dc/attachment.html>


More information about the mesa-dev mailing list