ddraw: SetSurfaceDesc is not allowed on managed textures.

This commit is contained in:
Stefan Dösinger 2013-12-03 13:44:34 +01:00 committed by Alexandre Julliard
parent eb361e9eec
commit 1f36605886
4 changed files with 179 additions and 97 deletions

View File

@ -4245,7 +4245,8 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface,
WARN("Flags is %x, returning DDERR_INVALIDPARAMS\n", Flags);
return DDERR_INVALIDPARAMS;
}
if (!(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY))
if (!(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY) ||
This->surface_desc.ddsCaps.dwCaps2 & (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE))
{
WARN("Surface is not in system memory, returning DDERR_INVALIDSURFACETYPE.\n");
return DDERR_INVALIDSURFACETYPE;

View File

@ -4414,6 +4414,18 @@ static void test_set_surface_desc(void)
IDirectDrawSurface3 *surface3;
BYTE data[16*16*4];
ULONG ref;
unsigned int i;
static const struct
{
DWORD caps;
BOOL supported;
const char *name;
}
invalid_caps_tests[] =
{
{DDSCAPS_VIDEOMEMORY, FALSE, "videomemory plain"},
{DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY, TRUE, "systemmemory texture"},
};
if (!(ddraw = create_ddraw()))
{
@ -4611,9 +4623,11 @@ static void test_set_surface_desc(void)
IDirectDrawSurface3_Release(surface3);
/* Need systemmemory surfaces.
/* SetSurfaceDesc needs systemmemory surfaces.
*
* As a sidenote, fourcc surfaces aren't allowed in sysmem, thus testing DDSD_LINEARSIZE is moot. */
for (i = 0; i < sizeof(invalid_caps_tests) / sizeof(*invalid_caps_tests); i++)
{
reset_ddsd(&ddsd);
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
ddsd.dwWidth = 8;
@ -4624,13 +4638,14 @@ static void test_set_surface_desc(void)
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
ddsd.ddsCaps.dwCaps = invalid_caps_tests[i].caps;
hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
ok(SUCCEEDED(hr) || hr == DDERR_NODIRECTDRAWHW, "Failed to create surface, hr %#x.\n", hr);
if (FAILED(hr))
{
skip("Cannot create a video memory surface, skipping vidmem SetSurfaceDesc test.\n");
skip("Cannot create a %s surface, skipping vidmem SetSurfaceDesc test.\n",
invalid_caps_tests[i].name);
goto done;
}
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
@ -4641,14 +4656,24 @@ static void test_set_surface_desc(void)
ddsd.dwFlags = DDSD_LPSURFACE;
ddsd.lpSurface = data;
hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a vidmem surface returned %#x.\n", hr);
if (invalid_caps_tests[i].supported)
{
ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
}
else
{
ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n",
invalid_caps_tests[i].name, hr);
/* Check priority of error conditions. */
ddsd.dwFlags = DDSD_WIDTH;
hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a vidmem surface returned %#x.\n", hr);
ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n",
invalid_caps_tests[i].name, hr);
}
IDirectDrawSurface3_Release(surface3);
}
done:
ref = IDirectDraw2_Release(ddraw);

View File

