I'm writing a script to overcome some of Cycles' limitations in terms of performance, namely the loading time, which is very long in the case of heavy scenes.
I wrote a modal operator which, at the moment, creates a timer, toggles the current space fullscreen, and takes a screenshot at fixed intervals; since the viewport rendering does not reload the scene at each frame, part of the BVH building time, shaders update and device loading are done only once. I will of course use the real rendering for the final render, but this may prove useful for quickly rendering previews of a WIP.
What I'd like is to check for some values in the viewport, eg. samples rendered, rendering state (updating mesh, loading BVH, path tracing, etc.), in the same way as it is displayed at the top of the 3D View. This way I can check the current state and take the screenshot and set the next frame accordingly (eg. (pseudo-code)
if samples_rendered > threshold: take_screenshot() and set_frame(current_frame+1). This wouldn't rely on an arbitrary timer, which doesn't account for the initial loading time, nor the time variations in rendering the frames.
Is there a way to access this information in Python?