From ce85a905382bc81a85df14b904f18cc5cbff2595 Mon Sep 17 00:00:00 2001 From: Jason Edmeades Date: Fri, 19 Sep 2003 04:02:35 +0000 Subject: [PATCH] DXTn format has odd mipmap levels in that the space allocated for small levels needs a lot of padding. --- dlls/d3d8/device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 922db5d0669..24e11a0f911 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -853,8 +853,14 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface object->myDesc.Usage = 0; object->myDesc.Pool = D3DPOOL_SYSTEMMEM; object->bytesPerPixel = D3DFmtGetBpp(This, Format); + /* DXTn mipmaps use the same number of 'levels' down to eg. 8x1, but since + it is based around 4x4 pixel blocks it requires padding, so allocate enough + space! */ if (Format == D3DFMT_DXT1) { - object->myDesc.Size = ((Width * object->bytesPerPixel) * Height) / 2; /* DXT1 is half byte per pixel */ + object->myDesc.Size = ((max(Width,4) * object->bytesPerPixel) * max(Height,4)) / 2; /* DXT1 is half byte per pixel */ + } else if (Format == D3DFMT_DXT2 || Format == D3DFMT_DXT3 || + Format == D3DFMT_DXT4 || Format == D3DFMT_DXT5) { + object->myDesc.Size = ((max(Width,4) * object->bytesPerPixel) * max(Height,4)); } else { object->myDesc.Size = (Width * object->bytesPerPixel) * Height; }