Commit be4fdb3f by Geoff Lang

Merge the sampler uniform application into ProgramBinary::setUniform.

* Fixes incorrect dirty checks for the dirty sampler mappings flag. * Fixes WebGL tests: * conformance_canvas_texture_bindings_unaffected_on_resize * conformance_reading_read_pixels_test * conformance_uniforms_uniform_default_values BUG=414450 Change-Id: I132dbc301a236aef153fb6da4c6b64c36b0ba3f3 Reviewed-on: https://chromium-review.googlesource.com/218501Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent ee85d1bb
...@@ -568,7 +568,7 @@ void ProgramBinary::setUniform(GLint location, GLsizei count, const T* v, GLenum ...@@ -568,7 +568,7 @@ void ProgramBinary::setUniform(GLint location, GLsizei count, const T* v, GLenum
if (targetUniform->type == targetUniformType) if (targetUniform->type == targetUniformType)
{ {
T *target = (T*)targetUniform->data + mUniformIndex[location].element * 4; T *target = reinterpret_cast<T*>(targetUniform->data) + mUniformIndex[location].element * 4;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
...@@ -587,7 +587,7 @@ void ProgramBinary::setUniform(GLint location, GLsizei count, const T* v, GLenum ...@@ -587,7 +587,7 @@ void ProgramBinary::setUniform(GLint location, GLsizei count, const T* v, GLenum
} }
else if (targetUniform->type == targetBoolType) else if (targetUniform->type == targetBoolType)
{ {
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4; GLint *boolParams = reinterpret_cast<GLint*>(targetUniform->data) + mUniformIndex[location].element * 4;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
...@@ -604,6 +604,30 @@ void ProgramBinary::setUniform(GLint location, GLsizei count, const T* v, GLenum ...@@ -604,6 +604,30 @@ void ProgramBinary::setUniform(GLint location, GLsizei count, const T* v, GLenum
} }
} }
} }
else if (IsSampler(targetUniform->type))
{
ASSERT(targetUniformType == GL_INT);
GLint *target = reinterpret_cast<GLint*>(targetUniform->data) + mUniformIndex[location].element * 4;
bool wasDirty = targetUniform->dirty;
for (int i = 0; i < count; i++)
{
GLint *dest = target + (i * 4);
const GLint *source = reinterpret_cast<const GLint*>(v) + (i * components);
SetIfDirty(dest + 0, source[0], &targetUniform->dirty);
SetIfDirty(dest + 1, 0, &targetUniform->dirty);
SetIfDirty(dest + 2, 0, &targetUniform->dirty);
SetIfDirty(dest + 3, 0, &targetUniform->dirty);
}
if (!wasDirty && targetUniform->dirty)
{
mDirtySamplerMapping = true;
}
}
else UNREACHABLE(); else UNREACHABLE();
} }
...@@ -769,48 +793,7 @@ void ProgramBinary::setUniformMatrix4x3fv(GLint location, GLsizei count, GLboole ...@@ -769,48 +793,7 @@ void ProgramBinary::setUniformMatrix4x3fv(GLint location, GLsizei count, GLboole
void ProgramBinary::setUniform1iv(GLint location, GLsizei count, const GLint *v) void ProgramBinary::setUniform1iv(GLint location, GLsizei count, const GLint *v)
{ {
LinkedUniform *targetUniform = mUniforms[mUniformIndex[location].index]; setUniform(location, count, v, GL_INT);
int elementCount = targetUniform->elementCount();
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
if (targetUniform->type == GL_INT || IsSampler(targetUniform->type))
{
GLint *target = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count; i++)
{
SetIfDirty(target + 0, v[0], &targetUniform->dirty);
SetIfDirty(target + 1, 0, &targetUniform->dirty);
SetIfDirty(target + 2, 0, &targetUniform->dirty);
SetIfDirty(target + 3, 0, &targetUniform->dirty);
target += 4;
v += 1;
}
}
else if (targetUniform->type == GL_BOOL)
{
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count; i++)
{
SetIfDirty(boolParams + 0, (v[0] == 0) ? GL_FALSE : GL_TRUE, &targetUniform->dirty);
SetIfDirty(boolParams + 1, GL_FALSE, &targetUniform->dirty);
SetIfDirty(boolParams + 2, GL_FALSE, &targetUniform->dirty);
SetIfDirty(boolParams + 3, GL_FALSE, &targetUniform->dirty);
boolParams += 4;
v += 1;
}
}
else UNREACHABLE();
// Set a special flag if we change a sampler uniform
if (IsSampler(targetUniform->type) &&
(memcmp(targetUniform->data, v, sizeof(GLint)) != 0))
{
mDirtySamplerMapping = true;
}
} }
void ProgramBinary::setUniform2iv(GLint location, GLsizei count, const GLint *v) void ProgramBinary::setUniform2iv(GLint location, GLsizei count, const GLint *v)
......
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