Add Peak Memory as render stamp option

This commit adds Peak Memory to the stamp options, the value is the same one that is already shown in the image viewer.

Requested by @nutel.

Reviewers: campbellbarton

Subscribers: campbellbarton, nutel

Differential Revision: https://developer.blender.org/D1989
This commit is contained in:
Lukas Stockner 2016-05-19 21:39:22 +02:00
parent ad14c471eb
commit 75a31c3670
5 changed files with 39 additions and 2 deletions

View File

@ -360,6 +360,7 @@ class RENDER_PT_stamp(RenderButtonsPanel, Panel):
col.prop(rd, "use_stamp_render_time", text="RenderTime")
col.prop(rd, "use_stamp_frame", text="Frame")
col.prop(rd, "use_stamp_scene", text="Scene")
col.prop(rd, "use_stamp_memory", text="Memory")
col = split.column()
col.prop(rd, "use_stamp_camera", text="Camera")

View File

@ -1748,6 +1748,7 @@ typedef struct StampData {
char scene[STAMP_NAME_SIZE];
char strip[STAMP_NAME_SIZE];
char rendertime[STAMP_NAME_SIZE];
char memory[STAMP_NAME_SIZE];
} StampData;
#undef STAMP_NAME_SIZE
@ -1869,6 +1870,13 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
else {
stamp_data->rendertime[0] = '\0';
}
if (stats && (scene->r.stamp & R_STAMP_MEMORY)) {
BLI_snprintf(stamp_data->memory, sizeof(stamp_data->memory), do_prefix ? "Peak Memory %.2fM" : "%.2fM", stats->mem_peak);
}
else {
stamp_data->memory[0] = '\0';
}
}
}
@ -1943,6 +1951,12 @@ static void stampdata_from_template(StampData *stamp_data,
else {
stamp_data->rendertime[0] = '\0';
}
if (scene->r.stamp & R_STAMP_MEMORY) {
BLI_snprintf(stamp_data->memory, sizeof(stamp_data->memory), "Peak Memory %s", stamp_data_template->memory);
}
else {
stamp_data->memory[0] = '\0';
}
}
void BKE_image_stamp_buf(
@ -2056,6 +2070,21 @@ void BKE_image_stamp_buf(
}
/* Top left corner, below File, Date, Rendertime */
if (TEXT_SIZE_CHECK(stamp_data.memory, w, h)) {
y -= h;
/* and space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
BLF_position(mono, x, y + y_ofs, 0.0);
BLF_draw_buffer(mono, stamp_data.memory, BLF_DRAW_STR_DUMMY_MAX);
/* the extra pixel for background. */
y -= BUFF_MARGIN_Y * 2;
}
/* Top left corner, below File, Date, Memory, Rendertime */
BLF_enable(mono, BLF_WORD_WRAP);
if (TEXT_SIZE_CHECK_WORD_WRAP(stamp_data.note, w, h)) {
y -= h;
@ -2219,6 +2248,7 @@ void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCall
CALL(scene, "Scene");
CALL(strip, "Strip");
CALL(rendertime, "RenderTime");
CALL(memory, "Memory");
#undef CALL
}

View File

@ -545,7 +545,7 @@ void BKE_scene_init(Scene *sce)
sce->r.bake.im_format.compress = 15;
sce->r.scemode = R_DOCOMP | R_DOSEQ | R_EXTENSION;
sce->r.stamp = R_STAMP_TIME | R_STAMP_FRAME | R_STAMP_DATE | R_STAMP_CAMERA | R_STAMP_SCENE | R_STAMP_FILENAME | R_STAMP_RENDERTIME;
sce->r.stamp = R_STAMP_TIME | R_STAMP_FRAME | R_STAMP_DATE | R_STAMP_CAMERA | R_STAMP_SCENE | R_STAMP_FILENAME | R_STAMP_RENDERTIME | R_STAMP_MEMORY;
sce->r.stamp_font_id = 12;
sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f;
sce->r.fg_stamp[3] = 1.0f;

View File

@ -1714,9 +1714,10 @@ typedef struct Scene {
#define R_STAMP_RENDERTIME 0x0400
#define R_STAMP_CAMERALENS 0x0800
#define R_STAMP_STRIPMETA 0x1000
#define R_STAMP_MEMORY 0x2000
#define R_STAMP_ALL (R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_CAMERA|R_STAMP_SCENE| \
R_STAMP_NOTE|R_STAMP_MARKER|R_STAMP_FILENAME|R_STAMP_SEQSTRIP| \
R_STAMP_RENDERTIME|R_STAMP_CAMERALENS)
R_STAMP_RENDERTIME|R_STAMP_CAMERALENS|R_STAMP_MEMORY)
/* alphamode */
#define R_ADDSKY 0

View File

@ -5968,6 +5968,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Strip Metadata", "Use metadata from the strips in the sequencer");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "use_stamp_memory", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_MEMORY);
RNA_def_property_ui_text(prop, "Stamp Peak Memory", "Include the peak memory usage in image metadata");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "stamp_font_size", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "stamp_font_id");
RNA_def_property_range(prop, 8, 64);