Commit 5051eee5 by Corentin Wallez

Revert "Program::getUniformInternal: return only one array element"

It breaks compilation on GPU Builder This reverts commit 3ea54ba8. Change-Id: Ie18f876b1db353d75cbd5a612f0a433cfc552ef2 Reviewed-on: https://chromium-review.googlesource.com/334405Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 3ea54ba8
...@@ -2508,7 +2508,7 @@ void Program::getUniformInternal(GLint location, DestT *dataOut) const ...@@ -2508,7 +2508,7 @@ void Program::getUniformInternal(GLint location, DestT *dataOut) const
return; return;
} }
int components = VariableComponentCount(uniform.type); int components = VariableComponentCount(uniform.type) * uniform.elementCount();
switch (componentType) switch (componentType)
{ {
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "test_utils/ANGLETest.h" #include "test_utils/ANGLETest.h"
#include <array>
#include <cmath> #include <cmath>
using namespace angle; using namespace angle;
...@@ -501,117 +500,6 @@ TEST_P(UniformTest, SamplerUniformsAppearOnce) ...@@ -501,117 +500,6 @@ TEST_P(UniformTest, SamplerUniformsAppearOnce)
glDeleteProgram(program); 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. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(UniformTest, ANGLE_INSTANTIATE_TEST(UniformTest,
ES2_D3D9(), ES2_D3D9(),
......
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