@ -5017,6 +5017,20 @@ static void test_set_surface_desc(void)
IDirectDrawSurface4 *surface;
BYTE data[16*16*4];
ULONG ref;
unsigned int i;
static const struct
{
DWORD caps, caps2;
BOOL supported;
const char *name;
}
invalid_caps_tests[] =
{
{DDSCAPS_VIDEOMEMORY, 0, FALSE, "videomemory plain"},
{DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY, 0, TRUE, "systemmemory texture"},
{DDSCAPS_TEXTURE, DDSCAPS2_D3DTEXTUREMANAGE, FALSE, "managed texture"},
{DDSCAPS_TEXTURE, DDSCAPS2_TEXTUREMANAGE, FALSE, "managed texture"},
};
if (!(ddraw = create_ddraw()))
{
@ -5210,9 +5224,11 @@ static void test_set_surface_desc(void)
IDirectDrawSurface4_Release(surface);
/* Need systemmemory surfaces.
/* SetSurfaceDesc needs systemmemory surfaces.
*
* As a sidenote, fourcc surfaces aren't allowed in sysmem, thus testing DDSD_LINEARSIZE is moot. */
for (i = 0; i < sizeof(invalid_caps_tests) / sizeof(*invalid_caps_tests); i++)
{
reset_ddsd(&ddsd);
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
ddsd.dwWidth = 8;
@ -5223,13 +5239,15 @@ static void test_set_surface_desc(void)
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
ddsd.ddsCaps.dwCaps = invalid_caps_tests[i].caps;
ddsd.ddsCaps.dwCaps2 = invalid_caps_tests[i].caps2;
hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
ok(SUCCEEDED(hr) || hr == DDERR_NODIRECTDRAWHW, "Failed to create surface, hr %#x.\n", hr);
if (FAILED(hr))
{
skip("Cannot create a video memory surface, skipping vidmem SetSurfaceDesc test.\n");
skip("Cannot create a %s surface, skipping vidmem SetSurfaceDesc test.\n",
invalid_caps_tests[i].name);
goto done;
}
@ -5237,14 +5255,24 @@ static void test_set_surface_desc(void)
ddsd.dwFlags = DDSD_LPSURFACE;
ddsd.lpSurface = data;
hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a vidmem surface returned %#x.\n", hr);
if (invalid_caps_tests[i].supported)
{
ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
}
else
{
ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n",
invalid_caps_tests[i].name, hr);
/* Check priority of error conditions. */
ddsd.dwFlags = DDSD_WIDTH;
hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a vidmem surface returned %#x.\n", hr);
ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n",
invalid_caps_tests[i].name, hr);
}
IDirectDrawSurface4_Release(surface);
}
done:
ref = IDirectDraw4_Release(ddraw);

View File

@ -4904,6 +4904,20 @@ static void test_set_surface_desc(void)
IDirectDrawSurface7 *surface;
BYTE data[16*16*4];
ULONG ref;
unsigned int i;
static const struct
{
DWORD caps, caps2;
BOOL supported;
const char *name;
}
invalid_caps_tests[] =
{
{DDSCAPS_VIDEOMEMORY, 0, FALSE, "videomemory plain"},
{DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY, 0, TRUE, "systemmemory texture"},
{DDSCAPS_TEXTURE, DDSCAPS2_D3DTEXTUREMANAGE, FALSE, "managed texture"},
{DDSCAPS_TEXTURE, DDSCAPS2_TEXTUREMANAGE, FALSE, "managed texture"},
};
if (!(ddraw = create_ddraw()))
{
@ -5097,9 +5111,11 @@ static void test_set_surface_desc(void)
IDirectDrawSurface7_Release(surface);
/* Need systemmemory surfaces.
/* SetSurfaceDesc needs systemmemory surfaces.
*
* As a sidenote, fourcc surfaces aren't allowed in sysmem, thus testing DDSD_LINEARSIZE is moot. */
for (i = 0; i < sizeof(invalid_caps_tests) / sizeof(*invalid_caps_tests); i++)
{
reset_ddsd(&ddsd);
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
ddsd.dwWidth = 8;
@ -5110,13 +5126,15 @@ static void test_set_surface_desc(void)
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
ddsd.ddsCaps.dwCaps = invalid_caps_tests[i].caps;
ddsd.ddsCaps.dwCaps2 = invalid_caps_tests[i].caps2;
hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
ok(SUCCEEDED(hr) || hr == DDERR_NODIRECTDRAWHW, "Failed to create surface, hr %#x.\n", hr);
if (FAILED(hr))
{
skip("Cannot create a video memory surface, skipping vidmem SetSurfaceDesc test.\n");
skip("Cannot create a %s surface, skipping vidmem SetSurfaceDesc test.\n",
invalid_caps_tests[i].name);
goto done;
}
@ -5124,14 +5142,24 @@ static void test_set_surface_desc(void)
ddsd.dwFlags = DDSD_LPSURFACE;
ddsd.lpSurface = data;
hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a vidmem surface returned %#x.\n", hr);
if (invalid_caps_tests[i].supported)
{
ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
}
else
{
ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n",
invalid_caps_tests[i].name, hr);
/* Check priority of error conditions. */
ddsd.dwFlags = DDSD_WIDTH;
hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a vidmem surface returned %#x.\n", hr);
ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n",
invalid_caps_tests[i].name, hr);
}
IDirectDrawSurface7_Release(surface);
}
done:
ref = IDirectDraw7_Release(ddraw);