[Bf-committers] texture painting blend mode patch

Xavier Thomas xavier.thomas.1980 at gmail.com
Wed Oct 31 20:25:08 CET 2012

I a looked at the patch and effectively the code for float images is

Another thing that might need investigating is the rgb_to_hsv and
hsv_to_rgb method,  basically duplicated code because the origiginal
version crash with threading! I think it might be better to fix the
original, it should be basic static methods, I do no see any reason to

Not related to this patch specifically but it seems there is quite a room
for optimisation. If I understood well, for each pixel that is painted
on, IMB_blend_color() is called, and this function is only a big
switch(blend_mode) that then call the method that blend the 2 colors.

One possibly better way to do this is to cache a pointer to the apropriate
method each time the blend mode is changed so the huge switch statement is
not done for every pixel.
Another way maybe to inline the blend funtions so we do a function call
less for each pixel.

For the float version of the blend funtion SSE2 will certainly provide a 20
to 40% gain, and (depending on the compilator and the images used) you
might want to avoid code like this:

    temp=big float calculation;
    temp=other big float calc;

which is not pipeline friendly, and prefer:

temp1 = big float calculation;
temp2 = other big float calc;
temp = test ? temp1 : temp2;

but this is not always the case so don't optimise blindly.


2012/10/31 Fredrik hansson <fredrikhansson_12345 at yahoo.com>

> oh
>  right i think that might have been why it wasn't added before or
> something i guess i could take a look at writing the float versions
> quickly should be the same pretty much.
> ________________________________
>  From: Antony Riakiotakis <kalast at gmail.com>
> To: Fredrik hansson <fredrikhansson_12345 at yahoo.com>; bf-blender
> developers <bf-committers at blender.org>
> Sent: Wednesday, October 31, 2012 4:39 PM
> Subject: Re: [Bf-committers] texture painting blend mode patch
> This looks cool! A little remark though, we would also need float
> versions for the functions to support float images properly.
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers

More information about the Bf-committers mailing list