Author: gbrunmar
Date: Sun Mar 9 09:11:32 2008
New Revision: 32622
URL:
http://svn.reactos.org/svn/reactos?rev=3D32622&view=3Drev
Log:
Second iteration of Direct3DCreate9()
Added:
trunk/reactos/dll/directx/d3d9/d3d9_caps.c (with props)
trunk/reactos/dll/directx/d3d9/d3d9_caps.h (with props)
Modified:
trunk/reactos/dll/directx/d3d9/d3d9.rbuild
trunk/reactos/dll/directx/d3d9/d3d9_create.c
trunk/reactos/dll/directx/d3d9/d3d9_private.h
Modified: trunk/reactos/dll/directx/d3d9/d3d9.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9=
.rbuild?rev=3D32622&r1=3D32621&r2=3D32622&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/dll/directx/d3d9/d3d9.rbuild (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9.rbuild Sun Mar 9 09:11:32 2008
@@ -17,6 +17,7 @@
<file>d3d9_helpers.c</file>
<file>d3d9_impl.c</file>
<file>d3d9_create.c</file>
+ <file>d3d9_caps.c</file>
<file>adapter.c</file>
<file>format.c</file>
<file>d3d9.rc</file>
Added: trunk/reactos/dll/directx/d3d9/d3d9_caps.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9=
_caps.c?rev=3D32622&view=3Dauto
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/dll/directx/d3d9/d3d9_caps.c (added)
+++ trunk/reactos/dll/directx/d3d9/d3d9_caps.c Sun Mar 9 09:11:32 2008
@@ -1,0 +1,880 @@
+#define STDCALL __stdcall
+#include <d3d9.h>
+#include <ddraw.h>
+#include <d3dnthal.h>
+#include <d3dhal.h>
+#include <ddrawi.h>
+#include <ddrawgdi.h>
+#include <dll/directx/d3d8thk.h>
+#include <debug.h>
+#include <strsafe.h>
+#include <limits.h>
+#include "d3d9_helpers.h"
+#include "d3d9_caps.h"
+#include "adapter.h"
+
+static INT g_NumDevices =3D 0;
+
+void CreateDisplayModeList(LPCSTR lpszDeviceName, D3DDISPLAYMODE* pDisplay=
Modes, DWORD* pNumDisplayModes, D3DFORMAT Default16BitFormat, D3D9_Unknown6=
BC_INT* pUnknown6BC)
+{
+ DEVMODEA DevMode;
+ DWORD ModeIndex =3D 0;
+ DWORD ValidModes =3D 0;
+
+ while (TRUE =3D=3D EnumDisplaySettingsA(lpszDeviceName, ModeIndex, &De=
vMode))
+ {
+ D3DFORMAT DefaultFormat;
+
+ if (DevMode.dmBitsPerPel !=3D 15 &&
+ DevMode.dmBitsPerPel !=3D 16 &&
+ DevMode.dmBitsPerPel !=3D 32)
+ {
+ ++ModeIndex;
+ continue;
+ }
+
+ ++ValidModes;
+
+ if (DevMode.dmBitsPerPel =3D=3D 15 || DevMode.dmBitsPerPel =3D=3D =
16)
+ {
+ if (NULL =3D=3D pUnknown6BC)
+ {
+ ++ModeIndex;
+ continue;
+ }
+
+ DefaultFormat =3D Default16BitFormat;
+ }
+ else
+ {
+ DefaultFormat =3D D3DFMT_X8R8G8B8;
+ }
+
+ if (NULL !=3D pDisplayModes)
+ {
+ if (ValidModes =3D=3D *pNumDisplayModes)
+ break;
+
+ pDisplayModes->Width =3D DevMode.dmPelsWidth;
+ pDisplayModes->Height =3D DevMode.dmPelsHeight;
+ pDisplayModes->RefreshRate =3D DevMode.dmDisplayFrequency;
+ pDisplayModes->Format =3D DefaultFormat;
+ ++pDisplayModes;
+ }
+
+ ++ModeIndex;
+ }
+
+ *pNumDisplayModes =3D ValidModes;
+}
+
+static void CreateInternalDeviceData(HDC hDC, LPCSTR lpszDeviceName, D3D9_=
Unknown6BC_INT** ppUnknown, D3DDEVTYPE DeviceType, HMODULE* hD3DRefDll)
+{
+ D3D9_Unknown6BC_INT* pUnknown6BC;
+ DWORD ValueSize;
+
+ if (ppUnknown) *ppUnknown =3D NULL;
+ if (hD3DRefDll) *hD3DRefDll =3D NULL;
+
+ if (DeviceType !=3D D3DDEVTYPE_HAL)
+ {
+ /* TODO: Implement D3DDEVTYPE_REF and D3DDEVTYPE_SW */
+ UNIMPLEMENTED;
+ return;
+ }
+
+ pUnknown6BC =3D HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(D=
3D9_Unknown6BC_INT));
+ if (NULL =3D=3D pUnknown6BC)
+ {
+ DPRINT1("Out of memory");
+ return;
+ }
+
+ pUnknown6BC->hDD =3D OsThunkDdCreateDirectDrawObject(hDC);
+ if (0 =3D=3D pUnknown6BC->hDD)
+ {
+ HeapFree(GetProcessHeap(), 0, pUnknown6BC);
+ return;
+ }
+
+
+ StringCbCopyA(pUnknown6BC->szDeviceName, CCHDEVICENAME, lpszDeviceName=
);
+ //pUnknown6BC->DeviceUniq =3D DdQueryDisplaySettingsUniqueness();
+ pUnknown6BC->DeviceType =3D DeviceType;
+
+
+ ValueSize =3D sizeof(DWORD);
+ ReadRegistryValue(REG_DWORD, "ForceDriverFlagsOn",
(LPBYTE)&pUnknown6B=
C->bForceDriverFlagsOn, &ValueSize);
+
+ ValueSize =3D sizeof(DWORD);
+ ReadRegistryValue(REG_DWORD, "ForceDriverFlagsOff",
(LPBYTE)&pUnknown6=
BC->bForceDriverFlagsOff, &ValueSize);
+
+ ++g_NumDevices;
+
+ *ppUnknown =3D pUnknown6BC;
+}
+
+static void ReleaseInternalDeviceData(LPD3D9_DEVICEDATA pDeviceData)
+{
+ OsThunkDdDeleteDirectDrawObject(pDeviceData->pUnknown6BC->hDD);
+
+ HeapFree(GetProcessHeap(), 0, pDeviceData->pUnknown6BC);
+ pDeviceData->pUnknown6BC =3D NULL;
+
+ --g_NumDevices;
+}
+
+BOOL GetDeviceData(LPD3D9_DEVICEDATA pDeviceData)
+{
+ BOOL bRet;
+ D3DHAL_GLOBALDRIVERDATA GlobalDriverData;
+ D3DHAL_D3DEXTENDEDCAPS D3dExtendedCaps;
+ LPDDSURFACEDESC puD3dTextureFormats;
+ DDPIXELFORMAT* pD3dZStencilFormatList;
+ D3DDISPLAYMODE* pD3dDisplayModeList;
+ D3DQUERYTYPE* pD3dQueryList;
+ DWORD NumTextureFormats =3D 0;
+ DWORD NumStencilFormats =3D 0;
+ DWORD NumExtendedFormats =3D 0;
+ DWORD NumQueries =3D 0;
+
+ if (NULL =3D=3D pDeviceData->pUnknown6BC)
+ {
+ CreateInternalDeviceData(
+ pDeviceData->hDC,
+ pDeviceData->szDeviceName,
+ &pDeviceData->pUnknown6BC,
+ pDeviceData->DeviceType,
+ &pDeviceData->hD3DRefDll
+ );
+
+ if (NULL =3D=3D pDeviceData->pUnknown6BC)
+ {
+ DPRINT1("Failed to create DirectDrawObject for Direct3D9");
+ return FALSE;
+ }
+ }
+ else
+ {
+ D3D9_DRIVERCAPS DriverCaps;
+ D3D9_UnknownA8h_INT unknownA8h;
+
+ if (FALSE =3D=3D CanReenableDirectDrawObject(pDeviceData->pUnknown=
6BC))
+ {
+ DPRINT1("Failed to re-enable DirectDrawObject");
+ return FALSE;
+ }
+
+ bRet =3D GetD3D9DriverInfo(
+ pDeviceData->pUnknown6BC,
+ &DriverCaps,
+ &unknownA8h,
+ pDeviceData->szDeviceName,
+ pDeviceData->hD3DRefDll,
+ &GlobalDriverData,
+ &D3dExtendedCaps,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &NumTextureFormats,
+ &NumStencilFormats,
+ &NumExtendedFormats,
+ &NumQueries
+ );
+
+ if (TRUE =3D=3D bRet)
+ {
+ pDeviceData->DriverCaps.dwDisplayWidth =3D DriverCaps.dwDispla=
yWidth;
+ pDeviceData->DriverCaps.dwDisplayHeight =3D DriverCaps.dwDispl=
ayHeight;
+ pDeviceData->DriverCaps.RawDisplayFormat =3D DriverCaps.RawDis=
playFormat;
+ pDeviceData->DriverCaps.DisplayFormat =3D DriverCaps.DisplayFo=
rmat;
+ pDeviceData->DriverCaps.dwRefreshRate =3D DriverCaps.dwRefresh=
Rate;
+ }
+
+ return bRet;
+ }
+
+ /* Cleanup of old stuff */
+ if (pDeviceData->DriverCaps.pSupportedFormatOps)
+ {
+ HeapFree(GetProcessHeap(), 0, pDeviceData->DriverCaps.pSupportedFo=
rmatOps);
+ pDeviceData->DriverCaps.pSupportedFormatOps =3D NULL;
+ }
+ if (pDeviceData->DriverCaps.pSupportedExtendedModes)
+ {
+ HeapFree(GetProcessHeap(), 0, pDeviceData->DriverCaps.pSupportedEx=
tendedModes);
+ pDeviceData->DriverCaps.pSupportedExtendedModes =3D NULL;
+ }
+ if (pDeviceData->DriverCaps.pSupportedQueriesList)
+ {
+ HeapFree(GetProcessHeap(), 0, pDeviceData->DriverCaps.pSupportedQu=
eriesList);
+ pDeviceData->DriverCaps.pSupportedQueriesList =3D NULL;
+ }
+
+ if (FALSE =3D=3D CanReenableDirectDrawObject(pDeviceData->pUnknown6BC))
+ {
+ DPRINT1("Failed to re-enable DirectDrawObject");
+ ReleaseInternalDeviceData(pDeviceData);
+ return FALSE;
+ }
+
+ bRet =3D GetD3D9DriverInfo(
+ pDeviceData->pUnknown6BC,
+ &pDeviceData->DriverCaps,
+ &pDeviceData->_UnknownA8h,
+ pDeviceData->szDeviceName,
+ pDeviceData->hD3DRefDll,
+ &GlobalDriverData,
+ &D3dExtendedCaps,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &NumTextureFormats,
+ &NumStencilFormats,
+ &NumExtendedFormats,
+ &NumQueries
+ );
+
+ if (FALSE =3D=3D bRet)
+ {
+ DPRINT1("Could not query DirectDrawObject, aborting");
+ ReleaseInternalDeviceData(pDeviceData);
+ return FALSE;
+ }
+
+ puD3dTextureFormats =3D HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, =
max(NumTextureFormats, 1) * sizeof(DDSURFACEDESC));
+ pD3dZStencilFormatList =3D HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMOR=
Y, max(NumStencilFormats, 1) * sizeof(DDPIXELFORMAT));
+ pD3dDisplayModeList =3D HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, =
max(NumExtendedFormats, 1) * sizeof(D3DDISPLAYMODE));
+ pD3dQueryList =3D HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, max(Nu=
mQueries, 1) * sizeof(D3DQUERYTYPE));
+
+ bRet =3D GetD3D9DriverInfo(
+ pDeviceData->pUnknown6BC,
+ &pDeviceData->DriverCaps,
+ &pDeviceData->_UnknownA8h,
+ pDeviceData->szDeviceName,
+ pDeviceData->hD3DRefDll,
+ &GlobalDriverData,
+ &D3dExtendedCaps,
+ puD3dTextureFormats,
+ pD3dZStencilFormatList,
+ pD3dDisplayModeList,
+ pD3dQueryList,
+ &NumTextureFormats,
+ &NumStencilFormats,
+ &NumExtendedFormats,
+ &NumQueries
+ );
+
+ if (FALSE =3D=3D bRet)
+ {
+ DPRINT1("Could not query DirectDrawObject, aborting");
+ HeapFree(GetProcessHeap(), 0, puD3dTextureFormats);
+ HeapFree(GetProcessHeap(), 0, pD3dZStencilFormatList);
+ HeapFree(GetProcessHeap(), 0, pD3dDisplayModeList);
+ HeapFree(GetProcessHeap(), 0, pD3dQueryList);
+ ReleaseInternalDeviceData(pDeviceData);
+ return FALSE;
+ }
+
+ pDeviceData->DriverCaps.NumSupportedFormatOps =3D NumTextureFormats;
+ if (NumTextureFormats > 0)
+ pDeviceData->DriverCaps.pSupportedFormatOps =3D puD3dTextureFormat=
s;
+
+ pDeviceData->DriverCaps.NumSupportedExtendedModes =3D NumExtendedForma=
ts;
+ if (NumExtendedFormats > 0)
+ pDeviceData->DriverCaps.pSupportedExtendedModes =3D pD3dDisplayMod=
eList;
+
+ pDeviceData->DriverCaps.NumSupportedQueries =3D NumQueries;
+ if (NumQueries > 0)
+ pDeviceData->DriverCaps.pSupportedQueriesList =3D pD3dQueryList;
+ =
+ HeapFree(GetProcessHeap(), 0, pD3dZStencilFormatList); =
+
+ return TRUE;
+}
+
+
+
+BOOL CanReenableDirectDrawObject(D3D9_Unknown6BC_INT* pUnknown)
+{
+ BOOL bDisplayModeWasChanged;
+
+ /* Try the real way first */
+ if (TRUE =3D=3D OsThunkDdReenableDirectDrawObject(pUnknown->hDD, &bDis=
playModeWasChanged))
+ return TRUE;
+
+ /* Ref types and software types can always be reenabled after a mode s=
witch */
+ if (pUnknown->DeviceType =3D=3D D3DDEVTYPE_REF || pUnknown->DeviceType=
=3D=3D D3DDEVTYPE_SW)
+ return TRUE;
+
+ return FALSE;
+}
+
+
+
+static void PrepareDriverInfoData(DD_GETDRIVERINFODATA* DrvInfo, LPVOID pD=
ata, DWORD dwExpectedSize)
+{
+ memset(DrvInfo, 0, sizeof(DD_GETDRIVERINFODATA));
+ DrvInfo->dwSize =3D sizeof(DD_GETDRIVERINFODATA);
+ DrvInfo->guidInfo =3D GUID_GetDriverInfo2;
+ DrvInfo->dwExpectedSize =3D dwExpectedSize;
+ DrvInfo->lpvData =3D pData;
+ DrvInfo->ddRVal =3D E_FAIL;
+}
+
+static void ResetGetDriverInfo2Data(DD_GETDRIVERINFO2DATA* DrvInfo2, DWORD=
dwType, DWORD dwExpectedSize)
+{
+ memset(DrvInfo2, 0, dwExpectedSize);
+ DrvInfo2->dwMagic =3D D3DGDI2_MAGIC;
+ DrvInfo2->dwType =3D dwType;
+ DrvInfo2->dwExpectedSize =3D dwExpectedSize;
+}
+
+BOOL GetD3D9DriverInfo( D3D9_Unknown6BC_INT* pUnknown6BC,
+ LPD3D9_DRIVERCAPS pDriverCaps,
+ D3D9_UnknownA8h_INT* pUnknownA8h,
+ LPCSTR lpszDeviceName,
+ HMODULE hD3dRefDll,
+ D3DHAL_GLOBALDRIVERDATA* pGblDriverData,
+ D3DHAL_D3DEXTENDEDCAPS* pD3dExtendedCaps,
+ LPDDSURFACEDESC puD3dTextureFormats,
+ DDPIXELFORMAT* pD3dZStencilFormatList,
+ D3DDISPLAYMODE* pD3dDisplayModeList,
+ D3DQUERYTYPE* pD3dQueryList,
+ LPDWORD pNumTextureFormats,
+ LPDWORD pNumZStencilFormats,
+ LPDWORD pNumExtendedFormats,
+ LPDWORD pNumQueries)
+{
+ BOOL bRet;
+ DWORD ValueSize;
+ DWORD dwDXVersion;
+
+ DD_HALINFO HalInfo;
+ DWORD CallBackFlags[3];
+ D3DNTHAL_CALLBACKS D3dCallbacks;
+ D3DNTHAL_GLOBALDRIVERDATA D3dDriverData;
+ DD_D3DBUFCALLBACKS D3dBufferCallbacks;
+ DWORD NumHeaps =3D 0;
+ DWORD NumFourCC =3D 0;
+
+ BOOL bDX8Mode =3D FALSE;
+
+ DD_GETDRIVERINFODATA DrvInfo;
+ DD_GETDDIVERSIONDATA DdiVersion;
+ DD_GETFORMATCOUNTDATA FormatCountData;
+ DD_GETEXTENDEDMODECOUNTDATA ExModeCountData;
+ DD_GETD3DQUERYCOUNTDATA D3dQueryCountData;
+
+ /* Init */
+ *pNumTextureFormats =3D 0;
+ *pNumZStencilFormats =3D 0;
+ *pNumExtendedFormats =3D 0;
+ *pNumQueries =3D 0;
+ memset(pD3dExtendedCaps, 0, sizeof(D3DHAL_D3DEXTENDEDCAPS));
+ memset(pGblDriverData, 0, sizeof(D3DHAL_GLOBALDRIVERDATA));
+ memset(pDriverCaps, 0, sizeof(D3D9_DRIVERCAPS));
+
+ /* Set runtime version */
+ ValueSize =3D sizeof(dwDXVersion);
+ if (FALSE =3D=3D ReadRegistryValue(REG_DWORD, "DD_RUNTIME_VERSION", (L=
PBYTE)&dwDXVersion, &ValueSize))
+ dwDXVersion =3D DD_RUNTIME_VERSION;
+
+
+ bRet =3D OsThunkDdQueryDirectDrawObject(
+ pUnknown6BC->hDD,
+ &HalInfo,
+ CallBackFlags,
+ &D3dCallbacks,
+ &D3dDriverData,
+ &D3dBufferCallbacks,
+ NULL,
+ &NumHeaps,
+ NULL,
+ &NumFourCC,
+ NULL
+ );
+
+ if (bRet =3D=3D FALSE)
+ {
+ /* TODO: Handle error */
+ return FALSE;
+ }
+
+ if ((HalInfo.ddCaps.dwSVBCaps2 & DDCAPS2_AUTOFLIPOVERLAY) =3D=3D 0 &&
+ puD3dTextureFormats !=3D NULL)
+ {
+ bRet =3D OsThunkDdQueryDirectDrawObject(
+ pUnknown6BC->hDD,
+ &HalInfo,
+ CallBackFlags,
+ &D3dCallbacks,
+ &D3dDriverData,
+ &D3dBufferCallbacks,
+ puD3dTextureFormats,
+ &NumHeaps,
+ NULL,
+ &NumFourCC,
+ NULL
+ );
+
+ if (FALSE =3D=3D bRet)
+ return FALSE;
+ }
+
+ if (NULL =3D=3D pUnknown6BC->swDDICreateDirectDrawObject)
+ {
+ *pNumTextureFormats =3D D3dDriverData.dwNumTextureFormats;
+ }
+
+ pDriverCaps->DriverCaps9.Caps =3D HalInfo.ddCaps.dwCaps;
+ pDriverCaps->DriverCaps9.Caps2 =3D HalInfo.ddCaps.dwCaps2;
+ pDriverCaps->DriverCaps9.Caps3 =3D HalInfo.ddCaps.dwSVCaps;
+ pDriverCaps->dwSVBCaps =3D HalInfo.ddCaps.dwSVBCaps;
+ pDriverCaps->dwVSBCaps =3D HalInfo.ddCaps.dwVSBCaps;
+ pDriverCaps->dwSVBCaps2 =3D HalInfo.ddCaps.dwSVBCaps2;
+ pUnknown6BC->lDisplayPitch =3D HalInfo.vmiData.lDisplayPitch;
+
+ if (HalInfo.dwFlags & DDHALINFO_GETDRIVERINFO2)
+ {
+ /* GUID_GetDriverInfo2 - Inform driver of DX version */
+ {
+ DD_DXVERSION DxVersion;
+
+ ResetGetDriverInfo2Data(&DxVersion.gdi2, D3DGDI2_TYPE_DXVERSIO=
N, sizeof(DD_DXVERSION));
+ DxVersion.dwDXVersion =3D dwDXVersion;
+
+ PrepareDriverInfoData(&DrvInfo, &DxVersion, sizeof(DxVersion));
+ OsThunkDdGetDriverInfo((HANDLE)pUnknown6BC->hDD, &DrvInfo);
+ }
+
+
+ /* GUID_GetDriverInfo2 - Get DDI version */
+ {
+ ResetGetDriverInfo2Data(&DdiVersion.gdi2, D3DGDI2_TYPE_GETDDIV=
ERSION, sizeof(DD_GETDDIVERSIONDATA));
+ PrepareDriverInfoData(&DrvInfo, &DdiVersion, sizeof(DdiVersion=
));
+ bRet =3D OsThunkDdGetDriverInfo((HANDLE)pUnknown6BC->hDD, &Drv=
Info);
+
+ if (DdiVersion.dwDDIVersion !=3D DX9_DDI_VERSION)
+ {
+ DWORD ForceDDIOn;
+
+ ValueSize =3D sizeof(ForceDDIOn);
+ if (TRUE =3D=3D ReadRegistryValue(REG_DWORD, "ForceOldDDIO=
n", (LPBYTE)&ForceDDIOn, &ValueSize) &&
+ 0 !=3D ForceDDIOn)
+ {
+ DdiVersion.dwDDIVersion =3D DX9_DDI_VERSION;
+ }
+ }
+ }
+
+
+ /* Check for errors to fallback to DX8 mode */
+ if (DdiVersion.dwDDIVersion < DX9_DDI_VERSION)
+ {
+ bDX8Mode =3D TRUE;
+
+ if (DdiVersion.dwDDIVersion =3D=3D 0)
+ {
+ DPRINT1("Driver claims to be DX9 driver, but didn't report=
DX9 DDI version - reverting to DX8 mode");
+ }
+ else
+ {
+ DPRINT1("Driver claims to be DX9 driver, but was built wit=
h an old DDI version - reverting to DX8 mode");
+ }
+
+ /* GUID_GetDriverInfo2 - Get D3DCAPS8 */
+ {
+ D3DCAPS8 DriverCaps8;
+
+ ResetGetDriverInfo2Data((DD_GETDRIVERINFO2DATA*)&DriverCap=
s8, D3DGDI2_TYPE_GETD3DCAPS8, sizeof(D3DCAPS8));
+ PrepareDriverInfoData(&DrvInfo, &DriverCaps8, sizeof(D3DCA=
PS8));
+ =
+ if (FALSE =3D=3D OsThunkDdGetDriverInfo((HANDLE)pUnknown6B=
C->hDD, &DrvInfo) ||
+ S_OK !=3D DrvInfo.ddRVal ||
+ DrvInfo.dwActualSize !=3D sizeof(D3DCAPS8))
+ {
+ DPRINT1("Driver returned an invalid D3DCAPS8 structure=
- aborting");
+ return FALSE;
+ }
+
+ memcpy(&pDriverCaps->DriverCaps9, &DriverCaps8, sizeof(D3D=
CAPS8));
+ pDriverCaps->DriverCaps9.Caps =3D HalInfo.ddCaps.dwCaps;
+ }
+ }
+
+
+ /* GUID_GetDriverInfo2 - Get D3DCAPS9 */
+ if (FALSE =3D=3D bDX8Mode)
+ {
+ D3DCAPS9 DriverCaps9;
+
+ ResetGetDriverInfo2Data((DD_GETDRIVERINFO2DATA*)&DriverCaps9, =
D3DGDI2_TYPE_GETD3DCAPS9, sizeof(D3DCAPS9));
+ PrepareDriverInfoData(&DrvInfo, &DriverCaps9, sizeof(D3DCAPS9)=
);
+ =
+ if (FALSE =3D=3D OsThunkDdGetDriverInfo((HANDLE)pUnknown6BC->h=
DD, &DrvInfo) ||
+ S_OK !=3D DrvInfo.ddRVal ||
+ DrvInfo.dwActualSize !=3D sizeof(D3DCAPS9))
+ {
+ DPRINT1("Driver returned an invalid D3DCAPS9 structure - a=
borting");
+ return FALSE;
+ }
+
+ pDriverCaps->DriverCaps9 =3D DriverCaps9;
+ pDriverCaps->DriverCaps9.Caps =3D HalInfo.ddCaps.dwCaps;
+ }
+
+
+ /* GUID_GetDriverInfo2 - Get format count data */
+ {
+ ResetGetDriverInfo2Data(&FormatCountData.gdi2, D3DGDI2_TYPE_GE=
TFORMATCOUNT, sizeof(DD_GETFORMATCOUNTDATA));
+ PrepareDriverInfoData(&DrvInfo, &FormatCountData, sizeof(DD_GE=
TFORMATCOUNTDATA));
+ FormatCountData.dwFormatCount =3D UINT_MAX;
+ FormatCountData.dwReserved =3D dwDXVersion;
+
+ if (TRUE =3D=3D OsThunkDdGetDriverInfo((HANDLE)pUnknown6BC->hD=
D, &DrvInfo))
+ {
+ if (DrvInfo.ddRVal !=3D S_OK)
+ {
+ DPRINT1("Driver claimed to be DX9 driver, but didn't s=
upport D3DGDI_TYPE_GETFORMATCOUNT in GetDriverInfo call");
+ return FALSE;
+ }
+ else if (DrvInfo.dwActualSize !=3D sizeof(DD_GETFORMATCOUN=
TDATA))
+ {
+ DPRINT1("Driver returned an invalid DD_GETFORMATCOUNTD=
ATA structure - aborting");
+ return FALSE;
+ }
+ else if (FormatCountData.dwFormatCount =3D=3D UINT_MAX)
+ {
+ DPRINT1("Driver didn't set DD_GETFORMATCOUNTDATA.dwFor=
matCount - aborting");
+ return FALSE;
+ }
+
+ *pNumTextureFormats =3D FormatCountData.dwFormatCount;
+ }
+ }
+
+ /* GUID_GetDriverInfo2 - Get format data */
+ if (puD3dTextureFormats !=3D NULL)
+ {
+ DWORD FormatIndex;
+ DD_GETFORMATDATA FormatData;
+
+ for (FormatIndex =3D 0; FormatIndex < FormatCountData.dwFormat=
Count; FormatIndex++)
+ {
+ ResetGetDriverInfo2Data(&FormatData.gdi2, D3DGDI2_TYPE_GET=
FORMAT, sizeof(DD_GETFORMATDATA));
+ PrepareDriverInfoData(&DrvInfo, &FormatData, sizeof(DD_GET=
FORMATDATA));
+ FormatData.dwFormatIndex =3D FormatIndex;
+
+ if (TRUE =3D=3D OsThunkDdGetDriverInfo((HANDLE)pUnknown6BC=
->hDD, &DrvInfo))
+ {
+ if (DrvInfo.ddRVal !=3D S_OK)
+ {
+ DPRINT1("Driver claimed to be DX9 driver, but didn=
't support D3DGDI_TYPE_GETFORMAT in GetDriverInfo call");
+ return FALSE;
+ }
+ else if (DrvInfo.dwActualSize !=3D sizeof(DD_GETFORMAT=
DATA))
+ {
+ DPRINT1("Driver returned an invalid DD_GETFORMATDA=
TA structure - aborting");
+ return FALSE;
+ }
+ else if (FormatData.format.dwSize !=3D sizeof(DDPIXELF=
ORMAT))
+ {
+ DPRINT1("Driver didn't set DD_GETFORMATDATA.format=
- aborting");
+ return FALSE;
+ }
+
+ /* Copy format data to puD3dTextureFormats */
+ memset(puD3dTextureFormats, 0, sizeof(DDSURFACEDESC));
+ puD3dTextureFormats->dwSize =3D sizeof(DDSURFACEDESC);
+ puD3dTextureFormats->dwFlags =3D DDSD_PIXELFORMAT;
+ memcpy(&puD3dTextureFormats->ddpfPixelFormat, &FormatD=
ata.format, sizeof(DDPIXELFORMAT));
+
+ if ((FormatData.format.dwOperations & D3DFORMAT_OP_PIX=
ELSIZE) !=3D 0 &&
+ FormatData.format.dwPrivateFormatBitCount > 0)
+ {
+ /* TODO: Register driver's own pixelformat */
+ }
+
+ ++puD3dTextureFormats;
+ }
+ }
+ }
+
+ /* GUID_GetDriverInfo2 - Get extended mode count data */
+ {
+ ResetGetDriverInfo2Data(&ExModeCountData.gdi2, D3DGDI2_TYPE_GE=
TEXTENDEDMODECOUNT, sizeof(DD_GETEXTENDEDMODECOUNTDATA));
+ PrepareDriverInfoData(&DrvInfo, &ExModeCountData, sizeof(DD_GE=
TEXTENDEDMODECOUNTDATA));
+ ExModeCountData.dwModeCount =3D UINT_MAX;
+ ExModeCountData.dwReserved =3D dwDXVersion;
+
+ if (TRUE =3D=3D OsThunkDdGetDriverInfo((HANDLE)pUnknown6BC->hD=
D, &DrvInfo))
+ {
+ if (DrvInfo.ddRVal =3D=3D S_OK)
+ {
+ if (DrvInfo.dwActualSize !=3D sizeof(DD_GETEXTENDEDMOD=
ECOUNTDATA))
+ {
+ DPRINT1("Driver returned an invalid DD_GETEXTENDED=
FORMATCOUNTDATA structure - aborting");
+ return FALSE;
+ }
+ else if (ExModeCountData.dwModeCount =3D=3D UINT_MAX)
+ {
+ DPRINT1("Driver didn't set DD_GETEXTENDEDMODECOUNT=
DATA.dwModeCount - aborting");
+ return FALSE;
+ }
+
+ *pNumExtendedFormats =3D ExModeCountData.dwModeCount;
+ }
+ else
+ {
+ ExModeCountData.dwModeCount =3D 0;
+ }
+ }
+ }
+
+ /* GUID_GetDriverInfo2 - Get extended mode data */
+ if (pD3dDisplayModeList !=3D NULL)
+ {
+ DWORD ModeIndex;
+ DD_GETEXTENDEDMODEDATA ExModeData;
+
+ for (ModeIndex =3D 0; ModeIndex < ExModeCountData.dwModeCount;=
ModeIndex++)
+ {
+ ResetGetDriverInfo2Data(&ExModeData.gdi2, D3DGDI2_TYPE_GET=
EXTENDEDMODE, sizeof(DD_GETEXTENDEDMODEDATA));
+ PrepareDriverInfoData(&DrvInfo, &ExModeData, sizeof(DD_GET=
EXTENDEDMODEDATA));
+ ExModeData.dwModeIndex =3D ModeIndex;
+ ExModeData.mode.Width =3D UINT_MAX;
+
+ if (TRUE =3D=3D OsThunkDdGetDriverInfo((HANDLE)pUnknown6BC=
->hDD, &DrvInfo))
+ {
+ if (DrvInfo.ddRVal !=3D S_OK)
+ {
+ DPRINT1("Driver claimed to be DX9 driver, but didn=
't support D3DGDI2_TYPE_GETEXTENDEDMODE in GetDriverInfo call");
+ return FALSE;
+ }
+ else if (DrvInfo.dwActualSize !=3D sizeof(DD_GETEXTEND=
EDMODEDATA))
+ {
+ DPRINT1("Driver returned an invalid DD_GETEXTENDED=
MODEDATA structure - aborting");
+ return FALSE;
+ }
+ else if (ExModeData.mode.Width !=3D UINT_MAX)
+ {
+ DPRINT1("Driver didn't set DD_GETEXTENDEDMODEDATA.=
mode - aborting");
+ return FALSE;
+ }
+
+ memcpy(pD3dDisplayModeList, &ExModeData.mode, sizeof(D=
3DDISPLAYMODE));
+ ++pD3dDisplayModeList;
+ }
+ }
+ }
+
+ /* GUID_GetDriverInfo2 - Get adapter group */
+ {
+ DD_GETADAPTERGROUPDATA AdapterGroupData;
+ ResetGetDriverInfo2Data(&AdapterGroupData.gdi2, D3DGDI2_TYPE_G=
ETADAPTERGROUP, sizeof(DD_GETADAPTERGROUPDATA));
+ PrepareDriverInfoData(&DrvInfo, &AdapterGroupData, sizeof(DD_G=
ETADAPTERGROUPDATA));
+ AdapterGroupData.ulUniqueAdapterGroupId =3D UINT_MAX;
+
+ if (TRUE =3D=3D OsThunkDdGetDriverInfo((HANDLE)pUnknown6BC->hD=
D, &DrvInfo))
+ {
+ if (DrvInfo.ddRVal !=3D S_OK)
+ {
+ DPRINT1("Driver claimed to be DX9 driver, but didn't s=
upport D3DGDI2_TYPE_GETADAPTERGROUP in GetDriverInfo call");
+ return FALSE;
+ }
+ else if (DrvInfo.dwActualSize !=3D sizeof(DD_GETADAPTERGRO=
UPDATA))
+ {
+ DPRINT1("Driver returned an invalid DD_GETADAPTERGROUP=
DATA structure - aborting");
+ return FALSE;
+ }
+ else if (AdapterGroupData.ulUniqueAdapterGroupId =3D=3D UI=
NT_MAX)
+ {
+ DPRINT1("Driver didn't set DD_GETADAPTERGROUPDATA.ulUn=
iqueAdapterGroupId - aborting");
+ return FALSE;
+ }
+
+ pDriverCaps->ulUniqueAdapterGroupId =3D (ULONG)AdapterGrou=
pData.ulUniqueAdapterGroupId;
+ }
+ }
+
+ /* GUID_GetDriverInfo2 - Query count data */
+ {
+ ResetGetDriverInfo2Data(&D3dQueryCountData.gdi2, D3DGDI2_TYPE_=
GETD3DQUERYCOUNT, sizeof(DD_GETD3DQUERYCOUNTDATA));
+ PrepareDriverInfoData(&DrvInfo, &D3dQueryCountData, sizeof(DD_=
GETD3DQUERYCOUNTDATA));
+ D3dQueryCountData.dwNumQueries =3D UINT_MAX;
+
+ if (TRUE =3D=3D OsThunkDdGetDriverInfo((HANDLE)pUnknown6BC->hD=
D, &DrvInfo))
+ {
+ if (DrvInfo.ddRVal !=3D S_OK)
+ {
+ DPRINT1("Driver claimed to be DX9 driver, but didn't s=
upport D3DGDI2_TYPE_GETD3DQUERYCOUNT in GetDriverInfo call");
+ return FALSE;
+ }
+ else if (DrvInfo.dwActualSize !=3D sizeof(DD_GETD3DQUERYCO=
UNTDATA))
+ {
+ DPRINT1("Driver returned an invalid DD_GETD3DQUERYCOUN=
TDATA structure - aborting");
+ return FALSE;
+ }
+ else if (D3dQueryCountData.dwNumQueries =3D=3D UINT_MAX)
+ {
+ DPRINT1("Driver didn't set DD_GETD3DQUERYCOUNTDATA.dwN=
umQueries - aborting");
+ return FALSE;
+ }
+
+ *pNumQueries =3D D3dQueryCountData.dwNumQueries;
+ }
+ }
+
+ /* GUID_GetDriverInfo2 - Query data */
+ if (pD3dQueryList !=3D NULL)
+ {
+ DWORD QueryIndex;
+ DD_GETD3DQUERYDATA D3dQueryData;
+
+ for (QueryIndex =3D 0; QueryIndex < D3dQueryCountData.dwNumQue=
ries; QueryIndex++)
+ {
+ ResetGetDriverInfo2Data(&D3dQueryData.gdi2, D3DGDI2_TYPE_G=
ETD3DQUERY, sizeof(DD_GETD3DQUERYDATA));
+ PrepareDriverInfoData(&DrvInfo, &D3dQueryData, sizeof(DD_G=
ETD3DQUERYDATA));
+ D3dQueryData.dwQueryIndex =3D QueryIndex;
+
+ if (TRUE =3D=3D OsThunkDdGetDriverInfo((HANDLE)pUnknown6BC=
->hDD, &DrvInfo))
+ {
+ if (DrvInfo.ddRVal !=3D S_OK)
+ {
+ DPRINT1("Driver claimed to be DX9 driver, but didn=
't support D3DGDI2_TYPE_GETD3DQUERY in GetDriverInfo call");
+ return FALSE;
+ }
+ else if (DrvInfo.dwActualSize !=3D sizeof(DD_GETD3DQUE=
RYDATA))
+ {
+ DPRINT1("Driver returned an invalid DD_GETD3DQUERY=
DATA structure - aborting");
+ return FALSE;
+ }
+
+ *pD3dQueryList =3D D3dQueryData.QueryType;
+ ++pD3dQueryList;
+ }
+ }
+ }
+ }
+
+ /* D3dDriverData -> pGblDriverData */
+ memcpy(&pGblDriverData->hwCaps, &D3dDriverData.hwCaps, sizeof(D3DNTHAL=
DEVICEDESC_V1));
+ pGblDriverData->dwNumVertices =3D D3dDriverData.dwNumVertices;
+ pGblDriverData->dwNumClipVertices =3D D3dDriverData.dwNumClipVertices;
+
+ /* GUID_D3DExtendedCaps */
+ { =
+ DrvInfo.dwSize =3D sizeof(DD_GETDRIVERINFODATA);
+ DrvInfo.guidInfo =3D GUID_D3DExtendedCaps;
+ DrvInfo.dwExpectedSize =3D sizeof(D3DHAL_D3DEXTENDEDCAPS);
+ DrvInfo.lpvData =3D pD3dExtendedCaps;
+ bRet =3D OsThunkDdGetDriverInfo((HANDLE)pUnknown6BC->hDD, &DrvInfo=
);
+
+ if (TRUE !=3D bRet || DrvInfo.ddRVal !=3D S_OK)
+ {
+ DPRINT1("Driver failed call to GetDriverInfo() with: GUID_D3DE=
xtendedCaps");
+ return FALSE;
+ }
+ }
+
+ /* GUID_ZPixelFormats */
+ {
+ DDPIXELFORMAT *pZPixelFormats =3D HeapAlloc(GetProcessHeap(), HEAP=
_ZERO_MEMORY, FormatCountData.dwFormatCount * sizeof(DDPIXELFORMAT));
+
+ DrvInfo.dwSize =3D sizeof(DD_GETDRIVERINFODATA);
+ DrvInfo.guidInfo =3D GUID_ZPixelFormats;
+ DrvInfo.dwExpectedSize =3D FormatCountData.dwFormatCount * sizeof(=
DDPIXELFORMAT);
+ DrvInfo.lpvData =3D pZPixelFormats;
+ bRet =3D OsThunkDdGetDriverInfo((HANDLE)pUnknown6BC->hDD, &DrvInfo=
);
+
+ if (TRUE !=3D bRet || DrvInfo.ddRVal !=3D S_OK)
+ {
+ DPRINT1("Driver failed call to GetDriverInfo() with: GUID_ZPix=
elFormats");
+ HeapFree(GetProcessHeap(), 0, pZPixelFormats);
+ return FALSE;
+ }
+
+ *pNumZStencilFormats =3D FormatCountData.dwFormatCount;
+
+ if (pD3dZStencilFormatList !=3D NULL)
+ memcpy(pD3dZStencilFormatList, pZPixelFormats, FormatCountData=
.dwFormatCount * sizeof(DDPIXELFORMAT));
+
+ HeapFree(GetProcessHeap(), 0, pZPixelFormats);
+ }
+
+ /* Get current display format */
+ {
+ D3DDISPLAYMODE CurrentDisplayMode;
+ GetAdapterMode(lpszDeviceName, &CurrentDisplayMode);
+ pUnknown6BC->RawDisplayFormat =3D CurrentDisplayMode.Format;
+ pUnknown6BC->DisplayFormat =3D CurrentDisplayMode.Format;
+
+ if ((HalInfo.vmiData.ddpfDisplay.dwFlags & DDPF_ALPHAPIXELS) !=3D =
0)
+ {
+ if (CurrentDisplayMode.Format =3D=3D D3DFMT_X8R8G8B8)
+ {
+ pUnknown6BC->DisplayFormat =3D D3DFMT_A8R8G8B8;
+ }
+ else if (CurrentDisplayMode.Format =3D=3D D3DFMT_X1R5G5B5)
+ {
+ pUnknown6BC->DisplayFormat =3D D3DFMT_A1R5G5B5;
+ }
+ }
+
+ pDriverCaps->dwDisplayWidth =3D CurrentDisplayMode.Width;
+ pDriverCaps->dwDisplayHeight =3D CurrentDisplayMode.Height;
+ pDriverCaps->RawDisplayFormat =3D CurrentDisplayMode.Format;
+ pDriverCaps->DisplayFormat =3D pUnknown6BC->DisplayFormat;
+ pDriverCaps->dwRefreshRate =3D CurrentDisplayMode.RefreshRate;
+ }
+
+ /* TODO: Set all internal function pointers to create surface, etc. */
+
+ /* Set device rect */
+ {
+ HMONITOR hMonitor;
+ MONITORINFO MonitorInfo;
+ =
+ memset(&MonitorInfo, 0, sizeof(MONITORINFO));
+ MonitorInfo.cbSize =3D sizeof(MONITORINFO);
+ =
+ hMonitor =3D GetAdapterMonitor(lpszDeviceName);
+ if (TRUE =3D=3D GetMonitorInfoA(hMonitor, &MonitorInfo))
+ {
+ pUnknown6BC->DeviceRect =3D MonitorInfo.rcMonitor;
+ }
+ else
+ {
+ DPRINT1("Could not get monitor information");
+ }
+ }
+
+ pUnknown6BC->dwCaps =3D pDriverCaps->DriverCaps9.Caps;
+ pUnknown6BC->dwSVBCaps =3D pDriverCaps->dwSVBCaps;
+
+ if (FALSE =3D=3D bDX8Mode)
+ {
+ pUnknown6BC->MajorDxVersion =3D 9;
+
+ if (0 !=3D (pDriverCaps->DriverCaps9.VertexProcessingCaps & D3DVTX=
PCAPS_NO_VSDT_UBYTE4))
+ {
+ DPRINT1("Driver claimed to be DX9 driver, but used depricated =
D3DCAPS9.VertexProcessingCaps: D3DVTXPCAPS_NO_VSDT_UBYTE4 instead of not se=
tting D3DCAPS9.DeclTypes: D3DDTCAPS_UBYTE4.");
+ return FALSE;
+ }
+ }
+ else
+ {
+ pUnknown6BC->MajorDxVersion =3D 8;
+
+ if (0 =3D=3D (pDriverCaps->DriverCaps9.VertexProcessingCaps & D3DV=
TXPCAPS_NO_VSDT_UBYTE4))
+ {
+ pDriverCaps->DriverCaps9.DeclTypes |=3D D3DDTCAPS_UBYTE4;
+ pDriverCaps->DriverCaps9.VertexProcessingCaps &=3D ~D3DVTXPCAP=
S_NO_VSDT_UBYTE4;
+ }
+ }
+
+ return TRUE;
+}
Propchange: trunk/reactos/dll/directx/d3d9/d3d9_caps.c
---------------------------------------------------------------------------=
---
svn:eol-style =3D native
Added: trunk/reactos/dll/directx/d3d9/d3d9_caps.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9=
_caps.h?rev=3D32622&view=3Dauto
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/dll/directx/d3d9/d3d9_caps.h (added)
+++ trunk/reactos/dll/directx/d3d9/d3d9_caps.h Sun Mar 9 09:11:32 2008
@@ -1,0 +1,39 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS ReactX
+ * FILE: dll/directx/d3d9/d3d9_caps.h
+ * PURPOSE: d3d9.dll device/driver caps functions, defines and mac=
ros
+ * PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) s=
e>
+ */
+
+#ifndef _D3D9_CAPS_H_
+#define _D3D9_CAPS_H_
+
+#include "d3d9_private.h"
+#include <d3dhal.h>
+
+#define DX9_DDI_VERSION 4
+
+void CreateDisplayModeList(LPCSTR lpszDeviceName, D3DDISPLAYMODE* pDisplay=
Modes, DWORD* pNumDisplayModes, D3DFORMAT DisplayFormat, D3D9_Unknown6BC_IN=
T* pUnknown6BC);
+
+BOOL GetDeviceData(LPD3D9_DEVICEDATA pDeviceData);
+
+BOOL CanReenableDirectDrawObject(D3D9_Unknown6BC_INT* ppUnknown);
+
+BOOL GetD3D9DriverInfo( D3D9_Unknown6BC_INT* pUnknown6BC,
+ LPD3D9_DRIVERCAPS pDriverCaps,
+ D3D9_UnknownA8h_INT* pUnknownA8h,
+ LPCSTR lpszDeviceName,
+ HMODULE hD3dRefDll,
+ D3DHAL_GLOBALDRIVERDATA* pGblDriverData,
+ D3DHAL_D3DEXTENDEDCAPS* pD3dExtendedCaps,
+ LPDDSURFACEDESC puD3dTextureFormats,
+ DDPIXELFORMAT* pD3dZStencilFormatList,
+ D3DDISPLAYMODE* pD3dDisplayModeList,
+ D3DQUERYTYPE* pD3dQueryList,
+ LPDWORD pNumTextureFormats,
+ LPDWORD pNumZStencilFormats,
+ LPDWORD pNumExtendedFormats,
+ LPDWORD pNumQueries);
+
+#endif // _D3D9_CAPS_H_
Propchange: trunk/reactos/dll/directx/d3d9/d3d9_caps.h
---------------------------------------------------------------------------=
---
svn:eol-style =3D native
Modified: trunk/reactos/dll/directx/d3d9/d3d9_create.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9=
_create.c?rev=3D32622&r1=3D32621&r2=3D32622&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/dll/directx/d3d9/d3d9_create.c (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_create.c Sun Mar 9 09:11:32 2008
@@ -9,6 +9,7 @@
#include <d3d9.h>
#include "d3d9_create.h"
#include "d3d9_helpers.h"
+#include "d3d9_caps.h"
#include <debug.h>
#include <ddrawi.h>
#include <ddrawgdi.h>
@@ -56,10 +57,67 @@
return FALSE;
}
=
-static BOOL GetDirect3DAdapterInfo(IN OUT LPDIRECT3D9_DISPLAYADAPTER_INT p=
DisplayAdapter)
+void GetDisplayAdapterFromDevice(IN OUT LPDIRECT3D9_DISPLAYADAPTER_INT pDi=
splayAdapters, IN DWORD AdapterIndex, IN LPD3D9_DEVICEDATA pDeviceData)
+{
+ LPDIRECT3D9_DISPLAYADAPTER_INT pDisplayAdapter =3D &pDisplayAdapters[A=
dapterIndex];
+ DWORD FormatOpIndex;
+ DWORD AdapterGroupId;
+ DWORD NumAdaptersInGroup;
+ DWORD Index;
+
+ memcpy(&pDisplayAdapter->DriverCaps, &pDeviceData->DriverCaps,
sizeof(=
D3D9_DRIVERCAPS));
+
+ for (FormatOpIndex =3D 0; FormatOpIndex < pDeviceData->DriverCaps.NumS=
upportedFormatOps; FormatOpIndex++)
+ {
+ LPDDSURFACEDESC pSurfaceDesc =3D &pDeviceData->DriverCaps.pSupport=
edFormatOps[FormatOpIndex];
+ D3DFORMAT Format =3D pSurfaceDesc->ddpfPixelFormat.dwFourCC;
+
+ if ((pSurfaceDesc->ddpfPixelFormat.dwOperations & D3DFORMAT_OP_DIS=
PLAYMODE) !=3D 0 &&
+ (Format =3D=3D D3DFMT_R5G6B5 || Format =3D=3D D3DFMT_X1R5G5B5))
+ {
+ pDisplayAdapter->Supported16bitFormat =3D Format;
+ break;
+ }
+ }
+
+ NumAdaptersInGroup =3D 0;
+ AdapterGroupId =3D pDeviceData->DriverCaps.ulUniqueAdapterGroupId;
+ for (Index =3D 0; Index < AdapterIndex; Index++)
+ {
+ if (AdapterGroupId =3D=3D pDisplayAdapters[Index].DriverCaps.ulUni=
queAdapterGroupId)
+ ++NumAdaptersInGroup;
+ }
+ pDisplayAdapter->MasterAdapterIndex =3D AdapterIndex;
+ pDisplayAdapter->NumAdaptersInGroup =3D NumAdaptersInGroup + 1; /* A=
dd self */
+ pDisplayAdapter->AdapterIndexInGroup =3D NumAdaptersInGroup;
+
+ CreateDisplayModeList(
+ pDisplayAdapter->szDeviceName,
+ NULL,
+ &pDisplayAdapter->NumSupportedD3DFormats,
+ pDisplayAdapter->Supported16bitFormat,
+ pDeviceData->pUnknown6BC
+ );
+
+ if (pDisplayAdapter->NumSupportedD3DFormats > 0)
+ {
+ pDisplayAdapter->pSupportedD3DFormats =3D HeapAlloc(GetProcessHeap=
(), 0, pDisplayAdapter->NumSupportedD3DFormats * sizeof(D3DDISPLAYMODE));
+
+ CreateDisplayModeList(
+ pDisplayAdapter->szDeviceName,
+ pDisplayAdapter->pSupportedD3DFormats,
+ &pDisplayAdapter->NumSupportedD3DFormats,
+ pDisplayAdapter->Supported16bitFormat,
+ pDeviceData->pUnknown6BC
+ );
+ }
+}
+
+static BOOL GetDirect3D9AdapterInfo(IN OUT LPDIRECT3D9_DISPLAYADAPTER_INT =
pDisplayAdapters, IN DWORD AdapterIndex)
{
HDC hDC;
LPD3D9_DEVICEDATA pDeviceData;
+ LPDIRECT3D9_DISPLAYADAPTER_INT pDisplayAdapter =3D &pDisplayAdapters[A=
dapterIndex];
=
/* Test DC creation for the display device */
if (NULL =3D=3D (hDC =3D CreateDCA(NULL, pDisplayAdapter->szDeviceName=
, NULL, NULL)))
@@ -88,9 +146,21 @@
pDeviceData->_UnknownA8h.DeviceType =3D D3DDEVTYPE_REF;
}
=
- //GetDeviceData(pDeviceData);
+ if (FALSE =3D=3D GetDeviceData(pDeviceData))
+ {
+ DeleteDC(hDC);
+ HeapFree(GetProcessHeap(), 0, pDeviceData->pUnknown6BC);
+ HeapFree(GetProcessHeap(), 0, pDeviceData);
+ return FALSE;
+ }
=
DeleteDC(hDC);
+
+ GetDisplayAdapterFromDevice(pDisplayAdapters, AdapterIndex, pDeviceDat=
a);
+
+ HeapFree(GetProcessHeap(), 0, pDeviceData->pUnknown6BC);
+ HeapFree(GetProcessHeap(), 0, pDeviceData);
+
return TRUE;
}
=
@@ -144,7 +214,7 @@
=
for (AdapterIndex =3D 0; AdapterIndex < pDirect3D9->NumDisplayAdapters=
; AdapterIndex++)
{
- GetDirect3DAdapterInfo(&pDirect3D9->DisplayAdapters[AdapterIndex]);
+ GetDirect3D9AdapterInfo(pDirect3D9->DisplayAdapters, AdapterIndex);
}
=
return TRUE;
@@ -191,3 +261,4 @@
=
return ERROR_SUCCESS;
}
+
Modified: trunk/reactos/dll/directx/d3d9/d3d9_private.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9=
_private.h?rev=3D32622&r1=3D32621&r2=3D32622&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/dll/directx/d3d9/d3d9_private.h (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_private.h Sun Mar 9 09:11:32 2008
@@ -12,6 +12,45 @@
#include <ddraw.h>
=
#define DX_D3D9_MAX_NUM_ADAPTERS 12
+
+typedef struct _D3D9Unknown6BC_INT_
+{
+/* 0x0000 */ HANDLE hDD;
+/* 0x0004 */ LPDWORD pUnknown0004;
+/* 0x0008 */
+/* 0x000c */ CHAR szDeviceName[CCHDEVICENAME];
+/* 0x002c */ HLOCAL swDDICreateDirectDrawObject;
+
+/* 0x0030 */ DWORD dwUnknown0030;
+
+/* 0x0034 */ ULONG DeviceUniq;
+
+/* 0x0040 */ D3DFORMAT RawDisplayFormat;
+/* 0x0044 */ D3DFORMAT DisplayFormat;
+/* 0x0048 */ LONG lDisplayPitch;
+/* 0x004c */ DWORD MajorDxVersion;
+/* 0x0050 */ RECT DeviceRect;
+/* 0x0060 */
+/* 0x0064 */ DWORD unknown0064; // =3D 0
+/* 0x0068 */ BOOL bIsXPorLater;
+/* 0x006c */ DWORD DevVenId; // DeviceId << 10 | VendorId
+#ifdef _WIN32
+/* 0x0070 */ LARGE_INTEGER DriverVersion;
+#else
+/* 0x0070 */ DWORD DriverVersionLowPart;
+/* 0x0074 */ DWORD DriverVersionHighPart;
+#endif
+/* 0x0078 */ DWORD bForceDriverFlagsOn;
+/* 0x007c */ DWORD bForceDriverFlagsOff;
+
+/* 0x0084 */ DWORD dwCaps;
+/* 0x0088 */ DWORD dwSVBCaps;
+/* 0x008c */ HMODULE _unknown0151;
+
+/* 0x0094 */ D3DDEVTYPE DeviceType;
+
+/* 0x00BC */ DDGAMMARAMP lpGammaRamp;
+} D3D9_Unknown6BC_INT;
=
typedef struct _tagD3D9_DRIVERCAPS
{
@@ -31,7 +70,7 @@
/* 0x0160 */ DWORD unknown0088;
/* 0x0164 */ DWORD NumSupportedExtendedModes;
/* 0x0168 */ D3DDISPLAYMODE* pSupportedExtendedModes;
-/* 0x016c */ ULONG_PTR ulUniqueAdapterGroupId;
+/* 0x016c */ ULONG ulUniqueAdapterGroupId;
/* 0x0170 */ DWORD NumSupportedQueries;
/* 0x0174 */ D3DQUERYTYPE* pSupportedQueriesList;
} D3D9_DRIVERCAPS, FAR *LPD3D9_DRIVERCAPS;
@@ -89,7 +128,7 @@
/* 0x0220 */ CHAR szDeviceName[CCHDEVICENAME];
/* 0x0240 */ HDC hDC;
/* 0x0244 */ GUID DisplayGuid;
-/* 0x0254 */ LPDWORD pUnknown0254; //D3D9_Unknown6BC_INT* pUnknown6BC;
+/* 0x0254 */ D3D9_Unknown6BC_INT* pUnknown6BC;
/* 0x0258 */ D3DDEVTYPE DeviceType;
/* 0x025c */ HMODULE hD3DRefDll;
/* 0x0260 */ DWORD unknown0152;
@@ -108,7 +147,7 @@
/* 0x012c */ DWORD NumSupportedD3DExtendedFormats;
/* 0x0130 */ D3DDISPLAYMODE* pSupportedD3DFormats;
/* 0x0134 */ D3DDISPLAYMODE* pSupportedD3DExtendedFormats;
-/* 0x0138 */ DWORD unknown000009;
+/* 0x0138 */ D3DFORMAT Supported16bitFormat;
/* 0x013c */ D3D9_DRIVERCAPS DriverCaps;
/* 0x02b4 */ DWORD unknown000104;
/* 0x02b8 */ DWORD unknown000105;