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:
parent
f84d093f66
commit
a3332d4f6a
|
@ -132,22 +132,24 @@ 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:
|
||||
# Check for render cancel
|
||||
if self.test_break():
|
||||
self._process.terminate()
|
||||
break
|
||||
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
|
||||
|
||||
# Get render output from stdin
|
||||
tmp = self._process.stdout.read1(2**16)
|
||||
if len(tmp) == 0:
|
||||
time.sleep(0.01)
|
||||
continue
|
||||
else:
|
||||
break
|
||||
# Check for render cancel
|
||||
if self.test_break():
|
||||
self._process.terminate()
|
||||
break
|
||||
|
||||
# Get render output from stdin
|
||||
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
|
||||
outputs = output.split(b'DIV\n')
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user