From 7002639452c275e990ebab4152c5d537f5ce5610 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Tue, 9 Jan 2024 20:44:04 +0100 Subject: [PATCH] #273 use 64bit aligned pitch --- src/dd.c | 18 +++++++++--------- src/ddsurface.c | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/dd.c b/src/dd.c index 5cbf6f7..1edb49d 100644 --- a/src/dd.c +++ b/src/dd.c @@ -211,7 +211,7 @@ HRESULT dd_EnumDisplayModes( s.dwRefreshRate = 60; s.dwHeight = m.dmPelsHeight; s.dwWidth = m.dmPelsWidth; - s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 31) & ~31) >> 3; + s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 63) & ~63) >> 3; s.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); if (s.ddpfPixelFormat.dwRGBBitCount == bpp_filter || !bpp_filter) @@ -237,7 +237,7 @@ HRESULT dd_EnumDisplayModes( s.ddpfPixelFormat.dwRBitMask = 0xF800; s.ddpfPixelFormat.dwGBitMask = 0x07E0; s.ddpfPixelFormat.dwBBitMask = 0x001F; - s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 31) & ~31) >> 3; + s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 63) & ~63) >> 3; if (s.ddpfPixelFormat.dwRGBBitCount == bpp_filter || !bpp_filter) { @@ -262,7 +262,7 @@ HRESULT dd_EnumDisplayModes( s.ddpfPixelFormat.dwRBitMask = 0xFF0000; s.ddpfPixelFormat.dwGBitMask = 0x00FF00; s.ddpfPixelFormat.dwBBitMask = 0x0000FF; - s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 31) & ~31) >> 3; + s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 63) & ~63) >> 3; if (s.ddpfPixelFormat.dwRGBBitCount == bpp_filter || !bpp_filter) { @@ -331,7 +331,7 @@ HRESULT dd_EnumDisplayModes( s.dwRefreshRate = 60; s.dwHeight = resolutions[i].cy; s.dwWidth = resolutions[i].cx; - s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 31) & ~31) >> 3; + s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 63) & ~63) >> 3; if (s.ddpfPixelFormat.dwRGBBitCount == bpp_filter || !bpp_filter) { @@ -353,7 +353,7 @@ HRESULT dd_EnumDisplayModes( s.ddpfPixelFormat.dwRBitMask = 0xF800; s.ddpfPixelFormat.dwGBitMask = 0x07E0; s.ddpfPixelFormat.dwBBitMask = 0x001F; - s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 31) & ~31) >> 3; + s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 63) & ~63) >> 3; if (s.ddpfPixelFormat.dwRGBBitCount == bpp_filter || !bpp_filter) { @@ -378,7 +378,7 @@ HRESULT dd_EnumDisplayModes( s.ddpfPixelFormat.dwRBitMask = 0xFF0000; s.ddpfPixelFormat.dwGBitMask = 0x00FF00; s.ddpfPixelFormat.dwBBitMask = 0x0000FF; - s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 31) & ~31) >> 3; + s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 63) & ~63) >> 3; if (s.ddpfPixelFormat.dwRGBBitCount == bpp_filter || !bpp_filter) { @@ -481,7 +481,7 @@ HRESULT dd_GetDisplayMode(LPDDSURFACEDESC lpDDSurfaceDesc) lpDDSurfaceDesc->dwWidth = g_ddraw->width ? g_ddraw->width : 1024; lpDDSurfaceDesc->lPitch = - ((lpDDSurfaceDesc->dwWidth * lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount + 31) & ~31) >> 3; + ((lpDDSurfaceDesc->dwWidth * lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount + 63) & ~63) >> 3; if (g_ddraw->bpp == 32 || g_config.vermeer_hack) { @@ -492,7 +492,7 @@ HRESULT dd_GetDisplayMode(LPDDSURFACEDESC lpDDSurfaceDesc) lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x0000FF; lpDDSurfaceDesc->lPitch = - ((lpDDSurfaceDesc->dwWidth * lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount + 31) & ~31) >> 3; + ((lpDDSurfaceDesc->dwWidth * lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount + 63) & ~63) >> 3; } else if (g_ddraw->bpp != 8) { @@ -503,7 +503,7 @@ HRESULT dd_GetDisplayMode(LPDDSURFACEDESC lpDDSurfaceDesc) lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x001F; lpDDSurfaceDesc->lPitch = - ((lpDDSurfaceDesc->dwWidth * lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount + 31) & ~31) >> 3; + ((lpDDSurfaceDesc->dwWidth * lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount + 63) & ~63) >> 3; } } diff --git a/src/ddsurface.c b/src/ddsurface.c index 29314bd..b45cc75 100644 --- a/src/ddsurface.c +++ b/src/ddsurface.c @@ -1405,7 +1405,7 @@ HRESULT dd_CreateSurface( else if (dst_surface->width && dst_surface->height) { dst_surface->bytes_pp = dst_surface->bpp / 8; - dst_surface->pitch = ((dst_surface->width * dst_surface->bpp + 31) & ~31) >> 3; + dst_surface->pitch = ((dst_surface->width * dst_surface->bpp + 63) & ~63) >> 3; dst_surface->size = dst_surface->pitch * dst_surface->height; DWORD aligned_width = dst_surface->pitch / dst_surface->bytes_pp; @@ -1429,7 +1429,7 @@ HRESULT dd_CreateSurface( } dst_surface->bmi->bmiHeader.biSizeImage = - ((aligned_width * clr_bits + 31) & ~31) / 8 * dst_surface->height; + ((aligned_width * clr_bits + 63) & ~63) / 8 * dst_surface->height; if (dst_surface->bpp == 8) {