Enhanced stats/reports for blendfile reading.

Add direct user feedback (as a warning report) to user when recursive
resync of overrides was needed.

And some timing (as CLOG logs) about main readfile process steps.

This is essentially adding a new BlendFileReadReport structure that wraps
BKE_reports list, and adds some extra info (some timing, some info about
overrides and (recursive) resync, etc.).
This commit is contained in:
Bastien Montagne 2021-06-22 17:28:19 +02:00
parent 6ff0d59967
commit f8d219dfd4
Notes: blender-bot 2023-02-14 07:25:51 +01:00
Referenced by commit 3a48147b8a, Revert "Enhanced stats/reports for blendfile reading."
14 changed files with 251 additions and 69 deletions

View File

@ -25,6 +25,7 @@ extern "C" {
struct BlendFileData;
struct BlendFileReadParams;
struct BlendFileReadReport;
struct ID;
struct Main;
struct MemFile;
@ -35,7 +36,7 @@ struct bContext;
void BKE_blendfile_read_setup_ex(struct bContext *C,
struct BlendFileData *bfd,
const struct BlendFileReadParams *params,
struct ReportList *reports,
struct BlendFileReadReport *reports,
/* Extra args. */
const bool startup_update_defaults,
const char *startup_app_template);
@ -43,11 +44,11 @@ void BKE_blendfile_read_setup_ex(struct bContext *C,
void BKE_blendfile_read_setup(struct bContext *C,
struct BlendFileData *bfd,
const struct BlendFileReadParams *params,
struct ReportList *reports);
struct BlendFileReadReport *reports);
struct BlendFileData *BKE_blendfile_read(const char *filepath,
const struct BlendFileReadParams *params,
struct ReportList *reports);
struct BlendFileReadReport *reports);
struct BlendFileData *BKE_blendfile_read_from_memory(const void *filebuf,
int filelength,

View File

@ -43,6 +43,7 @@ extern "C" {
#endif
struct Collection;
struct BlendFileReadReport;
struct ID;
struct IDOverrideLibrary;
struct IDOverrideLibraryProperty;
@ -90,11 +91,11 @@ bool BKE_lib_override_library_resync(struct Main *bmain,
struct Collection *override_resync_residual_storage,
const bool do_hierarchy_enforce,
const bool do_post_process,
struct ReportList *reports);
struct BlendFileReadReport *reports);
void BKE_lib_override_library_main_resync(struct Main *bmain,
struct Scene *scene,
struct ViewLayer *view_layer,
struct ReportList *reports);
struct BlendFileReadReport *reports);
void BKE_lib_override_library_delete(struct Main *bmain, struct ID *id_root);

View File

@ -78,9 +78,10 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
if (UNDO_DISK) {
const struct BlendFileReadParams params = {0};
struct BlendFileData *bfd = BKE_blendfile_read(mfu->filename, &params, NULL);
struct BlendFileData *bfd = BKE_blendfile_read(
mfu->filename, &params, &(BlendFileReadReport){NULL});
if (bfd != NULL) {
BKE_blendfile_read_setup(C, bfd, &params, NULL);
BKE_blendfile_read_setup(C, bfd, &params, &(BlendFileReadReport){NULL});
success = true;
}
}
@ -93,7 +94,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
struct BlendFileData *bfd = BKE_blendfile_read_from_memfile(
bmain, &mfu->memfile, &params, NULL);
if (bfd != NULL) {
BKE_blendfile_read_setup(C, bfd, &params, NULL);
BKE_blendfile_read_setup(C, bfd, &params, &(BlendFileReadReport){NULL});
success = true;
}
}

View File

