From 65a86d1b3fa5127acd345d0d2b5b29a6e4a0fced Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 16 Dec 2018 21:01:38 +0100 Subject: [PATCH] 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. --- panda/src/gobj/shader.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 4a1092eb9c..fde084aa18 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -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; }