Fix dirty state tracking of allocation attached to ProgramVertex objects when being updated while not attached.
diff --git a/libs/rs/rsProgram.cpp b/libs/rs/rsProgram.cpp
index 5f2a609..ed5918b 100644
--- a/libs/rs/rsProgram.cpp
+++ b/libs/rs/rsProgram.cpp
@@ -32,19 +32,23 @@
Program::~Program()
{
+ bindAllocation(NULL);
}
void Program::bindAllocation(Allocation *alloc)
{
+ if (mConstants.get() == alloc) {
+ return;
+ }
+ if (mConstants.get()) {
+ mConstants.get()->removeProgramToDirty(this);
+ }
mConstants.set(alloc);
+ if (alloc) {
+ alloc->addProgramToDirty(this);
+ }
mDirty = true;
}
-void Program::checkUpdatedAllocation(const Allocation *alloc)
-{
- if (mConstants.get() == alloc) {
- mDirty = true;
- }
-}