Commit b00dcee4 by Corentin Wallez Committed by Commit Bot

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/359621Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
parent a42e8b2c
...@@ -34,11 +34,13 @@ void TranslatorESSL::translate(TIntermNode *root, int) { ...@@ -34,11 +34,13 @@ void TranslatorESSL::translate(TIntermNode *root, int) {
sink << "#version " << shaderVer << " es\n"; sink << "#version " << shaderVer << " es\n";
} }
writePragma();
// Write built-in extension behaviors. // Write built-in extension behaviors.
writeExtensionBehavior(); writeExtensionBehavior();
// Write pragmas after extensions because some drivers consider pragmas
// like non-preprocessor tokens.
writePragma();
bool precisionEmulation = getResources().WEBGL_debug_shader_precision && getPragma().debugShaderPrecision; bool precisionEmulation = getResources().WEBGL_debug_shader_precision && getPragma().debugShaderPrecision;
if (precisionEmulation) if (precisionEmulation)
......
...@@ -37,11 +37,13 @@ void TranslatorGLSL::translate(TIntermNode *root, int compileOptions) ...@@ -37,11 +37,13 @@ void TranslatorGLSL::translate(TIntermNode *root, int compileOptions)
// Write GLSL version. // Write GLSL version.
writeVersion(root); writeVersion(root);
writePragma();
// Write extension behaviour as needed // Write extension behaviour as needed
writeExtensionBehavior(root); writeExtensionBehavior(root);
// Write pragmas after extensions because some drivers consider pragmas
// like non-preprocessor tokens.
writePragma();
bool precisionEmulation = getResources().WEBGL_debug_shader_precision && getPragma().debugShaderPrecision; bool precisionEmulation = getResources().WEBGL_debug_shader_precision && getPragma().debugShaderPrecision;
if (precisionEmulation) if (precisionEmulation)
......
...@@ -1865,6 +1865,29 @@ TEST_P(GLSLTest, IndexConstantSamplerArrayIndexing) ...@@ -1865,6 +1865,29 @@ TEST_P(GLSLTest, IndexConstantSamplerArrayIndexing)
EXPECT_NE(0u, program); 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. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(GLSLTest, ANGLE_INSTANTIATE_TEST(GLSLTest,
ES2_D3D9(), ES2_D3D9(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment