[Mesa-dev] [PATCH 11/34] glsl: support compilation of geometry shaders

Paul Berry stereotype441 at gmail.com
Wed Jul 31 21:04:45 PDT 2013


On 31 July 2013 20:41, Kenneth Graunke <kenneth at whitecape.org> wrote:

> On 07/31/2013 05:16 PM, Ian Romanick wrote:
>
>> On 07/30/2013 03:16 PM, Kenneth Graunke wrote:
>>
>>> This code is getting ugly.  It looks like the idea is to allocate two
>>> (now three) separate arrays, but somebody decided to be "clever" and
>>> batch them into a single calloc/free big enough to hold all of them.
>>>
>>
>> Yeah, that was me.  Since way back, I hate dipping into malloc/free for
>> a bunch of small, short-lived allocations.  What I really want to use is
>> alloca, but alas.
>>
>
> In C++ you can just do:
>
> struct gl_shader *vert_shader_list[prog->**NumShaders];
>
> which basically does alloca() as far as I can tell.  The problem is, any
> out of bounds writes smash the stack, and can't be caught by tools like
> Valgrind.
>
> --Ken
>

Actually that's a C99 feature ("variable length arrays"), although GCC
allows it as a C++ extension (try compiling with "-pedantic" and you'll get
a warning).  As far as I can tell from some internet research, MSVC doesn't
support the feature at all, so unfortunately we can't use it in core mesa.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130731/6af4849a/attachment.html>


More information about the mesa-dev mailing list