Blob Blame History Raw
diff --git a/dpsoftrast.c b/dpsoftrast.c
index 7f13246..35bf59d 100644
--- a/darkplaces/dpsoftrast.c
+++ b/darkplaces/dpsoftrast.c
@@ -198,6 +198,14 @@ DPSOFTRAST_State_Triangle);
 					
 #define DPSOFTRAST_DRAW_MAXSUBSPAN 16
 
+/* This structure is 16 byte aligned.  We need its size suitably aligned as
+   well since we build arrays of this object.  The easiest way to do that it
+   force alignment on a key field.  That way we don't have to introduce
+   manual padding and compute the right amount.
+
+   An even better solution would be to move the pointer to be the first
+   field, then ensure suitable alignment on startx.  But I don't know
+   the code well enough to know if that's safe.  */
 typedef ALIGN(struct DPSOFTRAST_State_Span_s
 {
 	int triangle; // triangle this span was generated by
@@ -205,7 +213,7 @@ typedef ALIGN(struct DPSOFTRAST_State_Span_s
 	int y; // framebuffer y coord
 	int startx; // usable range (according to pixelmask)
 	int endx; // usable range (according to pixelmask)
-	unsigned char *pixelmask; // true for pixels that passed depth test, false for others
+	__attribute__ ((aligned (16))) unsigned char *pixelmask; // true for pixels that passed depth test, false for others
 	int depthbase; // depthbuffer value at x (add depthslope*startx to get first pixel's depthbuffer value)
 	int depthslope; // depthbuffer value pixel delta
 }