SDL: Added a hint "SDL_SURFACE_MALLOC" to disable aligned surface allocation

From 156187bf58a3a556c6f669acb0639bc4b6ae6990 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 2 Apr 2026 10:30:32 -0700
Subject: [PATCH] Added a hint "SDL_SURFACE_MALLOC" to disable aligned surface
 allocation

This is needed for sdl12-compat, where all surfaces were not aligned.
---
 src/video/SDL_surface.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c
index c3350e311c3d4..6658ae8df5294 100644
--- a/src/video/SDL_surface.c
+++ b/src/video/SDL_surface.c
@@ -229,12 +229,16 @@ SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormat format)
 
     if (surface->w && surface->h && format != SDL_PIXELFORMAT_MJPG) {
         surface->flags &= ~SDL_SURFACE_PREALLOCATED;
-        surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size);
+        if (SDL_GetHintBoolean("SDL_SURFACE_MALLOC", false)) {
+            surface->pixels = SDL_malloc(size);
+        } else {
+            surface->flags |= SDL_SURFACE_SIMD_ALIGNED;
+            surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size);
+        }
         if (!surface->pixels) {
             SDL_DestroySurface(surface);
             return NULL;
         }
-        surface->flags |= SDL_SURFACE_SIMD_ALIGNED;
 
         // This is important for bitmaps
         SDL_memset(surface->pixels, 0, size);