DNA: Move irradiance grid light cache data to Object level #106808

Merged
Clément Foucault merged 13 commits from fclem/blender:lightprobe-data into main 2023-04-17 17:12:31 +02:00
11 changed files with 93 additions and 35 deletions
Showing only changes of commit f5072c573e - Show all commits

View File

@ -55,21 +55,29 @@ void WorkTileScheduler::reset_scheduler_state()
VLOG_WORK << "Will schedule tiles of size " << tile_size_;
if (VLOG_IS_ON(3)) {
/* The logging is based on multiple tiles scheduled, ignoring overhead of multi-tile scheduling
* and purely focusing on the number of used path states. */
const int num_path_states_in_tile = tile_size_.width * tile_size_.height *
tile_size_.num_samples;
const int num_tiles = max_num_path_states_ / num_path_states_in_tile;
VLOG_WORK << "Number of unused path states: "
<< max_num_path_states_ - num_tiles * num_path_states_in_tile;
const int num_path_states_in_tile = tile_size_.width * tile_size_.height *
tile_size_.num_samples;
if (num_path_states_in_tile == 0) {
num_tiles_x_ = 0;
num_tiles_y_ = 0;
num_tiles_per_sample_range_ = 0;
}
else {
if (VLOG_IS_ON(3)) {
/* The logging is based on multiple tiles scheduled, ignoring overhead of multi-tile
* scheduling and purely focusing on the number of used path states. */
const int num_tiles = max_num_path_states_ / num_path_states_in_tile;
VLOG_WORK << "Number of unused path states: "
<< max_num_path_states_ - num_tiles * num_path_states_in_tile;
}
num_tiles_x_ = divide_up(image_size_px_.x, tile_size_.width);
num_tiles_y_ = divide_up(image_size_px_.y, tile_size_.height);
num_tiles_per_sample_range_ = divide_up(samples_num_, tile_size_.num_samples);
}
num_tiles_x_ = divide_up(image_size_px_.x, tile_size_.width);
num_tiles_y_ = divide_up(image_size_px_.y, tile_size_.height);
total_tiles_num_ = num_tiles_x_ * num_tiles_y_;
num_tiles_per_sample_range_ = divide_up(samples_num_, tile_size_.num_samples);
next_work_index_ = 0;
total_work_size_ = total_tiles_num_ * num_tiles_per_sample_range_;

View File

@ -1046,7 +1046,7 @@ class I18nMessages:
self.unescape()
def write(self, kind, dest):
self.writers[kind](self, dest)
return self.writers[kind](self, dest)
def write_messages_to_po(self, fname, compact=False):
"""
@ -1126,8 +1126,8 @@ class I18nMessages:
"-o",
fname,
)
ret = subprocess.call(cmd)
return
ret = subprocess.run(cmd, capture_output=True)
return ret
# XXX Code below is currently broken (generates corrupted mo files it seems :( )!
# Using http://www.gnu.org/software/gettext/manual/html_node/MO-Files.html notation.
# Not generating hash table!
@ -1427,7 +1427,7 @@ class I18n:
self.unescape()
def write(self, kind, langs=set()):
self.writers[kind](self, langs)
return self.writers[kind](self, langs)
def write_to_po(self, langs=set()):
"""

View File

@ -96,7 +96,7 @@ class AddPresetBase:
# Reset preset name
wm = bpy.data.window_managers[0]
if name == wm.preset_name:
wm.preset_name = 'New Preset'
wm.preset_name = data_('New Preset')
filename = self.as_filename(name)

View File

@ -170,7 +170,10 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data)
{
const int cb_flag = cb_data->cb_flag;
if (cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_EMBEDDED_NOT_OWNING)) {
/* NOTE: Support remapping of `IDWALK_CB_EMBEDDED_NON_OWNING` pointers, this is necessary in some
* complex low-level ID manipulation cases (e.g. in ID swapping, see #BKE_lib_id_swap & co).
*/
if (cb_flag & IDWALK_CB_EMBEDDED) {
return IDWALK_RET_NOP;
}
@ -890,8 +893,8 @@ static void libblock_relink_to_newid_prepare_data(Main *bmain,
static int id_relink_to_newid_looper(LibraryIDLinkCallbackData *cb_data)
{
const int cb_flag = cb_data->cb_flag;
if (cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_EMBEDDED_NOT_OWNING |
IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE)) {
/* NOTE: For now, support remapping `IDWALK_CB_EMBEDDED_NON_OWNING` pointers. */
if (cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE)) {
return IDWALK_RET_NOP;
}

View File

@ -3104,6 +3104,7 @@ static void read_libblock_undo_restore_at_old_address(FileData *fd, Main *main,
* lib-linking to restore some data that should never be affected by undo, e.g. the 3D cursor of
* #Scene. */
id_old->orig_id = id;
id_old->tag |= LIB_TAG_UNDO_OLD_ID_REREAD_IN_PLACE;
BLI_addtail(new_lb, id_old);
BLI_addtail(old_lb, id);
@ -3122,18 +3123,21 @@ static bool read_libblock_undo_restore(
return true;
}
}
else if (id_type->flags & IDTYPE_FLAGS_NO_MEMFILE_UNDO) {
/* Skip reading any 'no undo' datablocks (typically UI-like ones), existing ones are kept.
* See `setup_app_data` for details. */
CLOG_INFO(&LOG_UNDO,
2,
"UNDO: skip restore datablock %s, 'NO_MEMFILE_UNDO' type of ID",
id->name);
return true;
}
else if (bhead->code == ID_LINK_PLACEHOLDER) {
/* Restore linked datablock. */
if (read_libblock_undo_restore_linked(fd, main, id, bhead)) {
return true;
}
}
else if (id_type->flags & IDTYPE_FLAGS_NO_MEMFILE_UNDO) {
/* Skip reading any UI datablocks, existing ones are kept. We don't
* support pointers from other datablocks to UI datablocks so those
* we also don't put UI datablocks in fd->libmap. */
return true;
}
/* Restore local datablocks. */
ID *id_old = nullptr;

View File

@ -159,7 +159,7 @@ static void createTransMeshSkin(bContext *UNUSED(C), TransInfo *t)
if (mirror_data.vert_map) {
tc->data_mirror_len = mirror_data.mirror_elem_len;
tc->data_mirror = MEM_mallocN(mirror_data.mirror_elem_len * sizeof(*tc->data_mirror),
tc->data_mirror = MEM_callocN(mirror_data.mirror_elem_len * sizeof(*tc->data_mirror),
__func__);
BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) {

View File

@ -239,21 +239,39 @@ static void memfile_undosys_step_decode(struct bContext *C,
bmain, id, memfile_undosys_step_id_reused_cb, nullptr, IDWALK_READONLY);
}
/* NOTE: Tagging `ID_RECALC_COPY_ON_WRITE` here should not be needed in practice, since
* modified IDs should already have other depsgraph update tags anyway. However, for sakes of
* consistency, it's better to effectively use it, since content of that ID pointer does have
* been modified. */
unsigned int recalc_flags = id->recalc | ((id->tag & LIB_TAG_UNDO_OLD_ID_REREAD_IN_PLACE) ?
ID_RECALC_COPY_ON_WRITE :
0);
/* Tag depsgraph to update data-block for changes that happened between the
* current and the target state, see direct_link_id_restore_recalc(). */
if (id->recalc != 0) {
DEG_id_tag_update_ex(bmain, id, id->recalc);
if (recalc_flags != 0) {
DEG_id_tag_update_ex(bmain, id, recalc_flags);
}
bNodeTree *nodetree = ntreeFromID(id);
if (nodetree != nullptr && nodetree->id.recalc != 0) {
DEG_id_tag_update_ex(bmain, &nodetree->id, nodetree->id.recalc);
if (nodetree != nullptr) {
recalc_flags = nodetree->id.recalc;
if (id->tag & LIB_TAG_UNDO_OLD_ID_REREAD_IN_PLACE) {
recalc_flags |= ID_RECALC_COPY_ON_WRITE;
}
if (recalc_flags != 0) {
DEG_id_tag_update_ex(bmain, &nodetree->id, recalc_flags);
}
}
if (GS(id->name) == ID_SCE) {
Scene *scene = (Scene *)id;
if (scene->master_collection != nullptr && scene->master_collection->id.recalc != 0) {
DEG_id_tag_update_ex(
bmain, &scene->master_collection->id, scene->master_collection->id.recalc);
if (scene->master_collection != nullptr) {
recalc_flags = scene->master_collection->id.recalc;
if (id->tag & LIB_TAG_UNDO_OLD_ID_REREAD_IN_PLACE) {
recalc_flags |= ID_RECALC_COPY_ON_WRITE;
}
if (recalc_flags != 0) {
DEG_id_tag_update_ex(bmain, &scene->master_collection->id, recalc_flags);
}
}
}
@ -264,7 +282,7 @@ static void memfile_undosys_step_decode(struct bContext *C,
FOREACH_MAIN_ID_BEGIN (bmain, id) {
/* Clear temporary tag. */
id->tag &= ~LIB_TAG_UNDO_OLD_ID_REUSED;
id->tag &= ~(LIB_TAG_UNDO_OLD_ID_REUSED | LIB_TAG_UNDO_OLD_ID_REREAD_IN_PLACE);
/* We only start accumulating from this point, any tags set up to here
* are already part of the current undo state. This is done in a second

View File

@ -0,0 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2022 Blender Foundation */
/** \file
* \ingroup gpu
*/

View File

@ -0,0 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2022 Blender Foundation */
/** \file
* \ingroup gpu
*/

View File

@ -485,6 +485,12 @@ void AbstractHierarchyIterator::context_update_for_graph_index(
{
/* Update the HierarchyContext so that it is consistent with the graph index. */
context->export_parent = graph_index.object;
/* If the parent type is such that it cannot be exported (at least not currently to USD or
* Alembic), always check the parent for animation. */
const short partype = context->object->partype & PARTYPE;
context->animation_check_include_parent |= ELEM(partype, PARBONE, PARVERT1, PARVERT3, PARSKEL);
if (context->export_parent != context->object->parent) {
/* The parent object in Blender is NOT used as the export parent. This means
* that the world transform of this object can be influenced by objects that

View File

@ -840,6 +840,13 @@ enum {
* RESET_AFTER_USE
*/
LIB_TAG_UNDO_OLD_ID_REUSED = 1 << 17,
/**
* ID has be re-read in-place, the ID address is the same as in the old BMain, but the content is
* different.
*
* RESET_AFTER_USE
*/
LIB_TAG_UNDO_OLD_ID_REREAD_IN_PLACE = 1 << 18,
/* ------------------------------------------------------------------------------------------- */
/**