wined3d: Pass "reset_enum_callback" directly to wined3d_device_reset().
It would have been nice if we could do all of this inside wined3d, but we need to determine what resources are in use by d3d8/d3d9, not wined3d. This is mostly an issue for "implicit" resources like swapchain render targets and the depth / stencil surface. The fact that we're having this problem probably means we're doing it wrong. Since these implicit resources should only be referenced by wined3d, we could probably just destroy and recreate the swapchain, instead of the little updateSurfaceDesc() dance we currently do.
This commit is contained in:
parent
366174b213
commit
0739cae273
|
@ -528,10 +528,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateAdditionalSwapChain(IDirect3DDe
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI reset_enum_callback(struct wined3d_resource *resource, void *data)
|
||||
static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
|
||||
{
|
||||
struct wined3d_resource_desc desc;
|
||||
BOOL *resources_ok = data;
|
||||
|
||||
wined3d_resource_get_desc(resource, &desc);
|
||||
if (desc.pool == WINED3DPOOL_DEFAULT)
|
||||
|
@ -541,8 +540,7 @@ static HRESULT WINAPI reset_enum_callback(struct wined3d_resource *resource, voi
|
|||
if (desc.resource_type != WINED3DRTYPE_SURFACE)
|
||||
{
|
||||
WARN("Resource %p in pool D3DPOOL_DEFAULT blocks the Reset call.\n", resource);
|
||||
*resources_ok = FALSE;
|
||||
return S_FALSE;
|
||||
return D3DERR_DEVICELOST;
|
||||
}
|
||||
|
||||
surface = wined3d_resource_get_parent(resource);
|
||||
|
@ -551,14 +549,13 @@ static HRESULT WINAPI reset_enum_callback(struct wined3d_resource *resource, voi
|
|||
if (IDirect3DSurface8_Release(surface))
|
||||
{
|
||||
WARN("Surface %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", surface, resource);
|
||||
*resources_ok = FALSE;
|
||||
return S_FALSE;
|
||||
return D3DERR_DEVICELOST;
|
||||
}
|
||||
|
||||
WARN("Surface %p (resource %p) is an implicit resource with ref 0.\n", surface, resource);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IDirect3DDevice8Impl_Reset(IDirect3DDevice8 *iface,
|
||||
|
@ -566,7 +563,6 @@ static HRESULT WINAPI IDirect3DDevice8Impl_Reset(IDirect3DDevice8 *iface,
|
|||
{
|
||||
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
|
||||
WINED3DPRESENT_PARAMETERS localParameters;
|
||||
BOOL resources_ok = TRUE;
|
||||
HRESULT hr;
|
||||
UINT i;
|
||||
|
||||
|
@ -583,16 +579,6 @@ static HRESULT WINAPI IDirect3DDevice8Impl_Reset(IDirect3DDevice8 *iface,
|
|||
wined3d_device_set_texture(This->wined3d_device, i, NULL);
|
||||
}
|
||||
|
||||
wined3d_device_enum_resources(This->wined3d_device, reset_enum_callback, &resources_ok);
|
||||
if (!resources_ok)
|
||||
{
|
||||
WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset.\n");
|
||||
This->lost = TRUE;
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return D3DERR_DEVICELOST;
|
||||
}
|
||||
|
||||
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
|
||||
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
|
||||
localParameters.BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters->BackBufferFormat);
|
||||
|
@ -609,7 +595,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_Reset(IDirect3DDevice8 *iface,
|
|||
localParameters.PresentationInterval = pPresentationParameters->FullScreen_PresentationInterval;
|
||||
localParameters.AutoRestoreDisplayMode = TRUE;
|
||||
|
||||
hr = wined3d_device_reset(This->wined3d_device, &localParameters);
|
||||
hr = wined3d_device_reset(This->wined3d_device, &localParameters, reset_enum_callback);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = wined3d_device_set_render_state(This->wined3d_device, WINED3DRS_POINTSIZE_MIN, 0);
|
||||
|
|
|
@ -516,10 +516,9 @@ static UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(IDirect3DDevice9Ex
|
|||
return count;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI reset_enum_callback(struct wined3d_resource *resource, void *data)
|
||||
static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
|
||||
{
|
||||
struct wined3d_resource_desc desc;
|
||||
BOOL *resources_ok = data;
|
||||
|
||||
wined3d_resource_get_desc(resource, &desc);
|
||||
if (desc.pool == WINED3DPOOL_DEFAULT)
|
||||
|
@ -529,8 +528,7 @@ static HRESULT WINAPI reset_enum_callback(struct wined3d_resource *resource, voi
|
|||
if (desc.resource_type != WINED3DRTYPE_SURFACE)
|
||||
{
|
||||
WARN("Resource %p in pool D3DPOOL_DEFAULT blocks the Reset call.\n", resource);
|
||||
*resources_ok = FALSE;
|
||||
return S_FALSE;
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
surface = wined3d_resource_get_parent(resource);
|
||||
|
@ -539,14 +537,13 @@ static HRESULT WINAPI reset_enum_callback(struct wined3d_resource *resource, voi
|
|||
if (IDirect3DSurface9_Release(surface))
|
||||
{
|
||||
WARN("Surface %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", surface, resource);
|
||||
*resources_ok = FALSE;
|
||||
return S_FALSE;
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
WARN("Surface %p (resource %p) is an implicit resource with ref 0.\n", surface, resource);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Reset(IDirect3DDevice9Ex *iface,
|
||||
|
@ -555,7 +552,6 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Reset(IDirect3DDevi
|
|||
IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
|
||||
WINED3DPRESENT_PARAMETERS localParameters;
|
||||
HRESULT hr;
|
||||
BOOL resources_ok = TRUE;
|
||||
UINT i;
|
||||
|
||||
TRACE("iface %p, present_parameters %p.\n", iface, pPresentationParameters);
|
||||
|
@ -579,16 +575,6 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Reset(IDirect3DDevi
|
|||
wined3d_device_set_texture(This->wined3d_device, i, NULL);
|
||||
}
|
||||
|
||||
wined3d_device_enum_resources(This->wined3d_device, reset_enum_callback, &resources_ok);
|
||||
if (!resources_ok)
|
||||
{
|
||||
WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset\n");
|
||||
This->notreset = TRUE;
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
|
||||
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
|
||||
localParameters.BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters->BackBufferFormat);
|
||||
|
@ -605,8 +591,9 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Reset(IDirect3DDevi
|
|||
localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
|
||||
localParameters.AutoRestoreDisplayMode = TRUE;
|
||||
|
||||
hr = wined3d_device_reset(This->wined3d_device, &localParameters);
|
||||
if(FAILED(hr)) {
|
||||
hr = wined3d_device_reset(This->wined3d_device, &localParameters, reset_enum_callback);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
This->notreset = TRUE;
|
||||
|
||||
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
|
||||
|
|
|
@ -5614,8 +5614,10 @@ err:
|
|||
|
||||
/* Do not call while under the GL lock. */
|
||||
HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
|
||||
WINED3DPRESENT_PARAMETERS *present_parameters)
|
||||
WINED3DPRESENT_PARAMETERS *present_parameters,
|
||||
wined3d_device_reset_cb callback)
|
||||
{
|
||||
struct wined3d_resource *resource, *cursor;
|
||||
struct wined3d_swapchain *swapchain;
|
||||
BOOL DisplayModeChanged = FALSE;
|
||||
WINED3DDISPLAYMODE mode;
|
||||
|
@ -5623,6 +5625,13 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
|
|||
|
||||
TRACE("device %p, present_parameters %p.\n", device, present_parameters);
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &device->resources, struct wined3d_resource, resource_list_entry)
|
||||
{
|
||||
TRACE("Enumerating resource %p.\n", resource);
|
||||
if (FAILED(hr = callback(resource)))
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = wined3d_device_get_swapchain(device, 0, &swapchain);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
@ cdecl wined3d_device_present(ptr ptr ptr ptr ptr)
|
||||
@ cdecl wined3d_device_process_vertices(ptr long long long ptr ptr long long)
|
||||
@ cdecl wined3d_device_release_focus_window(ptr)
|
||||
@ cdecl wined3d_device_reset(ptr ptr)
|
||||
@ cdecl wined3d_device_reset(ptr ptr ptr)
|
||||
@ cdecl wined3d_device_restore_fullscreen_window(ptr ptr)
|
||||
@ cdecl wined3d_device_set_base_vertex_index(ptr long)
|
||||
@ cdecl wined3d_device_set_clip_plane(ptr long ptr)
|
||||
|
|
|
@ -2108,6 +2108,7 @@ struct wined3d_device_parent_ops
|
|||
};
|
||||
|
||||
typedef HRESULT (__stdcall *D3DCB_ENUMRESOURCES)(struct wined3d_resource *resource, void *pData);
|
||||
typedef HRESULT (CDECL *wined3d_device_reset_cb)(struct wined3d_resource *resource);
|
||||
|
||||
void __stdcall wined3d_mutex_lock(void);
|
||||
void __stdcall wined3d_mutex_unlock(void);
|
||||
|
@ -2284,7 +2285,8 @@ 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,
|
||||
struct wined3d_vertex_declaration *declaration, DWORD flags, DWORD dst_fvf);
|
||||
void __cdecl wined3d_device_release_focus_window(struct wined3d_device *device);
|
||||
HRESULT __cdecl wined3d_device_reset(struct wined3d_device *device, WINED3DPRESENT_PARAMETERS *present_parameters);
|
||||
HRESULT __cdecl wined3d_device_reset(struct wined3d_device *device,
|
||||
WINED3DPRESENT_PARAMETERS *present_parameters, wined3d_device_reset_cb callback);
|
||||
void __cdecl wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window);
|
||||
HRESULT __cdecl wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index);
|
||||
HRESULT __cdecl wined3d_device_set_clip_plane(struct wined3d_device *device, UINT plane_idx, const float *plane);
|
||||
|
|
Loading…
Reference in New Issue