Commit 924b7de2 by Ian Ewell

Always write to gl_Position when compiling shaders with

SH_GLSL_COMPATIBILITY_OUTPUT. BUG=angleproject:1277 Change-Id: Ib820a46151637e8c61e94b966b970de46ccca6b9 Reviewed-on: https://chromium-review.googlesource.com/323160Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tryjob-Request: Jamie Madill <jmadill@chromium.org> Tested-by: 's avatarIan Ewell <ewell@google.com>
parent d544cc9f
...@@ -322,7 +322,10 @@ TIntermNode *TCompiler::compileTreeImpl(const char *const shaderStrings[], ...@@ -322,7 +322,10 @@ TIntermNode *TCompiler::compileTreeImpl(const char *const shaderStrings[],
if (success && (compileOptions & SH_CLAMP_INDIRECT_ARRAY_BOUNDS)) if (success && (compileOptions & SH_CLAMP_INDIRECT_ARRAY_BOUNDS))
arrayBoundsClamper.MarkIndirectArrayBoundsForClamping(root); arrayBoundsClamper.MarkIndirectArrayBoundsForClamping(root);
if (success && shaderType == GL_VERTEX_SHADER && (compileOptions & SH_INIT_GL_POSITION)) // gl_Position is always written in compatibility output mode
if (success && shaderType == GL_VERTEX_SHADER &&
((compileOptions & SH_INIT_GL_POSITION) ||
(outputType == SH_GLSL_COMPATIBILITY_OUTPUT)))
initializeGLPosition(root); initializeGLPosition(root);
// This pass might emit short circuits so keep it before the short circuit unfolding // This pass might emit short circuits so keep it before the short circuit unfolding
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
'<(angle_path)/src/tests/compiler_tests/ExpressionLimit_test.cpp', '<(angle_path)/src/tests/compiler_tests/ExpressionLimit_test.cpp',
'<(angle_path)/src/tests/compiler_tests/EXT_blend_func_extended_test.cpp', '<(angle_path)/src/tests/compiler_tests/EXT_blend_func_extended_test.cpp',
'<(angle_path)/src/tests/compiler_tests/FragDepth_test.cpp', '<(angle_path)/src/tests/compiler_tests/FragDepth_test.cpp',
'<(angle_path)/src/tests/compiler_tests/GLSLCompatibilityOutput_test.cpp',
'<(angle_path)/src/tests/compiler_tests/IntermNode_test.cpp', '<(angle_path)/src/tests/compiler_tests/IntermNode_test.cpp',
'<(angle_path)/src/tests/compiler_tests/MalformedShader_test.cpp', '<(angle_path)/src/tests/compiler_tests/MalformedShader_test.cpp',
'<(angle_path)/src/tests/compiler_tests/NV_draw_buffers_test.cpp', '<(angle_path)/src/tests/compiler_tests/NV_draw_buffers_test.cpp',
......
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// GLSLCompatibilityOutputTest.cpp
// Test compiler output for glsl compatibility mode
//
#include "angle_gl.h"
#include "gtest/gtest.h"
#include "GLSLANG/ShaderLang.h"
#include "tests/test_utils/compiler_test.h"
class GLSLCompatibilityOutputTest : public testing::Test
{
public:
GLSLCompatibilityOutputTest() {}
protected:
void compile(const std::string &shaderString)
{
int compilationFlags = SH_VARIABLES;
std::string infoLog;
bool compilationSuccess =
compileTestShader(GL_VERTEX_SHADER, SH_GLES2_SPEC, SH_GLSL_COMPATIBILITY_OUTPUT,
shaderString, compilationFlags, &mTranslatedSource, &infoLog);
if (!compilationSuccess)
{
FAIL() << "Shader compilation failed " << infoLog;
}
}
bool find(const char *name) const { return mTranslatedSource.find(name) != std::string::npos; }
private:
std::string mTranslatedSource;
};
// Verify gl_Position is written when compiling in compatibility mode
TEST_F(GLSLCompatibilityOutputTest, GLPositionWrittenTest)
{
const std::string &shaderString =
"precision mediump float;\n"
"void main() {\n"
"}";
compile(shaderString);
EXPECT_TRUE(find("gl_Position"));
}
\ No newline at end of file
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