d3d9/tests: Do not assume surface size and format in get_rt_readback().

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2017-01-05 11:50:50 +01:00 committed by Alexandre Julliard
parent b5ad6a4480
commit c6795afcdd
1 changed files with 7 additions and 3 deletions

View File

@ -129,12 +129,16 @@ struct surface_readback
static void get_rt_readback(IDirect3DSurface9 *surface, struct surface_readback *rb)
{
IDirect3DDevice9 *device;
D3DSURFACE_DESC desc;
HRESULT hr;
memset(rb, 0, sizeof(*rb));
IDirect3DSurface9_GetDevice(surface, &device);
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 640, 480,
D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &rb->surface, NULL);
hr = IDirect3DSurface9_GetDevice(surface, &device);
ok(SUCCEEDED(hr), "Failed to get device, hr %#x.\n", hr);
hr = IDirect3DSurface9_GetDesc(surface, &desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, desc.Width, desc.Height,
desc.Format, D3DPOOL_SYSTEMMEM, &rb->surface, NULL);
if (FAILED(hr) || !rb->surface)
{
trace("Can't create an offscreen plain surface to read the render target data, hr %#x.\n", hr);