Often repeated array allocations
Namespace
rswhite4 at googlemail.com
Mon Jul 22 12:00:16 PDT 2013
On Monday, 22 July 2013 at 09:26:33 UTC, David wrote:
> 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.
Hm, but Dgame isn't designed for that sort of thing. It's more
like SFML for C++. So do you think that such Framework will ever
use more vertices than 1024?
Anyway, if it's larger, I allocate with malloc enough memory and
free it at the end of the scope.
More information about the Digitalmars-d-learn
mailing list