Commit 5fa84c56 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Remove another hack.

It breaks actual front buffer / back buffer flips.
parent 02453013
......@@ -359,7 +359,6 @@ struct IDirect3DDeviceImpl
IDirectDrawImpl *ddraw;
IWineD3DBuffer *indexbuffer;
IDirectDrawSurfaceImpl *target;
BOOL OffScreenTarget;
/* Viewport management */
IDirect3DViewportImpl *viewport_list;
......
......@@ -311,34 +311,10 @@ IDirect3DDeviceImpl_7_Release(IDirect3DDevice7 *iface)
* IDirect3DVertexBuffer::Release will unset it.
*/
/* Restore the render targets */
if(This->OffScreenTarget)
{
WINED3DVIEWPORT vp;
vp.X = 0;
vp.Y = 0;
vp.Width = This->ddraw->d3d_target->surface_desc.dwWidth;
vp.Height = This->ddraw->d3d_target->surface_desc.dwHeight;
vp.MinZ = 0.0;
vp.MaxZ = 1.0;
IWineD3DDevice_SetViewport(This->wineD3DDevice,
&vp);
/* Set the device up to render to the front buffer since the back buffer will
* vanish soon.
*/
IWineD3DDevice_SetRenderTarget(This->wineD3DDevice, 0,
This->ddraw->d3d_target->WineD3DSurface,
FALSE);
/* This->target is the offscreen target.
* This->ddraw->d3d_target is the target used by DDraw
*/
TRACE("(%p) Release: Using %p as front buffer, %p as back buffer\n", This, This->ddraw->d3d_target, NULL);
IWineD3DDevice_SetFrontBackBuffers(This->wineD3DDevice,
This->ddraw->d3d_target->WineD3DSurface,
NULL);
}
/* Set the device up to render to the front buffer since the back
* buffer will vanish soon. */
IWineD3DDevice_SetRenderTarget(This->wineD3DDevice, 0,
This->ddraw->d3d_target->WineD3DSurface, TRUE);
/* Release the WineD3DDevice. This won't destroy it */
if(IWineD3DDevice_Release(This->wineD3DDevice) <= 0)
......@@ -7024,46 +7000,14 @@ HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw, IDi
device->wineD3DDevice = ddraw->wineD3DDevice;
IWineD3DDevice_AddRef(ddraw->wineD3DDevice);
/* This is for apps which create a non-flip, non-d3d primary surface
* and an offscreen D3DDEVICE surface, then render to the offscreen surface
* and do a Blt from the offscreen to the primary surface.
*
* Set the offscreen D3DDDEVICE surface(=target) as the back buffer,
* and the primary surface(=This->d3d_target) as the front buffer.
*
* This way the app will render to the D3DDEVICE surface and WineD3D
* will catch the Blt was Back Buffer -> Front buffer blt and perform
* a flip instead. This way we don't have to deal with a mixed GL / GDI
* environment.
*
* This should be checked against windowed apps. The only app tested with
* this is moto racer 2 during the loading screen.
*/
TRACE("Is rendertarget: %s, d3d_target %p.\n",
target->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE ? "true" : "false", ddraw->d3d_target);
if (!(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
&& ddraw->d3d_target != target)
{
TRACE("Using %p as front buffer, %p as back buffer.\n", ddraw->d3d_target, target);
hr = IWineD3DDevice_SetFrontBackBuffers(ddraw->wineD3DDevice,
ddraw->d3d_target->WineD3DSurface, target->WineD3DSurface);
if (FAILED(hr))
{
ERR("Failed to set front and back buffer, hr %#x.\n", hr);
IParent_Release((IParent *)index_buffer_parent);
ddraw_handle_table_destroy(&device->handle_table);
return hr;
}
/* Render to the back buffer */
IWineD3DDevice_SetRenderTarget(ddraw->wineD3DDevice, 0, target->WineD3DSurface, TRUE);
device->OffScreenTarget = TRUE;
}
else
/* Render to the back buffer */
hr = IWineD3DDevice_SetRenderTarget(ddraw->wineD3DDevice, 0, target->WineD3DSurface, TRUE);
if (FAILED(hr))
{
device->OffScreenTarget = FALSE;
ERR("Failed to set render target, hr %#x.\n", hr);
IParent_Release((IParent *)index_buffer_parent);
ddraw_handle_table_destroy(&device->handle_table);
return hr;
}
/* FIXME: This is broken. The target AddRef() makes some sense, because
......
......@@ -5636,91 +5636,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetRenderTarget(IWineD3DDevice *iface,
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetFrontBackBuffers(IWineD3DDevice *iface,
IWineD3DSurface *front, IWineD3DSurface *back)
{
IWineD3DSurfaceImpl *front_impl = (IWineD3DSurfaceImpl *)front;
IWineD3DSurfaceImpl *back_impl = (IWineD3DSurfaceImpl *)back;
IWineD3DSwapChainImpl *swapchain;
HRESULT hr;
TRACE("iface %p, front %p, back %p.\n", iface, front, back);
if (FAILED(hr = IWineD3DDevice_GetSwapChain(iface, 0, (IWineD3DSwapChain **)&swapchain)))
{
ERR("Failed to get the swapchain, hr %#x.\n", hr);
return hr;
}
if (front_impl && !(front_impl->resource.usage & WINED3DUSAGE_RENDERTARGET))
{
ERR("Trying to set a front buffer which doesn't have WINED3DUSAGE_RENDERTARGET usage.\n");
IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
return WINED3DERR_INVALIDCALL;
}
if (back_impl)
{
if (!(back_impl->resource.usage & WINED3DUSAGE_RENDERTARGET))
{
ERR("Trying to set a back buffer which doesn't have WINED3DUSAGE_RENDERTARGET usage.\n");
IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
return WINED3DERR_INVALIDCALL;
}
if (!swapchain->back_buffers)
{
swapchain->back_buffers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*swapchain->back_buffers));
if (!swapchain->back_buffers)
{
ERR("Failed to allocate back buffer array memory.\n");
IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
return E_OUTOFMEMORY;
}
}
}
if (swapchain->front_buffer != front_impl)
{
TRACE("Changing the front buffer from %p to %p.\n", swapchain->front_buffer, front_impl);
if (swapchain->front_buffer)
surface_set_container(swapchain->front_buffer, WINED3D_CONTAINER_NONE, NULL);
swapchain->front_buffer = front_impl;
if (front_impl)
surface_set_container(front_impl, WINED3D_CONTAINER_SWAPCHAIN, (IWineD3DBase *)swapchain);
}
if (swapchain->back_buffers[0] != back_impl)
{
TRACE("Changing the back buffer from %p to %p.\n", swapchain->back_buffers[0], back_impl);
if (swapchain->back_buffers[0])
surface_set_container(swapchain->back_buffers[0], WINED3D_CONTAINER_NONE, NULL);
swapchain->back_buffers[0] = back_impl;
if (back_impl)
{
swapchain->presentParms.BackBufferWidth = back_impl->currentDesc.Width;
swapchain->presentParms.BackBufferHeight = back_impl->currentDesc.Height;
swapchain->presentParms.BackBufferFormat = back_impl->resource.format->id;
swapchain->presentParms.BackBufferCount = 1;
surface_set_container(back_impl, WINED3D_CONTAINER_SWAPCHAIN, (IWineD3DBase *)swapchain);
}
else
{
swapchain->presentParms.BackBufferCount = 0;
HeapFree(GetProcessHeap(), 0, swapchain->back_buffers);
swapchain->back_buffers = NULL;
}
}
IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetDepthStencilSurface(IWineD3DDevice *iface, IWineD3DSurface **depth_stencil)
{
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
......@@ -6803,7 +6718,6 @@ static const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl =
IWineD3DDeviceImpl_GetRenderState,
IWineD3DDeviceImpl_SetRenderTarget,
IWineD3DDeviceImpl_GetRenderTarget,
IWineD3DDeviceImpl_SetFrontBackBuffers,
IWineD3DDeviceImpl_SetSamplerState,
IWineD3DDeviceImpl_GetSamplerState,
IWineD3DDeviceImpl_SetScissorRect,
......
......@@ -3137,10 +3137,6 @@ interface IWineD3DDevice : IUnknown
[in] DWORD render_target_idx,
[out] IWineD3DSurface **render_target
);
HRESULT SetFrontBackBuffers(
[in] IWineD3DSurface *front,
[in] IWineD3DSurface *back
);
HRESULT SetSamplerState(
[in] DWORD sampler_idx,
[in] WINED3DSAMPLERSTATETYPE state,
......
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