TranslatorGLSL/ESSL: Output #pragma before #extension

The Intel Mesa driver considers the #pragma directive to be a
non-preprocessor token which makes shaders fail compilation.

The relevant blurb from the spec is: "the extension directives
must occur before any non-preprocessor tokens"

BUG=627417

Change-Id: Ic22cff49a9f9c1fe5d140302581ca7b36688732c
Reviewed-on: https://chromium-review.googlesource.com/359621
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
diff --git a/src/tests/gl_tests/GLSLTest.cpp b/src/tests/gl_tests/GLSLTest.cpp
index 3970029..8736e93 100644
--- a/src/tests/gl_tests/GLSLTest.cpp
+++ b/src/tests/gl_tests/GLSLTest.cpp
@@ -1865,6 +1865,29 @@
     EXPECT_NE(0u, program);
 }
 
+// Test that the #pragma directive is supported and doesn't trigger a compilation failure on the
+// native driver. The only pragma that gets passed to the OpenGL driver is "invariant" but we don't
+// want to test its behavior, so don't use any varyings.
+TEST_P(GLSLTest, PragmaDirective)
+{
+    const std::string vertexShaderSource =
+        "#pragma STDGL invariant(all)\n"
+        "void main()\n"
+        "{\n"
+        "    gl_Position = vec4(1.0, 0.0, 0.0, 1.0);\n"
+        "}\n";
+
+    const std::string fragmentShaderSource =
+        "precision mediump float;\n"
+        "void main()\n"
+        "{\n"
+        "    gl_FragColor = vec4(1.0);\n"
+        "}\n";
+
+    GLuint program = CompileProgram(vertexShaderSource, fragmentShaderSource);
+    EXPECT_NE(0u, program);
+}
+
 // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
 ANGLE_INSTANTIATE_TEST(GLSLTest,
                        ES2_D3D9(),