d3d8: Add a separate function for swapchain initialization.
This commit is contained in:
parent
ecbe545e90
commit
2e27ab6b67
dlls/d3d8
|
@ -226,11 +226,6 @@ HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device,
|
|||
/* IDirect3DSwapChain8 */
|
||||
/* ------------------- */
|
||||
|
||||
/*****************************************************************************
|
||||
* Predeclare the interface implementation structures
|
||||
*/
|
||||
extern const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl DECLSPEC_HIDDEN;
|
||||
|
||||
/*****************************************************************************
|
||||
* IDirect3DSwapChain8 implementation structure
|
||||
*/
|
||||
|
@ -247,6 +242,9 @@ struct IDirect3DSwapChain8Impl
|
|||
LPDIRECT3DDEVICE8 parentDevice;
|
||||
};
|
||||
|
||||
HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, IDirect3DDevice8Impl *device,
|
||||
D3DPRESENT_PARAMETERS *present_parameters) DECLSPEC_HIDDEN;
|
||||
|
||||
/* ----------------- */
|
||||
/* IDirect3DSurface8 */
|
||||
/* ----------------- */
|
||||
|
|
|
@ -495,76 +495,35 @@ static BOOL WINAPI IDirect3DDevice8Impl_ShowCursor(LPDIRECT3DDEVICE8 iface, BOOL
|
|||
return ret;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IDirect3DDevice8Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain8** pSwapChain) {
|
||||
static HRESULT WINAPI IDirect3DDevice8Impl_CreateAdditionalSwapChain(IDirect3DDevice8 *iface,
|
||||
D3DPRESENT_PARAMETERS *present_parameters, IDirect3DSwapChain8 **swapchain)
|
||||
{
|
||||
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
||||
IDirect3DSwapChain8Impl* object;
|
||||
HRESULT hrc = D3D_OK;
|
||||
WINED3DPRESENT_PARAMETERS localParameters;
|
||||
IDirect3DSwapChain8Impl *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, present_parameters %p, swapchain %p.\n",
|
||||
iface, pPresentationParameters, pSwapChain);
|
||||
|
||||
/* Fix the back buffer count */
|
||||
if(pPresentationParameters->BackBufferCount == 0) {
|
||||
pPresentationParameters->BackBufferCount = 1;
|
||||
}
|
||||
iface, present_parameters, swapchain);
|
||||
|
||||
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
||||
if (NULL == object) {
|
||||
FIXME("Allocation of memory failed\n");
|
||||
*pSwapChain = NULL;
|
||||
return D3DERR_OUTOFVIDEOMEMORY;
|
||||
if (!object)
|
||||
{
|
||||
ERR("Failed to allocate swapchain memory.\n");
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
object->ref = 1;
|
||||
object->lpVtbl = &Direct3DSwapChain8_Vtbl;
|
||||
|
||||
/* Allocate an associated WineD3DDevice object */
|
||||
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
|
||||
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
|
||||
localParameters.BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters->BackBufferFormat);
|
||||
localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
|
||||
localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
|
||||
localParameters.MultiSampleQuality = 0; /* d3d9 only */
|
||||
localParameters.SwapEffect = pPresentationParameters->SwapEffect;
|
||||
localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
|
||||
localParameters.Windowed = pPresentationParameters->Windowed;
|
||||
localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
|
||||
localParameters.AutoDepthStencilFormat = wined3dformat_from_d3dformat(pPresentationParameters->AutoDepthStencilFormat);
|
||||
localParameters.Flags = pPresentationParameters->Flags;
|
||||
localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
|
||||
localParameters.PresentationInterval = pPresentationParameters->FullScreen_PresentationInterval;
|
||||
localParameters.AutoRestoreDisplayMode = TRUE;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hrc = IWineD3DDevice_CreateSwapChain(This->WineD3DDevice, &localParameters,
|
||||
&object->wineD3DSwapChain, (IUnknown *)object, SURFACE_OPENGL);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
|
||||
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
|
||||
pPresentationParameters->BackBufferFormat = d3dformat_from_wined3dformat(localParameters.BackBufferFormat);
|
||||
pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
|
||||
pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
|
||||
pPresentationParameters->SwapEffect = localParameters.SwapEffect;
|
||||
pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
|
||||
pPresentationParameters->Windowed = localParameters.Windowed;
|
||||
pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
|
||||
pPresentationParameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(localParameters.AutoDepthStencilFormat);
|
||||
pPresentationParameters->Flags = localParameters.Flags;
|
||||
pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
|
||||
pPresentationParameters->FullScreen_PresentationInterval = localParameters.PresentationInterval;
|
||||
|
||||
if (hrc != D3D_OK) {
|
||||
FIXME("(%p) call to IWineD3DDevice_CreateSwapChain failed\n", This);
|
||||
HeapFree(GetProcessHeap(), 0 , object);
|
||||
*pSwapChain = NULL;
|
||||
}else{
|
||||
IUnknown_AddRef(iface);
|
||||
object->parentDevice = iface;
|
||||
*pSwapChain = (IDirect3DSwapChain8 *)object;
|
||||
hr = swapchain_init(object, This, present_parameters);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to initialize swapchain, hr %#x.\n", hr);
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
return hr;
|
||||
}
|
||||
TRACE("(%p) returning %p\n", This, *pSwapChain);
|
||||
return hrc;
|
||||
|
||||
TRACE("Created swapchain %p.\n", object);
|
||||
*swapchain = (IDirect3DSwapChain8 *)object;
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IDirect3DDevice8Impl_Reset(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
|
||||
|
|
|
@ -102,7 +102,7 @@ static HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN8
|
|||
return hrc;
|
||||
}
|
||||
|
||||
const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl =
|
||||
static const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl =
|
||||
{
|
||||
IDirect3DSwapChain8Impl_QueryInterface,
|
||||
IDirect3DSwapChain8Impl_AddRef,
|
||||
|
@ -110,3 +110,59 @@ const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl =
|
|||
IDirect3DSwapChain8Impl_Present,
|
||||
IDirect3DSwapChain8Impl_GetBackBuffer
|
||||
};
|
||||
|
||||
HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, IDirect3DDevice8Impl *device,
|
||||
D3DPRESENT_PARAMETERS *present_parameters)
|
||||
{
|
||||
WINED3DPRESENT_PARAMETERS wined3d_parameters;
|
||||
HRESULT hr;
|
||||
|
||||
swapchain->ref = 1;
|
||||
swapchain->lpVtbl = &Direct3DSwapChain8_Vtbl;
|
||||
|
||||
wined3d_parameters.BackBufferWidth = present_parameters->BackBufferWidth;
|
||||
wined3d_parameters.BackBufferHeight = present_parameters->BackBufferHeight;
|
||||
wined3d_parameters.BackBufferFormat = wined3dformat_from_d3dformat(present_parameters->BackBufferFormat);
|
||||
wined3d_parameters.BackBufferCount = max(1, present_parameters->BackBufferCount);
|
||||
wined3d_parameters.MultiSampleType = present_parameters->MultiSampleType;
|
||||
wined3d_parameters.MultiSampleQuality = 0; /* d3d9 only */
|
||||
wined3d_parameters.SwapEffect = present_parameters->SwapEffect;
|
||||
wined3d_parameters.hDeviceWindow = present_parameters->hDeviceWindow;
|
||||
wined3d_parameters.Windowed = present_parameters->Windowed;
|
||||
wined3d_parameters.EnableAutoDepthStencil = present_parameters->EnableAutoDepthStencil;
|
||||
wined3d_parameters.AutoDepthStencilFormat = wined3dformat_from_d3dformat(present_parameters->AutoDepthStencilFormat);
|
||||
wined3d_parameters.Flags = present_parameters->Flags;
|
||||
wined3d_parameters.FullScreen_RefreshRateInHz = present_parameters->FullScreen_RefreshRateInHz;
|
||||
wined3d_parameters.PresentationInterval = present_parameters->FullScreen_PresentationInterval;
|
||||
wined3d_parameters.AutoRestoreDisplayMode = TRUE;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hr = IWineD3DDevice_CreateSwapChain(device->WineD3DDevice, &wined3d_parameters,
|
||||
&swapchain->wineD3DSwapChain, (IUnknown *)swapchain, SURFACE_OPENGL);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
present_parameters->BackBufferWidth = wined3d_parameters.BackBufferWidth;
|
||||
present_parameters->BackBufferHeight = wined3d_parameters.BackBufferHeight;
|
||||
present_parameters->BackBufferFormat = d3dformat_from_wined3dformat(wined3d_parameters.BackBufferFormat);
|
||||
present_parameters->BackBufferCount = wined3d_parameters.BackBufferCount;
|
||||
present_parameters->MultiSampleType = wined3d_parameters.MultiSampleType;
|
||||
present_parameters->SwapEffect = wined3d_parameters.SwapEffect;
|
||||
present_parameters->hDeviceWindow = wined3d_parameters.hDeviceWindow;
|
||||
present_parameters->Windowed = wined3d_parameters.Windowed;
|
||||
present_parameters->EnableAutoDepthStencil = wined3d_parameters.EnableAutoDepthStencil;
|
||||
present_parameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(wined3d_parameters.AutoDepthStencilFormat);
|
||||
present_parameters->Flags = wined3d_parameters.Flags;
|
||||
present_parameters->FullScreen_RefreshRateInHz = wined3d_parameters.FullScreen_RefreshRateInHz;
|
||||
present_parameters->FullScreen_PresentationInterval = wined3d_parameters.PresentationInterval;
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to create wined3d swapchain, hr %#x.\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
swapchain->parentDevice = (IDirect3DDevice8 *)device;
|
||||
IDirect3DDevice8_AddRef(swapchain->parentDevice);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue