Fix T51412: Instant crash with texture plugged into the Displacement output

The issue was caused by unlimited textures commit, root of the issue is that
displacement code updates some of the image slots directly, so it needs to
ensure device vectors are all proper size.
This commit is contained in:
Sergey Sharybin
2017-05-04 16:27:31 +02:00
parent b180900e52
commit a523dfd2fd
3 changed files with 20 additions and 9 deletions

View File

@@ -949,16 +949,8 @@ void ImageManager::device_free_image(Device *device, DeviceScene *dscene, ImageD
}
}
void ImageManager::device_update(Device *device,
DeviceScene *dscene,
Scene *scene,
Progress& progress)
void ImageManager::device_prepare_update(DeviceScene *dscene)
{
if(!need_update)
return;
TaskPool pool;
for(int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
switch(type) {
case IMAGE_DATA_TYPE_FLOAT4:
@@ -986,6 +978,23 @@ void ImageManager::device_update(Device *device,
dscene->tex_half_image.resize(tex_num_images[IMAGE_DATA_TYPE_HALF]);
break;
}
}
}
void ImageManager::device_update(Device *device,
DeviceScene *dscene,
Scene *scene,
Progress& progress)
{
if(!need_update) {
return;
}
/* Make sure arrays are proper size. */
device_prepare_update(dscene);
TaskPool pool;
for(int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
for(size_t slot = 0; slot < images[type].size(); slot++) {
if(!images[type][slot])
continue;

View File

@@ -59,6 +59,7 @@ public:
bool use_alpha);
ImageDataType get_image_metadata(const string& filename, void *builtin_data, bool& is_linear);
void device_prepare_update(DeviceScene *dscene);
void device_update(Device *device,
DeviceScene *dscene,
Scene *scene,

View File

@@ -1944,6 +1944,7 @@ void MeshManager::device_update_displacement_images(Device *device,
}
}
}
image_manager->device_prepare_update(dscene);
foreach(int slot, bump_images) {
pool.push(function_bind(&ImageManager::device_update_slot,
image_manager,