[Haskell-cafe] Memory efficiency questions for real-time graphics
sebastian.sylvan at gmail.com
Tue Oct 28 15:24:16 EDT 2008
2008/10/28 T Willingham <t.r.willingham at gmail.com>
> As my first Haskell exposure, I've been working through Real World
> I am considering converting some of my C++ graphics libraries to
> Haskell. I've done a fair amount of googling on the subject, however
> I haven't quite been able to find clear answers to some of following
> (1) Using an OpenGL vertex array (a contiguous chunk of memory which
> is handed to the graphics card) is important. I see the source code
> of Frag does this, so it looks like we're good. Check.
> (2) In-place modification of the vertex array is important. Every
> vertex changes on each frame update. And we always want more
> (3) Growing and shrinking the vertex array efficiently is important.
> Here the behavior of C++ std::vector happens to be ideal. When
> growing, extend the array in-place if possible (using reserved space
> if any), otherwise allocate a new chunk ("amortized constant time").
> When shrinking, do nothing but record the smaller size; the unused
> memory chunk is reserved for possible future growth.
> (4) Doing little to no allocations each frame update is important. In
> the current C++ version, zero allocations occur during a normal frame
> update. When the vertex array changes, that is the only allocation
> which happens.
> To give a context for all of this, I am applying a non-linear
> transformation to an object on every frame. (Note: non-linear, so a
> matrix transform will not suffice.)
Any reason why you can not do this in the vertex shader? You really should
avoid trying to touch the vertices with the CPU if at all possible.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe