diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index ecebe7fe58a..a12781e11d4 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5871,6 +5871,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, implementations that use separate pbuffers for different swapchains or rendertargets will have to duplicate the stencil buffer and incure an extra memory overhead */ hr = IWineD3DDeviceImpl_ActiveRender(iface, pRenderTarget); + + /* Replace the render target */ + if (This->render_targets[RenderTargetIndex]) IWineD3DSurface_Release(This->render_targets[RenderTargetIndex]); + This->render_targets[RenderTargetIndex] = pRenderTarget; + if (pRenderTarget) IWineD3DSurface_AddRef(pRenderTarget); + if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) { set_render_target_fbo(iface, pRenderTarget); } @@ -6352,13 +6358,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ActiveRender(IWineD3DDevice* iface, device_render_to_texture(This, TRUE); } - /* Replace the render target */ - if (This->render_targets[0] != RenderSurface) { - IWineD3DSurface_Release(This->render_targets[0]); - This->render_targets[0] = RenderSurface; - IWineD3DSurface_AddRef(RenderSurface); - } - if (cfgs != NULL) XFree(cfgs); if (implicitSwapchain != NULL) IWineD3DSwapChain_Release(implicitSwapchain); if (currentSwapchain != NULL) IWineD3DSwapChain_Release(currentSwapchain);