glsl: error if #include used while extension is disabled
authorTimothy Arceri <tarceri@itsqueeze.com>
Tue, 20 Aug 2019 04:20:33 +0000 (14:20 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Wed, 20 Nov 2019 05:05:55 +0000 (05:05 +0000)
In other words make sure the shader does this:

Reviewed-by: Witold Baryluk <witold.baryluk@gmail.com>
src/compiler/glsl/glcpp/glcpp-parse.y
src/compiler/glsl/glsl_lexer.ll

index 3cc00bd56e8abe21259ed7455148abd60db949a1..60323e449da38cfef31964baabef83e8abfc7f05 100644 (file)
@@ -377,6 +377,13 @@ control_line_success:
                                                glcpp_parser_copy_defines,
                                                &di);
 
+                       /* Print out '#include' to the glsl parser. We do this
+                        * so that it can do the error checking require to
+                        * make sure the ARB_shading_language_include
+                        * extension is enabled.
+                        */
+                       _mesa_string_buffer_printf(parser->output, "#include\n");
+
                        /* Parse the include string before adding to the
                         * preprocessor output.
                         */
index 8c59e1d748fa9f9236b3d87ee43013fd00149399..7d7ee0c00ff780d593352f88f573d9a2a1c130c2 100644 (file)
@@ -236,6 +236,14 @@ PATH               ["][./ _A-Za-z0-9]*["]
 ^[ \t]*#[ \t]*$                        ;
 ^[ \t]*#[ \t]*version          { BEGIN PP; return VERSION_TOK; }
 ^[ \t]*#[ \t]*extension                { BEGIN PP; return EXTENSION; }
+{HASH}include {
+                                  if (!yyextra->ARB_shading_language_include_enable) {
+                                     struct _mesa_glsl_parse_state *state = yyextra;
+                                     _mesa_glsl_error(yylloc, state,
+                                                      "ARB_shading_language_include required "
+                                                      "to use #include");
+                                   }
+}
 {HASH}line{SPCP}{INT}{SPCP}{INT}{SPC}$ {
                                   /* Eat characters until the first digit is
                                    * encountered