From 4191c1a57c1e806a078bfc5b074b557ff2b54c35 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 2 Jan 2016 20:16:16 +0100 Subject: glsl: optionally declare gl_FragCoord & gl_FrontFacing as system values Reviewed-by: Edward O'Callaghan --- src/glsl/ast_to_hir.cpp | 2 +- src/glsl/builtin_variables.cpp | 12 ++++++++++-- src/glsl/nir/shader_enums.h | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src/glsl') diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index e6aec3654b8..f3966d7e3f4 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -3517,7 +3517,7 @@ get_variable_being_redeclared(ir_variable *var, YYLTYPE loc, state->is_version(150, 0)) && strcmp(var->name, "gl_FragCoord") == 0 && earlier->type == var->type - && earlier->data.mode == var->data.mode) { + && var->data.mode == ir_var_shader_in) { /* Allow redeclaration of gl_FragCoord for ARB_fcc layout * qualifiers. */ diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index e82c99ee3bb..221aab0043b 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -1057,8 +1057,16 @@ builtin_variable_generator::generate_fs_special_vars() { ir_variable *var; - add_input(VARYING_SLOT_POS, vec4_t, "gl_FragCoord"); - add_input(VARYING_SLOT_FACE, bool_t, "gl_FrontFacing"); + if (this->state->ctx->Const.GLSLFragCoordIsSysVal) + add_system_value(SYSTEM_VALUE_FRAG_COORD, vec4_t, "gl_FragCoord"); + else + add_input(VARYING_SLOT_POS, vec4_t, "gl_FragCoord"); + + if (this->state->ctx->Const.GLSLFrontFacingIsSysVal) + add_system_value(SYSTEM_VALUE_FRONT_FACE, bool_t, "gl_FrontFacing"); + else + add_input(VARYING_SLOT_FACE, bool_t, "gl_FrontFacing"); + if (state->is_version(120, 100)) add_input(VARYING_SLOT_PNTC, vec2_t, "gl_PointCoord"); diff --git a/src/glsl/nir/shader_enums.h b/src/glsl/nir/shader_enums.h index 0be217c0cf7..8a2a81a333d 100644 --- a/src/glsl/nir/shader_enums.h +++ b/src/glsl/nir/shader_enums.h @@ -412,7 +412,8 @@ typedef enum * \name Fragment shader system values */ /*@{*/ - SYSTEM_VALUE_FRONT_FACE, /**< (not done yet) */ + SYSTEM_VALUE_FRAG_COORD, + SYSTEM_VALUE_FRONT_FACE, SYSTEM_VALUE_SAMPLE_ID, SYSTEM_VALUE_SAMPLE_POS, SYSTEM_VALUE_SAMPLE_MASK_IN, -- cgit v1.2.3