Often repeated array allocations

David d at dav1d.de
Mon Jul 22 02:26:33 PDT 2013


Am 22.07.2013 10:41, schrieb Namespace:
> It's part of Dgame and it's the shape draw method. The method collects
> the vertices and give them to the vertex buffer.
> I will try it with my current way: static stack buffer with a size of
> 1024 and otherwise I will temporary allocate memory. But how much shapes
> grow larger than 1024 vertices ;).

This will be over 1024 vertices in no time, I am currently drawing
vertices with a size of ~500MiB depending on the terrain. The CPU
doesn't need to know of all vertices at once, so collect them and upload
them  to the GPU if they go over a certain limit and begin to fill your
buffer from the start again. I use a malloc allocated buffer, its size
is never decreased, I initially allocate an educated guess + some extra
to be safe, then if it really happens to run ot of memory I simple
resize it depending on how much is left with another educated guess +
some extra.


More information about the Digitalmars-d-learn mailing list