Move forward with implementaiton
- The decision was made that blender and scenes can be found next to the benchmark running script. - Show real image of the currently rendering scene.
This commit is contained in:
@@ -76,6 +76,7 @@ def benchmarkBlenderWatched(command):
|
||||
|
||||
|
||||
def benchmarkScene(ctx, scene):
|
||||
progress.scene(scene)
|
||||
logger.BOLD("Begin benchmark of scene {}" . format(scene))
|
||||
# Get usable full path to the corresponding .blend file.
|
||||
blendfile = ctx.getSceneFilename(scene)
|
||||
@@ -111,6 +112,7 @@ def benchmarkScene(ctx, scene):
|
||||
util.humanReadableTimeDifference(
|
||||
stats.pipeline_render_time)))
|
||||
progress.step('')
|
||||
progress.scene('')
|
||||
return stats
|
||||
|
||||
|
||||
|
@@ -39,6 +39,9 @@ class DefaultProgressProvider:
|
||||
def step(self, step_name):
|
||||
pass
|
||||
|
||||
def scene(self, scene_name):
|
||||
pass
|
||||
|
||||
|
||||
PROGRESS_PROVIDER = DefaultProgressProvider()
|
||||
|
||||
@@ -56,10 +59,15 @@ def progressClear():
|
||||
"""
|
||||
PROGRESS_PROVIDER.clear()
|
||||
|
||||
|
||||
def step(step_name):
|
||||
PROGRESS_PROVIDER.step(step_name)
|
||||
|
||||
|
||||
def scene(scene_name):
|
||||
PROGRESS_PROVIDER.scene(scene_name)
|
||||
|
||||
|
||||
def setProvider(provider):
|
||||
"""
|
||||
Override progress provider with a given name.
|
||||
|
@@ -6,7 +6,7 @@ from threading import Thread, Lock
|
||||
import blf
|
||||
import bpy
|
||||
from bpy.types import Panel
|
||||
from bpy.props import IntProperty, FloatProperty
|
||||
from bpy.props import EnumProperty, IntProperty, FloatProperty
|
||||
from ..foundation import (benchrunner,
|
||||
buildbot,
|
||||
config,
|
||||
@@ -19,9 +19,21 @@ from ..foundation import context as benchmark_context
|
||||
################################################################################
|
||||
# Global state.
|
||||
|
||||
QUICK_SCENES = ["bmw27",
|
||||
"classroom"]
|
||||
|
||||
COMPLETE_SCENES = ["barbershop_interior",
|
||||
"bmw27",
|
||||
"classroom",
|
||||
"fishy_cat",
|
||||
"koro",
|
||||
"pavillon_barcelona",
|
||||
"victor"]
|
||||
|
||||
global_result_platform = None
|
||||
global_result_stats = None
|
||||
global_result_dict = None
|
||||
global_background_image_path = ""
|
||||
images = {}
|
||||
current_progress = 0.0
|
||||
progress_lock = Lock()
|
||||
@@ -88,9 +100,12 @@ def benchmark_draw_post_pixel(arg1, arg2):
|
||||
image_h = 370 * ui_scale
|
||||
image_y = window_height - image_h
|
||||
|
||||
splash_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
splash_filepath = os.path.join(splash_dir, 'splash.png')
|
||||
draw_image(splash_filepath, 0, image_y, window_width, image_h)
|
||||
if global_background_image_path:
|
||||
draw_image(global_background_image_path, 0, image_y, window_width, image_h)
|
||||
else:
|
||||
splash_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
splash_filepath = os.path.join(splash_dir, 'splash.png')
|
||||
draw_image(splash_filepath, 0, image_y, window_width, image_h)
|
||||
|
||||
if result_stats:
|
||||
blf.size(font_id, int(12 * ui_scale), 72)
|
||||
@@ -141,24 +156,36 @@ handle_draw = bpy.types.SpaceBenchmark.draw_handler_add(
|
||||
class ProgressProviderSink:
|
||||
current_progress = 0.0
|
||||
current_step = ''
|
||||
current_scene = ''
|
||||
|
||||
def __init__(self):
|
||||
self.current_progress = 0.0
|
||||
self.current_step = ''
|
||||
|
||||
def progress(self, count, total, prefix="", suffix=""):
|
||||
progress_lock.acquire()
|
||||
if total != 0:
|
||||
self.current_progress = float(count) / float(total)
|
||||
else:
|
||||
self.current_progress = 0.0
|
||||
progress_lock.release()
|
||||
|
||||
def clear(self):
|
||||
progress_lock.acquire()
|
||||
self.current_progress = 0
|
||||
progress_lock.release()
|
||||
|
||||
def step(self, step_name):
|
||||
progress_lock.acquire()
|
||||
if self.current_step != step_name:
|
||||
self.current_step = step_name
|
||||
self.current_progress = 0
|
||||
progress_lock.release()
|
||||
|
||||
def scene(self, scene_name):
|
||||
progress_lock.acquire()
|
||||
self.current_scene = scene_name
|
||||
progress_lock.release()
|
||||
|
||||
|
||||
class LoggerProviderSink:
|
||||
@@ -237,7 +264,7 @@ def convert_result_to_json_dict(ctx, results):
|
||||
stat['result'] = 'OK'
|
||||
else:
|
||||
stat = {'result': 'CRASH'}
|
||||
stat["scene"] = scene
|
||||
stat["scene_name"] = scene
|
||||
json_results['stats'] .append(stat)
|
||||
return json_results
|
||||
|
||||
@@ -316,14 +343,16 @@ class BENCHMARK_PT_main(Panel):
|
||||
|
||||
sub = col.row()
|
||||
sub.scale_y = 2.25
|
||||
sub.operator("benchmark.run", text="QUICK BENCHMARK")
|
||||
props = sub.operator("benchmark.run", text="QUICK BENCHMARK")
|
||||
props.run_type = 'QUICK'
|
||||
|
||||
col.separator()
|
||||
|
||||
sub = col.row()
|
||||
sub.emboss = 'NONE'
|
||||
sub.scale_y = 1.5
|
||||
sub.operator("benchmark.run", text="COMPLETE BENCHMARK (approx. 1.h)")
|
||||
props = sub.operator("benchmark.run", text="COMPLETE BENCHMARK (approx. 1.h)")
|
||||
props.run_type = 'COMPLETE'
|
||||
|
||||
sub = col.row()
|
||||
sub.emboss = 'NONE'
|
||||
@@ -341,6 +370,18 @@ class BENCHMARK_OT_run(bpy.types.Operator):
|
||||
bl_label = "Run Benchmark"
|
||||
bl_idname = "benchmark.run"
|
||||
|
||||
enum_run_type = (
|
||||
('QUICK', "QUICK", ""),
|
||||
('COMPLETE', "COMPLETE", ""),
|
||||
)
|
||||
|
||||
run_type: EnumProperty(
|
||||
name="Run Type",
|
||||
description="",
|
||||
items=enum_run_type,
|
||||
default='QUICK',
|
||||
)
|
||||
|
||||
benchmark_context = None
|
||||
thread = None
|
||||
timer = None
|
||||
@@ -354,7 +395,8 @@ class BENCHMARK_OT_run(bpy.types.Operator):
|
||||
logger.setProvider(self.logger_provider)
|
||||
|
||||
def update_status(self, context):
|
||||
global global_result_stats
|
||||
global global_result_stats, global_background_image_path
|
||||
progress_lock.acquire()
|
||||
step = self.progress_provider.current_step
|
||||
if step == 'WARM_UP':
|
||||
global_result_stats = "Rendering warm-up pass..."
|
||||
@@ -363,6 +405,16 @@ class BENCHMARK_OT_run(bpy.types.Operator):
|
||||
current_progress = self.progress_provider.current_progress
|
||||
global_result_stats = "Rendering..."
|
||||
context.area.tag_redraw()
|
||||
# Path to currently displayed background image.
|
||||
current_scene = self.progress_provider.current_scene
|
||||
if current_scene:
|
||||
global_background_image_path = os.path.join(
|
||||
self.benchmark_context.scenes_dir,
|
||||
current_scene,
|
||||
current_scene + ".png")
|
||||
else:
|
||||
global_background_image_path = ""
|
||||
progress_lock.release()
|
||||
|
||||
def done(self, context):
|
||||
global global_result_stats, current_progress
|
||||
@@ -383,11 +435,14 @@ class BENCHMARK_OT_run(bpy.types.Operator):
|
||||
if global_result_stats:
|
||||
global_result_stats += "\n"
|
||||
if stat["result"] == "OK":
|
||||
global_result_stats += "{}: {}" . format(stat["scene"],
|
||||
global_result_stats += "{}: {}" . format(stat["scene_name"],
|
||||
util.humanReadableTimeDifference(stat["total_render_time"]))
|
||||
else:
|
||||
global_result_stats += "{}: {}" . format(stat["scene"],
|
||||
global_result_stats += "{}: {}" . format(stat["scene_name"],
|
||||
stat["result"])
|
||||
# TOGO(sergey): Use some more nice picture for the final slide.
|
||||
global global_background_image_path
|
||||
global_background_image_path = ""
|
||||
# Tag for nice redraw
|
||||
current_progress = 0.0
|
||||
context.area.tag_redraw()
|
||||
@@ -414,13 +469,19 @@ class BENCHMARK_OT_run(bpy.types.Operator):
|
||||
self.setup_sink()
|
||||
wm = context.window_manager
|
||||
script_directory = os.path.dirname(os.path.realpath(__file__))
|
||||
benchmark_binary_dir = os.path.dirname(bpy.app.binary_path)
|
||||
benchmark_script_directory = os.path.dirname(script_directory)
|
||||
configure_script = os.path.join(benchmark_script_directory, "configure.py")
|
||||
configure_script = os.path.join(
|
||||
benchmark_script_directory, "configure.py")
|
||||
ctx = benchmark_context.Context()
|
||||
ctx.blender = "<blender>"
|
||||
# TODO(sergey): Update for MacOS and Windows.
|
||||
ctx.blender = os.path.join(benchmark_binary_dir, "blender", "blender")
|
||||
ctx.configure_script = configure_script
|
||||
ctx.scenes = ["<monkey>"]
|
||||
ctx.scenes_dir = "<scenes_folder>"
|
||||
if self.run_type == 'QUICK':
|
||||
ctx.scenes = QUICK_SCENES
|
||||
else:
|
||||
ctx.scenes = COMPLETE_SCENES
|
||||
ctx.scenes_dir = os.path.join(benchmark_binary_dir, "scenes")
|
||||
ctx.device_type = 'CPU'
|
||||
# Only applies for GPU, should match Cycles name
|
||||
ctx.device_name = ""
|
||||
|
Reference in New Issue
Block a user