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

View File

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