Commit 9cafbd6d authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Surface data is 32 bit aligned.

parent 96bce8d6
......@@ -113,6 +113,27 @@ cleanup:
if (surface_ptr) IDirect3DSurface9_Release(surface_ptr);
}
static void test_surface_alignment(IDirect3DDevice9 *device_ptr)
{
IDirect3DSurface9 *surface_ptr = 0;
HRESULT hr;
/* Test a sysmem surface as those aren't affected by the hardware's np2 restrictions */
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device_ptr, 5, 5, D3DFMT_R5G6B5, D3DPOOL_SYSTEMMEM, &surface_ptr, 0);
ok(hr == D3D_OK, "IDirect3DDevice9_CreateOffscreenPlainSurface returned %08lx\n", hr);
if(surface_ptr)
{
D3DLOCKED_RECT lockedRect;
hr = IDirect3DSurface9_LockRect(surface_ptr, &lockedRect, NULL, 0);
ok(hr == D3D_OK, "IDirect3DSurface9_LockRect returned %08lx\n", hr);
/* test is deactivated until out np2 support doesn't report the full power of 2 pitch to the app */
todo_wine ok(lockedRect.Pitch == 12, "Got pitch %d, expected 12\n", lockedRect.Pitch);
hr = IDirect3DSurface9_UnlockRect(surface_ptr);
IDirect3DSurface9_Release(surface_ptr);
}
}
START_TEST(surface)
{
HMODULE d3d9_handle;
......@@ -129,4 +150,5 @@ START_TEST(surface)
if (!device_ptr) return;
test_surface_get_container(device_ptr);
test_surface_alignment(device_ptr);
}
......@@ -1001,7 +1001,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
Format == WINED3DFMT_DXT4 || Format == WINED3DFMT_DXT5) {
Size = ((max(pow2Width,4) * tableEntry->bpp) * max(pow2Height,4));
} else {
Size = (pow2Width * tableEntry->bpp) * pow2Height;
/* The pitch is a multiple of 4 bytes */
Size = ((pow2Width * tableEntry->bpp) + 3) & ~3;
Size *= pow2Height;
}
/** Create and initialise the surface resource **/
......
......@@ -2170,7 +2170,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORM
format == WINED3DFMT_DXT4 || format == WINED3DFMT_DXT5) {
This->resource.size = ((max(This->pow2Width, 4) * formatEntry->bpp) * max(This->pow2Height, 4));
} else {
This->resource.size = (This->pow2Width * formatEntry->bpp) * This->pow2Height;
This->resource.size = ((This->pow2Width * formatEntry->bpp) + 3) & ~3;
This->resource.size *= This->pow2Height;
}
......@@ -3063,6 +3064,8 @@ DWORD WINAPI IWineD3DSurfaceImpl_GetPitch(IWineD3DSurface *iface) {
} else {
ret = This->bytesPerPixel * This->pow2Width;
}
/* Surfaces are 32 bit aligned */
ret = (ret + 3) & ~3;
}
TRACE("(%p) Returning %ld\n", This, ret);
return ret;
......
......@@ -1516,7 +1516,7 @@ IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
This->resource.allocatedMemory = NULL;
/* We don't mind the nonpow2 stuff in GDI */
This->resource.size = This->currentDesc.Width * getFormatDescEntry(This->resource.format)->bpp * This->currentDesc.Height;
This->resource.size = IWineD3DSurface_GetPitch(iface) * This->currentDesc.Height;
This->pow2Size = This->resource.size;
This->pow2Width = This->currentDesc.Width;
This->pow2Height = This->currentDesc.Height;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment