forked from bartvdbraak/blender
Cycles: Proper fix for recent OpenCL image crash
Problem was that some code checks to see if device_pointer is null or not and the new allocator wasn't even setting the pointer to anything as it tracks memory location separately. Setting the pointer to non null keeps all users of device_pointer happy.
This commit is contained in:
parent
06bf34227b
commit
55d28e604e
@ -519,20 +519,26 @@ void OpenCLDeviceBase::tex_alloc(const char *name,
|
|||||||
<< string_human_readable_size(mem.memory_size()) << ")";
|
<< string_human_readable_size(mem.memory_size()) << ")";
|
||||||
|
|
||||||
memory_manager.alloc(name, mem);
|
memory_manager.alloc(name, mem);
|
||||||
|
/* Set the pointer to non-null to keep code that inspects its value from thinking its unallocated. */
|
||||||
|
mem.device_pointer = 1;
|
||||||
textures[name] = Texture(&mem, interpolation, extension);
|
textures[name] = Texture(&mem, interpolation, extension);
|
||||||
textures_need_update = true;
|
textures_need_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenCLDeviceBase::tex_free(device_memory& mem)
|
void OpenCLDeviceBase::tex_free(device_memory& mem)
|
||||||
{
|
{
|
||||||
if(memory_manager.free(mem)) {
|
if(mem.device_pointer) {
|
||||||
textures_need_update = true;
|
mem.device_pointer = 0;
|
||||||
}
|
|
||||||
|
|
||||||
foreach(TexturesMap::value_type& value, textures) {
|
if(memory_manager.free(mem)) {
|
||||||
if(value.second.mem == &mem) {
|
textures_need_update = true;
|
||||||
textures.erase(value.first);
|
}
|
||||||
break;
|
|
||||||
|
foreach(TexturesMap::value_type& value, textures) {
|
||||||
|
if(value.second.mem == &mem) {
|
||||||
|
textures.erase(value.first);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user