Merge branch 'master' into blender2.8

This commit is contained in:
Campbell Barton 2017-05-05 08:23:59 +10:00
commit 1c2b5430ca
11 changed files with 100 additions and 21 deletions

@ -446,8 +446,7 @@ public:
kgbuffer.resize(sizeof(KernelGlobals));
mem_alloc("kernel_globals", kgbuffer, MEM_READ_WRITE);
KernelGlobals *kg = (KernelGlobals*)kgbuffer.device_pointer;
*kg = thread_kernel_globals_init();
KernelGlobals *kg = new ((void*) kgbuffer.device_pointer) KernelGlobals(thread_kernel_globals_init());
requested_features.max_closure = MAX_CLOSURE;
if(!split_kernel.load_kernels(requested_features)) {

@ -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;

@ -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,

@ -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,

@ -184,7 +184,7 @@ std::ostream& operator <<(std::ostream &os,
<< " Device type : " << opencl_device_type << "\n"
<< " Kernel type : " << opencl_kernel_type << "\n"
<< " Debug : " << string_from_bool(debug_flags.opencl.debug) << "\n"
<< " Signle program : " << string_from_bool(debug_flags.opencl.single_program)
<< " Single program : " << string_from_bool(debug_flags.opencl.single_program)
<< "\n";
return os;
}

@ -132,6 +132,12 @@
#include "atomic_ops.h"
//#define DEBUG_TIME
#ifdef DEBUG_TIME
# include "PIL_time_utildefines.h"
#endif
/* GS reads the memory pointed at in a specific ordering.
* only use this definition, makes little and big endian systems
* work fine, in conjunction with MAKE_ID */
@ -1776,9 +1782,18 @@ void BKE_library_make_local(
LinkNode *copied_ids = NULL;
MemArena *linklist_mem = BLI_memarena_new(512 * sizeof(*todo_ids), __func__);
GSet *done_ids = BLI_gset_ptr_new(__func__);
#ifdef DEBUG_TIME
TIMEIT_START(make_local);
#endif
BKE_main_relations_create(bmain);
GSet *done_ids = BLI_gset_ptr_new(__func__);
#ifdef DEBUG_TIME
printf("Pre-compute current ID relations: Done.\n");
TIMEIT_VALUE_PRINT(make_local);
#endif
/* Step 1: Detect datablocks to make local. */
for (a = set_listbasepointers(bmain, lbarray); a--; ) {
@ -1829,6 +1844,11 @@ void BKE_library_make_local(
}
}
#ifdef DEBUG_TIME
printf("Step 1: Detect datablocks to make local: Done.\n");
TIMEIT_VALUE_PRINT(make_local);
#endif
/* Step 2: Check which datablocks we can directly make local (because they are only used by already, or future,
* local data), others will need to be duplicated. */
GSet *loop_tags = BLI_gset_ptr_new(__func__);
@ -1842,6 +1862,11 @@ void BKE_library_make_local(
/* Next step will most likely add new IDs, better to get rid of this mapping now. */
BKE_main_relations_free(bmain);
#ifdef DEBUG_TIME
printf("Step 2: Check which datablocks we can directly make local: Done.\n");
TIMEIT_VALUE_PRINT(make_local);
#endif
/* Step 3: Make IDs local, either directly (quick and simple), or using generic process,
* which involves more complex checks and might instead create a local copy of original linked ID. */
for (LinkNode *it = todo_ids, *it_next; it; it = it_next) {
@ -1882,11 +1907,16 @@ void BKE_library_make_local(
}
}
#ifdef DEBUG_TIME
printf("Step 3: Make IDs local: Done.\n");
TIMEIT_VALUE_PRINT(make_local);
#endif
/* At this point, we are done with directly made local IDs. Now we have to handle duplicated ones, since their
* remaining linked original counterpart may not be needed anymore... */
todo_ids = NULL;
/* Step 4: We have to remap local usages of old (linked) ID to new (local) id in a separated loop,
/* Step 4: We have to remap local usages of old (linked) ID to new (local) ID in a separated loop,
* as lbarray ordering is not enough to ensure us we did catch all dependencies
* (e.g. if making local a parent object before its child...). See T48907. */
/* TODO This is now the biggest step by far (in term of processing time). We may be able to gain here by
@ -1910,6 +1940,11 @@ void BKE_library_make_local(
}
}
#ifdef DEBUG_TIME
printf("Step 4: Remap local usages of old (linked) ID to new (local) ID: Done.\n");
TIMEIT_VALUE_PRINT(make_local);
#endif
/* Note: Keeping both version of the code (old one being safer, since it still has checks against unused IDs)
* for now, we can remove old one once it has been tested for some time in master... */
#if 1
@ -1954,6 +1989,12 @@ void BKE_library_make_local(
}
}
}
#ifdef DEBUG_TIME
printf("Step 5: Proxy 'remapping' hack: Done.\n");
TIMEIT_VALUE_PRINT(make_local);
#endif
#else
LinkNode *linked_loop_candidates = NULL;
@ -2032,6 +2073,11 @@ void BKE_library_make_local(
}
}
#ifdef DEBUG_TIME
printf("Step 5: Remove linked datablocks that have been copied and ended fully localized: Done.\n");
TIMEIT_VALUE_PRINT(make_local);
#endif
/* Step 6: Try to find circle dependencies between indirectly-linked-only datablocks.
* Those are fake 'usages' that prevent their deletion. See T49775 for nice ugly case. */
BKE_library_unused_linked_data_set_tag(bmain, false);
@ -2068,10 +2114,21 @@ void BKE_library_make_local(
it->link = NULL;
}
}
#ifdef DEBUG_TIME
printf("Step 6: Try to find circle dependencies between indirectly-linked-only datablocks: Done.\n");
TIMEIT_END(make_local);
#endif
#endif
BKE_main_id_clear_newpoins(bmain);
BLI_memarena_free(linklist_mem);
#ifdef DEBUG_TIME
printf("Cleanup and finish: Done.\n");
TIMEIT_END(make_local);
#endif
}
/**

@ -550,8 +550,12 @@ void BKE_libblock_remap_locked(
id_us_clear_real(old_id);
}
BLI_assert(old_id->us - skipped_refcounted >= 0);
UNUSED_VARS_NDEBUG(skipped_refcounted);
if (old_id->us - skipped_refcounted < 0) {
printf("Error in remapping process from '%s' (%p) to '%s' (%p): "
"wrong user count in old ID after process (summing up to %d)\n",
old_id->name, old_id, new_id ? new_id->name : "<NULL>", new_id, old_id->us - skipped_refcounted);
BLI_assert(0);
}
if (skipped_direct == 0) {
/* old_id is assumed to not be used directly anymore... */

