Add final srceen to the benchmark process

Also moved blocks of information around.
This commit is contained in:
2018-08-03 17:46:00 +02:00
parent e6dfebbfd7
commit eca235f3df
3 changed files with 118 additions and 20 deletions

View File

@@ -112,6 +112,7 @@ def benchmarkScene(ctx, scene):
util.humanReadableTimeDifference(
stats.pipeline_render_time)))
progress.step('')
progress.scene_stats(scene, stats)
progress.scene('')
return stats

View File

@@ -42,6 +42,9 @@ class DefaultProgressProvider:
def scene(self, scene_name):
pass
def scene_stats(self, scene_name, stats):
pass
PROGRESS_PROVIDER = DefaultProgressProvider()
@@ -67,6 +70,9 @@ def step(step_name):
def scene(scene_name):
PROGRESS_PROVIDER.scene(scene_name)
def scene_stats(scene_name, stats):
PROGRESS_PROVIDER.scene_stats(scene_name, stats)
def setProvider(provider):
"""

View File

@@ -31,9 +31,11 @@ COMPLETE_SCENES = ["barbershop_interior",
"victor"]
global_result_platform = None
global_progress_status = None
global_result_stats = None
global_result_dict = None
global_background_image_path = ""
global_scene_status = {}
images = {}
current_progress = 0.0
progress_lock = Lock()
@@ -87,8 +89,10 @@ def draw_image(filepath, x, y, w, h):
def benchmark_draw_post_pixel(arg1, arg2):
global progress_lock
progress_lock.acquire()
progress_status = global_progress_status
result_platform = global_result_platform
result_stats = global_result_stats
result_dict = global_result_dict
progress_lock.release()
ui_scale = bpy.context.user_preferences.system.ui_scale
@@ -107,16 +111,38 @@ def benchmark_draw_post_pixel(arg1, arg2):
splash_filepath = os.path.join(splash_dir, 'splash.png')
draw_image(splash_filepath, 0, image_y, window_width, image_h)
if result_stats:
if result_dict:
x = 0.5 * window_width
y = 0.70 * window_height
score = 0
for stat in global_result_dict["stats"]:
if stat["result"] == "OK":
score += stat["total_render_time"]
else:
score = -1
blf.size(font_id, int(32 * ui_scale), 72)
if score >= 0:
draw_text_center("Render time is: {}" . format(
util.humanReadableTimeDifference(score)), x, y)
else:
# TODO(sergey): What is the score?
draw_text_center("CRASH :(", x, y)
elif result_stats or result_platform or progress_status:
blf.size(font_id, int(12 * ui_scale), 72)
x = 50.0 * ui_scale
y = image_y - 20 * ui_scale
# Stats
draw_text_multiline(result_platform, x, y)
draw_text_multiline(result_stats, 0.5 * window_width + x, y)
if result_platform:
draw_text_multiline(result_platform, 0.5 * window_width + x, y)
if result_stats:
draw_text_multiline(result_stats, x, y)
# Progress
progress_x = 0.0
progress_y = image_y + 1
progress_w = window_width * current_progress
@@ -124,6 +150,14 @@ def benchmark_draw_post_pixel(arg1, arg2):
progress_color = [0.8, 1.0, 1.0, 0.2]
draw_rect(progress_x, progress_y, progress_w, progress_h, progress_color)
# Current status
if global_progress_status:
blf.size(font_id, int(18 * ui_scale), 72)
draw_text_multiline(global_progress_status,
progress_x + 8.0 * ui_scale,
progress_y + progress_h + int(22 * ui_scale))
else:
# Title
x = 0.5 * window_width
@@ -185,6 +219,19 @@ class ProgressProviderSink:
def scene(self, scene_name):
progress_lock.acquire()
self.current_scene = scene_name
if scene_name:
global global_scene_status
global_scene_status[scene_name] = "Rendering..."
progress_lock.release()
def scene_stats(self, scene_name, stats):
progress_lock.acquire()
global global_scene_status
if stats:
global_scene_status[scene_name] = util.humanReadableTimeDifference(
stats.total_render_time)
else:
global_scene_status[scene_name] = "Crashed :("
progress_lock.release()
@@ -270,10 +317,10 @@ def convert_result_to_json_dict(ctx, results):
def benchmark_thread(ctx):
global progress_lock, global_result_platform, global_result_stats
global progress_lock, global_result_platform, global_progress_status
progress_lock.acquire()
global_result_stats = "Collecting system information..."
global_progress_status = "Collecting system information..."
progress_lock.release()
# This is all system information Blender knows.
@@ -295,7 +342,7 @@ def benchmark_thread(ctx):
progress_lock.release()
progress_lock.acquire()
global_result_stats = "Prepating render..."
global_progress_status = "Prepating render..."
progress_lock.release()
all_stats = benchrunner.benchmarkAll(ctx)
@@ -322,14 +369,7 @@ class BENCHMARK_PT_main(Panel):
bl_space_type = 'BENCHMARK'
bl_region_type = 'WINDOW'
def draw(self, context):
global progress_lock
progress_lock.acquire()
if global_result_stats:
progress_lock.release()
return
progress_lock.release()
def draw_welcome(self, context):
layout = self.layout
split = layout.split(0.65)
@@ -354,6 +394,24 @@ class BENCHMARK_PT_main(Panel):
props = sub.operator("benchmark.run", text="COMPLETE BENCHMARK (approx. 1.h)")
props.run_type = 'COMPLETE'
split.label()
def draw_submit(self, context):
layout = self.layout
split = layout.split(0.65)
split.label()
split = split.split(0.97)
col = split.column()
sub = col.row()
sub.scale_y = 64.0
sub.separator()
sub = col.row()
sub.scale_y = 2.25
sub.operator("benchmark.share", text="SHARE")
sub = col.row()
sub.emboss = 'NONE'
sub.scale_y = 1.5
@@ -361,6 +419,21 @@ class BENCHMARK_PT_main(Panel):
split.label()
def draw(self, context):
screen_index = 0
global progress_lock
progress_lock.acquire()
if global_result_dict:
screen_index = 2
elif global_result_stats or global_progress_status:
screen_index = 1
progress_lock.release()
if screen_index == 0:
self.draw_welcome(context)
elif screen_index == 2:
self.draw_submit(context)
################################################################################
# Operator
@@ -395,15 +468,15 @@ class BENCHMARK_OT_run(bpy.types.Operator):
logger.setProvider(self.logger_provider)
def update_status(self, context):
global global_result_stats, global_background_image_path
global global_progress_status, global_background_image_path
progress_lock.acquire()
step = self.progress_provider.current_step
if step == 'WARM_UP':
global_result_stats = "Rendering warm-up pass..."
global_progress_status = "Rendering warm-up pass..."
elif step == 'RUN':
global current_progress
current_progress = self.progress_provider.current_progress
global_result_stats = "Rendering..."
global_progress_status = "Rendering..."
context.area.tag_redraw()
# Path to currently displayed background image.
current_scene = self.progress_provider.current_scene
@@ -414,10 +487,16 @@ class BENCHMARK_OT_run(bpy.types.Operator):
current_scene + ".png")
else:
global_background_image_path = ""
# Update per-scene status string
global global_result_stats
global_result_stats = ""
for scene in global_scene_status:
global_result_stats += "{}: {}\n" . format(
scene, global_scene_status[scene])
progress_lock.release()
def done(self, context):
global global_result_stats, current_progress
global global_progress_status, global_result_stats, current_progress
wm = context.window_manager
wm.event_timer_remove(self.timer)
# Restore all modifications to the benchmark foundation.
@@ -444,6 +523,7 @@ class BENCHMARK_OT_run(bpy.types.Operator):
global global_background_image_path
global_background_image_path = ""
# Tag for nice redraw
global_progress_status = ""
current_progress = 0.0
context.area.tag_redraw()
@@ -459,9 +539,10 @@ class BENCHMARK_OT_run(bpy.types.Operator):
return {'PASS_THROUGH'}
def invoke(self, context, event):
global global_result_platform, global_result_stats
global global_result_platform, global_progress_status
global global_scene_status
global_result_platform = ""
global_result_stats = "Initializing..."
global_progress_status = "Initializing..."
context.area.tag_redraw()
# Before doing anything, make sure we have all sinks set up, so we do
@@ -481,6 +562,8 @@ class BENCHMARK_OT_run(bpy.types.Operator):
ctx.scenes = QUICK_SCENES
else:
ctx.scenes = COMPLETE_SCENES
for scene in ctx.scenes:
global_scene_status[scene] = "N/A"
ctx.scenes_dir = os.path.join(benchmark_binary_dir, "scenes")
ctx.device_type = 'CPU'
# Only applies for GPU, should match Cycles name
@@ -529,6 +612,13 @@ class BENCHMARK_OT_save(bpy.types.Operator):
wm.fileselect_add(self)
return {'RUNNING_MODAL'}
class BENCHMARK_OT_share(bpy.types.Operator):
bl_idname = "benchmark.share"
bl_label = "Share Benchmark Result"
def invoke(self, context, event):
return {'FINISHED'}
################################################################################
# Tweak User Preferences
@@ -550,4 +640,5 @@ classes = (
BENCHMARK_PT_main,
BENCHMARK_OT_run,
BENCHMARK_OT_save,
BENCHMARK_OT_share,
)