d3d8/tests: Port the block lock test to d3d8.
This commit is contained in:
parent
ecb403ee2a
commit
a3ca9a8bff
|
@ -483,6 +483,146 @@ static void test_surface_double_unlock(IDirect3DDevice8 *device)
|
|||
IDirect3D8_Release(d3d);
|
||||
}
|
||||
|
||||
static void test_surface_lockrect_blocks(IDirect3DDevice8 *device)
|
||||
{
|
||||
IDirect3DTexture8 *texture;
|
||||
IDirect3DSurface8 *surface;
|
||||
IDirect3D8 *d3d;
|
||||
D3DLOCKED_RECT locked_rect;
|
||||
unsigned int i, j;
|
||||
HRESULT hr;
|
||||
RECT rect;
|
||||
|
||||
const struct
|
||||
{
|
||||
D3DFORMAT fmt;
|
||||
const char *name;
|
||||
unsigned int block_width;
|
||||
unsigned int block_height;
|
||||
BOOL broken;
|
||||
}
|
||||
formats[] =
|
||||
{
|
||||
{D3DFMT_DXT1, "D3DFMT_DXT1", 4, 4, FALSE},
|
||||
{D3DFMT_DXT2, "D3DFMT_DXT2", 4, 4, FALSE},
|
||||
{D3DFMT_DXT3, "D3DFMT_DXT3", 4, 4, FALSE},
|
||||
{D3DFMT_DXT4, "D3DFMT_DXT4", 4, 4, FALSE},
|
||||
{D3DFMT_DXT5, "D3DFMT_DXT5", 4, 4, FALSE},
|
||||
/* ATI2N has 2x2 blocks on all AMD cards and Geforce 7 cards,
|
||||
* which doesn't match the format spec. On newer Nvidia cards
|
||||
* it has the correct 4x4 block size */
|
||||
{MAKEFOURCC('A','T','I','2'), "ATI2N", 4, 4, TRUE},
|
||||
/* YUY2 and UYVY are not supported in d3d8, there is no way
|
||||
* to use them with this API considering their restrictions */
|
||||
};
|
||||
const struct
|
||||
{
|
||||
D3DPOOL pool;
|
||||
const char *name;
|
||||
/* Don't check the return value, Nvidia returns D3DERR_INVALIDCALL for some formats
|
||||
* and E_INVALIDARG/DDERR_INVALIDPARAMS for others. */
|
||||
BOOL success;
|
||||
}
|
||||
pools[] =
|
||||
{
|
||||
{D3DPOOL_DEFAULT, "D3DPOOL_DEFAULT", FALSE},
|
||||
{D3DPOOL_SCRATCH, "D3DPOOL_SCRATCH", TRUE},
|
||||
{D3DPOOL_SYSTEMMEM, "D3DPOOL_SYSTEMMEM",TRUE},
|
||||
{D3DPOOL_MANAGED, "D3DPOOL_MANAGED", TRUE},
|
||||
};
|
||||
|
||||
hr = IDirect3DDevice8_GetDirect3D(device, &d3d);
|
||||
ok(SUCCEEDED(hr), "IDirect3DDevice8_GetDirect3D failed (%08x)\n", hr);
|
||||
|
||||
for (i = 0; i < (sizeof(formats) / sizeof(*formats)); ++i) {
|
||||
hr = IDirect3D8_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC,
|
||||
D3DRTYPE_TEXTURE, formats[i].fmt);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
skip("Format %s not supported, skipping lockrect offset test\n", formats[i].name);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < (sizeof(pools) / sizeof(*pools)); j++)
|
||||
{
|
||||
hr = IDirect3DDevice8_CreateTexture(device, 128, 128, 1,
|
||||
pools[j].pool == D3DPOOL_DEFAULT ? D3DUSAGE_DYNAMIC : 0,
|
||||
formats[i].fmt, pools[j].pool, &texture);
|
||||
ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateTexture failed (%08x)\n", hr);
|
||||
hr = IDirect3DTexture8_GetSurfaceLevel(texture, 0, &surface);
|
||||
ok(SUCCEEDED(hr), "IDirect3DTexture8_GetSurfaceLevel failed (%08x)\n", hr);
|
||||
IDirect3DTexture8_Release(texture);
|
||||
|
||||
if (formats[i].block_width > 1)
|
||||
{
|
||||
SetRect(&rect, formats[i].block_width >> 1, 0, formats[i].block_width, formats[i].block_height);
|
||||
hr = IDirect3DSurface8_LockRect(surface, &locked_rect, &rect, 0);
|
||||
ok(!SUCCEEDED(hr) == !pools[j].success || broken(formats[i].broken),
|
||||
"Partial block lock %s, expected %s, format %s, pool %s.\n",
|
||||
SUCCEEDED(hr) ? "succeeded" : "failed",
|
||||
pools[j].success ? "success" : "failure", formats[i].name, pools[j].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IDirect3DSurface8_UnlockRect(surface);
|
||||
ok(SUCCEEDED(hr), "IDirect3DSurface8_UnlockRect failed (%08x)\n", hr);
|
||||
}
|
||||
|
||||
SetRect(&rect, 0, 0, formats[i].block_width >> 1, formats[i].block_height);
|
||||
hr = IDirect3DSurface8_LockRect(surface, &locked_rect, &rect, 0);
|
||||
ok(!SUCCEEDED(hr) == !pools[j].success || broken(formats[i].broken),
|
||||
"Partial block lock %s, expected %s, format %s, pool %s.\n",
|
||||
SUCCEEDED(hr) ? "succeeded" : "failed",
|
||||
pools[j].success ? "success" : "failure", formats[i].name, pools[j].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IDirect3DSurface8_UnlockRect(surface);
|
||||
ok(SUCCEEDED(hr), "IDirect3DSurface8_UnlockRect failed (%08x)\n", hr);
|
||||
}
|
||||
}
|
||||
|
||||
if (formats[i].block_height > 1)
|
||||
{
|
||||
SetRect(&rect, 0, formats[i].block_height >> 1, formats[i].block_width, formats[i].block_height);
|
||||
hr = IDirect3DSurface8_LockRect(surface, &locked_rect, &rect, 0);
|
||||
ok(!SUCCEEDED(hr) == !pools[j].success || broken(formats[i].broken),
|
||||
"Partial block lock %s, expected %s, format %s, pool %s.\n",
|
||||
SUCCEEDED(hr) ? "succeeded" : "failed",
|
||||
pools[j].success ? "success" : "failure", formats[i].name, pools[j].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IDirect3DSurface8_UnlockRect(surface);
|
||||
ok(SUCCEEDED(hr), "IDirect3DSurface8_UnlockRect failed (%08x)\n", hr);
|
||||
}
|
||||
|
||||
SetRect(&rect, 0, 0, formats[i].block_width, formats[i].block_height >> 1);
|
||||
hr = IDirect3DSurface8_LockRect(surface, &locked_rect, &rect, 0);
|
||||
ok(!SUCCEEDED(hr) == !pools[j].success || broken(formats[i].broken),
|
||||
"Partial block lock %s, expected %s, format %s, pool %s.\n",
|
||||
SUCCEEDED(hr) ? "succeeded" : "failed",
|
||||
pools[j].success ? "success" : "failure", formats[i].name, pools[j].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IDirect3DSurface8_UnlockRect(surface);
|
||||
ok(SUCCEEDED(hr), "IDirect3DSurface8_UnlockRect failed (%08x)\n", hr);
|
||||
}
|
||||
}
|
||||
|
||||
SetRect(&rect, 0, 0, formats[i].block_width, formats[i].block_height);
|
||||
hr = IDirect3DSurface8_LockRect(surface, &locked_rect, &rect, 0);
|
||||
ok(hr == D3D_OK, "Full block lock returned %08x, expected %08x, format %s, pool %s\n",
|
||||
hr, D3D_OK, formats[i].name, pools[j].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IDirect3DSurface8_UnlockRect(surface);
|
||||
ok(SUCCEEDED(hr), "IDirect3DSurface8_UnlockRect failed (%08x)\n", hr);
|
||||
}
|
||||
|
||||
IDirect3DSurface8_Release(surface);
|
||||
}
|
||||
}
|
||||
IDirect3D8_Release(d3d);
|
||||
}
|
||||
|
||||
START_TEST(surface)
|
||||
{
|
||||
HMODULE d3d8_handle;
|
||||
|
@ -506,6 +646,7 @@ START_TEST(surface)
|
|||
test_surface_dimensions(device_ptr);
|
||||
test_surface_format_null(device_ptr);
|
||||
test_surface_double_unlock(device_ptr);
|
||||
test_surface_lockrect_blocks(device_ptr);
|
||||
|
||||
refcount = IDirect3DDevice8_Release(device_ptr);
|
||||
ok(!refcount, "Device has %u references left\n", refcount);
|
||||
|
|
Loading…
Reference in New Issue