[Mesa-dev] [PATCH 01/20] nir: Add intrinsics from ARB_shader_group_vote

Connor Abbott cwabbott0 at gmail.com
Fri Jul 7 00:07:38 UTC 2017


FYI, I already have another series which adds ARB_shader_ballot and
ARB_shader_group_vote intrinsics, in addition to adding some more
precise semantics to represent the restrictions on ballotARB() and
similar things [0]. The problem is that marking ballot as
can_eliminate but not can_reorder is overly conservative, since we
won't try to CSE it even in the same basic block. I think Jason had
some concern he was thinking about, so I'll ask him again.

[0] https://lists.freedesktop.org/archives/mesa-dev/2017-June/158672.html

On Thu, Jul 6, 2017 at 4:48 PM, Matt Turner <mattst88 at gmail.com> wrote:
> These are intrinsics rather than opcodes, because they operate across
> channels.
> ---
>  src/compiler/glsl/glsl_to_nir.cpp | 22 ++++++++++++++++++++++
>  src/compiler/nir/nir_intrinsics.h |  5 +++++
>  2 files changed, 27 insertions(+)
>
> diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
> index 21530040a9..43d7e07042 100644
> --- a/src/compiler/glsl/glsl_to_nir.cpp
> +++ b/src/compiler/glsl/glsl_to_nir.cpp
> @@ -799,6 +799,15 @@ nir_visitor::visit(ir_call *ir)
>        case ir_intrinsic_shared_atomic_comp_swap:
>           op = nir_intrinsic_shared_atomic_comp_swap;
>           break;
> +      case ir_intrinsic_vote_any:
> +         op = nir_intrinsic_vote_any;
> +         break;
> +      case ir_intrinsic_vote_all:
> +         op = nir_intrinsic_vote_all;
> +         break;
> +      case ir_intrinsic_vote_eq:
> +         op = nir_intrinsic_vote_eq;
> +         break;
>        default:
>           unreachable("not reached");
>        }
> @@ -1135,6 +1144,19 @@ nir_visitor::visit(ir_call *ir)
>           nir_builder_instr_insert(&b, &instr->instr);
>           break;
>        }
> +      case nir_intrinsic_vote_any:
> +      case nir_intrinsic_vote_all:
> +      case nir_intrinsic_vote_eq: {
> +         nir_ssa_dest_init(&instr->instr, &instr->dest, 1, 32, NULL);
> +
> +         instr->variables[0] = evaluate_deref(&instr->instr, ir->return_deref);
> +
> +         ir_instruction *value = (ir_instruction *)ir->actual_parameters.get_head();
> +         instr->src[0] = nir_src_for_ssa(evaluate_rvalue(value->as_rvalue()));
> +
> +         nir_builder_instr_insert(&b, &instr->instr);
> +         break;
> +      }
>        default:
>           unreachable("not reached");
>        }
> diff --git a/src/compiler/nir/nir_intrinsics.h b/src/compiler/nir/nir_intrinsics.h
> index 21e7d904b7..8a838df027 100644
> --- a/src/compiler/nir/nir_intrinsics.h
> +++ b/src/compiler/nir/nir_intrinsics.h
> @@ -107,6 +107,11 @@ BARRIER(memory_barrier_shared)
>  /** A conditional discard, with a single boolean source. */
>  INTRINSIC(discard_if, 1, ARR(1), false, 0, 0, 0, xx, xx, xx, 0)
>
> +/** ARB_shader_group_vote intrinsics */
> +INTRINSIC(vote_any, 1, ARR(1), true, 1, 1, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
> +INTRINSIC(vote_all, 1, ARR(1), true, 1, 1, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
> +INTRINSIC(vote_eq,  1, ARR(1), true, 1, 1, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
> +
>  /**
>   * Basic Geometry Shader intrinsics.
>   *
> --
> 2.13.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list