diff --git a/src/tests/gl_tests/UniformTest.cpp b/src/tests/gl_tests/UniformTest.cpp index acd53274c..67467f098 100644 --- a/src/tests/gl_tests/UniformTest.cpp +++ b/src/tests/gl_tests/UniformTest.cpp @@ -6,7 +6,6 @@ #include "test_utils/ANGLETest.h" -#include #include using namespace angle; @@ -501,117 +500,6 @@ TEST_P(UniformTest, SamplerUniformsAppearOnce) glDeleteProgram(program); } -template -void CheckOneElement(void (*getUniformv) (GLuint, int, T *), - GLuint program, - const std::string& name, - int components, - T canary) -{ - // The buffer getting the results has three chunks - // - A chunk to see underflows - // - A chunk that will hold the result - // - A chunk to see overflows for when components = kChunkSize - static const size_t kChunkSize = 4; - std::array buffer; - buffer.fill(canary); - - GLint location = glGetUniformLocation(program, name.c_str()); - ASSERT_NE(location, -1); - - getUniformv(program, location, &buffer[kChunkSize]); - for (size_t i = 0; i < kChunkSize; i++) - { - ASSERT_EQ(canary, buffer[i]); - } - for (size_t i = kChunkSize + components; i < buffer.size(); i++) - { - ASSERT_EQ(canary, buffer[i]); - } -} - -// Check that getting an element array doesn't return the whole array. -TEST_P(UniformTestES3, ReturnsOnlyOneArrayElement) -{ - static const size_t kArraySize = 4; - struct UniformArrayInfo - { - UniformArrayInfo(std::string type, std::string name, int components) - : type(type), name(name), components(components){} - std::string type; - std::string name; - int components; - }; - - // Check for various number of components and types - std::vector uniformArrays; - uniformArrays.emplace_back("bool", "uBool", 1); - uniformArrays.emplace_back("vec2", "uFloat", 2); - uniformArrays.emplace_back("ivec3", "uInt", 3); - uniformArrays.emplace_back("uvec4", "uUint", 4); - - std::ostringstream uniformStream; - std::ostringstream additionStream; - for (const auto &array : uniformArrays) - { - uniformStream << "uniform " << array.type << " " << array.name << "[" << std::to_string(kArraySize) << "];\n"; - - // We need to make use of the uniforms or they get compiled out. - for (int i = 0; i < 4; i++) - { - if (array.components == 1) - { - additionStream << " + float(" << array.name << "[" << i << "])"; - } - else - { - for (int component = 0; component < array.components; component++) - { - additionStream << " + float(" << array.name << "[" << i << "][" << component - << "])"; - } - } - } - } - - const std::string &vertexShader = - "#version 300 es\n" + - uniformStream.str() + - "void main()\n" - "{\n" - " gl_Position = vec4(1.0" + additionStream.str() + ");\n" - "}"; - - const std::string &fragmentShader = - "#version 300 es\n" - "precision mediump float;\n" - "out vec4 color;\n" - "void main ()\n" - "{\n" - " color = vec4(1, 0, 0, 1);\n" - "}"; - - GLuint program = CompileProgram(vertexShader, fragmentShader); - ASSERT_NE(0u, program); - - for (const auto &uniformArray : uniformArrays) - { - for (size_t index = 0; index < kArraySize; index++) - { - std::string strIndex = "[" + std::to_string(index) + "]"; - // Check all the different glGetUniformv functions - CheckOneElement(glGetUniformfv, program, uniformArray.name + strIndex, - uniformArray.components, 42.4242f); - CheckOneElement(glGetUniformiv, program, uniformArray.name + strIndex, - uniformArray.components, 0x7BADBED5); - CheckOneElement(glGetUniformuiv, program, uniformArray.name + strIndex, - uniformArray.components, 0xDEADBEEF); - } - } - - glDeleteProgram(program); -} - // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. ANGLE_INSTANTIATE_TEST(UniformTest, ES2_D3D9(), ES2_D3D11(), ES2_D3D11_FL9_3(), ES2_OPENGL()); ANGLE_INSTANTIATE_TEST(UniformTestES3, ES3_D3D11(), ES3_OPENGL());