nir: Add intrinsics for tessellation shader system values.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 9 Oct 2015 06:53:47 +0000 (23:53 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 29 Oct 2015 04:14:53 +0000 (21:14 -0700)
nir_intrinsic_load_patch_vertices_in corresponds to gl_PatchVerticesIn,
a special input in both the TCS and TES stages.

nir_intrinsic_load_tess_coord corresponds to gl_TessCoord, a special
tessellation evaluation shader input.

nir_intrinsic_load_tess_level_outer/inner correspond to the
gl_TessLevelOuter[] and gl_TessLevelInner[] evaluation shader inputs,
which we treat as system values because they're stored specially.
(These intrinsics are only for the TES - the TCS uses output variables.)

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
src/glsl/nir/nir.c
src/glsl/nir/nir_intrinsics.h

index 793bdafb54b53df078045ceffa08d22e732d8780..5f03095d673879011d6bcc4e15646b754564c02a 100644 (file)
@@ -1557,12 +1557,14 @@ nir_intrinsic_from_system_value(gl_system_value val)
       return nir_intrinsic_load_num_work_groups;
    case SYSTEM_VALUE_PRIMITIVE_ID:
       return nir_intrinsic_load_primitive_id;
-   /* FINISHME: Add tessellation intrinsics.
    case SYSTEM_VALUE_TESS_COORD:
-   case SYSTEM_VALUE_VERTICES_IN:
+      return nir_intrinsic_load_tess_coord;
    case SYSTEM_VALUE_TESS_LEVEL_OUTER:
+      return nir_intrinsic_load_tess_level_outer;
    case SYSTEM_VALUE_TESS_LEVEL_INNER:
-    */
+      return nir_intrinsic_load_tess_level_inner;
+   case SYSTEM_VALUE_VERTICES_IN:
+      return nir_intrinsic_load_patch_vertices_in;
    default:
       unreachable("system value does not directly correspond to intrinsic");
    }
@@ -1598,13 +1600,14 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
       return SYSTEM_VALUE_WORK_GROUP_ID;
    case nir_intrinsic_load_primitive_id:
       return SYSTEM_VALUE_PRIMITIVE_ID;
-   /* FINISHME: Add tessellation intrinsics.
+   case nir_intrinsic_load_tess_coord:
       return SYSTEM_VALUE_TESS_COORD;
-      return SYSTEM_VALUE_VERTICES_IN;
-      return SYSTEM_VALUE_PRIMITIVE_ID;
+   case nir_intrinsic_load_tess_level_outer:
       return SYSTEM_VALUE_TESS_LEVEL_OUTER;
+   case nir_intrinsic_load_tess_level_inner:
       return SYSTEM_VALUE_TESS_LEVEL_INNER;
-    */
+   case nir_intrinsic_load_patch_vertices_in:
+      return SYSTEM_VALUE_VERTICES_IN;
    default:
       unreachable("intrinsic doesn't produce a system value");
    }
index 49bf3b22aed2031c3727540f0137d53ebae0ab6b..c1fb1bad4bc3086691a01753d5f518abcae02769 100644 (file)
@@ -198,6 +198,10 @@ SYSTEM_VALUE(sample_pos, 2, 0)
 SYSTEM_VALUE(sample_mask_in, 1, 0)
 SYSTEM_VALUE(primitive_id, 1, 0)
 SYSTEM_VALUE(invocation_id, 1, 0)
+SYSTEM_VALUE(tess_coord, 3, 0)
+SYSTEM_VALUE(tess_level_outer, 4, 0)
+SYSTEM_VALUE(tess_level_inner, 2, 0)
+SYSTEM_VALUE(patch_vertices_in, 1, 0)
 SYSTEM_VALUE(local_invocation_id, 3, 0)
 SYSTEM_VALUE(work_group_id, 3, 0)
 SYSTEM_VALUE(user_clip_plane, 4, 1) /* const_index[0] is user_clip_plane[idx] */