Go to file
Bogdan Nagirniak 9075ec8269 Python: add foreach_get and foreach_set methods to pyrna_prop_array
This allows fast access to various arrays in the Python API.
Most notably, `image.pixels` can be accessed much more efficiently now.

**Benchmark**

Below are the results of a benchmark that compares different ways to
set/get all pixel values. I do the tests on 2048x2048 rgba images.
The benchmark tests the following dimensions:
- Byte vs. float per color channel
- Python list vs. numpy array containing floats
- `foreach_set` (new) vs. `image.pixels = ...` (old)

```
Pixel amount: 2048 * 2048 = 4.194.304
Byte buffer size:  16.8 mb
Float buffer size: 67.1 mb

Set pixel colors:
    byte  - new - list:    271 ms
    byte  - new - buffer:   29 ms
    byte  - old - list:    350 ms
    byte  - old - buffer: 2900 ms

    float - new - list:    249 ms
    float - new - buffer:    8 ms
    float - old - list:    330 ms
    float - old - buffer: 2880 ms

Get pixel colors:
    byte - list:   128 ms
    byte - buffer:   9 ms
    float - list:  125 ms
    float - buffer:  8 ms
```

**Observations**

The best set and get speed can be achieved with buffers and a float image,
at the cost of higher memory consumption. Furthermore, using buffers when
using `pixels = ...` is incredibly slow, because it is not optimized.
Optimizing this is possible, but might not be trivial (there were multiple
attempts afaik).

Float images are faster due to overhead introduced by the api for byte images.
If I profiled it correctly, a lot of time is spend in the `[0, 1] -> {0, ..., 255}`
conversion. The functions doing that conversion is `unit_float_to_uchar_clamp`.
While I have an idea on how it can be optimized, I do not know if it can be done
without changing its functionality slightly. Performance wise the best solution
would be to not do this conversion at all and accept byte input from the api
user directly, but that seems to be a more involved task as well.

Differential Revision: https://developer.blender.org/D7053

Reviewers: JacquesLucke, mont29
2020-03-13 12:59:36 +01:00
.github Revert "Merge branch 'master' into blender-v2.81-release" 2019-10-11 21:31:58 +02:00
build_files Buildbot: Enable version character for development builds 2020-03-10 10:23:28 +01:00
doc API Docs: Point to manual for Operator Cheat Sheet 2020-03-06 12:50:19 -05:00
extern Cleanup: use term suppress instead of repress 2020-03-12 12:13:41 +11:00
intern Fix memory leak in recent Cycles image texture refactor 2020-03-12 20:30:49 +01:00
release GPencil: Join Tint and Vertex Color modifier 2020-03-13 10:28:59 +01:00
source Python: add foreach_get and foreach_set methods to pyrna_prop_array 2020-03-13 12:59:36 +01:00
tests Python: add foreach_get and foreach_set methods to pyrna_prop_array 2020-03-13 12:59:36 +01:00
.arcconfig Fix .arcconfig not working with latest arcanist version 2020-03-01 22:35:31 +01:00
.clang-format clang-format: add particle loop macros 2019-09-26 17:52:49 +02:00
.editorconfig editorconfig: correct indent size 2019-04-17 13:34:46 +02:00
.gitignore Fluid: Added wavelet noise tile to the gitignore 2020-01-29 19:21:52 +01:00
.gitmodules Update for moving blender2.8 to master. 2018-12-21 12:15:21 +01:00
CMakeLists.txt Build System: Add OpenXR-SDK dependency and WITH_XR_OPENXR build option 2020-03-04 16:45:07 +01:00
COPYING == docs == 2010-10-13 14:44:22 +00:00
GNUmakefile Build: use clang-format from precompiled libraries for make format on Linux 2020-02-15 13:44:20 +01:00
make.bat Build: add "make test" command for Windows, output log file 2019-09-12 20:23:03 +02:00
readme.rst readme: separate development links 2019-04-13 14:45:51 +02:00

.. Keep this document short & concise,
   linking to external resources instead of including content in-line.
   See 'release/text/readme.html' for the end user read-me.


Blender
=======

Blender is the free and open source 3D creation suite.
It supports the entirety of the 3D pipeline-modeling, rigging, animation, simulation, rendering, compositing,
motion tracking and video editing.

.. figure:: https://code.blender.org/wp-content/uploads/2018/12/springrg.jpg
   :scale: 50 %
   :align: center


Project Pages
-------------

- `Main Website <http://www.blender.org>`__
- `Reference Manual <https://docs.blender.org/manual/en/latest/index.html>`__
- `User Community <https://www.blender.org/community/>`__

Development
-----------

- `Build Instructions <https://wiki.blender.org/wiki/Building_Blender>`__
- `Code Review & Bug Tracker <https://developer.blender.org>`__
- `Developer Forum <https://devtalk.blender.org>`__
- `Developer Documentation <https://wiki.blender.org>`__


License
-------

Blender as a whole is licensed under the GNU Public License, Version 3.
Individual files may have a different, but compatible license.

See `blender.org/about/license <https://www.blender.org/about/license>`__ for details.