aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-05-29 20:50:12 +0200
committermarha <marha@users.sourceforge.net>2014-05-29 20:50:12 +0200
commitaec798fb4dc72d616732d0fa711faffaa8cd7590 (patch)
tree2814dfe69e7fb25b57492244d5cfa59d80fc8837 /mesalib/src/glsl
parent78c6c2b88ae54977a2a617f116a1598657a98b6f (diff)
parent816a5430313e07083c5325f0a430126a2e10ec41 (diff)
downloadvcxsrv-aec798fb4dc72d616732d0fa711faffaa8cd7590.tar.gz
vcxsrv-aec798fb4dc72d616732d0fa711faffaa8cd7590.tar.bz2
vcxsrv-aec798fb4dc72d616732d0fa711faffaa8cd7590.zip
Merge remote-tracking branch 'origin/released'
Conflicts: mesalib/src/mesa/drivers/dri/common/dri_util.c
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp12
-rw-r--r--mesalib/src/glsl/ir.h9
-rw-r--r--mesalib/src/glsl/ir_print_visitor.cpp4
-rw-r--r--mesalib/src/glsl/link_uniforms.cpp4
-rw-r--r--mesalib/src/glsl/link_varyings.cpp3
5 files changed, 22 insertions, 10 deletions
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index 0128b3f4e..f230a70a3 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -3078,7 +3078,7 @@ validate_identifier(const char *identifier, YYLTYPE loc,
* OpenGL, and may not be declared in a shader as either a
* variable or a function."
*/
- if (strncmp(identifier, "gl_", 3) == 0) {
+ if (is_gl_identifier(identifier)) {
_mesa_glsl_error(&loc, state,
"identifier `%s' uses reserved `gl_' prefix",
identifier);
@@ -3651,11 +3651,15 @@ ast_declarator_list::hir(exec_list *instructions,
* instruction stream.
*/
exec_list initializer_instructions;
+
+ /* Examine var name here since var may get deleted in the next call */
+ bool var_is_gl_id = is_gl_identifier(var->name);
+
ir_variable *earlier =
get_variable_being_redeclared(var, decl->get_location(), state,
false /* allow_all_redeclarations */);
if (earlier != NULL) {
- if (strncmp(var->name, "gl_", 3) == 0 &&
+ if (var_is_gl_id &&
earlier->data.how_declared == ir_var_declared_in_block) {
_mesa_glsl_error(&loc, state,
"`%s' has already been redeclared using "
@@ -5399,7 +5403,7 @@ ast_interface_block::hir(exec_list *instructions,
ir_variable *earlier =
get_variable_being_redeclared(var, loc, state,
true /* allow_all_redeclarations */);
- if (strncmp(var->name, "gl_", 3) != 0 || earlier == NULL) {
+ if (!is_gl_identifier(var->name) || earlier == NULL) {
_mesa_glsl_error(&loc, state,
"redeclaration of gl_PerVertex can only "
"include built-in variables");
@@ -5634,7 +5638,7 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state,
gl_FragColor_assigned = true;
else if (strcmp(var->name, "gl_FragData") == 0)
gl_FragData_assigned = true;
- else if (strncmp(var->name, "gl_", 3) != 0) {
+ else if (!is_gl_identifier(var->name)) {
if (state->stage == MESA_SHADER_FRAGMENT &&
var->data.mode == ir_var_shader_out) {
user_defined_fs_output_assigned = true;
diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h
index ef4a12d60..80609829e 100644
--- a/mesalib/src/glsl/ir.h
+++ b/mesalib/src/glsl/ir.h
@@ -2342,6 +2342,15 @@ prototype_string(const glsl_type *return_type, const char *name,
const char *
mode_string(const ir_variable *var);
+/**
+ * Built-in / reserved GL variables names start with "gl_"
+ */
+static inline bool
+is_gl_identifier(const char *s)
+{
+ return s && s[0] == 'g' && s[1] == 'l' && s[2] == '_';
+}
+
extern "C" {
#endif /* __cplusplus */
diff --git a/mesalib/src/glsl/ir_print_visitor.cpp b/mesalib/src/glsl/ir_print_visitor.cpp
index 0a7695ae1..c4a6f9c9f 100644
--- a/mesalib/src/glsl/ir_print_visitor.cpp
+++ b/mesalib/src/glsl/ir_print_visitor.cpp
@@ -146,7 +146,7 @@ print_type(FILE *f, const glsl_type *t)
print_type(f, t->fields.array);
fprintf(f, " %u)", t->length);
} else if ((t->base_type == GLSL_TYPE_STRUCT)
- && (strncmp("gl_", t->name, 3) != 0)) {
+ && !is_gl_identifier(t->name)) {
fprintf(f, "%s@%p", t->name, (void *) t);
} else {
fprintf(f, "%s", t->name);
@@ -430,7 +430,7 @@ void ir_print_visitor::visit(ir_constant *ir)
case GLSL_TYPE_FLOAT:
if (ir->value.f[i] == 0.0f)
/* 0.0 == -0.0, so print with %f to get the proper sign. */
- fprintf(f, "%.1f", ir->value.f[i]);
+ fprintf(f, "%f", ir->value.f[i]);
else if (fabs(ir->value.f[i]) < 0.000001f)
fprintf(f, "%a", ir->value.f[i]);
else if (fabs(ir->value.f[i]) > 1000000.0f)
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index 95a0c1ac6..377fed64a 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/src/glsl/link_uniforms.cpp
@@ -848,7 +848,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
/* FINISHME: Update code to process built-in uniforms!
*/
- if (strncmp("gl_", var->name, 3) == 0) {
+ if (is_gl_identifier(var->name)) {
uniform_size.num_shader_uniform_components +=
var->type->component_slots();
continue;
@@ -900,7 +900,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
/* FINISHME: Update code to process built-in uniforms!
*/
- if (strncmp("gl_", var->name, 3) == 0)
+ if (is_gl_identifier(var->name))
continue;
parcel.set_and_process(prog, var);
diff --git a/mesalib/src/glsl/link_varyings.cpp b/mesalib/src/glsl/link_varyings.cpp
index 71998dfa9..686329857 100644
--- a/mesalib/src/glsl/link_varyings.cpp
+++ b/mesalib/src/glsl/link_varyings.cpp
@@ -77,8 +77,7 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
* correspondence between the vertex language and the
* fragment language."
*/
- if (!output->type->is_array()
- || (strncmp("gl_", output->name, 3) != 0)) {
+ if (!output->type->is_array() || !is_gl_identifier(output->name)) {
linker_error(prog,
"%s shader output `%s' declared as type `%s', "
"but %s shader input declared as type `%s'\n",