# SDL: Use aligned stride in sceGxmColorSurfaceInit

**URL:** <https://discourse.libsdl.org/t/sdl-use-aligned-stride-in-scegxmcolorsurfaceinit/32843>\
**Category:** SDL Commits\
**Created:** [September 20, 2021, 8:24pm UTC](https://discourse.libsdl.org/t/sdl-use-aligned-stride-in-scegxmcolorsurfaceinit/32843 "2021-09-20T20:24:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [September 20, 2021, 8:24pm UTC](https://discourse.libsdl.org/t/sdl-use-aligned-stride-in-scegxmcolorsurfaceinit/32843/1 "2021-09-20T20:24:08Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/fc4296c114640479b6862c03da73d26599c8e1a1>

```diff
From fc4296c114640479b6862c03da73d26599c8e1a1 Mon Sep 17 00:00:00 2001
From: Northfear <[EMAIL REDACTED]>
Date: Mon, 20 Sep 2021 23:02:43 +0300
Subject: [PATCH] Use aligned stride in sceGxmColorSurfaceInit

---
 src/render/vitagxm/SDL_render_vita_gxm_tools.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
index f4133a9d99..8d5ed5a1f1 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c
+++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
@@ -1056,6 +1056,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
         const uint32_t alignedHeight = ALIGN(h, SCE_GXM_TILE_SIZEY);
         uint32_t sampleCount = alignedWidth*alignedHeight;
         uint32_t depthStrideInSamples = alignedWidth;
+ const uint32_t alignedColorSurfaceStride = ALIGN(w, 8);
 
         int err = sceGxmColorSurfaceInit(
             &texture->gxm_colorsurface,
@@ -1065,7 +1066,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
             SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT,
             w,
             h,
- w,
+ alignedColorSurfaceStride,
             texture_data
         );
 

```
