dxgi: Call wined3d_device_init_3d() on device creation.
This commit is contained in:
parent
72aaaac486
commit
810977446a
|
@ -1,6 +1,6 @@
|
|||
MODULE = dxgi.dll
|
||||
IMPORTLIB = dxgi
|
||||
IMPORTS = dxguid uuid wined3d
|
||||
IMPORTS = dxguid uuid wined3d user32
|
||||
|
||||
C_SRCS = \
|
||||
adapter.c \
|
||||
|
|
|
@ -80,6 +80,7 @@ static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
|
|||
{
|
||||
if (This->child_layer) IUnknown_Release(This->child_layer);
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_device_uninit_3d(This->wined3d_device);
|
||||
wined3d_device_decref(This->wined3d_device);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
IDXGIFactory1_Release(This->factory);
|
||||
|
@ -248,18 +249,6 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_GetGPUThreadPriority(IWineDXGIDevic
|
|||
|
||||
/* IWineDXGIDevice methods */
|
||||
|
||||
static struct wined3d_device * STDMETHODCALLTYPE dxgi_device_get_wined3d_device(IWineDXGIDevice *iface)
|
||||
{
|
||||
struct dxgi_device *This = impl_from_IWineDXGIDevice(iface);
|
||||
|
||||
TRACE("iface %p\n", iface);
|
||||
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_device_incref(This->wined3d_device);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
return This->wined3d_device;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *iface, const DXGI_SURFACE_DESC *desc,
|
||||
DXGI_USAGE usage, const DXGI_SHARED_RESOURCE *shared_resource, IUnknown *outer, void **surface)
|
||||
{
|
||||
|
@ -338,7 +327,6 @@ static const struct IWineDXGIDeviceVtbl dxgi_device_vtbl =
|
|||
dxgi_device_SetGPUThreadPriority,
|
||||
dxgi_device_GetGPUThreadPriority,
|
||||
/* IWineDXGIAdapter methods */
|
||||
dxgi_device_get_wined3d_device,
|
||||
dxgi_device_create_surface,
|
||||
dxgi_device_create_swapchain,
|
||||
};
|
||||
|
@ -347,6 +335,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
|
|||
IDXGIFactory *factory, IDXGIAdapter *adapter)
|
||||
{
|
||||
struct wined3d_device_parent *wined3d_device_parent;
|
||||
struct wined3d_swapchain_desc swapchain_desc;
|
||||
IWineDXGIDeviceParent *dxgi_device_parent;
|
||||
struct dxgi_adapter *dxgi_adapter;
|
||||
struct dxgi_factory *dxgi_factory;
|
||||
|
@ -411,6 +400,18 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
|
|||
return hr;
|
||||
}
|
||||
|
||||
memset(&swapchain_desc, 0, sizeof(swapchain_desc));
|
||||
swapchain_desc.swap_effect = WINED3D_SWAP_EFFECT_DISCARD;
|
||||
swapchain_desc.device_window = dxgi_factory_get_device_window(dxgi_factory);
|
||||
swapchain_desc.windowed = TRUE;
|
||||
if (FAILED(hr = wined3d_device_init_3d(device->wined3d_device, &swapchain_desc)))
|
||||
{
|
||||
ERR("Failed to initialize 3D, hr %#x.\n", hr);
|
||||
wined3d_device_decref(device->wined3d_device);
|
||||
IUnknown_Release(device->child_layer);
|
||||
return hr;
|
||||
}
|
||||
|
||||
device->factory = &dxgi_factory->IDXGIFactory1_iface;
|
||||
IDXGIFactory1_AddRef(device->factory);
|
||||
|
||||
|
|
|
@ -86,9 +86,11 @@ struct dxgi_factory
|
|||
UINT adapter_count;
|
||||
IDXGIAdapter1 **adapters;
|
||||
BOOL extended;
|
||||
HWND device_window;
|
||||
};
|
||||
|
||||
HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended) DECLSPEC_HIDDEN;
|
||||
HWND dxgi_factory_get_device_window(struct dxgi_factory *factory) DECLSPEC_HIDDEN;
|
||||
struct dxgi_factory *unsafe_impl_from_IDXGIFactory1(IDXGIFactory1 *iface) DECLSPEC_HIDDEN;
|
||||
|
||||
/* IDXGIDevice */
|
||||
|
|
|
@ -72,6 +72,8 @@ static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IDXGIFactory1 *iface)
|
|||
{
|
||||
UINT i;
|
||||
|
||||
if (factory->device_window)
|
||||
DestroyWindow(factory->device_window);
|
||||
for (i = 0; i < factory->adapter_count; ++i)
|
||||
{
|
||||
IDXGIAdapter1_Release(factory->adapters[i]);
|
||||
|
@ -179,9 +181,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory1 *ifa
|
|||
{
|
||||
struct wined3d_swapchain *wined3d_swapchain;
|
||||
struct wined3d_swapchain_desc wined3d_desc;
|
||||
struct wined3d_device *wined3d_device;
|
||||
IWineDXGIDevice *dxgi_device;
|
||||
UINT count;
|
||||
HRESULT hr;
|
||||
|
||||
FIXME("iface %p, device %p, desc %p, swapchain %p partial stub!\n", iface, device, desc, swapchain);
|
||||
|
@ -193,17 +193,6 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory1 *ifa
|
|||
return hr;
|
||||
}
|
||||
|
||||
wined3d_device = IWineDXGIDevice_get_wined3d_device(dxgi_device);
|
||||
IWineDXGIDevice_Release(dxgi_device);
|
||||
|
||||
count = wined3d_device_get_swapchain_count(wined3d_device);
|
||||
if (count)
|
||||
{
|
||||
FIXME("Only a single swapchain supported.\n");
|
||||
wined3d_device_decref(wined3d_device);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (!desc->OutputWindow)
|
||||
{
|
||||
FIXME("No output window, should use factory output window\n");
|
||||
|
@ -234,29 +223,16 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory1 *ifa
|
|||
wined3d_desc.refresh_rate = dxgi_rational_to_uint(&desc->BufferDesc.RefreshRate);
|
||||
wined3d_desc.swap_interval = WINED3DPRESENT_INTERVAL_DEFAULT;
|
||||
|
||||
hr = wined3d_device_init_3d(wined3d_device, &wined3d_desc);
|
||||
hr = IWineDXGIDevice_create_swapchain(dxgi_device, &wined3d_desc, &wined3d_swapchain);
|
||||
IWineDXGIDevice_Release(dxgi_device);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to initialize 3D, returning %#x\n", hr);
|
||||
wined3d_device_decref(wined3d_device);
|
||||
WARN("Failed to create swapchain, hr %#x.\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
wined3d_swapchain = wined3d_device_get_swapchain(wined3d_device, 0);
|
||||
wined3d_device_decref(wined3d_device);
|
||||
if (!wined3d_swapchain)
|
||||
{
|
||||
WARN("Failed to get swapchain.\n");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
*swapchain = wined3d_swapchain_get_parent(wined3d_swapchain);
|
||||
|
||||
/* FIXME? The swapchain is created with refcount 1 by the wined3d device,
|
||||
* but the wined3d device can't hold a real reference. */
|
||||
|
||||
TRACE("Created IDXGISwapChain %p\n", *swapchain);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -395,3 +371,23 @@ HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended)
|
|||
|
||||
return hr;
|
||||
}
|
||||
|
||||
HWND dxgi_factory_get_device_window(struct dxgi_factory *factory)
|
||||
{
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
|
||||
if (!factory->device_window)
|
||||
{
|
||||
if (!(factory->device_window = CreateWindowA("static", "DXGI device window",
|
||||
WS_DISABLED, 0, 0, 0, 0, NULL, NULL, NULL, NULL)))
|
||||
{
|
||||
ERR("Failed to create a window.\n");
|
||||
return NULL;
|
||||
}
|
||||
TRACE("Created device window %p for factory %p.\n", factory->device_window, factory);
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
|
||||
return factory->device_window;
|
||||
}
|
||||
|
|
|
@ -72,19 +72,7 @@ static ULONG STDMETHODCALLTYPE dxgi_swapchain_Release(IDXGISwapChain *iface)
|
|||
TRACE("%p decreasing refcount to %u\n", This, refcount);
|
||||
|
||||
if (!refcount)
|
||||
{
|
||||
struct wined3d_device *wined3d_device;
|
||||
HRESULT hr;
|
||||
|
||||
FIXME("Only a single swapchain is supported\n");
|
||||
|
||||
wined3d_device = wined3d_swapchain_get_device(This->wined3d_swapchain);
|
||||
hr = wined3d_device_uninit_3d(wined3d_device);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
ERR("Uninit3D failed, hr %#x\n", hr);
|
||||
}
|
||||
}
|
||||
wined3d_swapchain_decref(This->wined3d_swapchain);
|
||||
|
||||
return refcount;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import "dxgi.idl";
|
|||
]
|
||||
interface IWineDXGIDevice : IDXGIDevice
|
||||
{
|
||||
struct wined3d_device *get_wined3d_device();
|
||||
HRESULT create_surface(
|
||||
[in] const DXGI_SURFACE_DESC *desc,
|
||||
[in] DXGI_USAGE usage,
|
||||
|
|
Loading…
Reference in New Issue