Fixed a PsychoBlend bug that resulted in render not being fully displayed.

Getting the interplay between the reading the process output and
polling to see if it's finished is a tad tricky.  I think I got
it right this time.
This commit is contained in:
Nathan Vegdahl 2017-06-03 01:12:21 -07:00
parent f84d093f66
commit a3332d4f6a
2 changed files with 29 additions and 18 deletions

View File

@ -132,10 +132,12 @@ class PsychopathRender(bpy.types.RenderEngine):
# Process output from rendering process
reached_first_bucket = False
output = b""
while self._process.poll() == None:
# Wait for render process output while checking for render
# cancellation
while True:
render_process_finished = False
all_output_consumed = False
while not (render_process_finished and all_output_consumed):
if self._process.poll() != None:
render_process_finished = True
# Check for render cancel
if self.test_break():
self._process.terminate()
@ -144,10 +146,10 @@ class PsychopathRender(bpy.types.RenderEngine):
# Get render output from stdin
tmp = self._process.stdout.read1(2**16)
if len(tmp) == 0:
time.sleep(0.01)
time.sleep(0.0001) # Don't spin on the CPU
if render_process_finished:
all_output_consumed = True
continue
else:
break
output += tmp
outputs = output.split(b'DIV\n')

View File

@ -264,6 +264,14 @@ impl<'a> Renderer<'a> {
}
stats.sample_writing_time += timer.tick() as f64;
// Pre-calculate base64 encoding if needed
let base64_enc = if do_blender_output {
use color::xyz_to_rec709e;
Some(img_bucket.rgba_base64(xyz_to_rec709e))
} else {
None
};
// Print render progress, and image data if doing blender output
let guard = pixels_rendered.lock().unwrap();
let mut pr = (*guard).get();
@ -276,15 +284,16 @@ impl<'a> Renderer<'a> {
let old_string = format!("{:.2}%", percentage_old);
let new_string = format!("{:.2}%", percentage_new);
if do_blender_output {
use color::xyz_to_rec709e;
if let Some(bucket_data) = base64_enc {
// If doing Blender output
println!("DIV");
println!("{}", new_string);
println!("{} {} {} {}", min.0, min.1, max.0, max.1);
println!("{}", img_bucket.rgba_base64(xyz_to_rec709e));
println!("{}", bucket_data);
println!("BUCKET_END");
println!("DIV");
} else {
// If doing console output
if new_string != old_string {
print!("\r{}", new_string);
}