Commit 6dc5d194 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: DDSCAPS_ALLOCONLOAD doesn't override DDSD_LPSURFACE.

parent 6c9e1a47
...@@ -5968,10 +5968,6 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ ...@@ -5968,10 +5968,6 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
} }
} }
/* If the surface is of the 'ALLOCONLOAD' type, ignore the LPSURFACE
* field. Frank Herbert's Dune specifies a NULL pointer for lpSurface. */
if (desc->ddsCaps.dwCaps & DDSCAPS_ALLOCONLOAD)
desc->dwFlags &= ~DDSD_LPSURFACE;
if (desc->dwFlags & DDSD_LPSURFACE) if (desc->dwFlags & DDSD_LPSURFACE)
{ {
if (wined3d_desc.pool != WINED3D_POOL_SYSTEM_MEM) if (wined3d_desc.pool != WINED3D_POOL_SYSTEM_MEM)
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "wine/test.h" #include "wine/test.h"
#include "d3d.h" #include "d3d.h"
static BOOL is_ddraw64 = sizeof(DWORD) != sizeof(DWORD *);
static DEVMODEW registry_mode; static DEVMODEW registry_mode;
struct create_window_thread_param struct create_window_thread_param
...@@ -4886,7 +4887,7 @@ static void test_create_surface_pitch(void) ...@@ -4886,7 +4887,7 @@ static void test_create_surface_pitch(void)
static const struct static const struct
{ {
DWORD placement; DWORD caps;
DWORD flags_in; DWORD flags_in;
DWORD pitch_in; DWORD pitch_in;
HRESULT hr; HRESULT hr;
...@@ -4896,26 +4897,51 @@ static void test_create_surface_pitch(void) ...@@ -4896,26 +4897,51 @@ static void test_create_surface_pitch(void)
} }
test_data[] = test_data[] =
{ {
{DDSCAPS_VIDEOMEMORY, 0, 0, DD_OK, /* 0 */
DDSD_PITCH, 0x100, 0x100}, {DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN,
{DDSCAPS_VIDEOMEMORY, DDSD_PITCH, 0x104, DD_OK, 0, 0, DD_OK,
DDSD_PITCH, 0x100, 0x100}, DDSD_PITCH, 0x100, 0x100},
{DDSCAPS_VIDEOMEMORY, DDSD_PITCH, 0x0f8, DD_OK, {DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN,
DDSD_PITCH, 0x100, 0x100}, DDSD_PITCH, 0x104, DD_OK,
{DDSCAPS_VIDEOMEMORY, DDSD_LPSURFACE | DDSD_PITCH, 0x100, DDERR_INVALIDCAPS, DDSD_PITCH, 0x100, 0x100},
0, 0, 0 }, {DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN,
{DDSCAPS_SYSTEMMEMORY, 0, 0, DD_OK, DDSD_PITCH, 0x0f8, DD_OK,
DDSD_PITCH, 0x100, 0x0fc}, DDSD_PITCH, 0x100, 0x100},
{DDSCAPS_SYSTEMMEMORY, DDSD_PITCH, 0x104, DD_OK, {DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN,
DDSD_PITCH, 0x100, 0x0fc}, DDSD_LPSURFACE | DDSD_PITCH, 0x100, DDERR_INVALIDCAPS,
{DDSCAPS_SYSTEMMEMORY, DDSD_PITCH, 0x0f8, DD_OK, 0, 0, 0 },
DDSD_PITCH, 0x100, 0x0fc}, {DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN,
{DDSCAPS_SYSTEMMEMORY, DDSD_PITCH | DDSD_LINEARSIZE, 0, DD_OK, 0, 0, DD_OK,
DDSD_PITCH, 0x100, 0x0fc}, DDSD_PITCH, 0x100, 0x0fc},
{DDSCAPS_SYSTEMMEMORY, DDSD_LPSURFACE, 0, DDERR_INVALIDPARAMS, /* 5 */
0, 0, 0 }, {DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN,
{DDSCAPS_SYSTEMMEMORY, DDSD_LPSURFACE | DDSD_PITCH, 0x100, DDERR_INVALIDPARAMS, DDSD_PITCH, 0x104, DD_OK,
0, 0, 0 }, DDSD_PITCH, 0x100, 0x0fc},
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN,
DDSD_PITCH, 0x0f8, DD_OK,
DDSD_PITCH, 0x100, 0x0fc},
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN,
DDSD_PITCH | DDSD_LINEARSIZE, 0, DD_OK,
DDSD_PITCH, 0x100, 0x0fc},
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN,
DDSD_LPSURFACE, 0, DDERR_INVALIDPARAMS,
0, 0, 0 },
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN,
DDSD_LPSURFACE | DDSD_PITCH, 0x100, DDERR_INVALIDPARAMS,
0, 0, 0 },
/* 10 */
{DDSCAPS_VIDEOMEMORY | DDSCAPS_TEXTURE | DDSCAPS_ALLOCONLOAD,
0, 0, DD_OK,
DDSD_PITCH, 0x100, 0 },
{DDSCAPS_VIDEOMEMORY | DDSCAPS_TEXTURE | DDSCAPS_ALLOCONLOAD,
DDSD_LPSURFACE | DDSD_PITCH, 0x100, DDERR_INVALIDCAPS,
0, 0, 0 },
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_TEXTURE | DDSCAPS_ALLOCONLOAD,
0, 0, DD_OK,
DDSD_PITCH, 0x100, 0 },
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_TEXTURE | DDSCAPS_ALLOCONLOAD,
DDSD_LPSURFACE | DDSD_PITCH, 0x100, DDERR_INVALIDPARAMS,
0, 0, 0 },
}; };
DWORD flags_mask = DDSD_PITCH | DDSD_LPSURFACE | DDSD_LINEARSIZE; DWORD flags_mask = DDSD_PITCH | DDSD_LPSURFACE | DDSD_LINEARSIZE;
...@@ -4933,7 +4959,7 @@ static void test_create_surface_pitch(void) ...@@ -4933,7 +4959,7 @@ static void test_create_surface_pitch(void)
memset(&surface_desc, 0, sizeof(surface_desc)); memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc); surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | test_data[i].flags_in; surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | test_data[i].flags_in;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | test_data[i].placement; surface_desc.ddsCaps.dwCaps = test_data[i].caps;
surface_desc.dwWidth = 63; surface_desc.dwWidth = 63;
surface_desc.dwHeight = 63; surface_desc.dwHeight = 63;
U1(surface_desc).lPitch = test_data[i].pitch_in; U1(surface_desc).lPitch = test_data[i].pitch_in;
...@@ -4951,8 +4977,9 @@ static void test_create_surface_pitch(void) ...@@ -4951,8 +4977,9 @@ static void test_create_surface_pitch(void)
surface_desc.lpSurface = mem; surface_desc.lpSurface = mem;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL); hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
} }
ok(hr == test_data[i].hr || (test_data[i].placement == DDSCAPS_VIDEOMEMORY && hr == DDERR_NODIRECTDRAWHW), if ((test_data[i].caps & DDSCAPS_VIDEOMEMORY) && hr == DDERR_NODIRECTDRAWHW)
"Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr); continue;
ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
if (FAILED(hr)) if (FAILED(hr))
continue; continue;
...@@ -4963,14 +4990,17 @@ static void test_create_surface_pitch(void) ...@@ -4963,14 +4990,17 @@ static void test_create_surface_pitch(void)
ok((surface_desc.dwFlags & flags_mask) == test_data[i].flags_out, ok((surface_desc.dwFlags & flags_mask) == test_data[i].flags_out,
"Test %u: Got unexpected flags %#x, expected %#x.\n", "Test %u: Got unexpected flags %#x, expected %#x.\n",
i, surface_desc.dwFlags & flags_mask, test_data[i].flags_out); i, surface_desc.dwFlags & flags_mask, test_data[i].flags_out);
if (sizeof(void *) != sizeof(DWORD) && test_data[i].pitch_out32 != test_data[i].pitch_out64) if (!(test_data[i].caps & DDSCAPS_TEXTURE))
todo_wine ok(U1(surface_desc).lPitch == test_data[i].pitch_out64, {
"Test %u: Got unexpected pitch %u, expected %u.\n", if (is_ddraw64 && test_data[i].pitch_out32 != test_data[i].pitch_out64)
i, U1(surface_desc).lPitch, test_data[i].pitch_out64); todo_wine ok(U1(surface_desc).lPitch == test_data[i].pitch_out64,
else "Test %u: Got unexpected pitch %u, expected %u.\n",
ok(U1(surface_desc).lPitch == test_data[i].pitch_out32, i, U1(surface_desc).lPitch, test_data[i].pitch_out64);
"Test %u: Got unexpected pitch %u, expected %u.\n", else
i, U1(surface_desc).lPitch, test_data[i].pitch_out32); ok(U1(surface_desc).lPitch == test_data[i].pitch_out32,
"Test %u: Got unexpected pitch %u, expected %u.\n",
i, U1(surface_desc).lPitch, test_data[i].pitch_out32);
}
ok(!surface_desc.lpSurface, "Test %u: Got unexpected lpSurface %p.\n", i, surface_desc.lpSurface); ok(!surface_desc.lpSurface, "Test %u: Got unexpected lpSurface %p.\n", i, surface_desc.lpSurface);
IDirectDrawSurface_Release(surface); IDirectDrawSurface_Release(surface);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "wine/test.h" #include "wine/test.h"
#include "d3d.h" #include "d3d.h"
static BOOL is_ddraw64 = sizeof(DWORD) != sizeof(DWORD *);
static DEVMODEW registry_mode; static DEVMODEW registry_mode;
struct create_window_thread_param struct create_window_thread_param
...@@ -5928,7 +5929,7 @@ static void test_create_surface_pitch(void) ...@@ -5928,7 +5929,7 @@ static void test_create_surface_pitch(void)
static const struct static const struct
{ {
DWORD placement; DWORD caps;
DWORD flags_in; DWORD flags_in;
DWORD pitch_in; DWORD pitch_in;
HRESULT hr; HRESULT hr;
...@@ -5938,26 +5939,51 @@ static void test_create_surface_pitch(void) ...@@ -5938,26 +5939,51 @@ static void test_create_surface_pitch(void)
} }
test_data[] = test_data[] =
{ {
{DDSCAPS_VIDEOMEMORY, 0, 0, DD_OK, /* 0 */
DDSD_PITCH, 0x100, 0x100}, {DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN,
{DDSCAPS_VIDEOMEMORY, DDSD_PITCH, 0x104, DD_OK, 0, 0, DD_OK,
DDSD_PITCH, 0x100, 0x100}, DDSD_PITCH, 0x100, 0x100},
{DDSCAPS_VIDEOMEMORY, DDSD_PITCH, 0x0f8, DD_OK, {DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN,
DDSD_PITCH, 0x100, 0x100}, DDSD_PITCH, 0x104, DD_OK,
{DDSCAPS_VIDEOMEMORY, DDSD_LPSURFACE | DDSD_PITCH, 0x100, DDERR_INVALIDCAPS, DDSD_PITCH, 0x100, 0x100},
0, 0, 0 }, {DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN,
{DDSCAPS_SYSTEMMEMORY, 0, 0, DD_OK, DDSD_PITCH, 0x0f8, DD_OK,
DDSD_PITCH, 0x100, 0x0fc}, DDSD_PITCH, 0x100, 0x100},
{DDSCAPS_SYSTEMMEMORY, DDSD_PITCH, 0x104, DD_OK, {DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN,
DDSD_PITCH, 0x100, 0x0fc}, DDSD_LPSURFACE | DDSD_PITCH, 0x100, DDERR_INVALIDCAPS,
{DDSCAPS_SYSTEMMEMORY, DDSD_PITCH, 0x0f8, DD_OK, 0, 0, 0 },
DDSD_PITCH, 0x100, 0x0fc}, {DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN,
{DDSCAPS_SYSTEMMEMORY, DDSD_PITCH | DDSD_LINEARSIZE, 0, DD_OK, 0, 0, DD_OK,
DDSD_PITCH, 0x100, 0x0fc}, DDSD_PITCH, 0x100, 0x0fc},
{DDSCAPS_SYSTEMMEMORY, DDSD_LPSURFACE, 0, DDERR_INVALIDPARAMS, /* 5 */
0, 0, 0 }, {DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN,
{DDSCAPS_SYSTEMMEMORY, DDSD_LPSURFACE | DDSD_PITCH, 0x100, DDERR_INVALIDPARAMS, DDSD_PITCH, 0x104, DD_OK,
0, 0, 0 }, DDSD_PITCH, 0x100, 0x0fc},
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN,
DDSD_PITCH, 0x0f8, DD_OK,
DDSD_PITCH, 0x100, 0x0fc},
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN,
DDSD_PITCH | DDSD_LINEARSIZE, 0, DD_OK,
DDSD_PITCH, 0x100, 0x0fc},
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN,
DDSD_LPSURFACE, 0, DDERR_INVALIDPARAMS,
0, 0, 0 },
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN,
DDSD_LPSURFACE | DDSD_PITCH, 0x100, DDERR_INVALIDPARAMS,
0, 0, 0 },
/* 10 */
{DDSCAPS_VIDEOMEMORY | DDSCAPS_TEXTURE | DDSCAPS_ALLOCONLOAD,
0, 0, DD_OK,
DDSD_PITCH, 0x100, 0 },
{DDSCAPS_VIDEOMEMORY | DDSCAPS_TEXTURE | DDSCAPS_ALLOCONLOAD,
DDSD_LPSURFACE | DDSD_PITCH, 0x100, DDERR_INVALIDCAPS,
0, 0, 0 },
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_TEXTURE | DDSCAPS_ALLOCONLOAD,
0, 0, DD_OK,
DDSD_PITCH, 0x100, 0 },
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_TEXTURE | DDSCAPS_ALLOCONLOAD,
DDSD_LPSURFACE | DDSD_PITCH, 0x100, DDERR_INVALIDPARAMS,
0, 0, 0 },
}; };
DWORD flags_mask = DDSD_PITCH | DDSD_LPSURFACE | DDSD_LINEARSIZE; DWORD flags_mask = DDSD_PITCH | DDSD_LPSURFACE | DDSD_LINEARSIZE;
...@@ -5975,7 +6001,7 @@ static void test_create_surface_pitch(void) ...@@ -5975,7 +6001,7 @@ static void test_create_surface_pitch(void)
memset(&surface_desc, 0, sizeof(surface_desc)); memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc); surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | test_data[i].flags_in; surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | test_data[i].flags_in;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | test_data[i].placement; surface_desc.ddsCaps.dwCaps = test_data[i].caps;
surface_desc.dwWidth = 63; surface_desc.dwWidth = 63;
surface_desc.dwHeight = 63; surface_desc.dwHeight = 63;
U1(surface_desc).lPitch = test_data[i].pitch_in; U1(surface_desc).lPitch = test_data[i].pitch_in;
...@@ -5993,8 +6019,9 @@ static void test_create_surface_pitch(void) ...@@ -5993,8 +6019,9 @@ static void test_create_surface_pitch(void)
surface_desc.lpSurface = mem; surface_desc.lpSurface = mem;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL); hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
} }
ok(hr == test_data[i].hr || (test_data[i].placement == DDSCAPS_VIDEOMEMORY && hr == DDERR_NODIRECTDRAWHW), if ((test_data[i].caps & DDSCAPS_VIDEOMEMORY) && hr == DDERR_NODIRECTDRAWHW)
"Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr); continue;
ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
if (FAILED(hr)) if (FAILED(hr))
continue; continue;
...@@ -6005,14 +6032,18 @@ static void test_create_surface_pitch(void) ...@@ -6005,14 +6032,18 @@ static void test_create_surface_pitch(void)
ok((surface_desc.dwFlags & flags_mask) == test_data[i].flags_out, ok((surface_desc.dwFlags & flags_mask) == test_data[i].flags_out,
"Test %u: Got unexpected flags %#x, expected %#x.\n", "Test %u: Got unexpected flags %#x, expected %#x.\n",
i, surface_desc.dwFlags & flags_mask, test_data[i].flags_out); i, surface_desc.dwFlags & flags_mask, test_data[i].flags_out);
if (sizeof(void *) != sizeof(DWORD) && test_data[i].pitch_out32 != test_data[i].pitch_out64) /* The pitch for textures seems to be implementation specific. */
todo_wine ok(U1(surface_desc).lPitch == test_data[i].pitch_out64, if (!(test_data[i].caps & DDSCAPS_TEXTURE))
"Test %u: Got unexpected pitch %u, expected %u.\n", {
i, U1(surface_desc).lPitch, test_data[i].pitch_out64); if (is_ddraw64 && test_data[i].pitch_out32 != test_data[i].pitch_out64)
else todo_wine ok(U1(surface_desc).lPitch == test_data[i].pitch_out64,
ok(U1(surface_desc).lPitch == test_data[i].pitch_out32, "Test %u: Got unexpected pitch %u, expected %u.\n",
"Test %u: Got unexpected pitch %u, expected %u.\n", i, U1(surface_desc).lPitch, test_data[i].pitch_out64);
i, U1(surface_desc).lPitch, test_data[i].pitch_out32); else
ok(U1(surface_desc).lPitch == test_data[i].pitch_out32,
"Test %u: Got unexpected pitch %u, expected %u.\n",
i, U1(surface_desc).lPitch, test_data[i].pitch_out32);
}
ok(!surface_desc.lpSurface, "Test %u: Got unexpected lpSurface %p.\n", i, surface_desc.lpSurface); ok(!surface_desc.lpSurface, "Test %u: Got unexpected lpSurface %p.\n", i, surface_desc.lpSurface);
IDirectDrawSurface_Release(surface); IDirectDrawSurface_Release(surface);
......
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