[Mesa-dev] [PATCH v2 03/73] nir: add load_frag_coord system value intrinsic

Jason Ekstrand jason at jlekstrand.net
Wed Jul 5 19:12:18 UTC 2017


We've been talking about switching frag_coord to an intrinsic in i965 for a
while.  It'll take a bit of work, but it's probably good to have the
intrinsic anyway.

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

On Wed, Jul 5, 2017 at 3:47 AM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:

> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> Some drivers prefer to treat gl_FragCoord as a system value rather than
> a fragment shader input, see Const.GLSLFragCoordIsSysVal.
> ---
>  src/compiler/nir/nir.c             | 4 ++++
>  src/compiler/nir/nir_gather_info.c | 1 +
>  src/compiler/nir/nir_intrinsics.h  | 1 +
>  3 files changed, 6 insertions(+)
>
> diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
> index f81f4ee..bb4e684 100644
> --- a/src/compiler/nir/nir.c
> +++ b/src/compiler/nir/nir.c
> @@ -1884,20 +1884,22 @@ nir_intrinsic_from_system_value(gl_system_value
> val)
>     case SYSTEM_VALUE_DRAW_ID:
>        return nir_intrinsic_load_draw_id;
>     case SYSTEM_VALUE_BASE_INSTANCE:
>        return nir_intrinsic_load_base_instance;
>     case SYSTEM_VALUE_VERTEX_ID_ZERO_BASE:
>        return nir_intrinsic_load_vertex_id_zero_base;
>     case SYSTEM_VALUE_BASE_VERTEX:
>        return nir_intrinsic_load_base_vertex;
>     case SYSTEM_VALUE_INVOCATION_ID:
>        return nir_intrinsic_load_invocation_id;
> +   case SYSTEM_VALUE_FRAG_COORD:
> +      return nir_intrinsic_load_frag_coord;
>     case SYSTEM_VALUE_FRONT_FACE:
>        return nir_intrinsic_load_front_face;
>     case SYSTEM_VALUE_SAMPLE_ID:
>        return nir_intrinsic_load_sample_id;
>     case SYSTEM_VALUE_SAMPLE_POS:
>        return nir_intrinsic_load_sample_pos;
>     case SYSTEM_VALUE_SAMPLE_MASK_IN:
>        return nir_intrinsic_load_sample_mask_in;
>     case SYSTEM_VALUE_LOCAL_INVOCATION_ID:
>        return nir_intrinsic_load_local_invocation_id;
> @@ -1937,20 +1939,22 @@ nir_system_value_from_intrinsic(nir_intrinsic_op
> intrin)
>     case nir_intrinsic_load_draw_id:
>        return SYSTEM_VALUE_DRAW_ID;
>     case nir_intrinsic_load_base_instance:
>        return SYSTEM_VALUE_BASE_INSTANCE;
>     case nir_intrinsic_load_vertex_id_zero_base:
>        return SYSTEM_VALUE_VERTEX_ID_ZERO_BASE;
>     case nir_intrinsic_load_base_vertex:
>        return SYSTEM_VALUE_BASE_VERTEX;
>     case nir_intrinsic_load_invocation_id:
>        return SYSTEM_VALUE_INVOCATION_ID;
> +   case nir_intrinsic_load_frag_coord:
> +      return SYSTEM_VALUE_FRAG_COORD;
>     case nir_intrinsic_load_front_face:
>        return SYSTEM_VALUE_FRONT_FACE;
>     case nir_intrinsic_load_sample_id:
>        return SYSTEM_VALUE_SAMPLE_ID;
>     case nir_intrinsic_load_sample_pos:
>        return SYSTEM_VALUE_SAMPLE_POS;
>     case nir_intrinsic_load_sample_mask_in:
>        return SYSTEM_VALUE_SAMPLE_MASK_IN;
>     case nir_intrinsic_load_local_invocation_id:
>        return SYSTEM_VALUE_LOCAL_INVOCATION_ID;
> diff --git a/src/compiler/nir/nir_gather_info.c
> b/src/compiler/nir/nir_gather_info.c
> index 24ac74e..ac87bec 100644
> --- a/src/compiler/nir/nir_gather_info.c
> +++ b/src/compiler/nir/nir_gather_info.c
> @@ -220,20 +220,21 @@ gather_intrinsic_info(nir_intrinsic_instr *instr,
> nir_shader *shader)
>              for (uint i = 0; i < glsl_count_attribute_slots(var->type,
> false); i++) {
>                 int idx = var->data.location + i;
>                 shader->info.double_inputs_read |= BITFIELD64_BIT(idx);
>              }
>           }
>        }
>        break;
>     }
>
>     case nir_intrinsic_load_draw_id:
> +   case nir_intrinsic_load_frag_coord:
>     case nir_intrinsic_load_front_face:
>     case nir_intrinsic_load_vertex_id:
>     case nir_intrinsic_load_vertex_id_zero_base:
>     case nir_intrinsic_load_base_vertex:
>     case nir_intrinsic_load_base_instance:
>     case nir_intrinsic_load_instance_id:
>     case nir_intrinsic_load_sample_id:
>     case nir_intrinsic_load_sample_pos:
>     case nir_intrinsic_load_sample_mask_in:
>     case nir_intrinsic_load_primitive_id:
> diff --git a/src/compiler/nir/nir_intrinsics.h b/src/compiler/nir/nir_
> intrinsics.h
> index 21e7d90..dcd9642 100644
> --- a/src/compiler/nir/nir_intrinsics.h
> +++ b/src/compiler/nir/nir_intrinsics.h
> @@ -297,20 +297,21 @@ INTRINSIC(shared_atomic_comp_swap, 3, ARR(1, 1, 1),
> true, 1, 0, 1, BASE, xx, xx,
>  #ifndef DEFINE_SYSTEM_VALUE
>  #define DEFINE_SYSTEM_VALUE(name)
>  #endif
>
>  #define SYSTEM_VALUE(name, components, num_indices, idx0, idx1, idx2) \
>     DEFINE_SYSTEM_VALUE(name) \
>     INTRINSIC(load_##name, 0, ARR(0), true, components, 0, num_indices, \
>     idx0, idx1, idx2, \
>     NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
>
> +SYSTEM_VALUE(frag_coord, 4, 0, xx, xx, xx)
>  SYSTEM_VALUE(front_face, 1, 0, xx, xx, xx)
>  SYSTEM_VALUE(vertex_id, 1, 0, xx, xx, xx)
>  SYSTEM_VALUE(vertex_id_zero_base, 1, 0, xx, xx, xx)
>  SYSTEM_VALUE(base_vertex, 1, 0, xx, xx, xx)
>  SYSTEM_VALUE(instance_id, 1, 0, xx, xx, xx)
>  SYSTEM_VALUE(base_instance, 1, 0, xx, xx, xx)
>  SYSTEM_VALUE(draw_id, 1, 0, xx, xx, xx)
>  SYSTEM_VALUE(sample_id, 1, 0, xx, xx, xx)
>  SYSTEM_VALUE(sample_pos, 2, 0, xx, xx, xx)
>  SYSTEM_VALUE(sample_mask_in, 1, 0, xx, xx, xx)
> --
> 2.9.3
>
> _______________________________________________
> 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/20170705/15a4bd92/attachment-0001.html>


More information about the mesa-dev mailing list