mirror of
https://github.com/stevenrobertson/cuburn.git
synced 2025-06-30 13:26:27 -04:00
Rearrange the main render loop... again.
Using one stream with two pagelocked host buffers allows us to keep the GPU work queue full without pegging the CPU, and also reduces the incidences where a host buffer will get overwritten before it can be written. devtid() was flaky, so this patch also introduces a ringbuffer to handle the 'slots' concept. It also introduces an adaptive number of temporal samples, which improves efficiency but also killed the assumption that (ntemporal_samples % 256 == 0), which required some additional fixes.
This commit is contained in:
18
run_job.py
18
run_job.py
@ -27,12 +27,13 @@ np.set_printoptions(precision=5, edgeitems=20)
|
||||
|
||||
real_stdout = sys.stdout
|
||||
|
||||
def save(time, raw, pfx):
|
||||
noalpha = raw[:,:,:3]
|
||||
name = pfx + '%05d' % time
|
||||
def save(rimg, pfx):
|
||||
noalpha = rimg.buf[:,:,:3]
|
||||
name = pfx + str(rimg.idx)
|
||||
img = scipy.misc.toimage(noalpha, cmin=0, cmax=1)
|
||||
img.save(name+'.png')
|
||||
print name
|
||||
print name, rimg.gpu_time
|
||||
sys.stdout.flush()
|
||||
|
||||
def main(jobfilepath, outprefix):
|
||||
# This includes the genomes and other cruft, a dedicated reader will be
|
||||
@ -40,16 +41,15 @@ def main(jobfilepath, outprefix):
|
||||
info = cuburn.genome.load_info(open(jobfilepath).read())
|
||||
|
||||
times = np.linspace(0, 1, info.duration * info.fps + 1)
|
||||
|
||||
# One still, one motion-blurred for testing
|
||||
rtimes = [(times[0], times[0]), (times[1], times[2])]
|
||||
#rtimes = zip(['%05d' % i for i in range(len(times))[1:]], times, times[1:])
|
||||
rtimes = [('still', times[0], times[0]), ('motion', times[1], times[2])]
|
||||
|
||||
renderer = cuburn.render.Renderer(info)
|
||||
renderer.compile()
|
||||
renderer.load()
|
||||
|
||||
for idx, (ftime, out) in enumerate(renderer.render(rtimes)):
|
||||
save(idx, out, outprefix)
|
||||
for out in renderer.render(rtimes):
|
||||
save(out, outprefix)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else 'out/')
|
||||
|
Reference in New Issue
Block a user