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,10 +132,12 @@ 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:
|
||||||
|
render_process_finished = True
|
||||||
|
|
||||||
# Check for render cancel
|
# Check for render cancel
|
||||||
if self.test_break():
|
if self.test_break():
|
||||||
self._process.terminate()
|
self._process.terminate()
|
||||||
|
@ -144,10 +146,10 @@ class PsychopathRender(bpy.types.RenderEngine):
|
||||||
# Get render output from stdin
|
# Get render output from stdin
|
||||||
tmp = self._process.stdout.read1(2**16)
|
tmp = self._process.stdout.read1(2**16)
|
||||||
if len(tmp) == 0:
|
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
|
continue
|
||||||
else:
|
|
||||||
break
|
|
||||||
output += tmp
|
output += tmp
|
||||||
outputs = output.split(b'DIV\n')
|
outputs = output.split(b'DIV\n')
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user