mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 05:00:27 +00:00
* Refactored GetDirect3D9AdapterInfo() to make life a little easier in InitD3D9BaseDevice().
* Filled IDirect3DDevice9::DeviceData[] with correct info svn path=/trunk/; revision=35568
This commit is contained in:
parent
48021764b4
commit
07147e6a3c
6 changed files with 66 additions and 26 deletions
|
@ -112,21 +112,14 @@ void GetDisplayAdapterFromDevice(IN OUT LPDIRECT3D9_DISPLAYADAPTER pDisplayAdapt
|
|||
}
|
||||
}
|
||||
|
||||
static BOOL GetDirect3D9AdapterInfo(IN OUT LPDIRECT3D9_DISPLAYADAPTER pDisplayAdapters, IN DWORD AdapterIndex)
|
||||
BOOL CreateD3D9DeviceData(IN LPDIRECT3D9_DISPLAYADAPTER pDisplayAdapter, IN LPD3D9_DEVICEDATA pDeviceData)
|
||||
{
|
||||
HDC hDC;
|
||||
LPD3D9_DEVICEDATA pDeviceData;
|
||||
LPDIRECT3D9_DISPLAYADAPTER pDisplayAdapter = &pDisplayAdapters[AdapterIndex];
|
||||
|
||||
/* Test DC creation for the display device */
|
||||
if (NULL == (hDC = CreateDCA(NULL, pDisplayAdapter->szDeviceName, NULL, NULL)))
|
||||
return FALSE;
|
||||
|
||||
pDeviceData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(D3D9_DEVICEDATA));
|
||||
if (NULL == pDeviceData)
|
||||
{
|
||||
DPRINT1("Out of memory, could not initialize Direct3D adapter");
|
||||
DeleteDC(hDC);
|
||||
DPRINT1("Could not create dc for display adapter: %s", pDisplayAdapter->szDeviceName);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -147,17 +140,39 @@ static BOOL GetDirect3D9AdapterInfo(IN OUT LPDIRECT3D9_DISPLAYADAPTER pDisplayAd
|
|||
|
||||
if (FALSE == GetDeviceData(pDeviceData))
|
||||
{
|
||||
DeleteDC(hDC);
|
||||
HeapFree(GetProcessHeap(), 0, pDeviceData->pUnknown6BC);
|
||||
HeapFree(GetProcessHeap(), 0, pDeviceData);
|
||||
DPRINT1("Could not get device data for display adapter: %s", pDisplayAdapter->szDeviceName);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DeleteDC(hDC);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID DestroyD3D9DeviceData(IN LPD3D9_DEVICEDATA pDeviceData)
|
||||
{
|
||||
DeleteDC(pDeviceData->hDC);
|
||||
HeapFree(GetProcessHeap(), 0, pDeviceData->pUnknown6BC);
|
||||
}
|
||||
|
||||
static BOOL GetDirect3D9AdapterInfo(IN OUT LPDIRECT3D9_DISPLAYADAPTER pDisplayAdapters, IN DWORD AdapterIndex)
|
||||
{
|
||||
LPD3D9_DEVICEDATA pDeviceData;
|
||||
|
||||
pDeviceData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(D3D9_DEVICEDATA));
|
||||
if (NULL == pDeviceData)
|
||||
{
|
||||
DPRINT1("Out of memory, could not initialize Direct3D adapter");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (FALSE == CreateD3D9DeviceData(&pDisplayAdapters[AdapterIndex], pDeviceData))
|
||||
{
|
||||
DPRINT1("Could not create device data for adapter: %d", AdapterIndex);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GetDisplayAdapterFromDevice(pDisplayAdapters, AdapterIndex, pDeviceData);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, pDeviceData->pUnknown6BC);
|
||||
DestroyD3D9DeviceData(pDeviceData);
|
||||
HeapFree(GetProcessHeap(), 0, pDeviceData);
|
||||
|
||||
return TRUE;
|
||||
|
@ -232,9 +247,6 @@ HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9, UINT SDKVersion)
|
|||
if (pDirect3D9 == 0)
|
||||
return DDERR_OUTOFMEMORY;
|
||||
|
||||
pDirect3D9->unknown000007 = 0;
|
||||
pDirect3D9->lpInt = 0;
|
||||
|
||||
pDirect3D9->lpVtbl = &Direct3D9_Vtbl;
|
||||
pDirect3D9->dwProcessId = GetCurrentThreadId();
|
||||
pDirect3D9->lRefCnt = 1;
|
||||
|
@ -246,10 +258,15 @@ HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9, UINT SDKVersion)
|
|||
|
||||
InitializeCriticalSection(&pDirect3D9->d3d9_cs);
|
||||
|
||||
GetDisplayDeviceInfo(pDirect3D9);
|
||||
if (FALSE == GetDisplayDeviceInfo(pDirect3D9))
|
||||
{
|
||||
DPRINT1("Could not create Direct3D9 object");
|
||||
AlignedFree(pDirect3D9);
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
|
||||
*ppDirect3D9 = (LPDIRECT3D9)&pDirect3D9->lpVtbl;
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,4 +15,7 @@
|
|||
/* Creates a Direct3D9 object */
|
||||
HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9, UINT SDKVersion);
|
||||
|
||||
BOOL CreateD3D9DeviceData(IN LPDIRECT3D9_DISPLAYADAPTER pDisplayAdapter, IN LPD3D9_DEVICEDATA pDeviceData);
|
||||
VOID DestroyD3D9DeviceData(IN LPD3D9_DEVICEDATA pDeviceData);
|
||||
|
||||
#endif // _D3D9_CREATE_H_
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
#include "d3d9_device.h"
|
||||
#include "d3d9_helpers.h"
|
||||
#include "adapter.h"
|
||||
#include "debug.h"
|
||||
#include <debug.h>
|
||||
#include "d3d9_create.h"
|
||||
|
||||
#define LOCK_D3DDEVICE9() if (This->bLockDevice) EnterCriticalSection(&This->CriticalSection);
|
||||
#define UNLOCK_D3DDEVICE9() if (This->bLockDevice) LeaveCriticalSection(&This->CriticalSection);
|
||||
|
@ -53,8 +54,16 @@ static ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9 iface)
|
|||
|
||||
if (ref == 0)
|
||||
{
|
||||
DWORD iAdapter;
|
||||
|
||||
EnterCriticalSection(&This->CriticalSection);
|
||||
|
||||
/* TODO: Free resources here */
|
||||
for (iAdapter = 0; iAdapter < This->NumAdaptersInDevice; iAdapter++)
|
||||
{
|
||||
DestroyD3D9DeviceData(&This->DeviceData[iAdapter]);
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&This->CriticalSection);
|
||||
AlignedFree(This);
|
||||
}
|
||||
|
|
|
@ -2667,6 +2667,6 @@ typedef struct _DIRECT3D9_INT
|
|||
/* 0x47ac */ DWORD unknown004587;
|
||||
/* 0x47b0 */ DWORD unknown004588;
|
||||
/* 0x47b4 */ UINT SDKVersion;
|
||||
} DIRECT3D9_INT, *LPDIRECT3D9_INT;
|
||||
} DIRECT3D9_INT, FAR *LPDIRECT3D9_INT;
|
||||
|
||||
#endif // _D3D9_PRIVATE_H_
|
||||
|
|
|
@ -150,6 +150,8 @@ HRESULT Direct3DSwapChain9_Init(Direct3DSwapChain9_INT* pThisSwapChain, D3DPRESE
|
|||
pThisSwapChain->GammaRamp.blue[i] = i;
|
||||
}
|
||||
|
||||
pThisSwapChain->PresentParameters = pPresentationParameters[pThisSwapChain->ChainIndex];
|
||||
|
||||
return Direct3DSwapChain9_Reset(pThisSwapChain, pPresentationParameters);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "device.h"
|
||||
#include <debug.h>
|
||||
#include "d3d9_helpers.h"
|
||||
#include "d3d9_create.h"
|
||||
|
||||
static HRESULT InitD3D9ResourceManager(D3D9ResourceManager* pThisResourceManager, LPDIRECT3DDEVICE9_INT pDirect3DDevice9)
|
||||
{
|
||||
|
@ -36,7 +37,6 @@ HRESULT InitD3D9BaseDevice(LPDIRECT3DDEVICE9_INT pThisBaseDevice, LPDIRECT3D9_IN
|
|||
{
|
||||
D3D9ResourceManager* pResourceManager;
|
||||
DWORD i;
|
||||
D3DDISPLAYMODE DisplayMode;
|
||||
|
||||
// Insert Reset/Ctor here
|
||||
|
||||
|
@ -59,16 +59,25 @@ HRESULT InitD3D9BaseDevice(LPDIRECT3DDEVICE9_INT pThisBaseDevice, LPDIRECT3D9_IN
|
|||
// TODO: Query driver for correct DX version
|
||||
pThisBaseDevice->dwDXVersion = 9;
|
||||
|
||||
DisplayMode = pThisBaseDevice->CurrentDisplayMode[0];
|
||||
pThisBaseDevice->CurrentDisplayMode[0].Width = pDirect3D9->DisplayAdapters[0].DriverCaps.dwDisplayWidth;
|
||||
pThisBaseDevice->CurrentDisplayMode[0].Height = pDirect3D9->DisplayAdapters[0].DriverCaps.dwDisplayHeight;
|
||||
pThisBaseDevice->CurrentDisplayMode[0].RefreshRate = pDirect3D9->DisplayAdapters[0].DriverCaps.dwRefreshRate;
|
||||
pThisBaseDevice->CurrentDisplayMode[0].Format = pDirect3D9->DisplayAdapters[0].DriverCaps.DisplayFormat;
|
||||
|
||||
for (i = 0; i < NumAdaptersToCreate; i++)
|
||||
{
|
||||
pThisBaseDevice->CurrentDisplayMode[i] = pThisBaseDevice->CurrentDisplayMode[0];
|
||||
if (FALSE == CreateD3D9DeviceData(&pDirect3D9->DisplayAdapters[i], &pThisBaseDevice->DeviceData[i]))
|
||||
{
|
||||
DPRINT1("Failed to get device data for adapter: %d", i);
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
|
||||
pThisBaseDevice->AdapterIndexInGroup[i] = i;
|
||||
// TODO: Fill pThisBaseDevice->DeviceData[i]
|
||||
pThisBaseDevice->CurrentDisplayMode[i] = pThisBaseDevice->CurrentDisplayMode[0];
|
||||
|
||||
pThisBaseDevice->pSwapChains[i] = CreateDirect3DSwapChain9(RT_BUILTIN, pThisBaseDevice, i);
|
||||
pThisBaseDevice->pSwapChains2[i] = pThisBaseDevice->pSwapChains[i];
|
||||
Direct3DSwapChain9_SetDisplayMode(pThisBaseDevice->pSwapChains[i], &DisplayMode);
|
||||
Direct3DSwapChain9_SetDisplayMode(pThisBaseDevice->pSwapChains[i], &pThisBaseDevice->CurrentDisplayMode[i]);
|
||||
|
||||
if (FAILED(Direct3DSwapChain9_Init(pThisBaseDevice->pSwapChains[i], pPresentationParameters)))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue