Hash :
fa05f607
Author :
Date :
2015-05-07T13:47:11
Use value-paramaterized tests instead of by type. This should fix our non-standard template use, which causes compile errors for the tests on GCC/Clang. BUG=angleproject:997 Change-Id: Id1bb15231eda445f37e53a5b33d4684ec6618d8e Reviewed-on: https://chromium-review.googlesource.com/269858 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
//
// Copyright 2015 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.
//
#include "ANGLETest.h"
#include <memory>
#include <stdint.h>
using namespace angle;
class ProgramBinaryTest : public ANGLETest
{
protected:
ProgramBinaryTest()
{
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).
TEST_P(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);
}
}
// This tests the ability to successfully save and load a program binary.
TEST_P(ProgramBinaryTest, SaveAndLoadBinary)
{
GLint programLength = 0;
GLint writtenLength = 0;
GLenum binaryFormat = 0;
glGetProgramiv(mProgram, GL_PROGRAM_BINARY_LENGTH_OES, &programLength);
EXPECT_GL_NO_ERROR();
std::vector<uint8_t> binary(programLength);
glGetProgramBinaryOES(mProgram, programLength, &writtenLength, &binaryFormat, binary.data());
EXPECT_GL_NO_ERROR();
// The lengths reported by glGetProgramiv and glGetProgramBinaryOES should match
EXPECT_EQ(programLength, writtenLength);
if (writtenLength)
{
GLuint program2 = glCreateProgram();
glProgramBinaryOES(program2, binaryFormat, binary.data(), writtenLength);
EXPECT_GL_NO_ERROR();
GLint linkStatus;
glGetProgramiv(program2, GL_LINK_STATUS, &linkStatus);
if (linkStatus == 0)
{
GLint infoLogLength;
glGetProgramiv(program2, GL_INFO_LOG_LENGTH, &infoLogLength);
if (infoLogLength > 0)
{
std::vector<GLchar> infoLog(infoLogLength);
glGetProgramInfoLog(program2, infoLog.size(), NULL, &infoLog[0]);
FAIL() << "program link failed: " << &infoLog[0];
}
else
{
FAIL() << "program link failed.";
}
}
else
{
glUseProgram(program2);
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 8, NULL);
glEnableVertexAttribArray(0);
glDrawArrays(GL_POINTS, 0, 1);
EXPECT_GL_NO_ERROR();
}
glDeleteProgram(program2);
}
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(ProgramBinaryTest, ES2_D3D9(), ES2_D3D11());