[Mesa-dev] [PATCH] vbo: Use alloca for _vbo_draw_indirect.

Jon Turney jon.turney at dronecode.org.uk
Tue Apr 3 16:57:31 UTC 2018


On 28/03/2018 11:35, Mathias.Froehlich at gmx.net wrote:
> 
> Avoid using malloc in the draw path of mesa.
> Since the draw_count is a user api input, fall back to malloc if
> the amount of consumed stack space may get too high.
> 
> Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
> ---
>   src/mesa/vbo/vbo_context.c | 70 +++++++++++++++++++++++++++++++---------------
>   1 file changed, 47 insertions(+), 23 deletions(-)

This adds uses of alloca, without a corresponding include of alloca.h.

Perhaps something like the attached is needed?

See also:
https://lists.freedesktop.org/archives/mesa-dev/2018-January/184030.html
https://lists.freedesktop.org/archives/mesa-dev/2017-December/180073.html
https://lists.freedesktop.org/archives/mesa-dev/2016-July/122346.html

-------------- next part --------------
From 8599fd9109d59adc541ab06570732776e2c098d6 Mon Sep 17 00:00:00 2001
From: Jon Turney <jon.turney at dronecode.org.uk>
Date: Tue, 3 Apr 2018 17:52:56 +0100
Subject: [PATCH] Fix use of alloca() without #include <c99_alloca.h>

Fix use of alloca() without #include <c99_alloca.h> in 1da345e5

vbo/vbo_context.c: In function '_vbo_draw_indirect':
vbo/vbo_context.c:284:34: error: implicit declaration of function 'alloca' [-Werror=implicit-function-declaration]
       struct _mesa_prim *space = alloca(draw_count*sizeof(struct _mesa_prim));
                                  ^~~~~~
vbo/vbo_context.c:284:34: warning: initialization makes pointer from integer without a cast [-Wint-conversion]

Signed-off-by: Jon Turney <jon.turney at dronecode.org.uk>
---
 src/mesa/vbo/vbo_context.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index e50cee7a8c..f698fd0f41 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -25,6 +25,7 @@
  *    Keith Whitwell <keithw at vmware.com>
  */
 
+#include "c99_alloca.h"
 #include "main/mtypes.h"
 #include "main/bufferobj.h"
 #include "math/m_eval.h"
-- 
2.16.2



More information about the mesa-dev mailing list