@ -36,6 +36,8 @@
#include "BLI_system.h"
#include "BLI_utildefines.h"
#include "PIL_time.h"
#include "IMB_colormanagement.h"
#include "BKE_addon.h"
@ -136,7 +138,7 @@ static void setup_app_userdef(BlendFileData *bfd)
static void setup_app_data(bContext *C,
BlendFileData *bfd,
const struct BlendFileReadParams *params,
ReportList *reports)
BlendFileReadReport *reports)
{
Main *bmain = G_MAIN;
Scene *curscene = NULL;
@ -155,7 +157,7 @@ static void setup_app_data(bContext *C,
/* may happen with library files - UNDO file should never have NULL curscene (but may have a
* NULL curscreen)... */
else if (ELEM(NULL, bfd->curscreen, bfd->curscene)) {
BKE_report(reports, RPT_WARNING, "Library file, loading empty scene");
BKE_report(reports->reports, RPT_WARNING, "Library file, loading empty scene");
mode = LOAD_UI_OFF;
}
else if (G.fileflags & G_FILE_NO_UI) {
@ -396,11 +398,17 @@ static void setup_app_data(bContext *C,
}
if (mode != LOAD_UNDO && !USER_EXPERIMENTAL_TEST(&U, no_override_auto_resync)) {
reports->duration.lib_overrides_resync = PIL_check_seconds_timer();
BKE_lib_override_library_main_resync(
bmain,
curscene,
bfd->cur_view_layer ? bfd->cur_view_layer : BKE_view_layer_default_view(curscene),
reports);
reports->duration.lib_overrides_resync = PIL_check_seconds_timer() -
reports->duration.lib_overrides_resync;
/* We need to rebuild some of the deleted override rules (for UI feedback purpose). */
BKE_lib_override_library_main_operations_create(bmain, true);
}
@ -409,7 +417,7 @@ static void setup_app_data(bContext *C,
static void setup_app_blend_file_data(bContext *C,
BlendFileData *bfd,
const struct BlendFileReadParams *params,
ReportList *reports)
BlendFileReadReport *reports)
{
if ((params->skip_flags & BLO_READ_SKIP_USERDEF) == 0) {
setup_app_userdef(bfd);
@ -419,12 +427,12 @@ static void setup_app_blend_file_data(bContext *C,
}
}
static void handle_subversion_warning(Main *main, ReportList *reports)
static void handle_subversion_warning(Main *main, BlendFileReadReport *reports)
{
if (main->minversionfile > BLENDER_FILE_VERSION ||
(main->minversionfile == BLENDER_FILE_VERSION &&
main->minsubversionfile > BLENDER_FILE_SUBVERSION)) {
BKE_reportf(reports,
BKE_reportf(reports->reports,
RPT_ERROR,
"File written by newer Blender binary (%d.%d), expect loss of data!",
main->minversionfile,
@ -443,7 +451,7 @@ static void handle_subversion_warning(Main *main, ReportList *reports)
void BKE_blendfile_read_setup_ex(bContext *C,
BlendFileData *bfd,
const struct BlendFileReadParams *params,
ReportList *reports,
BlendFileReadReport *reports,
/* Extra args. */
const bool startup_update_defaults,
const char *startup_app_template)
@ -460,7 +468,7 @@ void BKE_blendfile_read_setup_ex(bContext *C,
void BKE_blendfile_read_setup(bContext *C,
BlendFileData *bfd,
const struct BlendFileReadParams *params,
ReportList *reports)
BlendFileReadReport *reports)
{
BKE_blendfile_read_setup_ex(C, bfd, params, reports, false, NULL);
}
@ -470,7 +478,7 @@ void BKE_blendfile_read_setup(bContext *C,
*/
struct BlendFileData *BKE_blendfile_read(const char *filepath,
const struct BlendFileReadParams *params,
ReportList *reports)
BlendFileReadReport *reports)
{
/* Don't print startup file loading. */
if (params->is_startup == false) {
@ -482,7 +490,7 @@ struct BlendFileData *BKE_blendfile_read(const char *filepath,
handle_subversion_warning(bfd->main, reports);
}
else {
BKE_reports_prependf(reports, "Loading '%s' failed: ", filepath);
BKE_reports_prependf(reports->reports, "Loading '%s' failed: ", filepath);
}
return bfd;
}
@ -559,7 +567,9 @@ UserDef *BKE_blendfile_userdef_read(const char *filepath, ReportList *reports)
BlendFileData *bfd;
UserDef *userdef = NULL;
bfd = BLO_read_from_file(filepath, BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF, reports);
bfd = BLO_read_from_file(filepath,
BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF,
&(struct BlendFileReadReport){.reports = reports});
if (bfd) {
if (bfd->user) {
userdef = bfd->user;
@ -770,7 +780,8 @@ WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepat
WorkspaceConfigFileData *workspace_config = NULL;
if (filepath) {
bfd = BLO_read_from_file(filepath, BLO_READ_SKIP_USERDEF, reports);
bfd = BLO_read_from_file(
filepath, BLO_READ_SKIP_USERDEF, &(struct BlendFileReadReport){.reports = reports});
}
else {
bfd = BLO_read_from_memory(filebuf, filelength, BLO_READ_SKIP_USERDEF, reports);

View File

@ -52,12 +52,17 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BLO_readfile.h"
#include "BLI_ghash.h"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_task.h"
#include "BLI_utildefines.h"
#include "PIL_time.h"
#include "RNA_access.h"
#include "RNA_types.h"
@ -958,7 +963,7 @@ bool BKE_lib_override_library_resync(Main *bmain,
Collection *override_resync_residual_storage,
const bool do_hierarchy_enforce,
const bool do_post_process,
ReportList *reports)
BlendFileReadReport *reports)
{
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_root));
@ -1286,7 +1291,7 @@ bool BKE_lib_override_library_resync(Main *bmain,
id_root = id_root_reference->newid;
if (user_edited_overrides_deletion_count > 0) {
BKE_reportf(reports,
BKE_reportf(reports != NULL ? reports->reports : NULL,
RPT_WARNING,
"During resync of data-block %s, %d obsolete overrides were deleted, that had "
"local changes defined by user",
@ -1438,8 +1443,11 @@ static void lib_override_library_main_resync_on_library_indirect_level(
ViewLayer *view_layer,
Collection *override_resync_residual_storage,
const int library_indirect_level,
ReportList *reports)
BlendFileReadReport *reports)
{
const bool do_reports_recursive_resync_timing = (library_indirect_level != 0);
const double init_time = do_reports_recursive_resync_timing ? PIL_check_seconds_timer() : 0.0;
BKE_main_relations_create(bmain, 0);
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
@ -1530,6 +1538,7 @@ static void lib_override_library_main_resync_on_library_indirect_level(
(!ID_IS_LINKED(id) && library_indirect_level != 0)) {
continue;
}
Library *library = id->lib;
int level = 0;
/* In complex non-supported cases, with several different override hierarchies sharing
@ -1541,12 +1550,21 @@ static void lib_override_library_main_resync_on_library_indirect_level(
id = lib_override_library_main_resync_find_root_recurse(id, &level);
id->tag &= ~LIB_TAG_LIB_OVERRIDE_NEED_RESYNC;
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id));
BLI_assert(id->lib == library);
do_continue = true;
CLOG_INFO(&LOG, 2, "Resyncing %s (%p)...", id->name, id->lib);
CLOG_INFO(&LOG, 2, "Resyncing %s (%p)...", id->name, library);
const bool success = BKE_lib_override_library_resync(
bmain, scene, view_layer, id, override_resync_residual_storage, false, false, reports);
CLOG_INFO(&LOG, 2, "\tSuccess: %d", success);
if (success) {
reports->count.resynced_lib_overrides++;
if (library_indirect_level > 0 &&
BLI_linklist_index(reports->resynced_lib_overrides_libraries, library) < 0) {
BLI_linklist_prepend(&reports->resynced_lib_overrides_libraries, library);
reports->resynced_lib_overrides_libraries_count++;
}
}
break;
}
FOREACH_MAIN_LISTBASE_ID_END;
@ -1556,6 +1574,10 @@ static void lib_override_library_main_resync_on_library_indirect_level(
}
FOREACH_MAIN_LISTBASE_END;
}
if (do_reports_recursive_resync_timing) {
reports->duration.lib_overrides_recursive_resync += PIL_check_seconds_timer() - init_time;
}
}
static int lib_override_sort_libraries_func(LibraryIDLinkCallbackData *cb_data)
@ -1633,7 +1655,7 @@ static int lib_override_libraries_index_define(Main *bmain)
void BKE_lib_override_library_main_resync(Main *bmain,
Scene *scene,
ViewLayer *view_layer,
ReportList *reports)
BlendFileReadReport *reports)
{
/* We use a specific collection to gather/store all 'orphaned' override collections and objects
* generated by re-sync-process. This avoids putting them in scene's master collection. */

View File

@ -54,6 +54,7 @@ typedef struct BlendExpander BlendExpander;
typedef struct BlendLibReader BlendLibReader;
typedef struct BlendWriter BlendWriter;
struct BlendFileReadReport;
struct Main;
struct ReportList;
@ -216,7 +217,7 @@ bool BLO_read_requires_endian_switch(BlendDataReader *reader);
bool BLO_read_data_is_undo(BlendDataReader *reader);
void BLO_read_data_globmap_add(BlendDataReader *reader, void *oldaddr, void *newaddr);
void BLO_read_glob_list(BlendDataReader *reader, struct ListBase *list);
struct ReportList *BLO_read_data_reports(BlendDataReader *reader);
struct BlendFileReadReport *BLO_read_data_reports(BlendDataReader *reader);
/* Blend Read Lib API
* ===================
@ -233,7 +234,7 @@ ID *BLO_read_get_new_id_address(BlendLibReader *reader, struct Library *lib, str
/* Misc. */
bool BLO_read_lib_is_undo(BlendLibReader *reader);
struct Main *BLO_read_lib_get_main(BlendLibReader *reader);
struct ReportList *BLO_read_lib_reports(BlendLibReader *reader);
struct BlendFileReadReport *BLO_read_lib_reports(BlendLibReader *reader);
/* Blend Expand API
* ===================
@ -250,8 +251,10 @@ void BLO_expand_id(BlendExpander *expander, struct ID *id);
* ===================
*/
void BLO_reportf_wrap(struct ReportList *reports, ReportType type, const char *format, ...)
ATTR_PRINTF_FORMAT(3, 4);
void BLO_reportf_wrap(struct BlendFileReadReport *reports,
ReportType type,
const char *format,
...) ATTR_PRINTF_FORMAT(3, 4);
#ifdef __cplusplus
}

View File

@ -89,6 +89,35 @@ struct BlendFileReadParams {
int undo_direction; /* eUndoStepDir */
};
typedef struct BlendFileReadReport {
/* General reports handling. */
struct ReportList *reports;
/* Timing informations .*/
struct {
double whole;
double libraries;
double lib_overrides;
double lib_overrides_resync;
double lib_overrides_recursive_resync;
} duration;
/* Count informations. */
struct {
/* Some numbers of IDs that ended up in a specific state, or required some specific process
* during this file read. */
int missing_libraries;
int missing_linked_id;
/* Number of root override IDs that were resynced. */
int resynced_lib_overrides;
} count;
/* Number of libraries which had overrides that needed to be resynced, and a single linked list
* of those. */
int resynced_lib_overrides_libraries_count;
struct LinkNode *resynced_lib_overrides_libraries;
} BlendFileReadReport;
/* skip reading some data-block types (may want to skip screen data too). */
typedef enum eBLOReadSkip {
BLO_READ_SKIP_NONE = 0,
@ -101,7 +130,7 @@ typedef enum eBLOReadSkip {
BlendFileData *BLO_read_from_file(const char *filepath,
eBLOReadSkip skip_flags,
struct ReportList *reports);
struct BlendFileReadReport *reports);
BlendFileData *BLO_read_from_memory(const void *mem,
int memsize,
eBLOReadSkip skip_flags,

View File

@ -366,12 +366,12 @@ void BLO_blendhandle_close(BlendHandle *bh)
*/
BlendFileData *BLO_read_from_file(const char *filepath,
eBLOReadSkip skip_flags,
ReportList *reports)
BlendFileReadReport *reports)
{
BlendFileData *bfd = NULL;
FileData *fd;
fd = blo_filedata_from_file(filepath, reports);
fd = blo_filedata_from_file(filepath, reports->reports);
if (fd) {
fd->reports = reports;
fd->skip_flags = skip_flags;
@ -401,7 +401,7 @@ BlendFileData *BLO_read_from_memory(const void *mem,
fd = blo_filedata_from_memory(mem, memsize, reports);
if (fd) {
fd->reports = reports;
fd->reports = &(struct BlendFileReadReport){.reports = reports};
fd->skip_flags = skip_flags;
bfd = blo_read_file_internal(fd, "");
blo_filedata_free(fd);
@ -430,7 +430,7 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain,
fd = blo_filedata_from_memfile(memfile, params, reports);
if (fd) {
fd->reports = reports;
fd->reports = &(struct BlendFileReadReport){.reports = reports};
fd->skip_flags = params->skip_flags;
BLI_strncpy(fd->relabase, filename, sizeof(fd->relabase));

View File

@ -72,6 +72,8 @@
#include "BLI_mmap.h"
#include "BLI_threads.h"
#include "PIL_time.h"
#include "BLT_translation.h"
#include "BKE_anim_data.h"
@ -227,7 +229,7 @@ typedef struct BHeadN {
* bit kludge but better than doubling up on prints,
* we could alternatively have a versions of a report function which forces printing - campbell
*/
void BLO_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...)
void BLO_reportf_wrap(BlendFileReadReport *reports, ReportType type, const char *format, ...)
{
char fixed_buf[1024]; /* should be long enough */
@ -239,7 +241,7 @@ void BLO_reportf_wrap(ReportList *reports, ReportType type, const char *format,
fixed_buf[sizeof(fixed_buf) - 1] = '\0';
BKE_report(reports, type, fixed_buf);
BKE_report(reports->reports, type, fixed_buf);
if (G.background == 0) {
printf("%s: %s\n", BKE_report_type_str(type), fixed_buf);
@ -4206,6 +4208,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
}
if ((fd->skip_flags & BLO_READ_SKIP_DATA) == 0) {
fd->reports->duration.libraries = PIL_check_seconds_timer();
read_libraries(fd, &mainlist);
blo_join_main(&mainlist);
@ -4213,6 +4216,8 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
lib_link_all(fd, bfd->main);
after_liblink_merged_bmain_process(bfd->main);
fd->reports->duration.libraries = PIL_check_seconds_timer() - fd->reports->duration.libraries;
/* Skip in undo case. */
if (fd->memfile == NULL) {
/* Note that we can't recompute user-counts at this point in undo case, we play too much with
@ -4228,7 +4233,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
blo_split_main(&mainlist, bfd->main);
LISTBASE_FOREACH (Main *, mainvar, &mainlist) {
BLI_assert(mainvar->versionfile != 0);
do_versions_after_linking(mainvar, fd->reports);
do_versions_after_linking(mainvar, fd->reports->reports);
}
blo_join_main(&mainlist);
@ -4249,8 +4254,13 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
* we can re-generate overrides from their references. */
if (fd->memfile == NULL) {
/* Do not apply in undo case! */
BKE_lib_override_library_main_validate(bfd->main, fd->reports);
fd->reports->duration.lib_overrides = PIL_check_seconds_timer();
BKE_lib_override_library_main_validate(bfd->main, fd->reports->reports);
BKE_lib_override_library_main_update(bfd->main);
fd->reports->duration.lib_overrides = PIL_check_seconds_timer() -
fd->reports->duration.lib_overrides;
}
BKE_collections_after_lib_link(bfd->main);
@ -5206,7 +5216,7 @@ static void library_link_end(Main *mainl,
* or they will go again through do_versions - bad, very bad! */
split_main_newid(mainvar, main_newid);
do_versions_after_linking(main_newid, (*fd)->reports);
do_versions_after_linking(main_newid, (*fd)->reports->reports);
add_main_to_main(mainvar, main_newid);
}
@ -5340,7 +5350,7 @@ static void read_library_linked_id(
id->name + 2,
mainvar->curlib->filepath_abs,
library_parent_filepath(mainvar->curlib));
basefd->library_id_missing_count++;
basefd->reports->count.missing_linked_id++;
/* Generate a placeholder for this ID (simplified version of read_libblock actually...). */
if (r_id) {
@ -5444,7 +5454,7 @@ static FileData *read_library_file_data(FileData *basefd,
TIP_("Read packed library: '%s', parent '%s'"),
mainptr->curlib->filepath,
library_parent_filepath(mainptr->curlib));
fd = blo_filedata_from_memory(pf->data, pf->size, basefd->reports);
fd = blo_filedata_from_memory(pf->data, pf->size, basefd->reports->reports);
/* Needed for library_append and read_libraries. */
BLI_strncpy(fd->relabase, mainptr->curlib->filepath_abs, sizeof(fd->relabase));
@ -5457,7 +5467,7 @@ static FileData *read_library_file_data(FileData *basefd,
mainptr->curlib->filepath_abs,
mainptr->curlib->filepath,
library_parent_filepath(mainptr->curlib));
fd = blo_filedata_from_file(mainptr->curlib->filepath_abs, basefd->reports);
fd = blo_filedata_from_file(mainptr->curlib->filepath_abs, basefd->reports->reports);
}
if (fd) {
@ -5495,7 +5505,7 @@ static FileData *read_library_file_data(FileData *basefd,
if (fd == NULL) {
BLO_reportf_wrap(
basefd->reports, RPT_INFO, TIP_("Cannot find lib '%s'"), mainptr->curlib->filepath_abs);
basefd->library_file_missing_count++;
basefd->reports->count.missing_libraries++;
}
return fd;
@ -5589,15 +5599,6 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
mainptr->curlib->filedata = NULL;
}
BKE_main_free(main_newid);
if (basefd->library_file_missing_count != 0 || basefd->library_id_missing_count != 0) {
BKE_reportf(basefd->reports,
RPT_WARNING,
"LIB: %d libraries and %d linked data-blocks are missing, please check the "
"Info and Outliner editors for details",
basefd->library_file_missing_count,
basefd->library_id_missing_count);
}
}
void *BLO_read_get_new_data_address(BlendDataReader *reader, const void *old_address)
@ -5785,7 +5786,7 @@ void BLO_read_glob_list(BlendDataReader *reader, ListBase *list)
link_glob_list(reader->fd, list);
}
ReportList *BLO_read_data_reports(BlendDataReader *reader)
BlendFileReadReport *BLO_read_data_reports(BlendDataReader *reader)
{
return reader->fd->reports;
}
@ -5800,7 +5801,7 @@ Main *BLO_read_lib_get_main(BlendLibReader *reader)
return reader->main;
}
ReportList *BLO_read_lib_reports(BlendLibReader *reader)
BlendFileReadReport *BLO_read_lib_reports(BlendLibReader *reader)
{
return reader->fd->reports;
}

View File

@ -145,11 +145,7 @@ typedef struct FileData {
ListBase *old_mainlist;
struct IDNameLib_Map *old_idmap;
struct ReportList *reports;
/* Counters for amount of missing libraries, and missing IDs in libraries.
* Used to generate a synthetic report in the UI. */
int library_file_missing_count;
int library_id_missing_count;
struct BlendFileReadReport *reports;
} FileData;
#define SIZEOFBLENDERHEADER 12

View File

@ -1912,7 +1912,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_END;
if (error & NTREE_DOVERSION_NEED_OUTPUT) {
BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
BKE_report(fd->reports != NULL ? fd->reports->reports : NULL,
RPT_ERROR,
"Eevee material conversion problem. Error in console");
printf(
"You need to connect Principled and Eevee Specular shader nodes to new material "
"output "
@ -1920,7 +1922,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) {
BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
BKE_report(fd->reports != NULL ? fd->reports->reports : NULL,
RPT_ERROR,
"Eevee material conversion problem. Error in console");
printf(
"You need to combine transparency and emission shaders to the converted Principled "
"shader nodes.\n");

View File

@ -123,7 +123,8 @@ bool BlendfileLoadingBaseTest::blendfile_load(const char *filepath)
char abspath[FILENAME_MAX];
BLI_path_join(abspath, sizeof(abspath), test_assets_dir.c_str(), filepath, NULL);
bfile = BLO_read_from_file(abspath, BLO_READ_SKIP_NONE, nullptr /* reports */);
BlendFileReadReport bf_reports = {NULL};
bfile = BLO_read_from_file(abspath, BLO_READ_SKIP_NONE, &bf_reports);
if (bfile == nullptr) {
ADD_FAILURE() << "Unable to load file '" << filepath << "' from test assets dir '"
<< test_assets_dir << "'";

View File

@ -86,6 +86,8 @@
#include "UI_resources.h"
#include "UI_view2d.h"
#include "../../blender/blenloader/BLO_readfile.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@ -930,8 +932,14 @@ static void id_override_library_resync_fn(bContext *C,
te->store_elem->id->tag |= LIB_TAG_DOIT;
}
BKE_lib_override_library_resync(
bmain, scene, CTX_data_view_layer(C), id_root, NULL, do_hierarchy_enforce, true, reports);
BKE_lib_override_library_resync(bmain,
scene,
CTX_data_view_layer(C),
id_root,
NULL,
do_hierarchy_enforce,
true,
&(struct BlendFileReadReport){.reports = reports});
WM_event_add_notifier(C, NC_WINDOW, NULL);
}

View File

@ -52,12 +52,15 @@
#include "BLI_blenlib.h"
#include "BLI_fileops_types.h"
#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BLI_system.h"
#include "BLI_threads.h"
#include "BLI_timer.h"
#include "BLI_utildefines.h"
#include BLI_SYSTEM_PID_H
#include "PIL_time.h"
#include "BLT_translation.h"
#include "BLF_api.h"
@ -733,6 +736,97 @@ static void wm_file_read_post(bContext *C,
/** \name Read Main Blend-File API
* \{ */
static void file_read_reports_finalize(BlendFileReadReport *bf_reports)
{
double duration_whole_minutes, duration_whole_seconds;
double duration_libraries_minutes, duration_libraries_seconds;
double duration_lib_override_minutes, duration_lib_override_seconds;
double duration_lib_override_resync_minutes, duration_lib_override_resync_seconds;
double duration_lib_override_recursive_resync_minutes,
duration_lib_override_recursive_resync_seconds;
BLI_math_time_seconds_decompose(bf_reports->duration.whole,
NULL,
NULL,
&duration_whole_minutes,
&duration_whole_seconds,
NULL);
BLI_math_time_seconds_decompose(bf_reports->duration.libraries,
NULL,
NULL,
&duration_libraries_minutes,
&duration_libraries_seconds,
NULL);
BLI_math_time_seconds_decompose(bf_reports->duration.lib_overrides,
NULL,
NULL,
&duration_lib_override_minutes,
&duration_lib_override_seconds,
NULL);
BLI_math_time_seconds_decompose(bf_reports->duration.lib_overrides_resync,
NULL,
NULL,
&duration_lib_override_resync_minutes,
&duration_lib_override_resync_seconds,
NULL);
BLI_math_time_seconds_decompose(bf_reports->duration.lib_overrides_recursive_resync,
NULL,
NULL,
&duration_lib_override_recursive_resync_minutes,
&duration_lib_override_recursive_resync_seconds,
NULL);
CLOG_INFO(
&LOG, 0, "Blender file read in %.0fm%.2fs", duration_whole_minutes, duration_whole_seconds);
CLOG_INFO(&LOG,
0,
" * Loading libraries: %.0fm%.2fs",
duration_libraries_minutes,
duration_libraries_seconds);
CLOG_INFO(&LOG,
0,
" * Applying overrides: %.0fm%.2fs",
duration_lib_override_minutes,
duration_lib_override_seconds);
CLOG_INFO(&LOG,
0,
" * Resyncing overrides: %.0fm%.2fs (%d root overrides), including recursive "
"resyncs: %.0fm%.2fs)",
duration_lib_override_resync_minutes,
duration_lib_override_resync_seconds,
bf_reports->count.resynced_lib_overrides,
duration_lib_override_recursive_resync_minutes,
duration_lib_override_recursive_resync_seconds);
if (bf_reports->resynced_lib_overrides_libraries_count != 0) {
for (LinkNode *node_lib = bf_reports->resynced_lib_overrides_libraries; node_lib != NULL;
node_lib = node_lib->next) {
Library *library = node_lib->link;
BKE_reportf(
bf_reports->reports, RPT_INFO, "Library %s needs overrides resync.", library->filepath);
}
}
if (bf_reports->count.missing_libraries != 0 || bf_reports->count.missing_linked_id != 0) {
BKE_reportf(bf_reports->reports,
RPT_WARNING,
"%d libraries and %d linked data-blocks are missing, please check the "
"Info and Outliner editors for details",
bf_reports->count.missing_libraries,
bf_reports->count.missing_linked_id);
}
if (bf_reports->resynced_lib_overrides_libraries_count != 0) {
BKE_reportf(bf_reports->reports,
RPT_WARNING,
"%d libraries have overrides needing resync (auto resynced in %.0fm%.2fs), "
"please check the Info editor for details",
bf_reports->resynced_lib_overrides_libraries_count,
duration_lib_override_recursive_resync_minutes,
duration_lib_override_recursive_resync_seconds);
}
BLI_linklist_free(bf_reports->resynced_lib_overrides_libraries, NULL);
bf_reports->resynced_lib_overrides_libraries = NULL;
}
bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
{
/* assume automated tasks with background, don't write recent file list */
@ -763,7 +857,9 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
.skip_flags = BLO_READ_SKIP_USERDEF,
};
struct BlendFileData *bfd = BKE_blendfile_read(filepath, &params, reports);
BlendFileReadReport bf_reports = {.reports = reports,
.duration.whole = PIL_check_seconds_timer()};
struct BlendFileData *bfd = BKE_blendfile_read(filepath, &params, &bf_reports);
if (bfd != NULL) {
wm_file_read_pre(C, use_data, use_userdef);
@ -776,7 +872,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
* need to re-enable it here else drivers + registered scripts wont work. */
const int G_f_orig = G.f;
BKE_blendfile_read_setup(C, bfd, &params, reports);
BKE_blendfile_read_setup(C, bfd, &params, &bf_reports);
if (G.f != G_f_orig) {
const int flags_keep = G_FLAG_ALL_RUNTIME;
@ -807,6 +903,9 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
wm_file_read_post(C, false, false, use_data, use_userdef, false);
bf_reports.duration.whole = PIL_check_seconds_timer() - bf_reports.duration.whole;
file_read_reports_finalize(&bf_reports);
success = true;
}
}
@ -1087,10 +1186,15 @@ void wm_homefile_read(bContext *C,
.skip_flags = skip_flags | BLO_READ_SKIP_USERDEF,
};
struct BlendFileData *bfd = BKE_blendfile_read(filepath_startup, &params, NULL);
struct BlendFileData *bfd = BKE_blendfile_read(
filepath_startup, &params, &(BlendFileReadReport){NULL});
if (bfd != NULL) {
BKE_blendfile_read_setup_ex(
C, bfd, &params, NULL, update_defaults && use_data, app_template);
BKE_blendfile_read_setup_ex(C,
bfd,
&params,
&(BlendFileReadReport){NULL},
update_defaults && use_data,
app_template);
success = true;
}
}
@ -1120,7 +1224,7 @@ void wm_homefile_read(bContext *C,
struct BlendFileData *bfd = BKE_blendfile_read_from_memory(
datatoc_startup_blend, datatoc_startup_blend_size, &params, NULL);
if (bfd != NULL) {
BKE_blendfile_read_setup_ex(C, bfd, &params, NULL, true, NULL);
BKE_blendfile_read_setup_ex(C, bfd, &params, &(BlendFileReadReport){NULL}, true, NULL);
success = true;
}