summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Baierl <[email protected]>2019-06-04 13:23:44 +0200
committerQiang Yu <[email protected]>2019-07-18 13:20:39 +0000
commit24af57407c2b2689394aef5a6666ba33727879a7 (patch)
tree1b8efc09b65dd499d99529e2a4e39b67327d41a5
parentb178fdf486f3496270dd4ec12d9bc596d11433ad (diff)
glsl: Optionally declare gl_PointCoord as a system value
Signed-off-by: Andreas Baierl <[email protected]> Reviewed-by: Qiang Yu <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r--src/compiler/glsl/builtin_variables.cpp8
-rw-r--r--src/compiler/shader_enums.c1
-rw-r--r--src/compiler/shader_enums.h1
-rw-r--r--src/mesa/main/mtypes.h6
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp2
5 files changed, 15 insertions, 3 deletions
diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
index 56f62132b03..c10ea9e61a5 100644
--- a/src/compiler/glsl/builtin_variables.cpp
+++ b/src/compiler/glsl/builtin_variables.cpp
@@ -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) {
diff --git a/src/compiler/shader_enums.c b/src/compiler/shader_enums.c
index f7613cf01a2..71796687afa 100644
--- a/src/compiler/shader_enums.c
+++ b/src/compiler/shader_enums.c
@@ -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),
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index 4d5af8a815b..5c6437749b8 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -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,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 1313ea2a579..16a720febe1 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -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;
/**
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 18a5571aaa8..3c6e9601655 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -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: