First post, by 0x1F9F1
The surface returned from IDirectDrawSurface4::Lock sometimes has an lPitch less than dwWidth * ddpfPixelFormat.dwRGBBitCount (half, to be precise). For example:
'T_WALK_ALLEY' is opaque texture
Surface 64 x 64 (128 pitch, 32 bpp), (ff0000,ff00,ff,0), 7 mipmaps
Invalid Pitch: 128 < 256
Surface 32 x 32 (128 pitch, 32 bpp), (ff0000,ff00,ff,0), 0 mipmaps
Surface 16 x 16 (64 pitch, 32 bpp), (ff0000,ff00,ff,0), 0 mipmaps
Surface 8 x 8 (32 pitch, 32 bpp), (ff0000,ff00,ff,0), 0 mipmaps
Surface 4 x 4 (16 pitch, 32 bpp), (ff0000,ff00,ff,0), 0 mipmaps
Surface 2 x 2 (8 pitch, 32 bpp), (ff0000,ff00,ff,0), 0 mipmaps
Surface 1 x 1 (4 pitch, 32 bpp), (ff0000,ff00,ff,0), 0 mipmaps
'L_BOTTOM' is alpha texture
Surface 64 x 64 (128 pitch, 32 bpp), (ff0000,ff00,ff,ff000000), 7 mipmaps
Invalid Pitch: 128 < 256
Surface 32 x 32 (128 pitch, 32 bpp), (ff0000,ff00,ff,ff000000), 0 mipmaps
Surface 16 x 16 (64 pitch, 32 bpp), (ff0000,ff00,ff,ff000000), 0 mipmaps
Surface 8 x 8 (32 pitch, 32 bpp), (ff0000,ff00,ff,ff000000), 0 mipmaps
Surface 4 x 4 (16 pitch, 32 bpp), (ff0000,ff00,ff,ff000000), 0 mipmaps
Surface 2 x 2 (8 pitch, 32 bpp), (ff0000,ff00,ff,ff000000), 0 mipmaps
Surface 1 x 1 (4 pitch, 32 bpp), (ff0000,ff00,ff,ff000000), 0 mipmaps
This issue only seems to occur with the first surface of most mipmapped 32-bit surface. Using 16-bit surfaces, or disabling mipmaps via dwMipMapCount=0, dwFlags&=~DDSD_MIPMAPCOUNT seems to avoid the problem. Tested with 2.63.2, the debug layer also shows no warnings/errors, and this problem doesn't occur with native DDRAW.