glsl: Optionally declare gl_PointCoord as a system value
authorAndreas Baierl <ichgeh@imkreisrum.de>
Tue, 4 Jun 2019 11:23:44 +0000 (13:23 +0200)
committerQiang Yu <yuq825@gmail.com>
Thu, 18 Jul 2019 13:20:39 +0000 (13:20 +0000)
Signed-off-by: Andreas Baierl <ichgeh@imkreisrum.de>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/compiler/glsl/builtin_variables.cpp
src/compiler/shader_enums.c
src/compiler/shader_enums.h
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 56f62132b03f930b4dbd03ca0d45ff34f6fd700c..c10ea9e61a5003d0131ed8421f5fb100a70e92ba 100644 (file)
@@ -1258,8 +1258,12 @@ builtin_variable_generator::generate_fs_special_vars()
       add_input(VARYING_SLOT_FACE, bool_t, "gl_FrontFacing");
 
    if (state->is_version(120, 100)) {
-      add_input(VARYING_SLOT_PNTC, vec2_t, GLSL_PRECISION_MEDIUM,
-                "gl_PointCoord");
+      if (this->state->ctx->Const.GLSLPointCoordIsSysVal)
+         add_system_value(SYSTEM_VALUE_POINT_COORD, vec2_t,
+                          GLSL_PRECISION_MEDIUM, "gl_PointCoord");
+      else
+         add_input(VARYING_SLOT_PNTC, vec2_t, GLSL_PRECISION_MEDIUM,
+                   "gl_PointCoord");
    }
 
    if (state->has_geometry_shader() || state->EXT_gpu_shader4_enable) {
index f7613cf01a25bc0357598c8f4a72752e085133d3..71796687afa564396946d64f9b9646023a563be7 100644 (file)
@@ -226,6 +226,7 @@ gl_system_value_name(gl_system_value sysval)
      ENUM(SYSTEM_VALUE_DRAW_ID),
      ENUM(SYSTEM_VALUE_INVOCATION_ID),
      ENUM(SYSTEM_VALUE_FRAG_COORD),
+     ENUM(SYSTEM_VALUE_POINT_COORD),
      ENUM(SYSTEM_VALUE_FRONT_FACE),
      ENUM(SYSTEM_VALUE_SAMPLE_ID),
      ENUM(SYSTEM_VALUE_SAMPLE_POS),
index 4d5af8a815b62aabba6bc45ae59bea6f91328ef9..5c6437749b84d575dd14327362e2bffb86f285ee 100644 (file)
@@ -575,6 +575,7 @@ typedef enum
     */
    /*@{*/
    SYSTEM_VALUE_FRAG_COORD,
+   SYSTEM_VALUE_POINT_COORD,
    SYSTEM_VALUE_FRONT_FACE,
    SYSTEM_VALUE_SAMPLE_ID,
    SYSTEM_VALUE_SAMPLE_POS,
index 1313ea2a57943296916710d832542f43dbba4d54..16a720febe12f3b6c5ba2128fa8acf4ecc693407 100644 (file)
@@ -3912,8 +3912,12 @@ struct gl_constants
     */
    GLboolean GLSLSkipStrictMaxUniformLimitCheck;
 
-   /** Whether gl_FragCoord and gl_FrontFacing are system values. */
+   /**
+    * Whether gl_FragCoord, gl_PointCoord and gl_FrontFacing
+    * are system values.
+    **/
    bool GLSLFragCoordIsSysVal;
+   bool GLSLPointCoordIsSysVal;
    bool GLSLFrontFacingIsSysVal;
 
    /**
index 18a5571aaa87f48811a8b89e19e43e54bfdc2c10..3c6e9601655e3d8ecba0adc08cf7b7eed803acee 100644 (file)
@@ -5774,6 +5774,8 @@ _mesa_sysval_to_semantic(unsigned sysval)
    /* Fragment shader */
    case SYSTEM_VALUE_FRAG_COORD:
       return TGSI_SEMANTIC_POSITION;
+   case SYSTEM_VALUE_POINT_COORD:
+      return TGSI_SEMANTIC_PCOORD;
    case SYSTEM_VALUE_FRONT_FACE:
       return TGSI_SEMANTIC_FACE;
    case SYSTEM_VALUE_SAMPLE_ID: