On 01.02.2013 19:25, Brecht Van Lommel wrote: > There is already a trick that you can use, it didn't work entirely > before but I just committed a fix for that. Basically you use the > foreach_set method which accepts a buffer object: > http://www.blender.org/documentation/blender_python_api_2_65_9/bpy.types.bpy_prop_collection.html?highlight=foreach_get#bpy.types.bpy_prop_collection.foreach_set
I've finally gotten around to implementing this, and it does indeed work nicely. On a single 1920x1080 image with alpha and depth (zbuffer), it takes about 1.2 seconds total to update and transfer the image to the render result. About 400 ms is spent on our side tonemapping etc and converting to bottom-up format (internally we store top-down). The remainder, about 800 ms, is spent getting the result into Blender using the foreach_set. This was measured in different ways on my i7 2700k. The old method which returned a list of lists uses about 6-8 seconds on the same image, and considerably more memory. So indeed a nice boost there. Two catches: - foreach_set requires that the object not only follows the buffer protocol but also a subset of the sequence protocol. Specifically it has to pass PySequence_Check() which requires sq_item to be assigned, and foreach_set itself requires a valid sq_length implementation as it uses PySequence_Size(). Those are the only two PySequenceMethods fields that needs to be filled though. - As mentioned you have to assign all layers and passes in one go. We don't support multiple layers yet but we're talking about it, so it would be nice to be able to assign each layer individually using a buffer. Thanks again for the assistance. - Asbjørn _______________________________________________ Bf-python mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-python
