[Bf-committers] texture painting blend mode patch

patrick boelens p_boelens at msn.com
Wed Oct 31 23:57:45 CET 2012


> 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:
> 
> if(test)
>     temp=big float calculation;
> else
>     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;

I'm sorry if this is off-topic for the mailing list, but I'm really curious as to how the second method can be faster, as it seems really unintuitive. Is this something to keep in mind for specific kinds of operations/ data types or just a good rule of thumb in general?

Thanks,
Patrick


> Date: Wed, 31 Oct 2012 17:25:08 -0200
> From: xavier.thomas.1980 at gmail.com
> To: fredrikhansson_12345 at yahoo.com; bf-committers at blender.org
> Subject: Re: [Bf-committers] texture painting blend mode patch
> 
> I a looked at the patch and effectively the code for float images is
> missing.
> 
> 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
> crash.
> 
> 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:
> 
> if(test)
>     temp=big float calculation;
> else
>     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.
> 
> 
> Xavier
> 
> 
> 
> 
> 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
> >
> _______________________________________________
> 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