@ -1164,6 +1164,7 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, bool copy_caches)
/* increase user numbers */
id_us_plus((ID *)obn->data);
id_us_plus((ID *)obn->poselib);
id_us_plus((ID *)obn->gpd);
id_us_plus((ID *)obn->dup_group);

@ -291,6 +291,9 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
/* copy Freestyle settings */
new_srl = scen->r.layers.first;
for (srl = sce->r.layers.first; srl; srl = srl->next) {
if (new_srl->prop != NULL) {
new_srl->prop = IDP_CopyProperty(new_srl->prop);
}
BKE_freestyle_config_copy(&new_srl->freestyleConfig, &srl->freestyleConfig);
if (type == SCE_COPY_FULL) {
for (lineset = new_srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
@ -513,11 +516,15 @@ void BKE_scene_free(Scene *sce)
MEM_freeN(sce->r.ffcodecdata.properties);
sce->r.ffcodecdata.properties = NULL;
}
for (srl = sce->r.layers.first; srl; srl = srl->next) {
if (srl->prop != NULL) {
IDP_FreeProperty(srl->prop);
MEM_freeN(srl->prop);
}
BKE_freestyle_config_free(&srl->freestyleConfig);
}
BLI_freelistN(&sce->markers);
BLI_freelistN(&sce->transform_spaces);
BLI_freelistN(&sce->r.layers);

@ -549,11 +549,11 @@ int colorband_element_remove(struct ColorBand *coba, int index)
if (index < 0 || index >= coba->tot)
return 0;
coba->tot--;
for (a = index; a < coba->tot; a++) {
coba->data[a] = coba->data[a + 1];
}
if (coba->cur) coba->cur--;
coba->tot--;
return 1;
}

@ -9601,8 +9601,8 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
bbs_mesh_wire(em, dm, bm_solidoffs);
bm_wireoffs = bm_solidoffs + em->bm->totedge;
/* we draw verts if vert select mode or if in transform (for snap). */
if ((ts->selectmode & SCE_SELECT_VERTEX) || (G.moving & G_TRANSFORM_EDIT)) {
/* we draw verts if vert select mode. */
if (ts->selectmode & SCE_SELECT_VERTEX) {
bbs_mesh_verts(em, dm, bm_wireoffs);
bm_vertoffs = bm_wireoffs + em->bm->totvert;
}