Commit 972217fd authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Just return the surface from wined3d_device_get_render_target().

parent 93418213
......@@ -1100,14 +1100,12 @@ static HRESULT WINAPI d3d8_device_SetRenderTarget(IDirect3DDevice8 *iface,
/* If no render target is passed in check the size against the current RT */
if (!render_target)
{
hr = wined3d_device_get_render_target(device->wined3d_device, 0, &original_rt);
if (FAILED(hr) || !original_rt)
if (!(original_rt = wined3d_device_get_render_target(device->wined3d_device, 0)))
{
wined3d_mutex_unlock();
return hr;
return D3DERR_NOTFOUND;
}
wined3d_resource = wined3d_surface_get_resource(original_rt);
wined3d_surface_decref(original_rt);
}
else
wined3d_resource = wined3d_surface_get_resource(rt_impl->wined3d_surface);
......@@ -1156,18 +1154,18 @@ static HRESULT WINAPI d3d8_device_GetRenderTarget(IDirect3DDevice8 *iface, IDire
return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
hr = wined3d_device_get_render_target(device->wined3d_device, 0, &wined3d_surface);
if (SUCCEEDED(hr) && wined3d_surface)
if ((wined3d_surface = wined3d_device_get_render_target(device->wined3d_device, 0)))
{
surface_impl = wined3d_surface_get_parent(wined3d_surface);
*render_target = &surface_impl->IDirect3DSurface8_iface;
IDirect3DSurface8_AddRef(*render_target);
wined3d_surface_decref(wined3d_surface);
hr = D3D_OK;
}
else
{
ERR("Failed to get wined3d render target, hr %#x.\n", hr);
ERR("Failed to get wined3d render target.\n");
*render_target = NULL;
hr = D3DERR_NOTFOUND;
}
wined3d_mutex_unlock();
......
......@@ -1190,7 +1190,7 @@ static HRESULT WINAPI d3d9_device_GetRenderTarget(IDirect3DDevice9Ex *iface, DWO
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, idx %u, surface %p.\n", iface, idx, surface);
......@@ -1204,18 +1204,15 @@ static HRESULT WINAPI d3d9_device_GetRenderTarget(IDirect3DDevice9Ex *iface, DWO
}
wined3d_mutex_lock();
hr = wined3d_device_get_render_target(device->wined3d_device, idx, &wined3d_surface);
if (SUCCEEDED(hr))
if ((wined3d_surface = wined3d_device_get_render_target(device->wined3d_device, idx)))
{
surface_impl = wined3d_surface_get_parent(wined3d_surface);
*surface = &surface_impl->IDirect3DSurface9_iface;
IDirect3DSurface9_AddRef(*surface);
wined3d_surface_decref(wined3d_surface);
}
else
{
if (hr != WINED3DERR_NOTFOUND)
WARN("Failed to get render target %u, hr %#x.\n", idx, hr);
hr = WINED3DERR_NOTFOUND;
*surface = NULL;
}
wined3d_mutex_unlock();
......
......@@ -754,8 +754,8 @@ 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_stateblock *stateblock;
struct wined3d_surface *rt, *ds;
BOOL restore_state = FALSE;
HWND window;
HRESULT hr;
......@@ -932,12 +932,11 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
return hr;
}
wined3d_device_get_render_target(This->wined3d_device, 0, &rt);
rt = wined3d_device_get_render_target(This->wined3d_device, 0);
if (rt == This->wined3d_frontbuffer)
{
wined3d_surface_decref(rt);
rt = NULL;
}
else if (rt)
wined3d_surface_incref(rt);
wined3d_device_get_depth_stencil(This->wined3d_device, &ds);
}
......
......@@ -4479,27 +4479,18 @@ void CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device,
if (FAILED(hr)) ERR("Color fill failed, hr %#x.\n", hr);
}
HRESULT CDECL wined3d_device_get_render_target(const struct wined3d_device *device,
UINT render_target_idx, struct wined3d_surface **render_target)
struct wined3d_surface * CDECL wined3d_device_get_render_target(const struct wined3d_device *device,
UINT render_target_idx)
{
TRACE("device %p, render_target_idx %u, render_target %p.\n",
device, render_target_idx, render_target);
TRACE("device %p, render_target_idx %u.\n", device, render_target_idx);
if (render_target_idx >= device->adapter->gl_info.limits.buffers)
{
WARN("Only %u render targets are supported.\n", device->adapter->gl_info.limits.buffers);
return WINED3DERR_INVALIDCALL;
return NULL;
}
*render_target = device->fb.render_targets[render_target_idx];
TRACE("Returning render target %p.\n", *render_target);
if (!*render_target)
return WINED3DERR_NOTFOUND;
wined3d_surface_incref(*render_target);
return WINED3D_OK;
return device->fb.render_targets[render_target_idx];
}
HRESULT CDECL wined3d_device_get_depth_stencil(const struct wined3d_device *device,
......
......@@ -76,7 +76,7 @@
@ cdecl wined3d_device_get_ps_consts_i(ptr long ptr long)
@ cdecl wined3d_device_get_raster_status(ptr long ptr)
@ cdecl wined3d_device_get_render_state(ptr long)
@ cdecl wined3d_device_get_render_target(ptr long ptr)
@ cdecl wined3d_device_get_render_target(ptr long)
@ cdecl wined3d_device_get_sampler_state(ptr long long)
@ cdecl wined3d_device_get_scissor_rect(ptr ptr)
@ cdecl wined3d_device_get_software_vertex_processing(ptr)
......
......@@ -2143,8 +2143,8 @@ HRESULT __cdecl wined3d_device_get_ps_consts_i(const struct wined3d_device *devi
HRESULT __cdecl wined3d_device_get_raster_status(const struct wined3d_device *device,
UINT swapchain_idx, struct wined3d_raster_status *raster_status);
DWORD __cdecl wined3d_device_get_render_state(const struct wined3d_device *device, enum wined3d_render_state state);
HRESULT __cdecl wined3d_device_get_render_target(const struct wined3d_device *device,
UINT render_target_idx, struct wined3d_surface **render_target);
struct wined3d_surface * __cdecl wined3d_device_get_render_target(const struct wined3d_device *device,
UINT render_target_idx);
DWORD __cdecl wined3d_device_get_sampler_state(const struct wined3d_device *device,
UINT sampler_idx, enum wined3d_sampler_state state);
void __cdecl wined3d_device_get_scissor_rect(const struct wined3d_device *device, RECT *rect);
......
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