[Mesa-dev] [PATCH 03/20] nir: Support lowering vote intrinsics

Connor Abbott cwabbott0 at gmail.com
Fri Jul 7 03:04:07 UTC 2017


On Thu, Jul 6, 2017 at 4:48 PM, Matt Turner <mattst88 at gmail.com> wrote:
> ... trivially (as allowed by the spec!) by reusing the existing
> nir_opt_intrinsics code.
> ---
>  src/compiler/nir/nir.h                | 4 ++++
>  src/compiler/nir/nir_opt_intrinsics.c | 6 +++---
>  2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index 44a1d0887e..401c41f155 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -1821,6 +1821,10 @@ typedef struct nir_shader_compiler_options {
>     bool lower_extract_byte;
>     bool lower_extract_word;
>
> +   bool lower_vote_any;
> +   bool lower_vote_all;
> +   bool lower_vote_eq;

Since there are potentially multiple ways to lower these (voteAny(x)
-> !voteAll(!x), using ballotARB(), etc.), and the way they're lowered
is a little... unexpected (although admittedly legal!), why don't we
use a more descriptive name, like lower_vote_*_trivial? While we're at
it, I highly doubt that an implementation would want this kind of
lowering for just one of the intrinsics, so we can merge this into a
single flag, say lower_vote_trivial.

> +
>     /**
>      * Does the driver support real 32-bit integers?  (Otherwise, integers
>      * are simulated by floats.)
> diff --git a/src/compiler/nir/nir_opt_intrinsics.c b/src/compiler/nir/nir_opt_intrinsics.c
> index b63449b4fe..0cd75d8b28 100644
> --- a/src/compiler/nir/nir_opt_intrinsics.c
> +++ b/src/compiler/nir/nir_opt_intrinsics.c
> @@ -47,7 +47,7 @@ opt_intrinsics_impl(nir_function_impl *impl)
>           switch (intrin->intrinsic) {
>           case nir_intrinsic_vote_any: {
>              nir_const_value *val = nir_src_as_const_value(intrin->src[0]);
> -            if (!val)
> +            if (!val || b.shader->options->lower_vote_any)
>                 continue;
>
>              replacement = nir_imm_int(&b, val->i32[0]);
> @@ -55,7 +55,7 @@ opt_intrinsics_impl(nir_function_impl *impl)
>           }
>           case nir_intrinsic_vote_all: {
>              nir_const_value *val = nir_src_as_const_value(intrin->src[0]);
> -            if (!val)
> +            if (!val || b.shader->options->lower_vote_all)
>                 continue;
>
>              replacement = nir_imm_int(&b, val->i32[0]);
> @@ -63,7 +63,7 @@ opt_intrinsics_impl(nir_function_impl *impl)
>           }
>           case nir_intrinsic_vote_eq: {
>              nir_const_value *val = nir_src_as_const_value(intrin->src[0]);
> -            if (!val)
> +            if (!val || b.shader->options->lower_vote_eq)
>                 continue;
>
>              replacement = nir_imm_int(&b, NIR_TRUE);
> --
> 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