Henri Verbeet : wined3d: Just return the surface from wined3d_device_get_depth_stencil().
Alexandre Julliard
julliard at winehq.org
Mon Oct 1 13:35:01 CDT 2012
Module: wine
Branch: master
Commit: 95b4207c7fc553076242c799cd03d973521194ab
URL: http://source.winehq.org/git/wine.git/?a=commit;h=95b4207c7fc553076242c799cd03d973521194ab
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Mon Oct 1 11:05:22 2012 +0200
wined3d: Just return the surface from wined3d_device_get_depth_stencil().
---
dlls/d3d8/device.c | 26 +++++++++-----------------
dlls/d3d9/device.c | 9 +++------
dlls/ddraw/ddraw.c | 5 +++--
dlls/wined3d/device.c | 15 +++------------
dlls/wined3d/wined3d.spec | 2 +-
include/wine/wined3d.h | 3 +--
6 files changed, 20 insertions(+), 40 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 22280cd..751ba05 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -1122,19 +1122,14 @@ static HRESULT WINAPI d3d8_device_SetRenderTarget(IDirect3DDevice8 *iface,
}
}
- hr = wined3d_device_get_depth_stencil(device->wined3d_device, &original_ds);
- if (hr == WINED3D_OK || hr == WINED3DERR_NOTFOUND)
+ original_ds = wined3d_device_get_depth_stencil(device->wined3d_device);
+ hr = wined3d_device_set_depth_stencil(device->wined3d_device, ds_impl ? ds_impl->wined3d_surface : NULL);
+ if (SUCCEEDED(hr) && render_target)
{
- hr = wined3d_device_set_depth_stencil(device->wined3d_device, ds_impl ? ds_impl->wined3d_surface : NULL);
- if (SUCCEEDED(hr) && render_target)
- {
- hr = wined3d_device_set_render_target(device->wined3d_device, 0, rt_impl->wined3d_surface, TRUE);
- if (FAILED(hr))
- wined3d_device_set_depth_stencil(device->wined3d_device, original_ds);
- }
+ hr = wined3d_device_set_render_target(device->wined3d_device, 0, rt_impl->wined3d_surface, TRUE);
+ if (FAILED(hr))
+ wined3d_device_set_depth_stencil(device->wined3d_device, original_ds);
}
- if (original_ds)
- wined3d_surface_decref(original_ds);
wined3d_mutex_unlock();
@@ -1177,7 +1172,7 @@ static HRESULT WINAPI d3d8_device_GetDepthStencilSurface(IDirect3DDevice8 *iface
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
struct wined3d_surface *wined3d_surface;
struct d3d8_surface *surface_impl;
- HRESULT hr;
+ HRESULT hr = D3D_OK;
TRACE("iface %p, depth_stencil %p.\n", iface, depth_stencil);
@@ -1185,18 +1180,15 @@ static HRESULT WINAPI d3d8_device_GetDepthStencilSurface(IDirect3DDevice8 *iface
return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
- hr = wined3d_device_get_depth_stencil(device->wined3d_device, &wined3d_surface);
- if (SUCCEEDED(hr))
+ if ((wined3d_surface = wined3d_device_get_depth_stencil(device->wined3d_device)))
{
surface_impl = wined3d_surface_get_parent(wined3d_surface);
*depth_stencil = &surface_impl->IDirect3DSurface8_iface;
IDirect3DSurface8_AddRef(*depth_stencil);
- wined3d_surface_decref(wined3d_surface);
}
else
{
- if (hr != WINED3DERR_NOTFOUND)
- ERR("Failed to get wined3d depth stencil, hr %#x.\n", hr);
+ hr = WINED3DERR_NOTFOUND;
*depth_stencil = NULL;
}
wined3d_mutex_unlock();
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 68ab0a4..af2a92f 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1240,7 +1240,7 @@ static HRESULT WINAPI d3d9_device_GetDepthStencilSurface(IDirect3DDevice9Ex *ifa
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_surface *wined3d_surface;
struct d3d9_surface *surface_impl;
- HRESULT hr;
+ HRESULT hr = D3D_OK;
TRACE("iface %p, depth_stencil %p.\n", iface, depth_stencil);
@@ -1248,18 +1248,15 @@ static HRESULT WINAPI d3d9_device_GetDepthStencilSurface(IDirect3DDevice9Ex *ifa
return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
- hr = wined3d_device_get_depth_stencil(device->wined3d_device, &wined3d_surface);
- if (SUCCEEDED(hr))
+ if ((wined3d_surface = wined3d_device_get_depth_stencil(device->wined3d_device)))
{
surface_impl = wined3d_surface_get_parent(wined3d_surface);
*depth_stencil = &surface_impl->IDirect3DSurface9_iface;
IDirect3DSurface9_AddRef(*depth_stencil);
- wined3d_surface_decref(wined3d_surface);
}
else
{
- if (hr != WINED3DERR_NOTFOUND)
- WARN("Call to IWineD3DDevice_GetDepthStencilSurface failed with 0x%08x\n", hr);
+ hr = WINED3DERR_NOTFOUND;
*depth_stencil = NULL;
}
wined3d_mutex_unlock();
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index b352705..1530685 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -754,7 +754,7 @@ static HRESULT ddraw_create_swapchain(struct ddraw *ddraw, HWND window, BOOL win
static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd, DWORD cooplevel)
{
struct ddraw *This = impl_from_IDirectDraw7(iface);
- struct wined3d_surface *rt = NULL, *ds;
+ struct wined3d_surface *rt = NULL, *ds = NULL;
struct wined3d_stateblock *stateblock;
BOOL restore_state = FALSE;
HWND window;
@@ -938,7 +938,8 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
else if (rt)
wined3d_surface_incref(rt);
- wined3d_device_get_depth_stencil(This->wined3d_device, &ds);
+ if ((ds = wined3d_device_get_depth_stencil(This->wined3d_device)))
+ wined3d_surface_incref(ds);
}
ddraw_destroy_swapchain(This);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 29fb124..6927f9f 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4493,20 +4493,11 @@ struct wined3d_surface * CDECL wined3d_device_get_render_target(const struct win
return device->fb.render_targets[render_target_idx];
}
-HRESULT CDECL wined3d_device_get_depth_stencil(const struct wined3d_device *device,
- struct wined3d_surface **depth_stencil)
+struct wined3d_surface * CDECL wined3d_device_get_depth_stencil(const struct wined3d_device *device)
{
- TRACE("device %p, depth_stencil %p.\n", device, depth_stencil);
-
- *depth_stencil = device->fb.depth_stencil;
- TRACE("Returning depth/stencil surface %p.\n", *depth_stencil);
-
- if (!*depth_stencil)
- return WINED3DERR_NOTFOUND;
-
- wined3d_surface_incref(*depth_stencil);
+ TRACE("device %p.\n", device);
- return WINED3D_OK;
+ return device->fb.depth_stencil;
}
HRESULT CDECL wined3d_device_set_render_target(struct wined3d_device *device,
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 55bd32a..a885746 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -59,7 +59,7 @@
@ cdecl wined3d_device_get_clip_plane(ptr long ptr)
@ cdecl wined3d_device_get_clip_status(ptr ptr)
@ cdecl wined3d_device_get_creation_parameters(ptr ptr)
-@ cdecl wined3d_device_get_depth_stencil(ptr ptr)
+@ cdecl wined3d_device_get_depth_stencil(ptr)
@ cdecl wined3d_device_get_device_caps(ptr ptr)
@ cdecl wined3d_device_get_display_mode(ptr long ptr ptr)
@ cdecl wined3d_device_get_front_buffer_data(ptr long ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index a630e49..d527949 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2116,8 +2116,7 @@ HRESULT __cdecl wined3d_device_get_clip_status(const struct wined3d_device *devi
struct wined3d_clip_status *clip_status);
HRESULT __cdecl wined3d_device_get_creation_parameters(const struct wined3d_device *device,
struct wined3d_device_creation_parameters *creation_parameters);
-HRESULT __cdecl wined3d_device_get_depth_stencil(const struct wined3d_device *device,
- struct wined3d_surface **depth_stencil);
+struct wined3d_surface * __cdecl wined3d_device_get_depth_stencil(const struct wined3d_device *device);
HRESULT __cdecl wined3d_device_get_device_caps(const struct wined3d_device *device, WINED3DCAPS *caps);
HRESULT __cdecl wined3d_device_get_display_mode(const struct wined3d_device *device, UINT swapchain_idx,
struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation);
More information about the wine-cvs
mailing list