* 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);
exec_list initializer_instructions;
/* Examine var name here since var may get deleted in the next call */
- bool var_is_gl_id = (strncmp(var->name, "gl_", 3) == 0);
+ bool var_is_gl_id = is_gl_identifier(var->name);
ir_variable *earlier =
get_variable_being_redeclared(var, decl->get_location(), state,
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");
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;
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);
/* 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;
/* 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);
* 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",