summaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo/vbo_save_api.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2015-01-26 20:32:58 -0700
committerBrian Paul <[email protected]>2015-01-30 08:48:19 -0700
commit53b01938ed864e2efaa9389b45e88284eebaaa63 (patch)
tree99ef1f3c8e9af9f699fa0c927144faccac8f41fa /src/mesa/vbo/vbo_save_api.c
parentfbc3e030e658c2c6d44bac084c3166d1fb737c7e (diff)
mesa: fix display list 8-byte alignment issue
The _mesa_dlist_alloc() function is only guaranteed to return a pointer with 4-byte alignment. On 64-bit systems which don't support unaligned loads (e.g. SPARC or MIPS) this could lead to a bus error in the VBO code. The solution is to add a new _mesa_dlist_alloc_aligned() function which will return a pointer to an 8-byte aligned address on 64-bit systems. This is accomplished by inserting a 4-byte NOP instruction in the display list when needed. The only place this actually matters is the VBO code where we need to allocate a 'struct vbo_save_vertex_list' which needs to be 8-byte aligned (just as if it were malloc'd). The gears demo and others hit this bug. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88662 Cc: "10.4" <[email protected]> Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/mesa/vbo/vbo_save_api.c')
-rw-r--r--src/mesa/vbo/vbo_save_api.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 5055c221b6e..beef342bed8 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -375,11 +375,14 @@ _save_compile_vertex_list(struct gl_context *ctx)
* being compiled.
*/
node = (struct vbo_save_vertex_list *)
- _mesa_dlist_alloc(ctx, save->opcode_vertex_list, sizeof(*node));
+ _mesa_dlist_alloc_aligned(ctx, save->opcode_vertex_list, sizeof(*node));
if (!node)
return;
+ /* Make sure the pointer is aligned to the size of a pointer */
+ assert((GLintptr) node % sizeof(void *) == 0);
+
/* Duplicate our template, increment refcounts to the storage structs:
*/
memcpy(node->attrsz, save->attrsz, sizeof(node->attrsz));