compiler: Add color system value
authorConnor Abbott <cwabbott0@gmail.com>
Mon, 27 May 2019 15:48:42 +0000 (17:48 +0200)
committerConnor Abbott <cwabbott0@gmail.com>
Mon, 8 Jul 2019 12:18:34 +0000 (14:18 +0200)
This is nice to have with radeonsi, where color varyings are handled
specially to avoid recompiles.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/compiler/nir/nir.c
src/compiler/nir/nir_intrinsics.py
src/compiler/shader_enums.c
src/compiler/shader_enums.h

index 81f569b4c2b43517b4ce9f2884611aea5360d3cf..4f2da2d431fab03467788fa5232e110cc8064d55 100644 (file)
@@ -1848,6 +1848,10 @@ nir_intrinsic_from_system_value(gl_system_value val)
       return nir_intrinsic_load_patch_vertices_in;
    case SYSTEM_VALUE_HELPER_INVOCATION:
       return nir_intrinsic_load_helper_invocation;
+   case SYSTEM_VALUE_COLOR0:
+      return nir_intrinsic_load_color0;
+   case SYSTEM_VALUE_COLOR1:
+      return nir_intrinsic_load_color1;
    case SYSTEM_VALUE_VIEW_INDEX:
       return nir_intrinsic_load_view_index;
    case SYSTEM_VALUE_SUBGROUP_SIZE:
@@ -1933,6 +1937,10 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
       return SYSTEM_VALUE_VERTICES_IN;
    case nir_intrinsic_load_helper_invocation:
       return SYSTEM_VALUE_HELPER_INVOCATION;
+   case nir_intrinsic_load_color0:
+      return SYSTEM_VALUE_COLOR0;
+   case nir_intrinsic_load_color1:
+      return SYSTEM_VALUE_COLOR1;
    case nir_intrinsic_load_view_index:
       return SYSTEM_VALUE_VIEW_INDEX;
    case nir_intrinsic_load_subgroup_size:
index 24bb09908050e110ff367ce605320160e372f77c..70ff1b99de00b19b066593c693426fd4671f08a5 100644 (file)
@@ -594,6 +594,12 @@ system_value("blend_const_color_rgba", 4)
 system_value("blend_const_color_rgba8888_unorm", 1)
 system_value("blend_const_color_aaaa8888_unorm", 1)
 
+# System values for gl_Color, for radeonsi which interpolates these in the
+# shader prolog to handle two-sided color without recompiles and therefore
+# doesn't handle these in the main shader part like normal varyings.
+system_value("color0", 4)
+system_value("color1", 4)
+
 # Barycentric coordinate intrinsics.
 #
 # These set up the barycentric coordinates for a particular interpolation.
index 451f1b758de1a75bd2a38fdb6f561629854146e7..f7613cf01a25bc0357598c8f4a72752e085133d3 100644 (file)
@@ -231,6 +231,8 @@ gl_system_value_name(gl_system_value sysval)
      ENUM(SYSTEM_VALUE_SAMPLE_POS),
      ENUM(SYSTEM_VALUE_SAMPLE_MASK_IN),
      ENUM(SYSTEM_VALUE_HELPER_INVOCATION),
+     ENUM(SYSTEM_VALUE_COLOR0),
+     ENUM(SYSTEM_VALUE_COLOR1),
      ENUM(SYSTEM_VALUE_TESS_COORD),
      ENUM(SYSTEM_VALUE_VERTICES_IN),
      ENUM(SYSTEM_VALUE_PRIMITIVE_ID),
index cf753df37914e8c172f35483d2bcfabf1589c587..4d5af8a815b62aabba6bc45ae59bea6f91328ef9 100644 (file)
@@ -580,6 +580,8 @@ typedef enum
    SYSTEM_VALUE_SAMPLE_POS,
    SYSTEM_VALUE_SAMPLE_MASK_IN,
    SYSTEM_VALUE_HELPER_INVOCATION,
+   SYSTEM_VALUE_COLOR0,
+   SYSTEM_VALUE_COLOR1,
    /*@}*/
 
    /**