Cycles: Fix two small memory leaks and deduplicate table freeing
This commit makes remove_table skip the freeing if the offset is already set to invalid - or, if it wasn't, set it to invalid after freeing. That's what the current code was already doing in the Manager classes, this change allows them to just call remove without the additional code. Also, two potential memory leaks where new tables were always allocated without freeing the old ones are fixed. Reviewers: sergey, dingto, brecht Differential Revision: https://developer.blender.org/D1974
This commit is contained in:
@@ -404,8 +404,8 @@ void ShaderManager::device_update_common(Device *device,
|
||||
}
|
||||
}
|
||||
beckmann_table_offset = scene->lookup_tables->add_table(dscene, beckmann_table);
|
||||
ktables->beckmann_offset = (int)beckmann_table_offset;
|
||||
}
|
||||
ktables->beckmann_offset = (int)beckmann_table_offset;
|
||||
|
||||
/* integrator */
|
||||
KernelIntegrator *kintegrator = &dscene->data.integrator;
|
||||
@@ -418,10 +418,7 @@ void ShaderManager::device_update_common(Device *device,
|
||||
|
||||
void ShaderManager::device_free_common(Device *device, DeviceScene *dscene, Scene *scene)
|
||||
{
|
||||
if(beckmann_table_offset != TABLE_OFFSET_INVALID) {
|
||||
scene->lookup_tables->remove_table(beckmann_table_offset);
|
||||
beckmann_table_offset = TABLE_OFFSET_INVALID;
|
||||
}
|
||||
scene->lookup_tables->remove_table(&beckmann_table_offset);
|
||||
|
||||
device->tex_free(dscene->shader_flag);
|
||||
dscene->shader_flag.clear();
|
||||
|
Reference in New Issue
Block a user