From a9f3e3a74464475abc03d11b85b1a43aed7063ea Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Mon, 6 Mar 2023 13:44:17 +0000 Subject: [PATCH] Fix alignments --- GL/platforms/sh4.c | 4 +++- GL/private.h | 2 +- containers/aligned_vector.h | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/GL/platforms/sh4.c b/GL/platforms/sh4.c index 33a5f8f..78e1772 100644 --- a/GL/platforms/sh4.c +++ b/GL/platforms/sh4.c @@ -100,7 +100,7 @@ GL_FORCE_INLINE void _glSubmitHeaderOrVertex(const Vertex* v) { d += 8; } -static struct { +static struct __attribute__((aligned(32))) { Vertex* v; int visible; } triangle[3]; @@ -182,6 +182,8 @@ GL_FORCE_INLINE void ShiftRotateTriangle() { #define SPAN_SORT_CFG 0x005F8030 void SceneListSubmit(void* src, int n) { + Vertex __attribute__((aligned(32))) tmp; + /* Do everything, everywhere, all at once */ PVR_SET(SPAN_SORT_CFG, 0x0); diff --git a/GL/private.h b/GL/private.h index b61f29f..9fa45cf 100644 --- a/GL/private.h +++ b/GL/private.h @@ -251,7 +251,7 @@ typedef struct { * when a realloc could invalidate pointers. This structure holds all the information * we need on the target vertex array to allow passing around to the various stages (e.g. generate/clip etc.) */ -typedef struct { +typedef struct __attribute__((aligned(32))) { PolyList* output; uint32_t header_offset; // The offset of the header in the output list uint32_t start_offset; // The offset into the output list diff --git a/containers/aligned_vector.h b/containers/aligned_vector.h index cf89ffe..12f3ae3 100644 --- a/containers/aligned_vector.h +++ b/containers/aligned_vector.h @@ -25,10 +25,10 @@ static inline void* memalign(size_t alignment, size_t size) { #endif typedef struct { - unsigned int size; - unsigned int capacity; - unsigned char* data; - unsigned int element_size; + uint8_t* __attribute__((aligned(32))) data; + uint32_t size; + uint32_t capacity; + uint32_t element_size; } AlignedVector; #define ALIGNED_VECTOR_CHUNK_SIZE 256u