glsl: Refactor type checking for redeclarations
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
@@ -4281,10 +4281,13 @@ get_variable_being_redeclared(ir_variable **var_ptr, YYLTYPE loc,
|
|||||||
delete var;
|
delete var;
|
||||||
var = NULL;
|
var = NULL;
|
||||||
*var_ptr = NULL;
|
*var_ptr = NULL;
|
||||||
|
} else if (earlier->type != var->type) {
|
||||||
|
_mesa_glsl_error(&loc, state,
|
||||||
|
"redeclaration of `%s' has incorrect type",
|
||||||
|
var->name);
|
||||||
} else if ((state->ARB_fragment_coord_conventions_enable ||
|
} else if ((state->ARB_fragment_coord_conventions_enable ||
|
||||||
state->is_version(150, 0))
|
state->is_version(150, 0))
|
||||||
&& strcmp(var->name, "gl_FragCoord") == 0
|
&& strcmp(var->name, "gl_FragCoord") == 0) {
|
||||||
&& earlier->type == var->type) {
|
|
||||||
/* Allow redeclaration of gl_FragCoord for ARB_fcc layout
|
/* Allow redeclaration of gl_FragCoord for ARB_fcc layout
|
||||||
* qualifiers.
|
* qualifiers.
|
||||||
*/
|
*/
|
||||||
@@ -4307,16 +4310,14 @@ get_variable_being_redeclared(ir_variable **var_ptr, YYLTYPE loc,
|
|||||||
|| strcmp(var->name, "gl_FrontSecondaryColor") == 0
|
|| strcmp(var->name, "gl_FrontSecondaryColor") == 0
|
||||||
|| strcmp(var->name, "gl_BackSecondaryColor") == 0
|
|| strcmp(var->name, "gl_BackSecondaryColor") == 0
|
||||||
|| strcmp(var->name, "gl_Color") == 0
|
|| strcmp(var->name, "gl_Color") == 0
|
||||||
|| strcmp(var->name, "gl_SecondaryColor") == 0)
|
|| strcmp(var->name, "gl_SecondaryColor") == 0)) {
|
||||||
&& earlier->type == var->type) {
|
|
||||||
earlier->data.interpolation = var->data.interpolation;
|
earlier->data.interpolation = var->data.interpolation;
|
||||||
|
|
||||||
/* Layout qualifiers for gl_FragDepth. */
|
/* Layout qualifiers for gl_FragDepth. */
|
||||||
} else if ((state->is_version(420, 0) ||
|
} else if ((state->is_version(420, 0) ||
|
||||||
state->AMD_conservative_depth_enable ||
|
state->AMD_conservative_depth_enable ||
|
||||||
state->ARB_conservative_depth_enable)
|
state->ARB_conservative_depth_enable)
|
||||||
&& strcmp(var->name, "gl_FragDepth") == 0
|
&& strcmp(var->name, "gl_FragDepth") == 0) {
|
||||||
&& earlier->type == var->type) {
|
|
||||||
|
|
||||||
/** From the AMD_conservative_depth spec:
|
/** From the AMD_conservative_depth spec:
|
||||||
* Within any shader, the first redeclarations of gl_FragDepth
|
* Within any shader, the first redeclarations of gl_FragDepth
|
||||||
@@ -4343,7 +4344,6 @@ get_variable_being_redeclared(ir_variable **var_ptr, YYLTYPE loc,
|
|||||||
|
|
||||||
} else if (state->has_framebuffer_fetch() &&
|
} else if (state->has_framebuffer_fetch() &&
|
||||||
strcmp(var->name, "gl_LastFragData") == 0 &&
|
strcmp(var->name, "gl_LastFragData") == 0 &&
|
||||||
var->type == earlier->type &&
|
|
||||||
var->data.mode == ir_var_auto) {
|
var->data.mode == ir_var_auto) {
|
||||||
/* According to the EXT_shader_framebuffer_fetch spec:
|
/* According to the EXT_shader_framebuffer_fetch spec:
|
||||||
*
|
*
|
||||||
@@ -4363,11 +4363,6 @@ get_variable_being_redeclared(ir_variable **var_ptr, YYLTYPE loc,
|
|||||||
/* Allow verbatim redeclarations of built-in variables. Not explicitly
|
/* Allow verbatim redeclarations of built-in variables. Not explicitly
|
||||||
* valid, but some applications do it.
|
* valid, but some applications do it.
|
||||||
*/
|
*/
|
||||||
if (earlier->type != var->type) {
|
|
||||||
_mesa_glsl_error(&loc, state,
|
|
||||||
"redeclaration of `%s' has incorrect type",
|
|
||||||
var->name);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
_mesa_glsl_error(&loc, state, "`%s' redeclared", var->name);
|
_mesa_glsl_error(&loc, state, "`%s' redeclared", var->name);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user