[Mesa-dev] [PATCH] llvmpipe: align the array used for subdivived vertices

Roland Scheidegger sroland at vmware.com
Mon Sep 23 14:51:13 PDT 2013


Am 23.09.2013 23:31, schrieb Zack Rusin:
> When subdiving a triangle we're using a temporary array to store
> the new coordinates for the subdivided triangles. Unfortunately
> the array used for that was not aligned properly causing
> random crashes in the llvm jit code which was trying to load
> vectors from it.
> 
> Signed-off-by: Zack Rusin <zackr at vmware.com>
> ---
>  src/gallium/drivers/llvmpipe/lp_setup_tri.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
> index 8b0fcd0..cf67f29 100644
> --- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
> +++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
> @@ -909,7 +909,7 @@ subdiv_tri(struct lp_setup_context *setup,
>     unsigned n = setup->fs.current.variant->shader->info.base.num_inputs + 1;
>     const struct lp_shader_input *inputs =
>        setup->fs.current.variant->shader->inputs;
> -   float vmid[PIPE_MAX_ATTRIBS][4];
> +   PIPE_ALIGN_VAR(LP_MIN_VECTOR_ALIGN) float vmid[PIPE_MAX_ATTRIBS][4];
>     const float (*vm)[4] = (const float (*)[4]) vmid;
>     unsigned i;
>     float w0, w1, wm;
> 

Nice find! Looks good to me.
(The alignment restrictions are actually interesting, since with SSE all
128bit accesses must be aligned or it will throw an exception. But with
AVX or more accurately VEX-encoded instructions only explicit moves need
to be 128bit aligned (when using aligned mov) but when using the address
operand directly with some math instruction then it will work just fine
without alignment - hence if it actually crashes or not when you tell
llvm it's 128bit aligned but it isn't depends on if llvm will do the
memory access as part of a explicit mov or not...)

Roland


More information about the mesa-dev mailing list