gobj: Fix TextureReloadRequest not reloading in certain situations

This prevented async texture loading from working unless mipmapping was enabled
This commit is contained in:
rdb 2021-11-28 14:01:33 +01:00
parent 5eaa67fbc9
commit c0a9123dde

View File

@ -22,13 +22,21 @@ TypeHandle TextureReloadRequest::_type_handle;
AsyncTask::DoneStatus TextureReloadRequest:: AsyncTask::DoneStatus TextureReloadRequest::
do_task() { do_task() {
// Don't reload the texture if it doesn't need it. // Don't reload the texture if it doesn't need it.
if (_texture->was_image_modified(_pgo)) { if (!_texture->was_image_modified(_pgo) &&
(_allow_compressed ? _texture->has_ram_image() : _texture->has_uncompressed_ram_image())) {
return DS_done;
}
double delay = async_load_delay; double delay = async_load_delay;
if (delay != 0.0) { if (delay != 0.0) {
Thread::sleep(delay); Thread::sleep(delay);
if (!_texture->was_image_modified(_pgo) &&
(_allow_compressed ? _texture->has_ram_image() : _texture->has_uncompressed_ram_image())) {
return DS_done;
}
} }
if (_texture->was_image_modified(_pgo)) {
if (_allow_compressed) { if (_allow_compressed) {
_texture->get_ram_image(); _texture->get_ram_image();
} else { } else {
@ -36,13 +44,11 @@ do_task() {
} }
// Now that we've loaded the texture, we should ensure it actually gets // Now that we've loaded the texture, we should ensure it actually gets
// prepared--even if it's no longer visible in the frame--or it may // prepared--even if it's no longer visible in the frame--or it may become a
// become a kind of a leak (if the texture is never rendered again on // kind of a leak (if the texture is never rendered again on this GSG, we'll
// this GSG, we'll just end up carrying the texture memory in RAM // just end up carrying the texture memory in RAM forever, instead of dumping
// forever, instead of dumping it as soon as it gets prepared). // it as soon as it gets prepared).
_pgo->enqueue_texture(_texture); _pgo->enqueue_texture(_texture);
}
}
// Don't continue the task; we're done. // Don't continue the task; we're done.
return DS_done; return DS_done;