wined3d: Remove wined3d_device_present.
Signed-off-by: Stefan Dösinger <stefan@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
20d5be042c
commit
59ec72879f
|
@ -167,6 +167,9 @@ struct d3d9_device
|
||||||
LONG device_state;
|
LONG device_state;
|
||||||
BOOL in_destruction;
|
BOOL in_destruction;
|
||||||
BOOL in_scene;
|
BOOL in_scene;
|
||||||
|
|
||||||
|
UINT implicit_swapchain_count;
|
||||||
|
struct d3d9_swapchain **implicit_swapchains;
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wined3d *wined3d,
|
HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wined3d *wined3d,
|
||||||
|
|
|
@ -322,6 +322,8 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if
|
||||||
if (device->index_buffer)
|
if (device->index_buffer)
|
||||||
wined3d_buffer_decref(device->index_buffer);
|
wined3d_buffer_decref(device->index_buffer);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, device->implicit_swapchains);
|
||||||
|
|
||||||
wined3d_device_uninit_3d(device->wined3d_device);
|
wined3d_device_uninit_3d(device->wined3d_device);
|
||||||
wined3d_device_release_focus_window(device->wined3d_device);
|
wined3d_device_release_focus_window(device->wined3d_device);
|
||||||
wined3d_device_decref(device->wined3d_device);
|
wined3d_device_decref(device->wined3d_device);
|
||||||
|
@ -565,19 +567,16 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_GetSwapChain(IDirect3DDevice
|
||||||
UINT swapchain_idx, IDirect3DSwapChain9 **swapchain)
|
UINT swapchain_idx, IDirect3DSwapChain9 **swapchain)
|
||||||
{
|
{
|
||||||
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
||||||
struct wined3d_swapchain *wined3d_swapchain;
|
|
||||||
struct d3d9_swapchain *swapchain_impl;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("iface %p, swapchain_idx %u, swapchain %p.\n", iface, swapchain_idx, swapchain);
|
TRACE("iface %p, swapchain_idx %u, swapchain %p.\n", iface, swapchain_idx, swapchain);
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
if ((wined3d_swapchain = wined3d_device_get_swapchain(device->wined3d_device, swapchain_idx)))
|
if (swapchain_idx < device->implicit_swapchain_count)
|
||||||
{
|
{
|
||||||
swapchain_impl = wined3d_swapchain_get_parent(wined3d_swapchain);
|
*swapchain = (IDirect3DSwapChain9 *)&device->implicit_swapchains[swapchain_idx]->IDirect3DSwapChain9Ex_iface;
|
||||||
*swapchain = (IDirect3DSwapChain9 *)&swapchain_impl->IDirect3DSwapChain9Ex_iface;
|
IDirect3DSwapChain9Ex_AddRef(*swapchain);
|
||||||
IDirect3DSwapChain9Ex_AddRef(*swapchain);
|
hr = D3D_OK;
|
||||||
hr = D3D_OK;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -646,6 +645,25 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT d3d9_device_get_swapchains(struct d3d9_device *device)
|
||||||
|
{
|
||||||
|
UINT i, new_swapchain_count = wined3d_device_get_swapchain_count(device->wined3d_device);
|
||||||
|
struct wined3d_swapchain *wined3d_swapchain;
|
||||||
|
|
||||||
|
if (!(device->implicit_swapchains = HeapAlloc(GetProcessHeap(), 0,
|
||||||
|
new_swapchain_count * sizeof(*device->implicit_swapchains))))
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
for (i = 0; i < new_swapchain_count; ++i)
|
||||||
|
{
|
||||||
|
wined3d_swapchain = wined3d_device_get_swapchain(device->wined3d_device, i);
|
||||||
|
device->implicit_swapchains[i] = wined3d_swapchain_get_parent(wined3d_swapchain);
|
||||||
|
}
|
||||||
|
device->implicit_swapchain_count = new_swapchain_count;
|
||||||
|
|
||||||
|
return D3D_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static HRESULT d3d9_device_reset(struct d3d9_device *device,
|
static HRESULT d3d9_device_reset(struct d3d9_device *device,
|
||||||
D3DPRESENT_PARAMETERS *present_parameters, D3DDISPLAYMODEEX *mode)
|
D3DPRESENT_PARAMETERS *present_parameters, D3DDISPLAYMODEEX *mode)
|
||||||
{
|
{
|
||||||
|
@ -691,16 +709,22 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device,
|
||||||
if (SUCCEEDED(hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc,
|
if (SUCCEEDED(hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc,
|
||||||
mode ? &wined3d_mode : NULL, reset_enum_callback, !device->d3d_parent->extended)))
|
mode ? &wined3d_mode : NULL, reset_enum_callback, !device->d3d_parent->extended)))
|
||||||
{
|
{
|
||||||
struct wined3d_swapchain *wined3d_swapchain;
|
HeapFree(GetProcessHeap(), 0, device->implicit_swapchains);
|
||||||
|
|
||||||
wined3d_swapchain = wined3d_device_get_swapchain(device->wined3d_device, 0);
|
if (FAILED(hr = d3d9_device_get_swapchains(device)))
|
||||||
wined3d_swapchain_get_desc(wined3d_swapchain, &swapchain_desc);
|
{
|
||||||
present_parameters->BackBufferWidth = swapchain_desc.backbuffer_width;
|
device->device_state = D3D9_DEVICE_STATE_NOT_RESET;
|
||||||
present_parameters->BackBufferHeight = swapchain_desc.backbuffer_height;
|
}
|
||||||
present_parameters->BackBufferFormat = d3dformat_from_wined3dformat(swapchain_desc.backbuffer_format);
|
else
|
||||||
present_parameters->BackBufferCount = swapchain_desc.backbuffer_count;
|
{
|
||||||
|
wined3d_swapchain_get_desc(device->implicit_swapchains[0]->wined3d_swapchain, &swapchain_desc);
|
||||||
|
present_parameters->BackBufferWidth = swapchain_desc.backbuffer_width;
|
||||||
|
present_parameters->BackBufferHeight = swapchain_desc.backbuffer_height;
|
||||||
|
present_parameters->BackBufferFormat = d3dformat_from_wined3dformat(swapchain_desc.backbuffer_format);
|
||||||
|
present_parameters->BackBufferCount = swapchain_desc.backbuffer_count;
|
||||||
|
|
||||||
device->device_state = D3D9_DEVICE_STATE_OK;
|
device->device_state = D3D9_DEVICE_STATE_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!device->d3d_parent->extended)
|
else if (!device->d3d_parent->extended)
|
||||||
{
|
{
|
||||||
|
@ -726,6 +750,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Present(IDirect3DDevice9Ex *
|
||||||
const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region)
|
const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region)
|
||||||
{
|
{
|
||||||
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
||||||
|
UINT i;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("iface %p, src_rect %p, dst_rect %p, dst_window_override %p, dirty_region %p.\n",
|
TRACE("iface %p, src_rect %p, dst_rect %p, dst_window_override %p, dirty_region %p.\n",
|
||||||
|
@ -735,21 +760,26 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Present(IDirect3DDevice9Ex *
|
||||||
return device->d3d_parent->extended ? S_PRESENT_OCCLUDED : D3DERR_DEVICELOST;
|
return device->d3d_parent->extended ? S_PRESENT_OCCLUDED : D3DERR_DEVICELOST;
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
hr = wined3d_device_present(device->wined3d_device, src_rect, dst_rect,
|
for (i = 0; i < device->implicit_swapchain_count; ++i)
|
||||||
dst_window_override, dirty_region, 0);
|
{
|
||||||
|
hr = wined3d_swapchain_present(device->implicit_swapchains[i]->wined3d_swapchain, src_rect,
|
||||||
|
dst_rect, dst_window_override, dirty_region, 0);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
wined3d_mutex_unlock();
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
}
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
|
||||||
return hr;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI d3d9_device_GetBackBuffer(IDirect3DDevice9Ex *iface, UINT swapchain,
|
static HRESULT WINAPI d3d9_device_GetBackBuffer(IDirect3DDevice9Ex *iface, UINT swapchain,
|
||||||
UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface9 **backbuffer)
|
UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface9 **backbuffer)
|
||||||
{
|
{
|
||||||
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
||||||
struct wined3d_swapchain *wined3d_swapchain;
|
HRESULT hr;
|
||||||
struct wined3d_resource *wined3d_resource;
|
|
||||||
struct wined3d_texture *wined3d_texture;
|
|
||||||
struct d3d9_surface *surface_impl;
|
|
||||||
|
|
||||||
TRACE("iface %p, swapchain %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
|
TRACE("iface %p, swapchain %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
|
||||||
iface, swapchain, backbuffer_idx, backbuffer_type, backbuffer);
|
iface, swapchain, backbuffer_idx, backbuffer_type, backbuffer);
|
||||||
|
@ -757,29 +787,21 @@ static HRESULT WINAPI d3d9_device_GetBackBuffer(IDirect3DDevice9Ex *iface, UINT
|
||||||
/* backbuffer_type is ignored by native. */
|
/* backbuffer_type is ignored by native. */
|
||||||
|
|
||||||
/* No need to check for backbuffer == NULL, Windows crashes in that case. */
|
/* No need to check for backbuffer == NULL, Windows crashes in that case. */
|
||||||
|
*backbuffer = NULL;
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
|
if (swapchain >= device->implicit_swapchain_count)
|
||||||
if (!(wined3d_swapchain = wined3d_device_get_swapchain(device->wined3d_device, swapchain)))
|
|
||||||
{
|
{
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
*backbuffer = NULL;
|
WARN("Swapchain index %u is out of range, returning D3DERR_INVALIDCALL.\n", swapchain);
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(wined3d_texture = wined3d_swapchain_get_back_buffer(wined3d_swapchain, backbuffer_idx)))
|
hr = IDirect3DSwapChain9Ex_GetBackBuffer(&device->implicit_swapchains[swapchain]->IDirect3DSwapChain9Ex_iface,
|
||||||
{
|
backbuffer_idx, backbuffer_type, backbuffer);
|
||||||
wined3d_mutex_unlock();
|
|
||||||
*backbuffer = NULL;
|
|
||||||
return D3DERR_INVALIDCALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wined3d_resource = wined3d_texture_get_sub_resource(wined3d_texture, 0);
|
|
||||||
surface_impl = wined3d_resource_get_parent(wined3d_resource);
|
|
||||||
*backbuffer = &surface_impl->IDirect3DSurface9_iface;
|
|
||||||
IDirect3DSurface9_AddRef(*backbuffer);
|
|
||||||
|
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
return D3D_OK;
|
|
||||||
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI d3d9_device_GetRasterStatus(IDirect3DDevice9Ex *iface,
|
static HRESULT WINAPI d3d9_device_GetRasterStatus(IDirect3DDevice9Ex *iface,
|
||||||
|
@ -3190,6 +3212,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_PresentEx(IDirect3DDevice9Ex
|
||||||
const RGNDATA *dirty_region, DWORD flags)
|
const RGNDATA *dirty_region, DWORD flags)
|
||||||
{
|
{
|
||||||
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
||||||
|
UINT i;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("iface %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p, flags %#x.\n",
|
TRACE("iface %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p, flags %#x.\n",
|
||||||
|
@ -3200,11 +3223,18 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_PresentEx(IDirect3DDevice9Ex
|
||||||
return S_PRESENT_OCCLUDED;
|
return S_PRESENT_OCCLUDED;
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
hr = wined3d_device_present(device->wined3d_device, src_rect, dst_rect,
|
for (i = 0; i < device->implicit_swapchain_count; ++i)
|
||||||
dst_window_override, dirty_region, flags);
|
{
|
||||||
|
if (FAILED(hr = wined3d_swapchain_present(device->implicit_swapchains[i]->wined3d_swapchain, src_rect,
|
||||||
|
dst_rect, dst_window_override, dirty_region, flags)))
|
||||||
|
{
|
||||||
|
wined3d_mutex_unlock();
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
}
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
|
||||||
return hr;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI d3d9_device_GetGPUThreadPriority(IDirect3DDevice9Ex *iface, INT *priority)
|
static HRESULT WINAPI d3d9_device_GetGPUThreadPriority(IDirect3DDevice9Ex *iface, INT *priority)
|
||||||
|
@ -3744,12 +3774,22 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
wined3d_mutex_unlock();
|
if (FAILED(hr = d3d9_device_get_swapchains(device)))
|
||||||
|
{
|
||||||
|
wined3d_device_uninit_3d(device->wined3d_device);
|
||||||
|
wined3d_device_release_focus_window(device->wined3d_device);
|
||||||
|
wined3d_device_decref(device->wined3d_device);
|
||||||
|
wined3d_mutex_unlock();
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
present_parameters_from_wined3d_swapchain_desc(¶meters[i], &swapchain_desc[i]);
|
present_parameters_from_wined3d_swapchain_desc(¶meters[i], &swapchain_desc[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wined3d_mutex_unlock();
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, swapchain_desc);
|
HeapFree(GetProcessHeap(), 0, swapchain_desc);
|
||||||
|
|
||||||
/* Initialize the converted declaration array. This creates a valid pointer
|
/* Initialize the converted declaration array. This creates a valid pointer
|
||||||
|
@ -3759,6 +3799,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate FVF vertex declaration map memory.\n");
|
ERR("Failed to allocate FVF vertex declaration map memory.\n");
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
|
HeapFree(GetProcessHeap(), 0, device->implicit_swapchains);
|
||||||
wined3d_device_uninit_3d(device->wined3d_device);
|
wined3d_device_uninit_3d(device->wined3d_device);
|
||||||
wined3d_device_release_focus_window(device->wined3d_device);
|
wined3d_device_release_focus_window(device->wined3d_device);
|
||||||
wined3d_device_decref(device->wined3d_device);
|
wined3d_device_decref(device->wined3d_device);
|
||||||
|
|
|
@ -3290,24 +3290,6 @@ HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device)
|
||||||
return WINED3D_OK;
|
return WINED3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT CDECL wined3d_device_present(const struct wined3d_device *device, const RECT *src_rect,
|
|
||||||
const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region, DWORD flags)
|
|
||||||
{
|
|
||||||
UINT i;
|
|
||||||
|
|
||||||
TRACE("device %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p, flags %#x.\n",
|
|
||||||
device, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect),
|
|
||||||
dst_window_override, dirty_region, flags);
|
|
||||||
|
|
||||||
for (i = 0; i < device->swapchain_count; ++i)
|
|
||||||
{
|
|
||||||
wined3d_swapchain_present(device->swapchains[i], src_rect,
|
|
||||||
dst_rect, dst_window_override, dirty_region, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
return WINED3D_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_count,
|
HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_count,
|
||||||
const RECT *rects, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil)
|
const RECT *rects, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil)
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,7 +104,6 @@
|
||||||
@ cdecl wined3d_device_init_3d(ptr ptr)
|
@ cdecl wined3d_device_init_3d(ptr ptr)
|
||||||
@ cdecl wined3d_device_init_gdi(ptr ptr)
|
@ cdecl wined3d_device_init_gdi(ptr ptr)
|
||||||
@ cdecl wined3d_device_multiply_transform(ptr long ptr)
|
@ cdecl wined3d_device_multiply_transform(ptr long ptr)
|
||||||
@ cdecl wined3d_device_present(ptr ptr ptr ptr ptr long)
|
|
||||||
@ cdecl wined3d_device_process_vertices(ptr long long long ptr ptr long long)
|
@ cdecl wined3d_device_process_vertices(ptr long long long ptr ptr long long)
|
||||||
@ cdecl wined3d_device_release_focus_window(ptr)
|
@ cdecl wined3d_device_release_focus_window(ptr)
|
||||||
@ cdecl wined3d_device_reset(ptr ptr ptr ptr long)
|
@ cdecl wined3d_device_reset(ptr ptr ptr ptr long)
|
||||||
|
|
|
@ -2231,8 +2231,6 @@ HRESULT __cdecl wined3d_device_init_3d(struct wined3d_device *device, struct win
|
||||||
HRESULT __cdecl wined3d_device_init_gdi(struct wined3d_device *device, struct wined3d_swapchain_desc *swapchain_desc);
|
HRESULT __cdecl wined3d_device_init_gdi(struct wined3d_device *device, struct wined3d_swapchain_desc *swapchain_desc);
|
||||||
void __cdecl wined3d_device_multiply_transform(struct wined3d_device *device,
|
void __cdecl wined3d_device_multiply_transform(struct wined3d_device *device,
|
||||||
enum wined3d_transform_state state, const struct wined3d_matrix *matrix);
|
enum wined3d_transform_state state, const struct wined3d_matrix *matrix);
|
||||||
HRESULT __cdecl wined3d_device_present(const struct wined3d_device *device, const RECT *src_rect,
|
|
||||||
const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region, DWORD flags);
|
|
||||||
HRESULT __cdecl wined3d_device_process_vertices(struct wined3d_device *device,
|
HRESULT __cdecl wined3d_device_process_vertices(struct wined3d_device *device,
|
||||||
UINT src_start_idx, UINT dst_idx, UINT vertex_count, struct wined3d_buffer *dst_buffer,
|
UINT src_start_idx, UINT dst_idx, UINT vertex_count, struct wined3d_buffer *dst_buffer,
|
||||||
const struct wined3d_vertex_declaration *declaration, DWORD flags, DWORD dst_fvf);
|
const struct wined3d_vertex_declaration *declaration, DWORD flags, DWORD dst_fvf);
|
||||||
|
|
Loading…
Reference in New Issue