[d3d8] Fix CreateImageSurface implementation (with testcase)
Tobias Jakobi
liquid.acid at gmx.net
Fri Jun 20 07:41:03 CDT 2008
---
dlls/d3d8/device.c | 6 +++++-
dlls/d3d8/tests/surface.c | 42 ++++++++++++++++++++++++++++++++++++++++++
dlls/d3d9/device.c | 4 +++-
3 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index cf864cc..89a4d76 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -697,12 +697,16 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DD
return hr;
}
+/*
+A testcase for CreateImageSurface is implemented in tests/surface.c.
+It checks for the correct pool type of the returned surface object (which should be D3DPOOL_SYSTEMMEM and NOT D3DPOOL_SCRATCH)
+*/
static HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) {
HRESULT hr;
TRACE("Relay\n");
EnterCriticalSection(&d3d8_cs);
- hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Loackable */ , FALSE /*Discard*/ , 0 /* Level */ , ppSurface, D3DRTYPE_SURFACE, 0 /* Usage (undefined/none) */ , D3DPOOL_SCRATCH, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
+ hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Loackable */ , FALSE /*Discard*/ , 0 /* Level */ , ppSurface, D3DRTYPE_SURFACE, 0 /* Usage (undefined/none) */ , D3DPOOL_SYSTEMMEM, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
diff --git a/dlls/d3d8/tests/surface.c b/dlls/d3d8/tests/surface.c
index 6e0d48c..87a5e84 100644
--- a/dlls/d3d8/tests/surface.c
+++ b/dlls/d3d8/tests/surface.c
@@ -66,6 +66,48 @@ static IDirect3DDevice8 *init_d3d8(HMODULE d3d8_handle)
return device_ptr;
}
+/*
+The Direct3D9 documentation incorrectly states that CreateImageSurface
+returns a surface object with D3DPOOL_SCRATCH configuration. That conflicts
+with the explanation of CreateImageSurface in the documentation of the
+DirectX 8.1 SDK. There the surface has the D3DPOOL_SYSTEMMEM property.
+
+In fact the behaviour from the DX8.1 SDK seems the one implemented in
+Windows and the explanation from the D3D9 docs is wrong. This leads to
+screenshot problems in both Max Payne 1 and 2 (screenshots of the game
+scene aren't displayed in the savegame loading menu because the game
+engine wants to display a texture from the scratch pool).
+
+Find more information about the problem in this bugreport:
+http://bugs.winehq.org/show_bug.cgi?id=9775
+
+Interesting part of the MSDN DirectX documentation:
+Direct3D9 docs: "Converting to Direct3D 9"
+Direct3D9 docs: "IDirect3DDevice9::CreateOffscreenPlainSurface"
+*/
+static void test_image_surface_pool(IDirect3DDevice8 *device) {
+ IDirect3DSurface8 *surface = 0;
+ D3DSURFACE_DESC surf_desc;
+ HRESULT hr;
+
+ hr = IDirect3DDevice8_CreateImageSurface(device, 128, 128, D3DFMT_A8R8G8B8, &surface);
+ ok(SUCCEEDED(hr), "CreateImageSurface failed (0x%08x)\n", hr);
+
+ hr = IDirect3DSurface8_GetDesc(surface, &surf_desc);
+ ok(SUCCEEDED(hr), "GetDesc failed (0x%08x)\n", hr);
+
+ /*
+ D3DPOOL_DEFAULT = 0
+ D3DPOOL_MANAGED = 1
+ D3DPOOL_SYSTEMMEM = 2
+ D3DPOOL_SCRATCH = 3
+ */
+ ok((surf_desc.Pool == D3DPOOL_SYSTEMMEM),
+ "CreateImageSurface returns surface with unexpected pool type %u (should be SYSTEMMEM = 2)\n", surf_desc.Pool);
+
+ IDirect3DSurface8_Release(surface);
+}
+
static void test_surface_get_container(IDirect3DDevice8 *device_ptr)
{
IDirect3DTexture8 *texture_ptr = 0;
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index d69149d..a6ecacc 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -660,7 +660,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIREC
FIXME("Attempting to create a managed offscreen plain surface\n");
return D3DERR_INVALIDCALL;
}
- /*MSDN: D3DPOOL_SCRATCH will return a surface that has identical characteristics to a surface created by the Microsoft DirectX 8.x method CreateImageSurface.
+ /*MSDN: D3DPOOL_SCRATCH will return a surface that has identical characteristics to a surface created by the Microsoft DirectX 8.x method CreateImageSurface (quote from the DirectX9 documentation).
+ However this is wrong behaviour and conflicting with the explanation from the original DirectX8 documentation. According to DX8 docs it should be D3DPOOL_SYSTEMMEM and NOT D3DPOOL_SCRATCH.
+ For a testcase of the DX8 CreateImageSurface method look for test_image_surface_pool in dlls/d3d8/tests/surface.c
'Off-screen plain surfaces are always lockable, regardless of their pool types.'
but then...
--
1.5.4.5
--------------030303070707030805090708--
More information about the wine-patches
mailing list