diff options
author | Geoff Lang <geofflang@chromium.org> | 2014-09-16 14:11:40 -0400 |
---|---|---|
committer | Geoff Lang <geofflang@chromium.org> | 2014-09-17 20:43:38 +0000 |
commit | be4fdb3f5a1c2a3250a4b8351e3b09cc639a0672 (patch) | |
tree | 487320c47b2c34c7484568189cd19a88c5323e2b | |
parent | ee85d1bb2f9988644654299a87f476357a5ac79d (diff) | |
download | angle-be4fdb3f5a1c2a3250a4b8351e3b09cc639a0672.tar.gz |
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/218501
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
-rw-r--r-- | src/libGLESv2/ProgramBinary.cpp | 71 |
1 files changed, 27 insertions, 44 deletions
diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp index 299ed94a..2e755df3 100644 --- a/src/libGLESv2/ProgramBinary.cpp +++ b/src/libGLESv2/ProgramBinary.cpp @@ -568,7 +568,7 @@ void ProgramBinary::setUniform(GLint location, GLsizei count, const T* v, GLenum 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++) { @@ -587,7 +587,7 @@ void ProgramBinary::setUniform(GLint location, GLsizei count, const T* v, GLenum } 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++) { @@ -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(); } @@ -769,48 +793,7 @@ void ProgramBinary::setUniformMatrix4x3fv(GLint location, GLsizei count, GLboole void ProgramBinary::setUniform1iv(GLint location, GLsizei count, const GLint *v) { - LinkedUniform *targetUniform = mUniforms[mUniformIndex[location].index]; - - 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; - } + setUniform(location, count, v, GL_INT); } void ProgramBinary::setUniform2iv(GLint location, GLsizei count, const GLint *v) |