mirror of
https://github.com/utmapp/angle.git
synced 2026-12-01 14:00:09 -10:00
BUG=angle:611 Change-Id: I7d43612171c439045038db9ae82fd8716c0b31c6 Reviewed-on: https://chromium-review.googlesource.com/220400 Reviewed-by: Geoff Lang <[email protected]> Tested-by: Austin Kinross <[email protected]>
96 lines
2.6 KiB
C++
96 lines
2.6 KiB
C++
#include "ANGLETest.h"
|
|
|
|
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
|
|
typedef ::testing::Types<TFT<Gles::Two, Rend::D3D11>, TFT<Gles::Two, Rend::D3D9>> TestFixtureTypes;
|
|
TYPED_TEST_CASE(ProgramBinaryTest, TestFixtureTypes);
|
|
|
|
template<typename T>
|
|
class ProgramBinaryTest : public ANGLETest
|
|
{
|
|
protected:
|
|
ProgramBinaryTest() : ANGLETest(T::GetGlesMajorVersion(), T::GetRequestedRenderer())
|
|
{
|
|
setWindowWidth(128);
|
|
setWindowHeight(128);
|
|
setConfigRedBits(8);
|
|
setConfigGreenBits(8);
|
|
setConfigBlueBits(8);
|
|
setConfigAlphaBits(8);
|
|
}
|
|
|
|
virtual void SetUp()
|
|
{
|
|
ANGLETest::SetUp();
|
|
|
|
const std::string vertexShaderSource = SHADER_SOURCE
|
|
(
|
|
attribute vec4 inputAttribute;
|
|
void main()
|
|
{
|
|
gl_Position = inputAttribute;
|
|
}
|
|
);
|
|
|
|
const std::string fragmentShaderSource = SHADER_SOURCE
|
|
(
|
|
void main()
|
|
{
|
|
gl_FragColor = vec4(1,0,0,1);
|
|
}
|
|
);
|
|
|
|
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
|
|
if (mProgram == 0)
|
|
{
|
|
FAIL() << "shader compilation failed.";
|
|
}
|
|
|
|
glGenBuffers(1, &mBuffer);
|
|
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
|
glBufferData(GL_ARRAY_BUFFER, 128, NULL, GL_STATIC_DRAW);
|
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
|
|
ASSERT_GL_NO_ERROR();
|
|
}
|
|
|
|
virtual void TearDown()
|
|
{
|
|
glDeleteProgram(mProgram);
|
|
glDeleteBuffers(1, &mBuffer);
|
|
|
|
ANGLETest::TearDown();
|
|
}
|
|
|
|
GLuint mProgram;
|
|
GLuint mBuffer;
|
|
};
|
|
|
|
// This tests the assumption that float attribs of different size
|
|
// should not internally cause a vertex shader recompile (for conversion).
|
|
TYPED_TEST(ProgramBinaryTest, FloatDynamicShaderSize)
|
|
{
|
|
glUseProgram(mProgram);
|
|
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
|
|
|
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 8, NULL);
|
|
glEnableVertexAttribArray(0);
|
|
glDrawArrays(GL_POINTS, 0, 1);
|
|
|
|
GLint programLength;
|
|
glGetProgramiv(mProgram, GL_PROGRAM_BINARY_LENGTH_OES, &programLength);
|
|
|
|
EXPECT_GL_NO_ERROR();
|
|
|
|
for (GLsizei size = 1; size <= 3; size++)
|
|
{
|
|
glVertexAttribPointer(0, size, GL_FLOAT, GL_FALSE, 8, NULL);
|
|
glEnableVertexAttribArray(0);
|
|
glDrawArrays(GL_POINTS, 0, 1);
|
|
|
|
GLint newProgramLength;
|
|
glGetProgramiv(mProgram, GL_PROGRAM_BINARY_LENGTH_OES, &newProgramLength);
|
|
EXPECT_GL_NO_ERROR();
|
|
EXPECT_EQ(programLength, newProgramLength);
|
|
}
|
|
}
|