Module: wine Branch: master Commit: 1a78667862139fea1491453deddf285b52f85870 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1a78667862139fea1491453ded...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Thu Sep 12 09:20:52 2013 +0200
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.
---
dlls/d3d9/device.c | 6 ++++++ dlls/ddraw/device.c | 11 ++++++++--- dlls/wined3d/device.c | 10 ++-------- 3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 17664b1..a70832d 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -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); diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 15145c0..2c02d65 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -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; diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 1b0137f..ef0ba9e 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -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);