From 24af57407c2b2689394aef5a6666ba33727879a7 Mon Sep 17 00:00:00 2001 From: Andreas Baierl Date: Tue, 4 Jun 2019 13:23:44 +0200 Subject: [PATCH] glsl: Optionally declare gl_PointCoord as a system value Signed-off-by: Andreas Baierl Reviewed-by: Qiang Yu Reviewed-by: Eric Anholt --- src/compiler/glsl/builtin_variables.cpp | 8 ++++++-- src/compiler/shader_enums.c | 1 + src/compiler/shader_enums.h | 1 + src/mesa/main/mtypes.h | 6 +++++- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 ++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp index 56f6213..c10ea9e 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 f7613cf..7179668 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 4d5af8a..5c64377 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 1313ea2..16a720f 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 18a5571..3c6e960 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: -- 2.7.4