wined3d: Allow the first render target to be set to NULL.

Note that it still isn't necessarily safe to render in this case, because
there are places where we assume the first render target is always non-NULL in
order to determine e.g. framebuffer dimensions. It's now the responsibility of
the caller to ensure that doesn't happen.
This commit is contained in:
Henri Verbeet 2013-09-12 09:20:52 +02:00 committed by Alexandre Julliard
parent 1b53cbd8de
commit 1a78667862
3 changed files with 16 additions and 11 deletions

View File

@ -1226,6 +1226,12 @@ static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWO
return D3DERR_INVALIDCALL;
}
if (!idx && !surface_impl)
{
WARN("Trying to set render target 0 to NULL.\n");
return D3DERR_INVALIDCALL;
}
wined3d_mutex_lock();
hr = wined3d_device_set_render_target(device->wined3d_device, idx,
surface_impl ? surface_impl->wined3d_surface : NULL, TRUE);

View File

@ -1827,10 +1827,15 @@ static HRESULT d3d_device_set_render_target(struct d3d_device *device, struct dd
wined3d_mutex_unlock();
return D3D_OK;
}
if (!target)
{
WARN("Trying to set render target to NULL.\n");
wined3d_mutex_unlock();
return DDERR_INVALIDPARAMS;
}
device->target = target;
hr = wined3d_device_set_render_target(device->wined3d_device, 0,
target ? target->wined3d_surface : NULL, FALSE);
if(hr != D3D_OK)
if (FAILED(hr = wined3d_device_set_render_target(device->wined3d_device,
0, target->wined3d_surface, FALSE)))
{
wined3d_mutex_unlock();
return hr;

View File

@ -1350,7 +1350,8 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
TRACE("Setting rendertarget 0 to NULL\n");
device->fb.render_targets[0] = NULL;
TRACE("Releasing the render target at %p\n", surface);
wined3d_surface_decref(surface);
if (surface)
wined3d_surface_decref(surface);
context_release(context);
@ -4482,13 +4483,6 @@ HRESULT CDECL wined3d_device_set_render_target(struct wined3d_device *device,
return WINED3DERR_INVALIDCALL;
}
/* Render target 0 can't be set to NULL. */
if (!render_target && !render_target_idx)
{
WARN("Trying to set render target 0 to NULL.\n");
return WINED3DERR_INVALIDCALL;
}
if (render_target && !(render_target->resource.usage & WINED3DUSAGE_RENDERTARGET))
{
FIXME("Surface %p doesn't have render target usage.\n", render_target);