mirror of
https://github.com/utmapp/angle.git
synced 2026-12-01 22:13:25 -10:00
Revert tests changes of 3e7ae42492
The test changes had a function pointer type mismatch on some platforms, causing build failures. Revert the tests changes and keep only the fix for the buffer overflow. BUG=595836 Change-Id: Ia2db42dc7b19fc46676addaf8ad36f29d9bf69e5 Reviewed-on: https://chromium-review.googlesource.com/334396 Reviewed-by: Corentin Wallez <[email protected]>
This commit is contained in:
1 parent
3e7ae42492
commit
4e9536d0f6
1 file changed
-112
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "test_utils/ANGLETest.h"
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
|
||||
using namespace angle;
|
||||
@@ -501,117 +500,6 @@ TEST_P(UniformTest, SamplerUniformsAppearOnce)
|
||||
glDeleteProgram(program);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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<T, 3 * kChunkSize> 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<UniformArrayInfo> 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<float>(glGetUniformfv, program, uniformArray.name + strIndex,
|
||||
uniformArray.components, 42.4242f);
|
||||
CheckOneElement<int>(glGetUniformiv, program, uniformArray.name + strIndex,
|
||||
uniformArray.components, 0x7BADBED5);
|
||||
CheckOneElement<unsigned int>(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());
|
||||
|
||||
Reference in new issue
Block a user