[Bf-blender-cvs] [33e5156] alembic: Estimation for overall data size of Alembic components.
Lukas Tönne
noreply at git.blender.org
Tue Apr 21 17:28:34 CEST 2015
Commit: 33e515671acec007b66565381e5895e66ebf558a
Author: Lukas Tönne
Date: Tue Apr 21 17:26:33 2015 +0200
Branches: alembic
https://developer.blender.org/rB33e515671acec007b66565381e5895e66ebf558a
Estimation for overall data size of Alembic components.
This is not accurate, but should give some indication about the most
expensive parts of a cache, so it can be optimized efficiently.
===================================================================
M release/scripts/startup/bl_ui/properties_object.py
M source/blender/makesdna/DNA_cache_library_types.h
M source/blender/makesrna/intern/rna_cache_library.c
M source/blender/pointcache/alembic/abc_info.cpp
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index 8071b6a..5e231d4 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -501,6 +501,15 @@ class OBJECT_PT_cache_library(ObjectButtonsPanel, Panel):
layout.prop(md, "use_double_sided")
+
+# Simple human-readable size (based on http://stackoverflow.com/a/1094933)
+def sizeof_fmt(num, suffix='B'):
+ for unit in ['','K','M','G','T','P','E','Z']:
+ if abs(num) < 1024.0:
+ return "%3.1f%s%s" % (num, unit, suffix)
+ num /= 1024.0
+ return "%.1f%s%s" % (num, 'Y', suffix)
+
class OBJECT_PT_cache_archive_info(ObjectButtonsPanel, Panel):
bl_label = "Cache Archive Info"
bl_options = {'DEFAULT_CLOSED'}
@@ -526,14 +535,40 @@ class OBJECT_PT_cache_archive_info(ObjectButtonsPanel, Panel):
self.draw_node_structure(context, layout, child, indent + 1)
- def draw_node_info(self, context, layout, node):
- row = layout.row(align=True)
- row.prop(node, "name", text="")
- row.prop(node, "type", text="")
+ info_columns = ['Name', 'Node', 'Samples', 'Size', 'Data', '', 'Array Size']
+
+ def draw_node_info(self, context, layout, node, column):
+ if column == 0:
+ layout.prop(node, "name", text="")
+ if column == 1:
+ layout.prop(node, "type", text="")
+ if column == 2:
+ if node.type in {'SCALAR_PROPERTY', 'ARRAY_PROPERTY'}:
+ layout.prop(node, "samples", text="")
+ else:
+ layout.label(" ")
+ if column == 3:
+ size = int(node.bytes_size)
+ layout.label(sizeof_fmt(size))
+ if column == 4:
+ if node.type in {'SCALAR_PROPERTY', 'ARRAY_PROPERTY'}:
+ layout.prop(node, "datatype", text="")
+ else:
+ layout.label(" ")
+ if column == 5:
+ if node.type in {'SCALAR_PROPERTY', 'ARRAY_PROPERTY'}:
+ layout.prop(node, "datatype_extent", text="")
+ else:
+ layout.label(" ")
+ if column == 6:
+ if node.type in {'ARRAY_PROPERTY'}:
+ layout.prop(node, "array_size", text="")
+ else:
+ layout.label(" ")
if node.expand:
for child in node.child_nodes:
- self.draw_node_info(context, layout, child)
+ self.draw_node_info(context, layout, child, column)
def draw(self, context):
ob = context.object
@@ -558,8 +593,15 @@ class OBJECT_PT_cache_archive_info(ObjectButtonsPanel, Panel):
if info.root_node:
row = layout.row()
- self.draw_node_structure(context, row.column(), info.root_node, 0)
- self.draw_node_info(context, row.column(), info.root_node)
+
+ col = row.column()
+ col.label(" ")
+ self.draw_node_structure(context, col, info.root_node, 0)
+
+ for i, column in enumerate(self.info_columns):
+ col = row.column()
+ col.label(column)
+ self.draw_node_info(context, col, info.root_node, i)
class OBJECT_PT_relations_extras(ObjectButtonsPanel, Panel):
diff --git a/source/blender/makesdna/DNA_cache_library_types.h b/source/blender/makesdna/DNA_cache_library_types.h
index f8f49bb..d76aa4c 100644
--- a/source/blender/makesdna/DNA_cache_library_types.h
+++ b/source/blender/makesdna/DNA_cache_library_types.h
@@ -119,7 +119,17 @@ typedef struct CacheArchiveInfoNode {
ListBase child_nodes;
- int64_t bytes_size;
+ int64_t bytes_size; /* overall size of data stored in this node and children */
+
+ char datatype_name[64];
+ short datatype_extent;
+ short pad2;
+
+ int num_samples;
+
+ /* array properties */
+ int array_size;
+ int pad3;
} CacheArchiveInfoNode;
typedef enum eCacheArchiveInfoNode_Flag {
diff --git a/source/blender/makesrna/intern/rna_cache_library.c b/source/blender/makesrna/intern/rna_cache_library.c
index 4e634ed..521f2d5 100644
--- a/source/blender/makesrna/intern/rna_cache_library.c
+++ b/source/blender/makesrna/intern/rna_cache_library.c
@@ -234,6 +234,20 @@ static int rna_HairSimulationCacheModifier_hair_system_poll(PointerRNA *ptr, Poi
return true;
}
+static void rna_CacheArchiveInfoNode_bytes_size_get(PointerRNA *ptr, char *value)
+{
+ CacheArchiveInfoNode *node = ptr->data;
+ BLI_snprintf(value, MAX_NAME, "%lu", node->bytes_size);
+}
+
+static int rna_CacheArchiveInfoNode_bytes_size_length(PointerRNA *ptr)
+{
+ char buf[MAX_NAME];
+ /* theoretically could do a dummy BLI_snprintf here, but BLI does not allow NULL buffer ... */
+ CacheArchiveInfoNode *node = ptr->data;
+ return BLI_snprintf(buf, sizeof(buf), "%lu", node->bytes_size);
+}
+
#else
static void rna_def_hair_sim_params(BlenderRNA *brna)
@@ -611,6 +625,32 @@ static void rna_def_cache_archive_info_node(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", eCacheArchiveInfoNode_Flag_Expand);
RNA_def_property_ui_text(prop, "Expand", "Show contents of the node");
RNA_def_property_update(prop, 0, "rna_CacheArchiveInfo_update");
+
+ /* XXX this is a 64bit integer, not supported nicely by RNA,
+ * but string encoding is sufficient for feedback
+ */
+ prop = RNA_def_property(srna, "bytes_size", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_funcs(prop, "rna_CacheArchiveInfoNode_bytes_size_get", "rna_CacheArchiveInfoNode_bytes_size_length", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Bytes Size", "Overall size of the node data in bytes");
+
+ prop = RNA_def_property(srna, "datatype", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "datatype_name");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Datatype", "Type of values stored in the property");
+
+ prop = RNA_def_property(srna, "datatype_extent", PROP_INT, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Datatype Extent", "Array extent of a single data element");
+
+ prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "num_samples");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Samples", "Number of samples stored for the property");
+
+ prop = RNA_def_property(srna, "array_size", PROP_INT, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Array Size", "Maximum array size for any sample of the property");
}
static void rna_def_cache_archive_info(BlenderRNA *brna)
diff --git a/source/blender/pointcache/alembic/abc_info.cpp b/source/blender/pointcache/alembic/abc_info.cpp
index 911159b..721623e 100644
--- a/source/blender/pointcache/alembic/abc_info.cpp
+++ b/source/blender/pointcache/alembic/abc_info.cpp
@@ -63,6 +63,7 @@
#include "alembic.h"
extern "C" {
+#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_cache_library.h"
@@ -289,38 +290,27 @@ static void info_nodes_array_property(CacheArchiveInfo *info, PROP iProp, CacheA
{
CacheArchiveInfoNode *node = BKE_cache_archive_info_add_node(info, parent, eCacheArchiveInfoNode_Type_ArrayProperty, iProp.getName().c_str());
-#if 0
- std::string ptype = "ArrayProperty ";
- size_t asize = 0;
-
- AbcA::ArraySamplePtr samp;
- index_t maxSamples = iProp.getNumSamples();
- for (index_t i = 0 ; i < maxSamples; ++i) {
+ index_t num_samples = iProp.getNumSamples();
+ size_t max_array_size = 0;
+ size_t tot_array_size = 0;
+ for (index_t i = 0; i < num_samples; ++i) {
+ AbcA::ArraySamplePtr samp;
iProp.get(samp, ISampleSelector(i));
- asize = samp->size();
+ size_t array_size = samp->size();
+ max_array_size = std::max(max_array_size, array_size);
+ tot_array_size += array_size;
}
- std::string mdstring = "interpretation=";
- mdstring += iProp.getMetaData().get("interpretation");
+ const DataType &datatype = iProp.getDataType();
- std::stringstream dtype;
- dtype << "datatype=";
- dtype << iProp.getDataType();
+ node->num_samples = num_samples;
+ BLI_strncpy(node->datatype_name, PODName(datatype.getPod()), sizeof(node->datatype_name));
+ node->datatype_extent = (short)datatype.getExtent();
+ node->bytes_size = datatype.getNumBytes() * tot_array_size;
+ node->array_size = max_array_size;
- std::stringstream asizestr;
- asizestr << ";arraysize=";
- asizestr << asize;
-
- mdstring += g_sep;
-
- mdstring += dtype.str();
-
- mdstring += asizestr.str();
-
- ss << iIndent << " " << ptype << "name=" << iProp.getName()
- << g_sep << mdstring << g_sep << "numsamps="
- << iProp.getNumSamples() << g_endl;
-#endif
+ if (parent)
+ parent->bytes_size += node->bytes_size;
}
template <class PROP>
@@ -328,41 +318,17 @@ static void info_nodes_scalar_property(CacheArchiveInfo *info, PROP iProp, Cache
{
CacheArchiveInfoNode *node = BKE_cache_archive_info_add_node(info, parent, eCacheArchiveInfoNode_Type_ScalarProperty, iProp.getName().c_str());
-#if 0
- std::string ptype = "ScalarProperty ";
- size_t asize = 0;
+ index_t num_samples = iProp.getNumSamples();
- const AbcA::DataType &dt = iProp.getDataType();
- const Alembic::Util ::uint8_t extent = dt.getExtent();
- Alembic::Util::Dimensions dims(extent);
- AbcA::ArraySamplePtr samp = AbcA::AllocateArraySample( dt, dims );
- index_t maxSamples = iProp.getNumSamples();
- for (index_t i = 0 ; i < maxSamples; ++i) {
- iProp.get(const_cast<void *>(samp->getData()), ISampleSelector(i));
- asize = samp->size();
- }
-
- std::string mdstring = "interpretation=";
- mdstring += iProp.getMetaData().get("interpretation");
-
- std::stringstream dtype;
- dtype << "datatype=";
- dtype << dt;
+ const DataType &datatype = iProp.getDataType();
- std::stringstream asizestr;
- asizestr << ";arraysize=";
- asizestr << asize;
-
- mdstring += g_sep;
-
- mdstring += dtype.str();
+ node->num_samples = num_samples;
+ BLI_strncpy(node->datatype_name, PODName(datatype.getPod()), sizeof(n
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list