summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/ast_function.cpp2
-rw-r--r--src/glsl/ast_to_hir.cpp40
-rw-r--r--src/glsl/glsl_lexer.ll4
-rw-r--r--src/glsl/glsl_parser.yy5
-rw-r--r--src/glsl/glsl_types.cpp8
5 files changed, 33 insertions, 26 deletions
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index c0e05ad8589..5e1c8918b17 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -277,7 +277,7 @@ generate_call(exec_list *instructions, ir_function_signature *sig,
*
* Function calls were first allowed to be constant expressions in GLSL 1.20.
*/
- if (state->language_version >= 120) {
+ if (state->is_version(120, 0)) {
ir_constant *value = sig->constant_expression_value(actual_parameters, NULL);
if (value != NULL) {
return value;
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index adada30509e..79e4be8dcf1 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -121,7 +121,7 @@ apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from,
/* This conversion was added in GLSL 1.20. If the compilation mode is
* GLSL 1.10, the conversion is skipped.
*/
- if (state->language_version < 120)
+ if (!state->is_version(120, 0))
return false;
/* From page 27 (page 33 of the PDF) of the GLSL 1.50 spec:
@@ -1660,15 +1660,18 @@ ast_expression::hir(exec_list *instructions,
array->type->element_type()->is_sampler() &&
const_index == NULL) {
- if (state->language_version == 100) {
- _mesa_glsl_warning(&loc, state,
- "sampler arrays indexed with non-constant "
- "expressions is optional in GLSL ES 1.00");
- } else if (state->language_version < 130) {
- _mesa_glsl_warning(&loc, state,
- "sampler arrays indexed with non-constant "
- "expressions is forbidden in GLSL 1.30 and "
- "later");
+ if (!state->is_version(130, 100)) {
+ if (state->es_shader) {
+ _mesa_glsl_warning(&loc, state,
+ "sampler arrays indexed with non-constant "
+ "expressions is optional in %s",
+ state->get_version_string());
+ } else {
+ _mesa_glsl_warning(&loc, state,
+ "sampler arrays indexed with non-constant "
+ "expressions will be forbidden in GLSL 1.30 and "
+ "later");
+ }
} else {
_mesa_glsl_error(&loc, state,
"sampler arrays indexed with non-constant "
@@ -2288,7 +2291,7 @@ get_variable_being_redeclared(ir_variable *var, ast_declaration *decl,
* * gl_Color
* * gl_SecondaryColor
*/
- } else if (state->language_version >= 130
+ } else if (state->is_version(130, 0)
&& (strcmp(var->name, "gl_FrontColor") == 0
|| strcmp(var->name, "gl_BackColor") == 0
|| strcmp(var->name, "gl_FrontSecondaryColor") == 0
@@ -2611,7 +2614,7 @@ ast_declarator_list::hir(exec_list *instructions,
* This is relaxed in GLSL 1.30. It is also relaxed by any extension
* that adds the 'layout' keyword.
*/
- if ((state->language_version < 130)
+ if (!state->is_version(130, 0)
&& !state->ARB_explicit_attrib_location_enable
&& !state->ARB_fragment_coord_conventions_enable) {
if (this->type->qualifier.flags.q.out) {
@@ -2712,7 +2715,7 @@ ast_declarator_list::hir(exec_list *instructions,
break;
case GLSL_TYPE_UINT:
case GLSL_TYPE_INT:
- if (state->language_version > 120)
+ if (state->is_version(120, 0))
break;
/* FALLTHROUGH */
default:
@@ -2741,7 +2744,7 @@ ast_declarator_list::hir(exec_list *instructions,
* vector, then it must be qualified with the interpolation qualifier
* flat."
*/
- if (state->language_version >= 130
+ if (state->is_version(130, 0)
&& state->target == vertex_shader
&& state->current_function == NULL
&& var->type->is_integer()
@@ -2761,7 +2764,7 @@ ast_declarator_list::hir(exec_list *instructions,
* centroid in, out, or centroid out in a declaration. They do not apply
* to the deprecated storage qualifiers varying or centroid varying."
*/
- if (state->language_version >= 130
+ if (state->is_version(130, 0)
&& this->type->qualifier.has_interpolation()
&& this->type->qualifier.flags.q.varying) {
@@ -2787,7 +2790,7 @@ ast_declarator_list::hir(exec_list *instructions,
* shader (in) can be further qualified with one or more of these
* interpolation qualifiers"
*/
- if (state->language_version >= 130
+ if (state->is_version(130, 0)
&& this->type->qualifier.has_interpolation()) {
const char *i = this->type->qualifier.interpolation_string();
@@ -2817,7 +2820,7 @@ ast_declarator_list::hir(exec_list *instructions,
/* From section 4.3.4 of the GLSL 1.30 spec:
* "It is an error to use centroid in in a vertex shader."
*/
- if (state->language_version >= 130
+ if (state->is_version(130, 0)
&& this->type->qualifier.flags.q.centroid
&& this->type->qualifier.flags.q.in
&& state->target == vertex_shader) {
@@ -3161,7 +3164,8 @@ ast_function::hir(exec_list *instructions,
*
* Note that this language does not appear in GLSL 1.10.
*/
- if ((state->current_function != NULL) && (state->language_version != 110)) {
+ if ((state->current_function != NULL) &&
+ state->is_version(120, 100)) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(&loc, state,
"declaration of function `%s' not allowed within "
diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index c538d7d8e30..d2c8c317454 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -103,7 +103,7 @@ literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
if (value > UINT_MAX) {
/* Note that signed 0xffffffff is valid, not out of range! */
- if (state->language_version >= 130) {
+ if (state->is_version(130, 0)) {
_mesa_glsl_error(lloc, state,
"Literal value `%s' out of range", text);
} else {
@@ -333,7 +333,7 @@ struct return STRUCT;
void return VOID_TOK;
layout {
- if ((yyextra->language_version >= 140)
+ if ((yyextra->is_version(140, 0))
|| yyextra->AMD_conservative_depth_enable
|| yyextra->ARB_conservative_depth_enable
|| yyextra->ARB_explicit_attrib_location_enable
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index e68a601c89e..3b4d84b6e6d 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -310,9 +310,10 @@ pragma_statement:
| PRAGMA_OPTIMIZE_OFF EOL
| PRAGMA_INVARIANT_ALL EOL
{
- if (state->language_version == 110) {
+ if (!state->is_version(120, 100)) {
_mesa_glsl_warning(& @1, state,
- "pragma `invariant(all)' not supported in %s",
+ "pragma `invariant(all)' not supported in %s "
+ "(GLSL ES 1.00 or GLSL 1.20 required).",
state->get_version_string());
} else {
state->all_invariant = true;
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index 3940a12a5cd..9edb7124cc2 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -290,16 +290,18 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
}
if (state->ARB_texture_rectangle_enable ||
- state->language_version >= 140) {
+ state->is_version(140, 0)) {
glsl_type::generate_ARB_texture_rectangle_types(state->symbols,
state->ARB_texture_rectangle_warn);
}
- if (state->OES_texture_3D_enable && state->language_version == 100) {
+ if (state->OES_texture_3D_enable
+ && state->is_version(0, 100)) {
glsl_type::generate_OES_texture_3D_types(state->symbols,
state->OES_texture_3D_warn);
}
- if (state->EXT_texture_array_enable && state->language_version < 130) {
+ if (state->EXT_texture_array_enable
+ && !state->is_version(130, 0)) {
// These are already included in 130; don't create twice.
glsl_type::generate_EXT_texture_array_types(state->symbols,
state->EXT_texture_array_warn);