compiler: Add a system value for the line coord
authorNeil Roberts <nroberts@igalia.com>
Fri, 3 Jul 2020 10:57:36 +0000 (12:57 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 6 Jul 2020 21:59:15 +0000 (21:59 +0000)
The line coord is a coordinate along the axis perpendicular to the line.
It is in the range [0,1] between the two edges of the line. It is
available at least on Broadcom hardware.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5624>

src/compiler/nir/nir.c
src/compiler/nir/nir_divergence_analysis.c
src/compiler/nir/nir_gather_info.c
src/compiler/nir/nir_intrinsics.py
src/compiler/shader_enums.c
src/compiler/shader_enums.h

index 37c1a953e85cb4ed867a0a48a755cb58b2f01364..d6616a80bc80e89125cdcee7700fdf6f5fdc6789 100644 (file)
@@ -2025,6 +2025,8 @@ nir_intrinsic_from_system_value(gl_system_value val)
       return nir_intrinsic_load_frag_coord;
    case SYSTEM_VALUE_POINT_COORD:
       return nir_intrinsic_load_point_coord;
+   case SYSTEM_VALUE_LINE_COORD:
+      return nir_intrinsic_load_line_coord;
    case SYSTEM_VALUE_FRONT_FACE:
       return nir_intrinsic_load_front_face;
    case SYSTEM_VALUE_SAMPLE_ID:
@@ -2122,6 +2124,8 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
       return SYSTEM_VALUE_FRAG_COORD;
    case nir_intrinsic_load_point_coord:
       return SYSTEM_VALUE_POINT_COORD;
+   case nir_intrinsic_load_line_coord:
+      return SYSTEM_VALUE_LINE_COORD;
    case nir_intrinsic_load_front_face:
       return SYSTEM_VALUE_FRONT_FACE;
    case nir_intrinsic_load_sample_id:
index 3e2e4b86e2045dff3778a817392be0ffaead2840..fc57220f71070eca2895de72101a15872b67fbb1 100644 (file)
@@ -314,6 +314,7 @@ visit_intrinsic(nir_intrinsic_instr *instr, struct divergence_state *state)
    case nir_intrinsic_interp_deref_at_vertex:
    case nir_intrinsic_load_tess_coord:
    case nir_intrinsic_load_point_coord:
+   case nir_intrinsic_load_line_coord:
    case nir_intrinsic_load_frag_coord:
    case nir_intrinsic_load_sample_pos:
    case nir_intrinsic_load_vertex_id_zero_base:
index 1fc3740372165fdffb6a4c7ae83b963407d941cb..7a6448887b459a5acae19ea97d24c5f5241d8f1d 100644 (file)
@@ -348,6 +348,7 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader,
    case nir_intrinsic_load_draw_id:
    case nir_intrinsic_load_frag_coord:
    case nir_intrinsic_load_point_coord:
+   case nir_intrinsic_load_line_coord:
    case nir_intrinsic_load_front_face:
    case nir_intrinsic_load_vertex_id:
    case nir_intrinsic_load_vertex_id_zero_base:
index 5cc45f64c1b5669cebe1f344b07d7b5a360ce2b8..db5de37018721edd2a51f91e3c8682b0892c1246 100644 (file)
@@ -560,6 +560,7 @@ def system_value(name, dest_comp, indices=[], bit_sizes=[32]):
 
 system_value("frag_coord", 4)
 system_value("point_coord", 2)
+system_value("line_coord", 1)
 system_value("front_face", 1, bit_sizes=[1, 32])
 system_value("vertex_id", 1)
 system_value("vertex_id_zero_base", 1)
index a2a5eb82a61f4d71ff69c5c7af22b8afb7a8ec99..be382f5535dc4a0d1b41e7025b005812b5dad215 100644 (file)
@@ -228,6 +228,7 @@ gl_system_value_name(gl_system_value sysval)
      ENUM(SYSTEM_VALUE_INVOCATION_ID),
      ENUM(SYSTEM_VALUE_FRAG_COORD),
      ENUM(SYSTEM_VALUE_POINT_COORD),
+     ENUM(SYSTEM_VALUE_LINE_COORD),
      ENUM(SYSTEM_VALUE_FRONT_FACE),
      ENUM(SYSTEM_VALUE_SAMPLE_ID),
      ENUM(SYSTEM_VALUE_SAMPLE_POS),
index b33a91727a157ea599686fb5e6efa084ddbd08bc..11cd3b5b1da6d837a14f21e468dcc7f883f1c454 100644 (file)
@@ -585,6 +585,7 @@ typedef enum
    /*@{*/
    SYSTEM_VALUE_FRAG_COORD,
    SYSTEM_VALUE_POINT_COORD,
+   SYSTEM_VALUE_LINE_COORD, /**< Coord along axis perpendicular to line */
    SYSTEM_VALUE_FRONT_FACE,
    SYSTEM_VALUE_SAMPLE_ID,
    SYSTEM_VALUE_SAMPLE_POS,