dxgi: Add a separate function for swapchain initialization.
This commit is contained in:
parent
d588d2b489
commit
044a989d79
|
@ -291,10 +291,12 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *ifa
|
|||
static HRESULT STDMETHODCALLTYPE dxgi_device_create_swapchain(IWineDXGIDevice *iface,
|
||||
WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **wined3d_swapchain)
|
||||
{
|
||||
struct dxgi_device *This = (struct dxgi_device *)iface;
|
||||
struct dxgi_swapchain *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, present_parameters %p, wined3d_swapchain %p.\n",
|
||||
iface, present_parameters, wined3d_swapchain);
|
||||
|
||||
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
||||
if (!object)
|
||||
{
|
||||
|
@ -302,20 +304,16 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_swapchain(IWineDXGIDevice *i
|
|||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
object->vtbl = &dxgi_swapchain_vtbl;
|
||||
object->refcount = 1;
|
||||
|
||||
hr = IWineD3DDevice_CreateSwapChain(This->wined3d_device, present_parameters,
|
||||
&object->wined3d_swapchain, (IUnknown *)object, SURFACE_OPENGL);
|
||||
hr = dxgi_swapchain_init(object, (struct dxgi_device *)iface, present_parameters);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to create a swapchain, returning %#x\n", hr);
|
||||
WARN("Failed to initialize swapchain, hr %#x.\n", hr);
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
return hr;
|
||||
}
|
||||
*wined3d_swapchain = object->wined3d_swapchain;
|
||||
|
||||
TRACE("Created IDXGISwapChain %p\n", object);
|
||||
*wined3d_swapchain = object->wined3d_swapchain;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -121,7 +121,6 @@ struct dxgi_adapter
|
|||
HRESULT dxgi_adapter_init(struct dxgi_adapter *adapter, IWineDXGIFactory *parent, UINT ordinal) DECLSPEC_HIDDEN;
|
||||
|
||||
/* IDXGISwapChain */
|
||||
extern const struct IDXGISwapChainVtbl dxgi_swapchain_vtbl DECLSPEC_HIDDEN;
|
||||
struct dxgi_swapchain
|
||||
{
|
||||
const struct IDXGISwapChainVtbl *vtbl;
|
||||
|
@ -129,6 +128,9 @@ struct dxgi_swapchain
|
|||
IWineD3DSwapChain *wined3d_swapchain;
|
||||
};
|
||||
|
||||
HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device *device,
|
||||
WINED3DPRESENT_PARAMETERS *present_parameters) DECLSPEC_HIDDEN;
|
||||
|
||||
/* IDXGISurface */
|
||||
struct dxgi_surface
|
||||
{
|
||||
|
|
|
@ -249,7 +249,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetLastPresentCount(IDXGISwapCha
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
const struct IDXGISwapChainVtbl dxgi_swapchain_vtbl =
|
||||
static const struct IDXGISwapChainVtbl dxgi_swapchain_vtbl =
|
||||
{
|
||||
/* IUnknown methods */
|
||||
dxgi_swapchain_QueryInterface,
|
||||
|
@ -274,3 +274,22 @@ const struct IDXGISwapChainVtbl dxgi_swapchain_vtbl =
|
|||
dxgi_swapchain_GetFrameStatistics,
|
||||
dxgi_swapchain_GetLastPresentCount,
|
||||
};
|
||||
|
||||
HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device *device,
|
||||
WINED3DPRESENT_PARAMETERS *present_parameters)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
swapchain->vtbl = &dxgi_swapchain_vtbl;
|
||||
swapchain->refcount = 1;
|
||||
|
||||
hr = IWineD3DDevice_CreateSwapChain(device->wined3d_device, present_parameters,
|
||||
&swapchain->wined3d_swapchain, (IUnknown *)swapchain, SURFACE_OPENGL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to create wined3d swapchain, hr %#x.\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue