[PATCH] WineD3D: Compressed surface sizes are multiples of 4=0A=

Stefan Doesinger stefan at codeweavers.com
Sun Aug 31 23:16:10 CDT 2008


=0A=
Since those surfaces are stored in blocks, the 4 pixel step doesn't only =
apply to surfaces < 4, but=0A=
also to surfaces bigger than that, with a non-multiple-of-4 size.=0A=
---=0A=
 dlls/wined3d/device.c |    7 +++++--=0A=
 1 files changed, 5 insertions(+), 2 deletions(-)=0A=
=0A=
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c=0A=
index 2085b07..d7b527a 100644=0A=
--- a/dlls/wined3d/device.c=0A=
+++ b/dlls/wined3d/device.c=0A=
@@ -588,6 +588,7 @@ static HRESULT  WINAPI =
IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U=0A=
     unsigned int Size       =3D 1;=0A=
     const GlPixelFormatDesc *glDesc;=0A=
     const StaticPixelFormatDesc *tableEntry =3D =
getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);=0A=
+    UINT mul_4w, mul_4h;=0A=
     TRACE("(%p) Create surface\n",This);=0A=
     =0A=
     /** FIXME: Check ranges on the inputs are valid =0A=
@@ -625,16 +626,18 @@ static HRESULT  WINAPI =
IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U=0A=
      *  it is based around 4x4 pixel blocks it requires padding, so =
allocate enough=0A=
      *  space!=0A=
       *********************************/=0A=
+    mul_4w =3D (Width + 3) & ~3;=0A=
+    mul_4h =3D (Height + 3) & ~3;=0A=
     if (WINED3DFMT_UNKNOWN =3D=3D Format) {=0A=
         Size =3D 0;=0A=
     } else if (Format =3D=3D WINED3DFMT_DXT1) {=0A=
         /* DXT1 is half byte per pixel */=0A=
-       Size =3D ((max(Width,4) * tableEntry->bpp) * max(Height,4)) >> 1;=0A=
+        Size =3D (mul_4w * tableEntry->bpp * mul_4h) >> 1;=0A=
 =0A=
     } else if (Format =3D=3D WINED3DFMT_DXT2 || Format =3D=3D =
WINED3DFMT_DXT3 ||=0A=
                Format =3D=3D WINED3DFMT_DXT4 || Format =3D=3D =
WINED3DFMT_DXT5 ||=0A=
                Format =3D=3D WINED3DFMT_ATI2N) {=0A=
-       Size =3D ((max(Width,4) * tableEntry->bpp) * max(Height,4));=0A=
+        Size =3D (mul_4w * tableEntry->bpp * mul_4h);=0A=
     } else {=0A=
        /* The pitch is a multiple of 4 bytes */=0A=
         Size =3D ((Width * tableEntry->bpp) + This->surface_alignment - =
1) & ~(This->surface_alignment - 1);=0A=
-- =0A=
1.5.6.4=0A=
=0A=

------=_NextPart_000_02F1_01C90DB8.F5E0BE20--




More information about the wine-patches mailing list