Commit 5599c8f6 by Jamie Madill

Use shared compile helpers in the ANGLE tests.

BUG=angle:730 Change-Id: Ib3bd646c73355449105e6cf79bdcf0a14b391fd2 Reviewed-on: https://chromium-review.googlesource.com/213550Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 5704d6e8
...@@ -99,49 +99,6 @@ GLuint ANGLETest::compileShader(GLenum type, const std::string &source) ...@@ -99,49 +99,6 @@ GLuint ANGLETest::compileShader(GLenum type, const std::string &source)
return shader; return shader;
} }
GLuint ANGLETest::compileProgram(const std::string &vsSource, const std::string &fsSource)
{
GLuint program = glCreateProgram();
GLuint vs = compileShader(GL_VERTEX_SHADER, vsSource);
GLuint fs = compileShader(GL_FRAGMENT_SHADER, fsSource);
if (vs == 0 || fs == 0)
{
glDeleteShader(fs);
glDeleteShader(vs);
glDeleteProgram(program);
return 0;
}
glAttachShader(program, vs);
glDeleteShader(vs);
glAttachShader(program, fs);
glDeleteShader(fs);
glLinkProgram(program);
GLint linkStatus;
glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
if (linkStatus == 0)
{
GLint infoLogLength;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
std::vector<GLchar> infoLog(infoLogLength);
glGetProgramInfoLog(program, infoLog.size(), NULL, infoLog.data());
std::cerr << "program link failed: " << infoLog.data();
glDeleteProgram(program);
return 0;
}
return program;
}
bool ANGLETest::extensionEnabled(const std::string &extName) bool ANGLETest::extensionEnabled(const std::string &extName)
{ {
const char* extString = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); const char* extString = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <algorithm> #include <algorithm>
#include "shared_utils.h" #include "shared_utils.h"
#include "shader_utils.h"
#define EXPECT_GL_ERROR(err) EXPECT_EQ((err), glGetError()) #define EXPECT_GL_ERROR(err) EXPECT_EQ((err), glGetError())
#define EXPECT_GL_NO_ERROR() EXPECT_GL_ERROR(GL_NO_ERROR) #define EXPECT_GL_NO_ERROR() EXPECT_GL_ERROR(GL_NO_ERROR)
...@@ -54,7 +55,6 @@ class ANGLETest : public testing::Test ...@@ -54,7 +55,6 @@ class ANGLETest : public testing::Test
static void drawQuad(GLuint program, const std::string& positionAttribName, GLfloat quadDepth); static void drawQuad(GLuint program, const std::string& positionAttribName, GLfloat quadDepth);
static GLuint compileShader(GLenum type, const std::string &source); static GLuint compileShader(GLenum type, const std::string &source);
static GLuint compileProgram(const std::string &vsSource, const std::string &fsSource);
static bool extensionEnabled(const std::string &extName); static bool extensionEnabled(const std::string &extName);
void setClientVersion(int clientVersion); void setClientVersion(int clientVersion);
......
...@@ -88,7 +88,7 @@ protected: ...@@ -88,7 +88,7 @@ protected:
} }
); );
mProgram = compileProgram(testVertexShaderSource, testFragmentShaderSource); mProgram = CompileProgram(testVertexShaderSource, testFragmentShaderSource);
if (mProgram == 0) if (mProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
...@@ -92,8 +92,8 @@ protected: ...@@ -92,8 +92,8 @@ protected:
} }
); );
mCheckerProgram = compileProgram(passthroughVS, checkeredFS); mCheckerProgram = CompileProgram(passthroughVS, checkeredFS);
mBlueProgram = compileProgram(passthroughVS, blueFS); mBlueProgram = CompileProgram(passthroughVS, blueFS);
if (mCheckerProgram == 0 || mBlueProgram == 0) if (mCheckerProgram == 0 || mBlueProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
...@@ -48,7 +48,7 @@ class BufferDataTest : public ANGLETest ...@@ -48,7 +48,7 @@ class BufferDataTest : public ANGLETest
glGenBuffers(1, &mBuffer); glGenBuffers(1, &mBuffer);
ASSERT_NE(mBuffer, 0U); ASSERT_NE(mBuffer, 0U);
mProgram = compileProgram(vsSource, fsSource); mProgram = CompileProgram(vsSource, fsSource);
ASSERT_NE(mProgram, 0U); ASSERT_NE(mProgram, 0U);
mAttribLocation = glGetAttribLocation(mProgram, "in_attrib"); mAttribLocation = glGetAttribLocation(mProgram, "in_attrib");
...@@ -231,7 +231,7 @@ class IndexedBufferCopyTest : public ANGLETest ...@@ -231,7 +231,7 @@ class IndexedBufferCopyTest : public ANGLETest
glGenBuffers(1, &mElementBuffer); glGenBuffers(1, &mElementBuffer);
ASSERT_NE(mElementBuffer, 0U); ASSERT_NE(mElementBuffer, 0U);
mProgram = compileProgram(vsSource, fsSource); mProgram = CompileProgram(vsSource, fsSource);
ASSERT_NE(mProgram, 0U); ASSERT_NE(mProgram, 0U);
mAttribLocation = glGetAttribLocation(mProgram, "in_attrib"); mAttribLocation = glGetAttribLocation(mProgram, "in_attrib");
......
...@@ -40,7 +40,7 @@ protected: ...@@ -40,7 +40,7 @@ protected:
} }
); );
mProgram = compileProgram(vertexShaderSource, fragmentShaderSource); mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
if (mProgram == 0) if (mProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
...@@ -44,7 +44,7 @@ protected: ...@@ -44,7 +44,7 @@ protected:
} }
); );
mTextureProgram = compileProgram(vsSource, textureFSSource); mTextureProgram = CompileProgram(vsSource, textureFSSource);
if (mTextureProgram == 0) if (mTextureProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
...@@ -48,7 +48,7 @@ TEST_F(GLSLTest, NamelessScopedStructs) ...@@ -48,7 +48,7 @@ TEST_F(GLSLTest, NamelessScopedStructs)
} }
); );
GLuint program = compileProgram(mSimpleVSSource, fragmentShaderSource); GLuint program = CompileProgram(mSimpleVSSource, fragmentShaderSource);
EXPECT_NE(0u, program); EXPECT_NE(0u, program);
} }
TEST_F(GLSLTest, ScopedStructsOrderBug) TEST_F(GLSLTest, ScopedStructsOrderBug)
...@@ -79,7 +79,7 @@ TEST_F(GLSLTest, ScopedStructsOrderBug) ...@@ -79,7 +79,7 @@ TEST_F(GLSLTest, ScopedStructsOrderBug)
} }
); );
GLuint program = compileProgram(mSimpleVSSource, fragmentShaderSource); GLuint program = CompileProgram(mSimpleVSSource, fragmentShaderSource);
EXPECT_NE(0u, program); EXPECT_NE(0u, program);
} }
...@@ -111,7 +111,7 @@ TEST_F(GLSLTest, ScopedStructsBug) ...@@ -111,7 +111,7 @@ TEST_F(GLSLTest, ScopedStructsBug)
} }
); );
GLuint program = compileProgram(mSimpleVSSource, fragmentShaderSource); GLuint program = CompileProgram(mSimpleVSSource, fragmentShaderSource);
EXPECT_NE(0u, program); EXPECT_NE(0u, program);
} }
...@@ -140,7 +140,7 @@ TEST_F(GLSLTest, DxPositionBug) ...@@ -140,7 +140,7 @@ TEST_F(GLSLTest, DxPositionBug)
} }
); );
GLuint program = compileProgram(vertexShaderSource, fragmentShaderSource); GLuint program = CompileProgram(vertexShaderSource, fragmentShaderSource);
EXPECT_NE(0u, program); EXPECT_NE(0u, program);
} }
...@@ -169,7 +169,7 @@ TEST_F(GLSLTest, ElseIfRewriting) ...@@ -169,7 +169,7 @@ TEST_F(GLSLTest, ElseIfRewriting)
" gl_FragColor = color;\n" " gl_FragColor = color;\n"
"}\n"; "}\n";
GLuint program = compileProgram(vertexShaderSource, fragmentShaderSource); GLuint program = CompileProgram(vertexShaderSource, fragmentShaderSource);
ASSERT_NE(0u, program); ASSERT_NE(0u, program);
drawQuad(program, "a_position", 0.5f); drawQuad(program, "a_position", 0.5f);
...@@ -202,7 +202,7 @@ TEST_F(GLSLTest, TwoElseIfRewriting) ...@@ -202,7 +202,7 @@ TEST_F(GLSLTest, TwoElseIfRewriting)
" gl_FragColor = vec4(v, 0.0, 0.0, 1.0);\n" " gl_FragColor = vec4(v, 0.0, 0.0, 1.0);\n"
"}\n"; "}\n";
GLuint program = compileProgram(vertexShaderSource, fragmentShaderSource); GLuint program = CompileProgram(vertexShaderSource, fragmentShaderSource);
EXPECT_NE(0u, program); EXPECT_NE(0u, program);
} }
...@@ -222,7 +222,7 @@ TEST_F(GLSLTest, InvariantVaryingOut) ...@@ -222,7 +222,7 @@ TEST_F(GLSLTest, InvariantVaryingOut)
void main() { v_varying = a_position.x; gl_Position = a_position; } void main() { v_varying = a_position.x; gl_Position = a_position; }
); );
GLuint program = compileProgram(vertexShaderSource, fragmentShaderSource); GLuint program = CompileProgram(vertexShaderSource, fragmentShaderSource);
EXPECT_NE(0u, program); EXPECT_NE(0u, program);
} }
...@@ -242,7 +242,7 @@ TEST_F(GLSLTest, InvariantVaryingIn) ...@@ -242,7 +242,7 @@ TEST_F(GLSLTest, InvariantVaryingIn)
void main() { v_varying = a_position.x; gl_Position = a_position; } void main() { v_varying = a_position.x; gl_Position = a_position; }
); );
GLuint program = compileProgram(vertexShaderSource, fragmentShaderSource); GLuint program = CompileProgram(vertexShaderSource, fragmentShaderSource);
EXPECT_NE(0u, program); EXPECT_NE(0u, program);
} }
...@@ -262,7 +262,7 @@ TEST_F(GLSLTest, InvariantVaryingBoth) ...@@ -262,7 +262,7 @@ TEST_F(GLSLTest, InvariantVaryingBoth)
void main() { v_varying = a_position.x; gl_Position = a_position; } void main() { v_varying = a_position.x; gl_Position = a_position; }
); );
GLuint program = compileProgram(vertexShaderSource, fragmentShaderSource); GLuint program = CompileProgram(vertexShaderSource, fragmentShaderSource);
EXPECT_NE(0u, program); EXPECT_NE(0u, program);
} }
...@@ -283,7 +283,7 @@ TEST_F(GLSLTest, InvariantGLPosition) ...@@ -283,7 +283,7 @@ TEST_F(GLSLTest, InvariantGLPosition)
void main() { v_varying = a_position.x; gl_Position = a_position; } void main() { v_varying = a_position.x; gl_Position = a_position; }
); );
GLuint program = compileProgram(vertexShaderSource, fragmentShaderSource); GLuint program = CompileProgram(vertexShaderSource, fragmentShaderSource);
EXPECT_NE(0u, program); EXPECT_NE(0u, program);
} }
...@@ -302,6 +302,6 @@ TEST_F(GLSLTest, InvariantAll) ...@@ -302,6 +302,6 @@ TEST_F(GLSLTest, InvariantAll)
"varying float v_varying;\n" "varying float v_varying;\n"
"void main() { v_varying = a_position.x; gl_Position = a_position; }\n"; "void main() { v_varying = a_position.x; gl_Position = a_position; }\n";
GLuint program = compileProgram(vertexShaderSource, fragmentShaderSource); GLuint program = CompileProgram(vertexShaderSource, fragmentShaderSource);
EXPECT_NE(0u, program); EXPECT_NE(0u, program);
} }
...@@ -44,7 +44,7 @@ protected: ...@@ -44,7 +44,7 @@ protected:
} }
); );
mProgram = compileProgram(vertexShaderSource, fragmentShaderSource); mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
if (mProgram == 0) if (mProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
...@@ -52,7 +52,7 @@ protected: ...@@ -52,7 +52,7 @@ protected:
} }
); );
mProgram = compileProgram(vertexShaderSource, fragmentShaderSource); mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
if (mProgram == 0) if (mProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
...@@ -40,7 +40,7 @@ protected: ...@@ -40,7 +40,7 @@ protected:
} }
); );
mProgram = compileProgram(vsSource, fsSource); mProgram = CompileProgram(vsSource, fsSource);
if (mProgram == 0) if (mProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
...@@ -52,8 +52,8 @@ protected: ...@@ -52,8 +52,8 @@ protected:
} }
); );
mTextureProgram = compileProgram(vsSource, textureFSSource); mTextureProgram = CompileProgram(vsSource, textureFSSource);
mBlueProgram = compileProgram(vsSource, blueFSSource); mBlueProgram = CompileProgram(vsSource, blueFSSource);
if (mTextureProgram == 0 || mBlueProgram == 0) if (mTextureProgram == 0 || mBlueProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
...@@ -41,7 +41,7 @@ protected: ...@@ -41,7 +41,7 @@ protected:
} }
); );
mProgram = compileProgram(passthroughVS, passthroughPS); mProgram = CompileProgram(passthroughVS, passthroughPS);
if (mProgram == 0) if (mProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
...@@ -50,7 +50,7 @@ protected: ...@@ -50,7 +50,7 @@ protected:
} }
); );
mProgram = compileProgram(vertexShaderSrc, fragmentShaderSrc); mProgram = CompileProgram(vertexShaderSrc, fragmentShaderSrc);
glGenBuffers(1, &mPositionVBO); glGenBuffers(1, &mPositionVBO);
glBindBuffer(GL_ARRAY_BUFFER, mPositionVBO); glBindBuffer(GL_ARRAY_BUFFER, mPositionVBO);
......
...@@ -34,7 +34,7 @@ protected: ...@@ -34,7 +34,7 @@ protected:
} }
); );
mProgram = compileProgram(vertexShaderSource, fragmentShaderSource); mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
if (mProgram == 0) if (mProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
...@@ -48,7 +48,7 @@ protected: ...@@ -48,7 +48,7 @@ protected:
} }
); );
mProgram = compileProgram(vertexShaderSrc, fragmentShaderSrc); mProgram = CompileProgram(vertexShaderSrc, fragmentShaderSrc);
glGenTextures(1, &mTexture); glGenTextures(1, &mTexture);
glBindTexture(GL_TEXTURE_2D, mTexture); glBindTexture(GL_TEXTURE_2D, mTexture);
......
...@@ -74,7 +74,7 @@ protected: ...@@ -74,7 +74,7 @@ protected:
} }
); );
mProgram = compileProgram(vertexShaderSource, fragmentShaderSource); mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
if (mProgram == 0) if (mProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
...@@ -68,8 +68,8 @@ protected: ...@@ -68,8 +68,8 @@ protected:
} }
); );
m2DProgram = compileProgram(vertexShaderSource, fragmentShaderSource2D); m2DProgram = CompileProgram(vertexShaderSource, fragmentShaderSource2D);
mCubeProgram = compileProgram(vertexShaderSource, fragmentShaderSourceCube); mCubeProgram = CompileProgram(vertexShaderSource, fragmentShaderSourceCube);
if (m2DProgram == 0 || mCubeProgram == 0) if (m2DProgram == 0 || mCubeProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
...@@ -43,7 +43,7 @@ protected: ...@@ -43,7 +43,7 @@ protected:
} }
); );
mProgram = compileProgram(vertexShaderSource, fragmentShaderSource); mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
if (mProgram == 0) if (mProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
...@@ -86,7 +86,7 @@ protected: ...@@ -86,7 +86,7 @@ protected:
} }
); );
mProgram = compileProgram(testVertexShaderSource, testFragmentShaderSource); mProgram = CompileProgram(testVertexShaderSource, testFragmentShaderSource);
if (mProgram == 0) if (mProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
......
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