ddraw/tests: Rewrite StructSizeTest().
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:
parent
aac4cc8fbb
commit
2c46fd0807
@ -4121,6 +4121,10 @@ static void test_surface_lock(void)
|
||||
ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#x.\n", tests[i].name, hr);
|
||||
}
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
hr = IDirectDrawSurface_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x, type %s.\n", hr, tests[i].name);
|
||||
|
||||
IDirectDrawSurface_Release(surface);
|
||||
}
|
||||
|
||||
@ -9793,6 +9797,162 @@ static void test_display_mode_surface_pixel_format(void)
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
static void test_surface_desc_size(void)
|
||||
{
|
||||
union
|
||||
{
|
||||
DWORD dwSize;
|
||||
DDSURFACEDESC desc1;
|
||||
DDSURFACEDESC2 desc2;
|
||||
BYTE blob[1024];
|
||||
} desc;
|
||||
IDirectDrawSurface7 *surface7;
|
||||
IDirectDrawSurface *surface;
|
||||
DDSURFACEDESC surface_desc;
|
||||
HRESULT expected_hr, hr;
|
||||
IDirectDraw *ddraw;
|
||||
unsigned int i, j;
|
||||
ULONG refcount;
|
||||
|
||||
static const struct
|
||||
{
|
||||
unsigned int caps;
|
||||
const char *name;
|
||||
}
|
||||
surface_caps[] =
|
||||
{
|
||||
{DDSCAPS_OFFSCREENPLAIN, "offscreenplain"},
|
||||
{DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY, "systemmemory texture"},
|
||||
{DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY, "videomemory texture"},
|
||||
};
|
||||
static const unsigned int desc_sizes[] =
|
||||
{
|
||||
sizeof(DDSURFACEDESC),
|
||||
sizeof(DDSURFACEDESC2),
|
||||
sizeof(DDSURFACEDESC) + 1,
|
||||
sizeof(DDSURFACEDESC2) + 1,
|
||||
2 * sizeof(DDSURFACEDESC),
|
||||
2 * sizeof(DDSURFACEDESC2),
|
||||
sizeof(DDSURFACEDESC) - 1,
|
||||
sizeof(DDSURFACEDESC2) - 1,
|
||||
sizeof(DDSURFACEDESC) / 2,
|
||||
sizeof(DDSURFACEDESC2) / 2,
|
||||
0,
|
||||
1,
|
||||
12,
|
||||
sizeof(desc) / 2,
|
||||
sizeof(desc) - 100,
|
||||
};
|
||||
|
||||
if (!(ddraw = create_ddraw()))
|
||||
{
|
||||
skip("Failed to create ddraw.\n");
|
||||
return;
|
||||
}
|
||||
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
|
||||
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
|
||||
|
||||
for (i = 0; i < sizeof(surface_caps) / sizeof(*surface_caps); ++i)
|
||||
{
|
||||
memset(&surface_desc, 0, sizeof(surface_desc));
|
||||
surface_desc.dwSize = sizeof(surface_desc);
|
||||
surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
||||
surface_desc.ddsCaps.dwCaps = surface_caps[i].caps;
|
||||
surface_desc.dwHeight = 128;
|
||||
surface_desc.dwWidth = 128;
|
||||
if (FAILED(IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL)))
|
||||
{
|
||||
skip("Failed to create surface, type %s.\n", surface_caps[i].name);
|
||||
continue;
|
||||
}
|
||||
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7);
|
||||
ok(hr == DD_OK, "Failed to query IDirectDrawSurface7, hr %#x, type %s.\n", hr, surface_caps[i].name);
|
||||
|
||||
/* GetSurfaceDesc() */
|
||||
for (j = 0; j < sizeof(desc_sizes) / sizeof(*desc_sizes); ++j)
|
||||
{
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc.desc1);
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
expected_hr = desc.dwSize == sizeof(DDSURFACEDESC2) ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc.desc2);
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
}
|
||||
|
||||
/* Lock() */
|
||||
for (j = 0; j < sizeof(desc_sizes) / sizeof(*desc_sizes); ++j)
|
||||
{
|
||||
const BOOL valid_size = desc_sizes[j] == sizeof(DDSURFACEDESC)
|
||||
|| desc_sizes[j] == sizeof(DDSURFACEDESC2);
|
||||
DWORD expected_texture_stage;
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
desc.desc2.dwTextureStage = 0xdeadbeef;
|
||||
desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
|
||||
hr = IDirectDrawSurface_Lock(surface, NULL, &desc.desc1, 0, 0);
|
||||
expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
|
||||
desc_sizes[j], desc.dwSize, surface_caps[i].name);
|
||||
ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
|
||||
desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(desc.desc1.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
|
||||
desc.desc1.dwWidth, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.desc1.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
|
||||
desc.desc1.dwHeight, desc_sizes[j], surface_caps[i].name);
|
||||
expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
|
||||
todo_wine_if(!expected_texture_stage)
|
||||
ok(desc.desc2.dwTextureStage == expected_texture_stage,
|
||||
"Got unexpected texture stage %#x, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
|
||||
IDirectDrawSurface_Unlock(surface, NULL);
|
||||
}
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
desc.desc2.dwTextureStage = 0xdeadbeef;
|
||||
desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
|
||||
hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
|
||||
expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
|
||||
desc_sizes[j], desc.dwSize, surface_caps[i].name);
|
||||
ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
|
||||
desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(desc.desc2.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwWidth, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.desc2.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwHeight, desc_sizes[j], surface_caps[i].name);
|
||||
expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
|
||||
ok(desc.desc2.dwTextureStage == expected_texture_stage,
|
||||
"Got unexpected texture stage %#x, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
|
||||
IDirectDrawSurface7_Unlock(surface7, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
IDirectDrawSurface7_Release(surface7);
|
||||
IDirectDrawSurface_Release(surface);
|
||||
}
|
||||
|
||||
refcount = IDirectDraw7_Release(ddraw);
|
||||
ok(!refcount, "DirectDraw has %u references left.\n", refcount);
|
||||
}
|
||||
|
||||
START_TEST(ddraw1)
|
||||
{
|
||||
IDirectDraw *ddraw;
|
||||
@ -9877,4 +10037,5 @@ START_TEST(ddraw1)
|
||||
test_getdc();
|
||||
test_transform_vertices();
|
||||
test_display_mode_surface_pixel_format();
|
||||
test_surface_desc_size();
|
||||
}
|
||||
|
@ -4751,6 +4751,10 @@ static void test_surface_lock(void)
|
||||
ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#x.\n", tests[i].name, hr);
|
||||
}
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
hr = IDirectDrawSurface_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x, type %s.\n", hr, tests[i].name);
|
||||
|
||||
IDirectDrawSurface_Release(surface);
|
||||
}
|
||||
|
||||
@ -11247,6 +11251,199 @@ static void test_display_mode_surface_pixel_format(void)
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
static void test_surface_desc_size(void)
|
||||
{
|
||||
union
|
||||
{
|
||||
DWORD dwSize;
|
||||
DDSURFACEDESC desc1;
|
||||
DDSURFACEDESC2 desc2;
|
||||
BYTE blob[1024];
|
||||
} desc;
|
||||
IDirectDrawSurface7 *surface7;
|
||||
IDirectDrawSurface2 *surface2;
|
||||
IDirectDrawSurface *surface;
|
||||
DDSURFACEDESC surface_desc;
|
||||
HRESULT expected_hr, hr;
|
||||
IDirectDraw2 *ddraw;
|
||||
unsigned int i, j;
|
||||
ULONG refcount;
|
||||
|
||||
static const struct
|
||||
{
|
||||
unsigned int caps;
|
||||
const char *name;
|
||||
}
|
||||
surface_caps[] =
|
||||
{
|
||||
{DDSCAPS_OFFSCREENPLAIN, "offscreenplain"},
|
||||
{DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY, "systemmemory texture"},
|
||||
{DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY, "videomemory texture"},
|
||||
};
|
||||
static const unsigned int desc_sizes[] =
|
||||
{
|
||||
sizeof(DDSURFACEDESC),
|
||||
sizeof(DDSURFACEDESC2),
|
||||
sizeof(DDSURFACEDESC) + 1,
|
||||
sizeof(DDSURFACEDESC2) + 1,
|
||||
2 * sizeof(DDSURFACEDESC),
|
||||
2 * sizeof(DDSURFACEDESC2),
|
||||
sizeof(DDSURFACEDESC) - 1,
|
||||
sizeof(DDSURFACEDESC2) - 1,
|
||||
sizeof(DDSURFACEDESC) / 2,
|
||||
sizeof(DDSURFACEDESC2) / 2,
|
||||
0,
|
||||
1,
|
||||
12,
|
||||
sizeof(desc) / 2,
|
||||
sizeof(desc) - 100,
|
||||
};
|
||||
|
||||
if (!(ddraw = create_ddraw()))
|
||||
{
|
||||
skip("Failed to create ddraw.\n");
|
||||
return;
|
||||
}
|
||||
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
|
||||
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
|
||||
|
||||
for (i = 0; i < sizeof(surface_caps) / sizeof(*surface_caps); ++i)
|
||||
{
|
||||
memset(&surface_desc, 0, sizeof(surface_desc));
|
||||
surface_desc.dwSize = sizeof(surface_desc);
|
||||
surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
||||
surface_desc.ddsCaps.dwCaps = surface_caps[i].caps;
|
||||
surface_desc.dwHeight = 128;
|
||||
surface_desc.dwWidth = 128;
|
||||
if (FAILED(IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL)))
|
||||
{
|
||||
skip("Failed to create surface, type %s.\n", surface_caps[i].name);
|
||||
continue;
|
||||
}
|
||||
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface2, (void **)&surface2);
|
||||
ok(hr == DD_OK, "Failed to query IDirectDrawSurface2, hr %#x, type %s.\n", hr, surface_caps[i].name);
|
||||
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7);
|
||||
ok(hr == DD_OK, "Failed to query IDirectDrawSurface7, hr %#x, type %s.\n", hr, surface_caps[i].name);
|
||||
|
||||
/* GetSurfaceDesc() */
|
||||
for (j = 0; j < sizeof(desc_sizes) / sizeof(*desc_sizes); ++j)
|
||||
{
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc.desc1);
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
hr = IDirectDrawSurface2_GetSurfaceDesc(surface2, &desc.desc1);
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
expected_hr = desc.dwSize == sizeof(DDSURFACEDESC2) ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc.desc2);
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
}
|
||||
|
||||
/* Lock() */
|
||||
for (j = 0; j < sizeof(desc_sizes) / sizeof(*desc_sizes); ++j)
|
||||
{
|
||||
const BOOL valid_size = desc_sizes[j] == sizeof(DDSURFACEDESC)
|
||||
|| desc_sizes[j] == sizeof(DDSURFACEDESC2);
|
||||
DWORD expected_texture_stage;
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
desc.desc2.dwTextureStage = 0xdeadbeef;
|
||||
desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
|
||||
hr = IDirectDrawSurface_Lock(surface, NULL, &desc.desc1, 0, 0);
|
||||
expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
|
||||
desc_sizes[j], desc.dwSize, surface_caps[i].name);
|
||||
ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
|
||||
desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(desc.desc1.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
|
||||
desc.desc1.dwWidth, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.desc1.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
|
||||
desc.desc1.dwHeight, desc_sizes[j], surface_caps[i].name);
|
||||
expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
|
||||
todo_wine_if(!expected_texture_stage)
|
||||
ok(desc.desc2.dwTextureStage == expected_texture_stage,
|
||||
"Got unexpected texture stage %#x, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
|
||||
IDirectDrawSurface_Unlock(surface, NULL);
|
||||
}
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
desc.desc2.dwTextureStage = 0xdeadbeef;
|
||||
desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
|
||||
hr = IDirectDrawSurface2_Lock(surface2, NULL, &desc.desc1, 0, 0);
|
||||
expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
|
||||
desc_sizes[j], desc.dwSize, surface_caps[i].name);
|
||||
ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
|
||||
desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(desc.desc2.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwWidth, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.desc2.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwHeight, desc_sizes[j], surface_caps[i].name);
|
||||
expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
|
||||
todo_wine_if(!expected_texture_stage)
|
||||
ok(desc.desc2.dwTextureStage == expected_texture_stage,
|
||||
"Got unexpected texture stage %#x, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
|
||||
IDirectDrawSurface2_Unlock(surface2, NULL);
|
||||
}
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
desc.desc2.dwTextureStage = 0xdeadbeef;
|
||||
desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
|
||||
hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
|
||||
expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
|
||||
desc_sizes[j], desc.dwSize, surface_caps[i].name);
|
||||
ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
|
||||
desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(desc.desc2.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwWidth, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.desc2.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwHeight, desc_sizes[j], surface_caps[i].name);
|
||||
expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
|
||||
ok(desc.desc2.dwTextureStage == expected_texture_stage,
|
||||
"Got unexpected texture stage %#x, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
|
||||
IDirectDrawSurface7_Unlock(surface7, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
IDirectDrawSurface7_Release(surface7);
|
||||
IDirectDrawSurface2_Release(surface2);
|
||||
IDirectDrawSurface_Release(surface);
|
||||
}
|
||||
|
||||
refcount = IDirectDraw2_Release(ddraw);
|
||||
ok(!refcount, "DirectDraw has %u references left.\n", refcount);
|
||||
}
|
||||
|
||||
START_TEST(ddraw2)
|
||||
{
|
||||
IDirectDraw2 *ddraw;
|
||||
@ -11340,4 +11537,5 @@ START_TEST(ddraw2)
|
||||
test_edge_antialiasing_blending();
|
||||
test_transform_vertices();
|
||||
test_display_mode_surface_pixel_format();
|
||||
test_surface_desc_size();
|
||||
}
|
||||
|
@ -6022,6 +6022,10 @@ static void test_surface_lock(void)
|
||||
ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#x.\n", tests[i].name, hr);
|
||||
}
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
hr = IDirectDrawSurface4_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x, type %s.\n", hr, tests[i].name);
|
||||
|
||||
IDirectDrawSurface4_Release(surface);
|
||||
}
|
||||
|
||||
@ -7260,12 +7264,12 @@ static void test_private_data(void)
|
||||
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
|
||||
|
||||
/* NULL pointers are not valid, but don't cause a crash. */
|
||||
hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL,
|
||||
hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL,
|
||||
sizeof(IUnknown *), DDSPD_IUNKNOWNPOINTER);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 0, 0);
|
||||
hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 0, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 1, 0);
|
||||
hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 1, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
/* DDSPD_IUNKNOWNPOINTER needs sizeof(IUnknown *) bytes of data. */
|
||||
@ -12532,6 +12536,199 @@ static void test_display_mode_surface_pixel_format(void)
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
static void test_surface_desc_size(void)
|
||||
{
|
||||
union
|
||||
{
|
||||
DWORD dwSize;
|
||||
DDSURFACEDESC desc1;
|
||||
DDSURFACEDESC2 desc2;
|
||||
BYTE blob[1024];
|
||||
} desc;
|
||||
IDirectDrawSurface4 *surface4;
|
||||
IDirectDrawSurface3 *surface3;
|
||||
IDirectDrawSurface *surface;
|
||||
DDSURFACEDESC2 surface_desc;
|
||||
HRESULT expected_hr, hr;
|
||||
IDirectDraw4 *ddraw;
|
||||
unsigned int i, j;
|
||||
ULONG refcount;
|
||||
|
||||
static const struct
|
||||
{
|
||||
unsigned int caps;
|
||||
const char *name;
|
||||
}
|
||||
surface_caps[] =
|
||||
{
|
||||
{DDSCAPS_OFFSCREENPLAIN, "offscreenplain"},
|
||||
{DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY, "systemmemory texture"},
|
||||
{DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY, "videomemory texture"},
|
||||
};
|
||||
static const unsigned int desc_sizes[] =
|
||||
{
|
||||
sizeof(DDSURFACEDESC),
|
||||
sizeof(DDSURFACEDESC2),
|
||||
sizeof(DDSURFACEDESC) + 1,
|
||||
sizeof(DDSURFACEDESC2) + 1,
|
||||
2 * sizeof(DDSURFACEDESC),
|
||||
2 * sizeof(DDSURFACEDESC2),
|
||||
sizeof(DDSURFACEDESC) - 1,
|
||||
sizeof(DDSURFACEDESC2) - 1,
|
||||
sizeof(DDSURFACEDESC) / 2,
|
||||
sizeof(DDSURFACEDESC2) / 2,
|
||||
0,
|
||||
1,
|
||||
12,
|
||||
sizeof(desc) / 2,
|
||||
sizeof(desc) - 100,
|
||||
};
|
||||
|
||||
if (!(ddraw = create_ddraw()))
|
||||
{
|
||||
skip("Failed to create ddraw.\n");
|
||||
return;
|
||||
}
|
||||
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
|
||||
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
|
||||
|
||||
for (i = 0; i < sizeof(surface_caps) / sizeof(*surface_caps); ++i)
|
||||
{
|
||||
memset(&surface_desc, 0, sizeof(surface_desc));
|
||||
surface_desc.dwSize = sizeof(surface_desc);
|
||||
surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
||||
surface_desc.ddsCaps.dwCaps = surface_caps[i].caps;
|
||||
surface_desc.dwHeight = 128;
|
||||
surface_desc.dwWidth = 128;
|
||||
if (FAILED(IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface4, NULL)))
|
||||
{
|
||||
skip("Failed to create surface, type %s.\n", surface_caps[i].name);
|
||||
continue;
|
||||
}
|
||||
hr = IDirectDrawSurface_QueryInterface(surface4, &IID_IDirectDrawSurface, (void **)&surface);
|
||||
ok(hr == DD_OK, "Failed to query IDirectDrawSurface, hr %#x, type %s.\n", hr, surface_caps[i].name);
|
||||
hr = IDirectDrawSurface_QueryInterface(surface4, &IID_IDirectDrawSurface3, (void **)&surface3);
|
||||
ok(hr == DD_OK, "Failed to query IDirectDrawSurface3, hr %#x, type %s.\n", hr, surface_caps[i].name);
|
||||
|
||||
/* GetSurfaceDesc() */
|
||||
for (j = 0; j < sizeof(desc_sizes) / sizeof(*desc_sizes); ++j)
|
||||
{
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc.desc1);
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
hr = IDirectDrawSurface3_GetSurfaceDesc(surface3, &desc.desc1);
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
expected_hr = desc.dwSize == sizeof(DDSURFACEDESC2) ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
hr = IDirectDrawSurface4_GetSurfaceDesc(surface4, &desc.desc2);
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
}
|
||||
|
||||
/* Lock() */
|
||||
for (j = 0; j < sizeof(desc_sizes) / sizeof(*desc_sizes); ++j)
|
||||
{
|
||||
const BOOL valid_size = desc_sizes[j] == sizeof(DDSURFACEDESC)
|
||||
|| desc_sizes[j] == sizeof(DDSURFACEDESC2);
|
||||
DWORD expected_texture_stage;
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
desc.desc2.dwTextureStage = 0xdeadbeef;
|
||||
desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
|
||||
hr = IDirectDrawSurface_Lock(surface, NULL, &desc.desc1, 0, 0);
|
||||
expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
|
||||
desc_sizes[j], desc.dwSize, surface_caps[i].name);
|
||||
ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
|
||||
desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(desc.desc1.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
|
||||
desc.desc1.dwWidth, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.desc1.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
|
||||
desc.desc1.dwHeight, desc_sizes[j], surface_caps[i].name);
|
||||
expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
|
||||
todo_wine_if(!expected_texture_stage)
|
||||
ok(desc.desc2.dwTextureStage == expected_texture_stage,
|
||||
"Got unexpected texture stage %#x, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
|
||||
IDirectDrawSurface_Unlock(surface, NULL);
|
||||
}
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
desc.desc2.dwTextureStage = 0xdeadbeef;
|
||||
desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
|
||||
hr = IDirectDrawSurface3_Lock(surface3, NULL, &desc.desc1, 0, 0);
|
||||
expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
|
||||
desc_sizes[j], desc.dwSize, surface_caps[i].name);
|
||||
ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
|
||||
desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(desc.desc1.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
|
||||
desc.desc1.dwWidth, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.desc1.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
|
||||
desc.desc1.dwHeight, desc_sizes[j], surface_caps[i].name);
|
||||
expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
|
||||
todo_wine_if(!expected_texture_stage)
|
||||
ok(desc.desc2.dwTextureStage == expected_texture_stage,
|
||||
"Got unexpected texture stage %#x, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
|
||||
IDirectDrawSurface3_Unlock(surface3, NULL);
|
||||
}
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
desc.desc2.dwTextureStage = 0xdeadbeef;
|
||||
desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
|
||||
hr = IDirectDrawSurface4_Lock(surface4, NULL, &desc.desc2, 0, 0);
|
||||
expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
|
||||
desc_sizes[j], desc.dwSize, surface_caps[i].name);
|
||||
ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
|
||||
desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(desc.desc2.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwWidth, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.desc2.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwHeight, desc_sizes[j], surface_caps[i].name);
|
||||
expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
|
||||
ok(desc.desc2.dwTextureStage == expected_texture_stage,
|
||||
"Got unexpected texture stage %#x, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
|
||||
IDirectDrawSurface4_Unlock(surface4, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
IDirectDrawSurface4_Release(surface4);
|
||||
IDirectDrawSurface3_Release(surface3);
|
||||
IDirectDrawSurface_Release(surface);
|
||||
}
|
||||
|
||||
refcount = IDirectDraw4_Release(ddraw);
|
||||
ok(!refcount, "DirectDraw has %u references left.\n", refcount);
|
||||
}
|
||||
|
||||
START_TEST(ddraw4)
|
||||
{
|
||||
IDirectDraw4 *ddraw;
|
||||
@ -12633,4 +12830,5 @@ START_TEST(ddraw4)
|
||||
test_edge_antialiasing_blending();
|
||||
test_transform_vertices();
|
||||
test_display_mode_surface_pixel_format();
|
||||
test_surface_desc_size();
|
||||
}
|
||||
|
@ -5692,7 +5692,7 @@ static void test_surface_lock(void)
|
||||
IDirect3D7 *d3d = NULL;
|
||||
IDirectDrawSurface7 *surface;
|
||||
IDirect3DDevice7 *device;
|
||||
HRESULT hr;
|
||||
HRESULT hr, expected_hr;
|
||||
HWND window;
|
||||
unsigned int i;
|
||||
DDSURFACEDESC2 ddsd;
|
||||
@ -5882,6 +5882,21 @@ static void test_surface_lock(void)
|
||||
ok(SUCCEEDED(hr), "Failed to lock surface, type %s, hr %#x.\n", tests[i].name, hr);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(ddsd.dwSize == sizeof(ddsd), "Got unexpected dwSize %u, type %s.\n", ddsd.dwSize, tests[i].name);
|
||||
hr = IDirectDrawSurface7_Unlock(surface, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#x.\n", tests[i].name, hr);
|
||||
}
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
expected_hr = tests[i].caps & DDSCAPS_TEXTURE && !(tests[i].caps & DDSCAPS_VIDEOMEMORY)
|
||||
? DD_OK : DDERR_INVALIDPARAMS;
|
||||
hr = IDirectDrawSurface7_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
|
||||
todo_wine_if(expected_hr == D3D_OK)
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, type %s.\n", hr, expected_hr, tests[i].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(!ddsd.dwSize, "Got unexpected dwSize %u, type %s.\n", ddsd.dwSize, tests[i].name);
|
||||
ok(!!ddsd.lpSurface, "Got NULL lpSurface, type %s.\n", tests[i].name);
|
||||
hr = IDirectDrawSurface7_Unlock(surface, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#x.\n", tests[i].name, hr);
|
||||
}
|
||||
@ -12193,6 +12208,204 @@ static void test_display_mode_surface_pixel_format(void)
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
static void test_surface_desc_size(void)
|
||||
{
|
||||
union
|
||||
{
|
||||
DWORD dwSize;
|
||||
DDSURFACEDESC desc1;
|
||||
DDSURFACEDESC2 desc2;
|
||||
BYTE blob[1024];
|
||||
} desc;
|
||||
IDirectDrawSurface7 *surface7;
|
||||
IDirectDrawSurface3 *surface3;
|
||||
IDirectDrawSurface *surface;
|
||||
DDSURFACEDESC2 surface_desc;
|
||||
HRESULT expected_hr, hr;
|
||||
IDirectDraw7 *ddraw;
|
||||
unsigned int i, j;
|
||||
ULONG refcount;
|
||||
|
||||
static const struct
|
||||
{
|
||||
unsigned int caps;
|
||||
const char *name;
|
||||
}
|
||||
surface_caps[] =
|
||||
{
|
||||
{DDSCAPS_OFFSCREENPLAIN, "offscreenplain"},
|
||||
{DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY, "systemmemory texture"},
|
||||
{DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY, "videomemory texture"},
|
||||
};
|
||||
static const unsigned int desc_sizes[] =
|
||||
{
|
||||
sizeof(DDSURFACEDESC),
|
||||
sizeof(DDSURFACEDESC2),
|
||||
sizeof(DDSURFACEDESC) + 1,
|
||||
sizeof(DDSURFACEDESC2) + 1,
|
||||
2 * sizeof(DDSURFACEDESC),
|
||||
2 * sizeof(DDSURFACEDESC2),
|
||||
sizeof(DDSURFACEDESC) - 1,
|
||||
sizeof(DDSURFACEDESC2) - 1,
|
||||
sizeof(DDSURFACEDESC) / 2,
|
||||
sizeof(DDSURFACEDESC2) / 2,
|
||||
0,
|
||||
1,
|
||||
12,
|
||||
sizeof(desc) / 2,
|
||||
sizeof(desc) - 100,
|
||||
};
|
||||
|
||||
if (!(ddraw = create_ddraw()))
|
||||
{
|
||||
skip("Failed to create ddraw.\n");
|
||||
return;
|
||||
}
|
||||
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
|
||||
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
|
||||
|
||||
for (i = 0; i < sizeof(surface_caps) / sizeof(*surface_caps); ++i)
|
||||
{
|
||||
memset(&surface_desc, 0, sizeof(surface_desc));
|
||||
surface_desc.dwSize = sizeof(surface_desc);
|
||||
surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
||||
surface_desc.ddsCaps.dwCaps = surface_caps[i].caps;
|
||||
surface_desc.dwHeight = 128;
|
||||
surface_desc.dwWidth = 128;
|
||||
if (FAILED(IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface7, NULL)))
|
||||
{
|
||||
skip("Failed to create surface, type %s.\n", surface_caps[i].name);
|
||||
continue;
|
||||
}
|
||||
hr = IDirectDrawSurface_QueryInterface(surface7, &IID_IDirectDrawSurface, (void **)&surface);
|
||||
ok(hr == DD_OK, "Failed to query IDirectDrawSurface, hr %#x, type %s.\n", hr, surface_caps[i].name);
|
||||
hr = IDirectDrawSurface_QueryInterface(surface7, &IID_IDirectDrawSurface3, (void **)&surface3);
|
||||
ok(hr == DD_OK, "Failed to query IDirectDrawSurface3, hr %#x, type %s.\n", hr, surface_caps[i].name);
|
||||
|
||||
/* GetSurfaceDesc() */
|
||||
for (j = 0; j < sizeof(desc_sizes) / sizeof(*desc_sizes); ++j)
|
||||
{
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc.desc1);
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
hr = IDirectDrawSurface3_GetSurfaceDesc(surface3, &desc.desc1);
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
expected_hr = desc.dwSize == sizeof(DDSURFACEDESC2) ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc.desc2);
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
}
|
||||
|
||||
/* Lock() */
|
||||
for (j = 0; j < sizeof(desc_sizes) / sizeof(*desc_sizes); ++j)
|
||||
{
|
||||
const BOOL ignore_size = surface_caps[i].caps & DDSCAPS_TEXTURE
|
||||
&& !(surface_caps[i].caps & DDSCAPS_VIDEOMEMORY);
|
||||
const BOOL valid_size = desc_sizes[j] == sizeof(DDSURFACEDESC)
|
||||
|| desc_sizes[j] == sizeof(DDSURFACEDESC2);
|
||||
DWORD expected_texture_stage;
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
desc.desc2.dwTextureStage = 0xdeadbeef;
|
||||
desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
|
||||
hr = IDirectDrawSurface_Lock(surface, NULL, &desc.desc1, 0, 0);
|
||||
expected_hr = ignore_size || valid_size ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
todo_wine_if(ignore_size && !valid_size)
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
|
||||
desc_sizes[j], desc.dwSize, surface_caps[i].name);
|
||||
ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
|
||||
desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(desc.desc1.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
|
||||
desc.desc1.dwWidth, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.desc1.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
|
||||
desc.desc1.dwHeight, desc_sizes[j], surface_caps[i].name);
|
||||
expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
|
||||
todo_wine_if(!expected_texture_stage)
|
||||
ok(desc.desc2.dwTextureStage == expected_texture_stage,
|
||||
"Got unexpected texture stage %#x, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
|
||||
IDirectDrawSurface_Unlock(surface, NULL);
|
||||
}
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
desc.desc2.dwTextureStage = 0xdeadbeef;
|
||||
desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
|
||||
hr = IDirectDrawSurface3_Lock(surface3, NULL, &desc.desc1, 0, 0);
|
||||
expected_hr = ignore_size || valid_size ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
todo_wine_if(ignore_size && !valid_size)
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
|
||||
desc_sizes[j], desc.dwSize, surface_caps[i].name);
|
||||
ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
|
||||
desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(desc.desc1.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
|
||||
desc.desc1.dwWidth, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.desc1.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
|
||||
desc.desc1.dwHeight, desc_sizes[j], surface_caps[i].name);
|
||||
expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
|
||||
todo_wine_if(!expected_texture_stage)
|
||||
ok(desc.desc2.dwTextureStage == expected_texture_stage,
|
||||
"Got unexpected texture stage %#x, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
|
||||
IDirectDrawSurface3_Unlock(surface3, NULL);
|
||||
}
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = desc_sizes[j];
|
||||
desc.desc2.dwTextureStage = 0xdeadbeef;
|
||||
desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
|
||||
hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
|
||||
expected_hr = ignore_size || valid_size ? DD_OK : DDERR_INVALIDPARAMS;
|
||||
todo_wine_if(ignore_size && !valid_size)
|
||||
ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
|
||||
hr, expected_hr, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
|
||||
desc_sizes[j], desc.dwSize, surface_caps[i].name);
|
||||
ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
|
||||
desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(desc.desc2.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwWidth, desc_sizes[j], surface_caps[i].name);
|
||||
ok(desc.desc2.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwHeight, desc_sizes[j], surface_caps[i].name);
|
||||
expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
|
||||
ok(desc.desc2.dwTextureStage == expected_texture_stage,
|
||||
"Got unexpected texture stage %#x, dwSize %u, type %s.\n",
|
||||
desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
|
||||
IDirectDrawSurface7_Unlock(surface7, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
IDirectDrawSurface7_Release(surface7);
|
||||
IDirectDrawSurface3_Release(surface3);
|
||||
IDirectDrawSurface_Release(surface);
|
||||
}
|
||||
|
||||
refcount = IDirectDraw7_Release(ddraw);
|
||||
ok(!refcount, "DirectDraw has %u references left.\n", refcount);
|
||||
}
|
||||
|
||||
START_TEST(ddraw7)
|
||||
{
|
||||
HMODULE module = GetModuleHandleA("ddraw.dll");
|
||||
@ -12304,4 +12517,5 @@ START_TEST(ddraw7)
|
||||
test_draw_primitive();
|
||||
test_edge_antialiasing_blending();
|
||||
test_display_mode_surface_pixel_format();
|
||||
test_surface_desc_size();
|
||||
}
|
||||
|
@ -1997,112 +1997,6 @@ static void PaletteTest(void)
|
||||
IDirectDrawSurface_Release(lpSurf);
|
||||
}
|
||||
|
||||
static void StructSizeTest(void)
|
||||
{
|
||||
IDirectDrawSurface *surface1;
|
||||
IDirectDrawSurface7 *surface7;
|
||||
union {
|
||||
DDSURFACEDESC desc1;
|
||||
DDSURFACEDESC2 desc2;
|
||||
char blob[1024]; /* To get a bunch of writable memory */
|
||||
} desc;
|
||||
DDSURFACEDESC create;
|
||||
HRESULT hr;
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
memset(&create, 0, sizeof(create));
|
||||
|
||||
memset(&create, 0, sizeof(create));
|
||||
create.dwSize = sizeof(create);
|
||||
create.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
||||
create.ddsCaps.dwCaps |= DDSCAPS_OFFSCREENPLAIN;
|
||||
create.dwHeight = 128;
|
||||
create.dwWidth = 128;
|
||||
hr = IDirectDraw_CreateSurface(lpDD, &create, &surface1, NULL);
|
||||
ok(hr == DD_OK, "Creating an offscreen plain surface failed with %08x\n", hr);
|
||||
hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface7, (void **) &surface7);
|
||||
ok(hr == DD_OK, "IDirectDrawSurface_QueryInterface failed with %08x\n", hr);
|
||||
|
||||
desc.desc1.dwSize = sizeof(DDSURFACEDESC);
|
||||
hr = IDirectDrawSurface_GetSurfaceDesc(surface1, &desc.desc1);
|
||||
ok(hr == DD_OK, "IDirectDrawSurface_GetSurfaceDesc with desc size sizeof(DDSURFACEDESC) returned %08x\n", hr);
|
||||
hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc.desc2);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_GetSurfaceDesc with desc size sizeof(DDSURFACEDESC) returned %08x\n", hr);
|
||||
|
||||
desc.desc2.dwSize = sizeof(DDSURFACEDESC2);
|
||||
hr = IDirectDrawSurface_GetSurfaceDesc(surface1, &desc.desc1);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface_GetSurfaceDesc with desc size sizeof(DDSURFACEDESC2) returned %08x\n", hr);
|
||||
hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc.desc2);
|
||||
ok(hr == DD_OK, "IDirectDrawSurface7_GetSurfaceDesc with desc size sizeof(DDSURFACEDESC2) returned %08x\n", hr);
|
||||
|
||||
desc.desc2.dwSize = 0;
|
||||
hr = IDirectDrawSurface_GetSurfaceDesc(surface1, &desc.desc1);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface_GetSurfaceDesc with desc size 0 returned %08x\n", hr);
|
||||
hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc.desc2);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_GetSurfaceDesc with desc size 0 returned %08x\n", hr);
|
||||
|
||||
desc.desc1.dwSize = sizeof(DDSURFACEDESC) + 1;
|
||||
hr = IDirectDrawSurface_GetSurfaceDesc(surface1, &desc.desc1);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface_GetSurfaceDesc with desc size sizeof(DDSURFACEDESC) + 1 returned %08x\n", hr);
|
||||
hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc.desc2);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_GetSurfaceDesc with desc size sizeof(DDSURFACEDESC) + 1 returned %08x\n", hr);
|
||||
|
||||
desc.desc2.dwSize = sizeof(DDSURFACEDESC2) + 1;
|
||||
hr = IDirectDrawSurface_GetSurfaceDesc(surface1, &desc.desc1);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface_GetSurfaceDesc with desc size sizeof(DDSURFACEDESC2) + 1returned %08x\n", hr);
|
||||
hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc.desc2);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_GetSurfaceDesc with desc size sizeof(DDSURFACEDESC2) + 1returned %08x\n", hr);
|
||||
|
||||
/* Tests for Lock() */
|
||||
|
||||
desc.desc1.dwSize = sizeof(DDSURFACEDESC);
|
||||
hr = IDirectDrawSurface_Lock(surface1, NULL, &desc.desc1, 0, 0);
|
||||
ok(hr == DD_OK, "IDirectDrawSurface_Lock with desc size sizeof(DDSURFACEDESC) returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface_Unlock(surface1, NULL);
|
||||
ok(desc.desc1.dwSize == sizeof(DDSURFACEDESC), "Destination size was changed to %d\n", desc.desc1.dwSize);
|
||||
hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
|
||||
ok(hr == DD_OK, "IDirectDrawSurface7_Lock with desc size sizeof(DDSURFACEDESC) returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface7_Unlock(surface7, NULL);
|
||||
ok(desc.desc2.dwSize == sizeof(DDSURFACEDESC), "Destination size was changed to %d\n", desc.desc1.dwSize);
|
||||
|
||||
desc.desc2.dwSize = sizeof(DDSURFACEDESC2);
|
||||
hr = IDirectDrawSurface_Lock(surface1, NULL, &desc.desc1, 0, 0);
|
||||
ok(hr == DD_OK, "IDirectDrawSurface_Lock with desc size sizeof(DDSURFACEDESC2) returned %08x\n", hr);
|
||||
ok(desc.desc1.dwSize == sizeof(DDSURFACEDESC2), "Destination size was changed to %d\n", desc.desc1.dwSize);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface_Unlock(surface1, NULL);
|
||||
hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
|
||||
ok(hr == DD_OK, "IDirectDrawSurface7_Lock with desc size sizeof(DDSURFACEDESC2) returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface7_Unlock(surface7, NULL);
|
||||
ok(desc.desc2.dwSize == sizeof(DDSURFACEDESC2), "Destination size was changed to %d\n", desc.desc1.dwSize);
|
||||
|
||||
desc.desc2.dwSize = 0;
|
||||
hr = IDirectDrawSurface_Lock(surface1, NULL, &desc.desc1, 0, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface_Lock with desc size 0 returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface_Unlock(surface1, NULL);
|
||||
hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_Lock with desc size 0 returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface7_Unlock(surface7, NULL);
|
||||
|
||||
desc.desc1.dwSize = sizeof(DDSURFACEDESC) + 1;
|
||||
hr = IDirectDrawSurface_Lock(surface1, NULL, &desc.desc1, 0, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface_Lock with desc size sizeof(DDSURFACEDESC) + 1 returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface_Unlock(surface1, NULL);
|
||||
hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_Lock with desc size sizeof(DDSURFACEDESC) + 1 returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface7_Unlock(surface7, NULL);
|
||||
|
||||
desc.desc2.dwSize = sizeof(DDSURFACEDESC2) + 1;
|
||||
hr = IDirectDrawSurface_Lock(surface1, NULL, &desc.desc1, 0, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface_Lock with desc size sizeof(DDSURFACEDESC2) + 1returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface_Unlock(surface1, NULL);
|
||||
hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
|
||||
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_Lock with desc size sizeof(DDSURFACEDESC2) + 1returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr)) IDirectDrawSurface7_Unlock(surface7, NULL);
|
||||
|
||||
IDirectDrawSurface7_Release(surface7);
|
||||
IDirectDrawSurface_Release(surface1);
|
||||
}
|
||||
|
||||
static void SurfaceCapsTest(void)
|
||||
{
|
||||
DDSURFACEDESC create;
|
||||
@ -3381,7 +3275,6 @@ START_TEST(dsurface)
|
||||
CompressedTest();
|
||||
SizeTest();
|
||||
BltParamTest();
|
||||
StructSizeTest();
|
||||
PaletteTest();
|
||||
SurfaceCapsTest();
|
||||
GetDCTest();
|
||||
|
Loading…
x
Reference in New Issue
Block a user