ast_operators op,
struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
{
- if (state->language_version < 130) {
- _mesa_glsl_error(loc, state, "bit operations require GLSL 1.30");
+ if (!state->check_bitwise_operations_allowed(loc)) {
return glsl_type::error_type;
}
const struct glsl_type *type_b,
struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
{
- if (state->language_version < 130) {
- _mesa_glsl_error(loc, state,
- "operator '%%' is reserved in %s",
- state->get_version_string());
+ if (!state->check_version(130, 0, loc, "operator '%%' is reserved")) {
return glsl_type::error_type;
}
ast_operators op,
struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
{
- if (state->language_version < 130) {
- _mesa_glsl_error(loc, state, "bit operations require GLSL 1.30");
+ if (!state->check_bitwise_operations_allowed(loc)) {
return glsl_type::error_type;
}
lhs->variable_referenced()->name);
error_emitted = true;
- } else if (state->language_version <= 110 && lhs->type->is_array()) {
+ } else if (lhs->type->is_array() &&
+ !state->check_version(120, 0, &lhs_loc,
+ "whole array assignment forbidden")) {
/* From page 32 (page 38 of the PDF) of the GLSL 1.10 spec:
*
* "Other binary or unary expressions, non-dereferenced
* arrays, function names, swizzles with repeated fields,
* and constants cannot be l-values."
*/
- _mesa_glsl_error(&lhs_loc, state, "whole array assignment is not "
- "allowed in GLSL 1.10 or GLSL ES 1.00.");
error_emitted = true;
} else if (!lhs->is_lvalue()) {
_mesa_glsl_error(& lhs_loc, state, "non-lvalue in assignment");
case ast_lshift:
case ast_rshift:
- if (state->language_version < 130) {
- _mesa_glsl_error(&loc, state, "operator %s requires GLSL 1.30",
- operator_string(this->oper));
+ if (!state->check_bitwise_operations_allowed(&loc)) {
error_emitted = true;
}
_mesa_glsl_error(& loc, state, "operands of `%s' must have the same "
"type", (this->oper == ast_equal) ? "==" : "!=");
error_emitted = true;
- } else if ((state->language_version <= 110)
- && (op[0]->type->is_array() || op[1]->type->is_array())) {
- _mesa_glsl_error(& loc, state, "array comparisons forbidden in "
- "GLSL 1.10");
+ } else if ((op[0]->type->is_array() || op[1]->type->is_array()) &&
+ !state->check_version(120, 0, &loc,
+ "array comparisons forbidden")) {
error_emitted = true;
}
case ast_bit_not:
op[0] = this->subexpressions[0]->hir(instructions, state);
- if (state->language_version < 130) {
- _mesa_glsl_error(&loc, state, "bit-wise operations require GLSL 1.30");
+ if (!state->check_bitwise_operations_allowed(&loc)) {
error_emitted = true;
}
* "The second and third expressions must be the same type, but can
* be of any type other than an array."
*/
- if ((state->language_version <= 110) && type->is_array()) {
- _mesa_glsl_error(& loc, state, "Second and third operands of ?: "
- "operator must not be arrays.");
+ if (type->is_array() &&
+ !state->check_version(120, 0, &loc,
+ "Second and third operands of ?: operator "
+ "cannot be arrays")) {
error_emitted = true;
}
* directly by an application via API commands, or indirectly by
* OpenGL."
*/
- if ((state->language_version <= 110)
- && (var->mode == ir_var_uniform)) {
- _mesa_glsl_error(& initializer_loc, state,
- "cannot initialize uniforms in GLSL 1.10");
+ if (var->mode == ir_var_uniform) {
+ state->check_version(120, 0, &initializer_loc,
+ "cannot initialize uniforms");
}
if (var->type->is_sampler()) {
error_emitted = true;
}
- if (!error_emitted && (state->language_version <= 130)
- && var->type->is_array()) {
- _mesa_glsl_error(& loc, state,
- "vertex shader input / attribute cannot have "
- "array type");
+ if (!error_emitted && var->type->is_array() &&
+ !state->check_version(140, 0, &loc,
+ "vertex shader input / attribute "
+ "cannot have array type")) {
error_emitted = true;
}
}
/* Precision qualifiers exists only in GLSL versions 1.00 and >= 1.30.
*/
- if (this->type->specifier->precision != ast_precision_none
- && state->language_version != 100
- && state->language_version < 130) {
-
- _mesa_glsl_error(&loc, state,
- "precision qualifiers are supported only in GLSL ES "
- "1.00, and GLSL 1.30 and later");
+ if (this->type->specifier->precision != ast_precision_none) {
+ state->check_precision_qualifiers_allowed(&loc);
}
* allowed. This restriction is removed in GLSL 1.20, and in GLSL ES.
*/
if ((var->mode == ir_var_inout || var->mode == ir_var_out)
- && type->is_array() && state->language_version == 110) {
- _mesa_glsl_error(&loc, state, "Arrays cannot be out or inout parameters in GLSL 1.10");
+ && type->is_array()
+ && !state->check_version(120, 100, &loc,
+ "Arrays cannot be out or inout parameters")) {
type = glsl_type::error_type;
}
YYLTYPE loc = this->get_location();
if (this->precision != ast_precision_none
- && state->language_version != 100
- && state->language_version < 130) {
- _mesa_glsl_error(&loc, state,
- "precision qualifiers exist only in "
- "GLSL ES 1.00, and GLSL 1.30 and later");
+ && !state->check_precision_qualifiers_allowed(&loc)) {
return NULL;
}
if (this->precision != ast_precision_none