Browse Source

Work around bug in certain Intel drivers with #pragma include

rdb 9 years ago
parent
commit
873fd3294a
1 changed files with 5 additions and 3 deletions
  1. 5 3
      panda/src/gobj/shader.cxx

+ 5 - 3
panda/src/gobj/shader.cxx

@@ -2274,15 +2274,14 @@ r_preprocess_source(ostream &out, const Filename &fn,
   bool had_include = false;
   int lineno = 0;
   while (getline(*source, line)) {
-    // We always forward the actual line - the GLSL compiler will
-    // silently ignore #pragma lines anyway.
     ++lineno;
-    out << line << "\n";
 
     // Check if this line contains a #pragma.
     char pragma[64];
     if (line.size() < 8 ||
         sscanf(line.c_str(), " # pragma %63s", pragma) != 1) {
+      // Just pass the line through unmodified.
+      out << line << "\n";
 
       // One exception: check for an #endif after an include.  We have
       // to restore the line number in case the include happened under
@@ -2347,8 +2346,11 @@ r_preprocess_source(ostream &out, const Filename &fn,
 
     } else if (strcmp(pragma, "optionNV") == 0) {
       // This is processed by NVIDIA drivers.  Don't touch it.
+      out << line << "\n";
 
     } else {
+      // Forward it, the driver will ignore it if it doesn't know it.
+      out << line << "\n";
       shader_cat.warning()
         << "Ignoring unknown pragma directive \"" << pragma << "\" at line "
         << lineno << " of file " << fn << ":\n  " << line << "\n";