Add top-level dirty bits for texture and samplers.
These will have to be fleshed out in the back-ends.
Also currently uses a single bit for all the bindings, and we can
extend this to more fine-grained updates in the future.
This patch implements top-level updates for texture completeness.
Sampler completeness caches are removed from the Texture class, and
replaced by a cache in the gl::State class. The State class also
keeps a channel binding to the bound textures so it can be notified
when textures might change from complete <-> incomplete.
In future CLs we skip updating back-ends if texture state doesn't
change.
BUG=angleproject:1387
Change-Id: If580b4851303c86f3240e62891f5f6047eefb6a2
Reviewed-on: https://chromium-review.googlesource.com/648053
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index bf6d20c..3d87d08 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -505,6 +505,7 @@
// TODO(jmadill): Rework this when we support ContextImpl
mGLState.setAllDirtyBits();
+ mGLState.setAllDirtyObjects();
ANGLE_TRY(releaseSurface(display));
@@ -1723,24 +1724,28 @@
{
Texture *texture = getTargetTexture(target);
SetTexParameterf(this, texture, pname, param);
+ onTextureChange(texture);
}
void Context::texParameterfv(GLenum target, GLenum pname, const GLfloat *params)
{
Texture *texture = getTargetTexture(target);
SetTexParameterfv(this, texture, pname, params);
+ onTextureChange(texture);
}
void Context::texParameteri(GLenum target, GLenum pname, GLint param)
{
Texture *texture = getTargetTexture(target);
SetTexParameteri(this, texture, pname, param);
+ onTextureChange(texture);
}
void Context::texParameteriv(GLenum target, GLenum pname, const GLint *params)
{
Texture *texture = getTargetTexture(target);
SetTexParameteriv(this, texture, pname, params);
+ onTextureChange(texture);
}
void Context::drawArrays(GLenum mode, GLint first, GLsizei count)
@@ -2521,12 +2526,12 @@
// Release the shader compiler so it will be re-created with the requested extensions enabled.
releaseShaderCompiler();
- // Invalidate all cached completenesses for textures and framebuffer. Some extensions make new
- // formats renderable or sampleable.
- mState.mTextures->invalidateTextureComplenessCache();
+ // Invalidate all textures and framebuffer. Some extensions make new formats renderable or
+ // sampleable.
+ mState.mTextures->signalAllTexturesDirty();
for (auto &zeroTexture : mZeroTextures)
{
- zeroTexture.second->invalidateCompletenessCache();
+ zeroTexture.second->signalDirty();
}
mState.mFramebuffers->invalidateFramebufferComplenessCache();
@@ -4665,13 +4670,19 @@
void Context::uniform1i(GLint location, GLint x)
{
Program *program = mGLState.getProgram();
- program->setUniform1iv(location, 1, &x);
+ if (program->setUniform1iv(location, 1, &x) == Program::SetUniformResult::SamplerChanged)
+ {
+ mGLState.setObjectDirty(GL_PROGRAM);
+ }
}
void Context::uniform1iv(GLint location, GLsizei count, const GLint *v)
{
Program *program = mGLState.getProgram();
- program->setUniform1iv(location, count, v);
+ if (program->setUniform1iv(location, count, v) == Program::SetUniformResult::SamplerChanged)
+ {
+ mGLState.setObjectDirty(GL_PROGRAM);
+ }
}
void Context::uniform2f(GLint location, GLfloat x, GLfloat y)
@@ -5248,4 +5259,22 @@
QueryInternalFormativ(formatCaps, pname, bufSize, params);
}
+void Context::programUniform1iv(GLuint program, GLint location, GLsizei count, const GLint *value)
+{
+ Program *programObject = getProgram(program);
+ ASSERT(programObject);
+ if (programObject->setUniform1iv(location, count, value) ==
+ Program::SetUniformResult::SamplerChanged)
+ {
+ mGLState.setObjectDirty(GL_PROGRAM);
+ }
+}
+
+void Context::onTextureChange(const Texture *texture)
+{
+ // Conservatively assume all textures are dirty.
+ // TODO(jmadill): More fine-grained update.
+ mGLState.setObjectDirty(GL_TEXTURE);
+}
+
} // namespace gl