mesa/st: Allocate the gl_context with 16-byte alignment.
The _ModelProjectMatrix matrix embedded inside has members inside of it
marked as 16-byte aligned, and so the context also has to be 16-byte
aligned or access to those members would be invalid. I believe the
compiler used this to use better 16-byte-aligned load/stores to other
members of the context, breaking when the context's alignment was only 8
(as normal mallocs guarantee).
Fixes: 3175b63a0d
("mesa: don't allocate matrices with malloc")
Tested-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8783>
This commit is contained in:
parent
25c70a9a1e
commit
55e853d823
|
@ -1026,12 +1026,14 @@ st_create_context(gl_api api, struct pipe_context *pipe,
|
|||
if (pipe->set_context_param)
|
||||
funcs.PinDriverToL3Cache = st_pin_driver_to_l3_cache;
|
||||
|
||||
ctx = calloc(1, sizeof(struct gl_context));
|
||||
/* gl_context must be 16-byte aligned due to the alignment on GLmatrix. */
|
||||
ctx = align_malloc(sizeof(struct gl_context), 16);
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
|
||||
if (!_mesa_initialize_context(ctx, api, visual, shareCtx, &funcs)) {
|
||||
free(ctx);
|
||||
align_free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1164,7 +1166,7 @@ st_destroy_context(struct st_context *st)
|
|||
|
||||
_mesa_destroy_debug_output(ctx);
|
||||
|
||||
free(ctx);
|
||||
align_free(ctx);
|
||||
|
||||
if (save_ctx == ctx) {
|
||||
/* unbind the context we just deleted */
|
||||
|
|
Loading…
Reference in New Issue