[Bf-blender-cvs] [b464a82916c] override-recursive-resync: ReadFile stats: Add more data to new BlendReadFileReport structure.

Bastien Montagne noreply at git.blender.org
Wed Jun 9 14:57:08 CEST 2021


Commit: b464a82916ce2c8d04defd3bf7775c90ed8eefd1
Author: Bastien Montagne
Date:   Wed Jun 9 14:55:34 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rBb464a82916ce2c8d04defd3bf7775c90ed8eefd1

ReadFile stats: Add more data to new BlendReadFileReport structure.

===================================================================

M	source/blender/blenkernel/intern/blendfile.c
M	source/blender/blenkernel/intern/lib_override.c
M	source/blender/blenloader/BLO_readfile.h
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/readfile.h
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/windowmanager/intern/wm_files.c

===================================================================

diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index ae8dc5bffc0..ec9abdbbfc9 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -36,6 +36,8 @@
 #include "BLI_system.h"
 #include "BLI_utildefines.h"
 
+#include "PIL_time.h"
+
 #include "IMB_colormanagement.h"
 
 #include "BKE_addon.h"
@@ -398,11 +400,21 @@ static void setup_app_data(bContext *C,
   }
 
   if (mode != LOAD_UNDO && !USER_EXPERIMENTAL_TEST(&U, no_override_auto_resync)) {
+    if (reports != NULL) {
+      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);
+
+    if (reports != NULL) {
+      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);
   }
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index bda97f82de2..6b3ee8f5c1f 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -60,6 +60,8 @@
 #include "BLI_task.h"
 #include "BLI_utildefines.h"
 
+#include "PIL_time.h"
+
 #include "RNA_access.h"
 #include "RNA_types.h"
 
@@ -1442,6 +1444,9 @@ static void lib_override_library_main_resync_on_library_indirect_level(
     const int library_indirect_level,
     BlendFileReadReport *reports)
 {
+  const bool do_reports_timing = (library_indirect_level != 0 && reports != NULL);
+  const double init_time = do_reports_timing ? PIL_check_seconds_timer() : 0.0;
+
   BKE_main_relations_create(bmain, 0);
   BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
 
@@ -1558,6 +1563,10 @@ static void lib_override_library_main_resync_on_library_indirect_level(
     }
     FOREACH_MAIN_LISTBASE_END;
   }
+
+  if (do_reports_timing) {
+    reports->duration_lib_overrides_recursive_resync += PIL_check_seconds_timer() - init_time;
+  }
 }
 
 static int lib_override_sort_libraries_func(LibraryIDLinkCallbackData *cb_data)
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 38de20f2449..4e12508ec8b 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -94,14 +94,15 @@ typedef struct BlendFileReadReport {
   struct ReportList *reports;
 
   /* Timing informations .*/
-  float duration_whole;
-  float duration_libraries;
-  float duration_lib_overrides;
-  float duration_lib_overrides_resync;
-  float duration_lib_overrides_recursive_resync;
+  double duration_whole;
+  double duration_libraries;
+  double duration_lib_overrides;
+  double duration_lib_overrides_resync;
+  double duration_lib_overrides_recursive_resync;
 
   /* Some numbers of IDs that ended up in a specific state, or required some specific process
    * during this file read. */
+  int num_missing_libraries;
   int num_missing_linked_id;
   int num_resynced_lib_overrides;
 
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 8ba8a0693f2..8a4cca9af93 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -71,6 +71,8 @@
 #include "BLI_mmap.h"
 #include "BLI_threads.h"
 
+#include "PIL_time.h"
+
 #include "BLT_translation.h"
 
 #include "BKE_anim_data.h"
@@ -4205,6 +4207,9 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
   }
 
   if ((fd->skip_flags & BLO_READ_SKIP_DATA) == 0) {
+    if (fd->reports != NULL) {
+      fd->reports->duration_libraries = PIL_check_seconds_timer();
+    }
     read_libraries(fd, &mainlist);
 
     blo_join_main(&mainlist);
@@ -4212,6 +4217,11 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
     lib_link_all(fd, bfd->main);
     after_liblink_merged_bmain_process(bfd->main);
 
+    if (fd->reports != NULL) {
+      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
@@ -4248,9 +4258,18 @@ 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! */
+      if (fd->reports != NULL) {
+        fd->reports->duration_lib_overrides = PIL_check_seconds_timer();
+      }
+
       BKE_lib_override_library_main_validate(bfd->main,
                                              fd->reports != NULL ? fd->reports->reports : NULL);
       BKE_lib_override_library_main_update(bfd->main);
+
+      if (fd->reports != NULL) {
+        fd->reports->duration_lib_overrides = PIL_check_seconds_timer() -
+                                              fd->reports->duration_lib_overrides;
+      }
     }
 
     BKE_collections_after_lib_link(bfd->main);
@@ -5340,7 +5359,9 @@ static void read_library_linked_id(
                      id->name + 2,
                      mainvar->curlib->filepath_abs,
                      library_parent_filepath(mainvar->curlib));
-    basefd->library_id_missing_count++;
+    if (basefd->reports != NULL) {
+      basefd->reports->num_missing_linked_id++;
+    }
 
     /* Generate a placeholder for this ID (simplified version of read_libblock actually...). */
     if (r_id) {
@@ -5444,7 +5465,8 @@ 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 != NULL ? basefd->reports->reports : NULL);
 
     /* Needed for library_append and read_libraries. */
     BLI_strncpy(fd->relabase, mainptr->curlib->filepath_abs, sizeof(fd->relabase));
@@ -5457,7 +5479,8 @@ 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 != NULL ? basefd->reports->reports : NULL);
   }
 
   if (fd) {
@@ -5495,7 +5518,9 @@ 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++;
+    if (basefd->reports != NULL) {
+      basefd->reports->num_missing_libraries++;
+    }
   }
 
   return fd;
@@ -5590,13 +5615,14 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
   }
   BKE_main_free(main_newid);
 
-  if (basefd->library_file_missing_count != 0 || basefd->library_id_missing_count != 0) {
-    BKE_reportf(basefd->reports != NULL ? basefd->reports->reports : NULL,
+  if (basefd->reports != NULL && (basefd->reports->num_missing_libraries != 0 ||
+                                  basefd->reports->num_missing_linked_id != 0)) {
+    BKE_reportf(basefd->reports->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);
+                basefd->reports->num_missing_libraries,
+                basefd->reports->num_missing_linked_id);
   }
 }
 
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 9a87387069d..0fc71760b44 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -146,10 +146,6 @@ typedef struct FileData {
   struct IDNameLib_Map *old_idmap;
 
   struct BlendFileReadReport *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;
 } FileData;
 
 #define SIZEOFBLENDERHEADER 12
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index cf082393803..400405886e0 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -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 transpa

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list