nir: add load_frag_coord system value intrinsic
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 4 Jul 2017 08:34:02 +0000 (10:34 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 31 Jul 2017 12:55:28 +0000 (14:55 +0200)
Some drivers prefer to treat gl_FragCoord as a system value rather than
a fragment shader input, see Const.GLSLFragCoordIsSysVal.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir.c
src/compiler/nir/nir_gather_info.c
src/compiler/nir/nir_intrinsics.h

index b33f56d3d3a2b96b07b37fc768bc896745bae56a..841b7f427ab1353648bfaf6ae060d8e161e313a1 100644 (file)
@@ -1891,6 +1891,8 @@ nir_intrinsic_from_system_value(gl_system_value val)
       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:
@@ -1958,6 +1960,8 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
       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:
index 24ac74ee79da7aede4174aef4797a407f9b875d3..ac87bec46c0c22e79afcbd09bce750f605da36db 100644 (file)
@@ -227,6 +227,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_front_face:
    case nir_intrinsic_load_vertex_id:
    case nir_intrinsic_load_vertex_id_zero_base:
index 96ecfbc338df5a734be0101f048a353f7d843b1d..ea51525056ddf49b0fe4bddab286f3246937cdb2 100644 (file)
@@ -322,6 +322,7 @@ INTRINSIC(shared_atomic_comp_swap, 3, ARR(1, 1, 1), true, 1, 0, 1, BASE, xx, xx,
    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)