[Verse-dev] Persuade flickering

Emil Brink emil at obsession.se
Mon Jan 8 17:08:12 CET 2007


Hello.

I'm not sure how many of you run Eskil's applications out of CVS, but if you
do, and you're on Linux, chances are you've noticed some annoying flickering
when shading, lately.

The flickering started with Eskil's fix for the memory leaks in the
p_render_to_texture.c module, and have been annoying me ever since.

Today, I implemented a solution that Eskil has suggested, but not done any-
thing about, and it no longer flickers for me. The changed code runs in
Windows as well, where it (still) doesn't flicker.

See the top News post on verse.blender.org, or this link to the diff:
<http://projects.blender.org/viewcvs/viewcvs.cgi/quelsolaar/p_render_to_texture.c.diff?r1=1.16&r2=1.17&cvsroot=verse>.

The change can be summarized like this: in the p_texture_render_bind()
function, instead of changing the size of a previously created texture
if the application requests a new size, we maintain an array of textures
of fixed sizes. That's it.

The size_to_index() function looks slow (it basically computes log2(size)
using a switch statement), but I've profiled it and it does not even show
up in the top 30 when profiling Connector rendering the car.vml scene. So
I don't worry about it that much.

This fix uses up a bit more texture memory, but in practice the only change
is that two textures (64 and 256 pixels) are kept, rather than one size
being replaced by the other all the time. I think this is a rather small
amount of memory, so it shouldn't be a huge problem as far as I understand.

Comments, especially from Eskil, are welcome. Personally, I hope this code
can live on, since the flickering was really annoying. :)

There is one major bug left: all Persuade-based applications crash on exit
if shading has been enabled. I think the cause of this issue also lives in
p_render_to_texture.c, but have not been able to figure it out. This crash
happens in both Linux and Windows, and typically in the OpenGL driver (only
tested on Nvidia hardware).

Regards,

/Emil


More information about the Verse-dev mailing list