Commit 1f366058 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ddraw: SetSurfaceDesc is not allowed on managed textures.

parent eb361e9e
......@@ -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;
......
......@@ -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,44 +4623,57 @@ 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. */
reset_ddsd(&ddsd);
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
ddsd.dwWidth = 8;
ddsd.dwHeight = 8;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
ok(SUCCEEDED(hr) || hr == DDERR_NODIRECTDRAWHW, "Failed to create surface, hr %#x.\n", hr);
if (FAILED(hr))
for (i = 0; i < sizeof(invalid_caps_tests) / sizeof(*invalid_caps_tests); i++)
{
skip("Cannot create a video memory surface, skipping vidmem SetSurfaceDesc test.\n");
goto done;
}
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface3 interface, hr %#x.\n", hr);
IDirectDrawSurface_Release(surface);
reset_ddsd(&ddsd);
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);
reset_ddsd(&ddsd);
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
ddsd.dwWidth = 8;
ddsd.dwHeight = 8;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
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 %s surface, skipping vidmem SetSurfaceDesc test.\n",
invalid_caps_tests[i].name);
goto done;
}
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface3 interface, hr %#x.\n", hr);
IDirectDrawSurface_Release(surface);
/* 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);
reset_ddsd(&ddsd);
ddsd.dwFlags = DDSD_LPSURFACE;
ddsd.lpSurface = data;
hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
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 %s surface returned %#x.\n",
invalid_caps_tests[i].name, hr);
}
IDirectDrawSurface3_Release(surface3);
IDirectDrawSurface3_Release(surface3);
}
done:
ref = IDirectDraw2_Release(ddraw);
......
......@@ -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,41 +5224,55 @@ 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. */
reset_ddsd(&ddsd);
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
ddsd.dwWidth = 8;
ddsd.dwHeight = 8;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
ok(SUCCEEDED(hr) || hr == DDERR_NODIRECTDRAWHW, "Failed to create surface, hr %#x.\n", hr);
if (FAILED(hr))
for (i = 0; i < sizeof(invalid_caps_tests) / sizeof(*invalid_caps_tests); i++)
{
skip("Cannot create a video memory surface, skipping vidmem SetSurfaceDesc test.\n");
goto done;
}
reset_ddsd(&ddsd);
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
ddsd.dwWidth = 8;
ddsd.dwHeight = 8;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
ddsd.ddsCaps.dwCaps = invalid_caps_tests[i].caps;
ddsd.ddsCaps.dwCaps2 = invalid_caps_tests[i].caps2;
reset_ddsd(&ddsd);
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);
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 %s surface, skipping vidmem SetSurfaceDesc test.\n",
invalid_caps_tests[i].name);
goto done;
}
/* 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);
reset_ddsd(&ddsd);
ddsd.dwFlags = DDSD_LPSURFACE;
ddsd.lpSurface = data;
hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
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 %s surface returned %#x.\n",
invalid_caps_tests[i].name, hr);
}
IDirectDrawSurface4_Release(surface);
IDirectDrawSurface4_Release(surface);
}
done:
ref = IDirectDraw4_Release(ddraw);
......
......@@ -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,41 +5111,55 @@ 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. */
reset_ddsd(&ddsd);
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
ddsd.dwWidth = 8;
ddsd.dwHeight = 8;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
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");
goto done;
}
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;
ddsd.dwHeight = 8;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
ddsd.ddsCaps.dwCaps = invalid_caps_tests[i].caps;
ddsd.ddsCaps.dwCaps2 = invalid_caps_tests[i].caps2;
reset_ddsd(&ddsd);
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);
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 %s surface, skipping vidmem SetSurfaceDesc test.\n",
invalid_caps_tests[i].name);
goto done;
}
/* 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);
reset_ddsd(&ddsd);
ddsd.dwFlags = DDSD_LPSURFACE;
ddsd.lpSurface = data;
hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
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 %s surface returned %#x.\n",
invalid_caps_tests[i].name, hr);
}
IDirectDrawSurface7_Release(surface);
IDirectDrawSurface7_Release(surface);
}
done:
ref = IDirectDraw7_Release(ddraw);
......
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