shader: warn if GLSL shader does not contain #version line

Shaders without #version line (which are supposed to indicate GLSL 1.10) will be interpreted differently by different drivers, so this is almost certainly a mistake.  In the future, we can forbid this altogether or insert #version 110 automatically.
This commit is contained in:
rdb 2018-12-16 21:01:38 +01:00
parent 73452957ee
commit 65a86d1b3f

View File

@ -2750,6 +2750,7 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn,
int ext_google_include = 0; // 1 = warn, 2 = enable
int ext_google_line = 0;
bool had_include = false;
bool had_version = false;
int lineno = 0;
bool write_line_directive = (fileno != 0);
@ -2920,6 +2921,9 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn,
write_line_directive = true;
}
} else if (strcmp(directive, "version") == 0) {
had_version = true;
} else if (strcmp(directive, "extension") == 0) {
// Check for special preprocessing extensions.
char extension[256];
@ -3047,6 +3051,11 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn,
out << line << "\n";
}
if (fileno == 0 && !had_version) {
shader_cat.warning()
<< "GLSL shader " << fn << " does not contain a #version line!\n";
}
return true;
}