Commit 1a786678 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

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.
parent 1b53cbd8
...@@ -1226,6 +1226,12 @@ static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWO ...@@ -1226,6 +1226,12 @@ static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWO
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }
if (!idx && !surface_impl)
{
WARN("Trying to set render target 0 to NULL.\n");
return D3DERR_INVALIDCALL;
}
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_device_set_render_target(device->wined3d_device, idx, hr = wined3d_device_set_render_target(device->wined3d_device, idx,
surface_impl ? surface_impl->wined3d_surface : NULL, TRUE); surface_impl ? surface_impl->wined3d_surface : NULL, TRUE);
......
...@@ -1827,10 +1827,15 @@ static HRESULT d3d_device_set_render_target(struct d3d_device *device, struct dd ...@@ -1827,10 +1827,15 @@ static HRESULT d3d_device_set_render_target(struct d3d_device *device, struct dd
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;
} }
if (!target)
{
WARN("Trying to set render target to NULL.\n");
wined3d_mutex_unlock();
return DDERR_INVALIDPARAMS;
}
device->target = target; device->target = target;
hr = wined3d_device_set_render_target(device->wined3d_device, 0, if (FAILED(hr = wined3d_device_set_render_target(device->wined3d_device,
target ? target->wined3d_surface : NULL, FALSE); 0, target->wined3d_surface, FALSE)))
if(hr != D3D_OK)
{ {
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
......
...@@ -1350,7 +1350,8 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) ...@@ -1350,7 +1350,8 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
TRACE("Setting rendertarget 0 to NULL\n"); TRACE("Setting rendertarget 0 to NULL\n");
device->fb.render_targets[0] = NULL; device->fb.render_targets[0] = NULL;
TRACE("Releasing the render target at %p\n", surface); TRACE("Releasing the render target at %p\n", surface);
wined3d_surface_decref(surface); if (surface)
wined3d_surface_decref(surface);
context_release(context); context_release(context);
...@@ -4482,13 +4483,6 @@ HRESULT CDECL wined3d_device_set_render_target(struct wined3d_device *device, ...@@ -4482,13 +4483,6 @@ HRESULT CDECL wined3d_device_set_render_target(struct wined3d_device *device,
return WINED3DERR_INVALIDCALL; 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)) if (render_target && !(render_target->resource.usage & WINED3DUSAGE_RENDERTARGET))
{ {
FIXME("Surface %p doesn't have render target usage.\n", render_target); FIXME("Surface %p doesn't have render target usage.\n", render_target);
......
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