39 if (
NULL == pUnknown6BC)
45 DefaultFormat = Default16BitFormat;
52 if (
NULL != pDisplayModes)
54 if (ValidModes == *pNumDisplayModes)
60 pDisplayModes->
Format = DefaultFormat;
67 *pNumDisplayModes = ValidModes;
75 if (ppUnknown) *ppUnknown =
NULL;
76 if (hD3DRefDll) *hD3DRefDll =
NULL;
86 if (
NULL == pUnknown6BC)
105 ValueSize =
sizeof(
DWORD);
108 ValueSize =
sizeof(
DWORD);
113 *ppUnknown = pUnknown6BC;
135 DWORD NumTextureFormats = 0;
136 DWORD NumStencilFormats = 0;
137 DWORD NumExtendedFormats = 0;
138 DWORD NumQueries = 0;
152 DPRINT1(
"Failed to create DirectDrawObject for Direct3D9");
163 DPRINT1(
"Failed to re-enable DirectDrawObject");
216 DPRINT1(
"Failed to re-enable DirectDrawObject");
241 DPRINT1(
"Could not query DirectDrawObject, aborting");
260 pD3dZStencilFormatList,
271 DPRINT1(
"Could not query DirectDrawObject, aborting");
281 if (NumTextureFormats > 0)
285 if (NumExtendedFormats > 0)
301 BOOL bDisplayModeWasChanged;
320 DrvInfo->
guidInfo = GUID_GetDriverInfo2;
328 memset(DrvInfo2, 0, dwExpectedSize);
329 DrvInfo2->dwMagic = D3DGDI2_MAGIC;
330 DrvInfo2->dwType = dwType;
331 DrvInfo2->dwExpectedSize = dwExpectedSize;
355 DWORD CallBackFlags[3];
365 DD_GETDDIVERSIONDATA DdiVersion;
366 DD_GETFORMATCOUNTDATA FormatCountData;
367 DD_GETEXTENDEDMODECOUNTDATA ExModeCountData;
368 DD_GETD3DQUERYCOUNTDATA D3dQueryCountData;
371 *pNumTextureFormats = 0;
372 *pNumZStencilFormats = 0;
373 *pNumExtendedFormats = 0;
380 ValueSize =
sizeof(dwDXVersion);
406 puD3dTextureFormats !=
NULL)
443 DD_DXVERSION DxVersion;
446 DxVersion.dwDXVersion = dwDXVersion;
463 ValueSize =
sizeof(ForceDDIOn);
478 if (DdiVersion.dwDDIVersion == 0)
480 DPRINT1(
"Driver claims to be DX9 driver, but didn't report DX9 DDI version - reverting to DX8 mode");
484 DPRINT1(
"Driver claims to be DX9 driver, but was built with an old DDI version - reverting to DX8 mode");
498 DPRINT1(
"Driver returned an invalid D3DCAPS8 structure - aborting");
510 if (
FALSE == bDX8Mode)
521 DPRINT1(
"Driver returned an invalid D3DCAPS9 structure - aborting");
535 FormatCountData.dwFormatCount =
UINT_MAX;
536 FormatCountData.dwReserved = dwDXVersion;
542 DPRINT1(
"Driver claimed to be DX9 driver, but didn't support D3DGDI_TYPE_GETFORMATCOUNT in GetDriverInfo call");
545 else if (DrvInfo.
dwActualSize !=
sizeof(DD_GETFORMATCOUNTDATA))
547 DPRINT1(
"Driver returned an invalid DD_GETFORMATCOUNTDATA structure - aborting");
550 else if (FormatCountData.dwFormatCount ==
UINT_MAX)
552 DPRINT1(
"Driver didn't set DD_GETFORMATCOUNTDATA.dwFormatCount - aborting");
556 *pNumTextureFormats = FormatCountData.dwFormatCount;
561 if (puD3dTextureFormats !=
NULL)
564 DD_GETFORMATDATA FormatData;
566 for (FormatIndex = 0; FormatIndex < FormatCountData.dwFormatCount; FormatIndex++)
570 FormatData.dwFormatIndex = FormatIndex;
576 DPRINT1(
"Driver claimed to be DX9 driver, but didn't support D3DGDI_TYPE_GETFORMAT in GetDriverInfo call");
579 else if (DrvInfo.
dwActualSize !=
sizeof(DD_GETFORMATDATA))
581 DPRINT1(
"Driver returned an invalid DD_GETFORMATDATA structure - aborting");
586 DPRINT1(
"Driver didn't set DD_GETFORMATDATA.format - aborting");
597 FormatData.format.dwPrivateFormatBitCount > 0)
602 ++puD3dTextureFormats;
609 ResetGetDriverInfo2Data(&ExModeCountData.gdi2, D3DGDI2_TYPE_GETEXTENDEDMODECOUNT,
sizeof(DD_GETEXTENDEDMODECOUNTDATA));
611 ExModeCountData.dwModeCount =
UINT_MAX;
612 ExModeCountData.dwReserved = dwDXVersion;
618 if (DrvInfo.
dwActualSize !=
sizeof(DD_GETEXTENDEDMODECOUNTDATA))
620 DPRINT1(
"Driver returned an invalid DD_GETEXTENDEDFORMATCOUNTDATA structure - aborting");
623 else if (ExModeCountData.dwModeCount ==
UINT_MAX)
625 DPRINT1(
"Driver didn't set DD_GETEXTENDEDMODECOUNTDATA.dwModeCount - aborting");
629 *pNumExtendedFormats = ExModeCountData.dwModeCount;
633 ExModeCountData.dwModeCount = 0;
639 if (pD3dDisplayModeList !=
NULL)
642 DD_GETEXTENDEDMODEDATA ExModeData;
644 for (ModeIndex = 0; ModeIndex < ExModeCountData.dwModeCount; ModeIndex++)
648 ExModeData.dwModeIndex = ModeIndex;
655 DPRINT1(
"Driver claimed to be DX9 driver, but didn't support D3DGDI2_TYPE_GETEXTENDEDMODE in GetDriverInfo call");
658 else if (DrvInfo.
dwActualSize !=
sizeof(DD_GETEXTENDEDMODEDATA))
660 DPRINT1(
"Driver returned an invalid DD_GETEXTENDEDMODEDATA structure - aborting");
663 else if (ExModeData.mode.Width !=
UINT_MAX)
665 DPRINT1(
"Driver didn't set DD_GETEXTENDEDMODEDATA.mode - aborting");
670 ++pD3dDisplayModeList;
677 DD_GETADAPTERGROUPDATA AdapterGroupData;
680 AdapterGroupData.ulUniqueAdapterGroupId =
UINT_MAX;
686 DPRINT1(
"Driver claimed to be DX9 driver, but didn't support D3DGDI2_TYPE_GETADAPTERGROUP in GetDriverInfo call");
689 else if (DrvInfo.
dwActualSize !=
sizeof(DD_GETADAPTERGROUPDATA))
691 DPRINT1(
"Driver returned an invalid DD_GETADAPTERGROUPDATA structure - aborting");
694 else if (AdapterGroupData.ulUniqueAdapterGroupId ==
UINT_MAX)
696 DPRINT1(
"Driver didn't set DD_GETADAPTERGROUPDATA.ulUniqueAdapterGroupId - aborting");
706 ResetGetDriverInfo2Data(&D3dQueryCountData.gdi2, D3DGDI2_TYPE_GETD3DQUERYCOUNT,
sizeof(DD_GETD3DQUERYCOUNTDATA));
708 D3dQueryCountData.dwNumQueries =
UINT_MAX;
714 DPRINT1(
"Driver claimed to be DX9 driver, but didn't support D3DGDI2_TYPE_GETD3DQUERYCOUNT in GetDriverInfo call");
717 else if (DrvInfo.
dwActualSize !=
sizeof(DD_GETD3DQUERYCOUNTDATA))
719 DPRINT1(
"Driver returned an invalid DD_GETD3DQUERYCOUNTDATA structure - aborting");
722 else if (D3dQueryCountData.dwNumQueries ==
UINT_MAX)
724 DPRINT1(
"Driver didn't set DD_GETD3DQUERYCOUNTDATA.dwNumQueries - aborting");
728 *pNumQueries = D3dQueryCountData.dwNumQueries;
733 if (pD3dQueryList !=
NULL)
736 DD_GETD3DQUERYDATA D3dQueryData;
738 for (QueryIndex = 0; QueryIndex < D3dQueryCountData.dwNumQueries; QueryIndex++)
742 D3dQueryData.dwQueryIndex = QueryIndex;
748 DPRINT1(
"Driver claimed to be DX9 driver, but didn't support D3DGDI2_TYPE_GETD3DQUERY in GetDriverInfo call");
751 else if (DrvInfo.
dwActualSize !=
sizeof(DD_GETD3DQUERYDATA))
753 DPRINT1(
"Driver returned an invalid DD_GETD3DQUERYDATA structure - aborting");
757 *pD3dQueryList = D3dQueryData.QueryType;
772 DrvInfo.
guidInfo = GUID_D3DExtendedCaps;
774 DrvInfo.
lpvData = pD3dExtendedCaps;
779 DPRINT1(
"Driver failed call to GetDriverInfo() with: GUID_D3DExtendedCaps");
789 DrvInfo.
guidInfo = GUID_ZPixelFormats;
791 DrvInfo.
lpvData = pZPixelFormats;
796 DPRINT1(
"Driver failed call to GetDriverInfo() with: GUID_ZPixelFormats");
801 *pNumZStencilFormats = FormatCountData.dwFormatCount;
803 if (pD3dZStencilFormatList !=
NULL)
804 memcpy(pD3dZStencilFormatList, pZPixelFormats, FormatCountData.dwFormatCount *
sizeof(
DDPIXELFORMAT));
853 DPRINT1(
"Could not get monitor information");
860 if (
FALSE == bDX8Mode)
866 DPRINT1(
"Driver claimed to be DX9 driver, but used depricated D3DCAPS9.VertexProcessingCaps: D3DVTXPCAPS_NO_VSDT_UBYTE4 instead of not setting D3DCAPS9.DeclTypes: D3DDTCAPS_UBYTE4.");
#define D3DVTXPCAPS_NO_VSDT_UBYTE4
BOOL WINAPI OsThunkDdQueryDirectDrawObject(HANDLE hDirectDrawLocal, DD_HALINFO *pHalInfo, DWORD *pCallBackFlags, LPD3DNTHAL_CALLBACKS puD3dCallbacks, LPD3DNTHAL_GLOBALDRIVERDATA puD3dDriverData, PDD_D3DBUFCALLBACKS puD3dBufferCallbacks, LPDDSURFACEDESC puD3dTextureFormats, DWORD *puNumHeaps, VIDEOMEMORY *puvmList, DWORD *puNumFourCC, DWORD *puFourCC)
DWORD WINAPI OsThunkDdGetDriverInfo(HANDLE hDirectDraw, PDD_GETDRIVERINFODATA puGetDriverInfoData)
BOOL WINAPI OsThunkDdDeleteDirectDrawObject(HANDLE hDirectDrawLocal)
HANDLE WINAPI OsThunkDdCreateDirectDrawObject(HDC hdc)
BOOL WINAPI OsThunkDdReenableDirectDrawObject(HANDLE hDirectDrawLocal, BOOL *pubNewMode)
enum _D3DDEVTYPE D3DDEVTYPE
enum _D3DFORMAT D3DFORMAT
#define D3D9_INT_D3DCAPS9_VALID
#define D3D9_INT_D3DCAPS8_VALID
DWORD WINAPI D3d9GetAvailDriverMemory(LPD3D9_GETAVAILDRIVERMEMORYDATA pData)
static void ReleaseInternalDeviceData(LPD3D9_DEVICEDATA pDeviceData)
static void PrepareDriverInfoData(DD_GETDRIVERINFODATA *DrvInfo, LPVOID pData, DWORD dwExpectedSize)
void CreateDisplayModeList(LPCSTR lpszDeviceName, D3DDISPLAYMODE *pDisplayModes, DWORD *pNumDisplayModes, D3DFORMAT Default16BitFormat, D3D9_Unknown6BC *pUnknown6BC)
static void ResetGetDriverInfo2Data(DD_GETDRIVERINFO2DATA *DrvInfo2, DWORD dwType, DWORD dwExpectedSize)
BOOL GetD3D9DriverInfo(D3D9_Unknown6BC *pUnknown6BC, LPD3D9_DRIVERCAPS pDriverCaps, D3D9_CALLBACKS *pD3D9Callbacks, 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)
static void CreateInternalDeviceData(HDC hDC, LPCSTR lpszDeviceName, D3D9_Unknown6BC **ppUnknown, D3DDEVTYPE DeviceType, HMODULE *hD3DRefDll)
BOOL CanReenableDirectDrawObject(D3D9_Unknown6BC *pUnknown)
BOOL GetDeviceData(LPD3D9_DEVICEDATA pDeviceData)
HRESULT SafeCopyString(OUT LPSTR Dst, IN DWORD DstSize, IN LPCSTR Src)
BOOL ReadRegistryValue(IN DWORD ValueType, IN LPCSTR ValueName, OUT LPBYTE DataBuffer, IN OUT LPDWORD DataBufferSize)
enum _D3DQUERYTYPE D3DQUERYTYPE
struct _D3DHAL_D3DEXTENDEDCAPS D3DHAL_D3DEXTENDEDCAPS
#define DD_RUNTIME_VERSION
#define DDHALINFO_GETDRIVERINFO2
#define D3DFORMAT_OP_PIXELSIZE
BOOL GetAdapterMode(LPCSTR lpszDeviceName, D3DDISPLAYMODE *pMode)
HMONITOR GetAdapterMonitor(LPCSTR lpszDeviceName)
#define HeapFree(x, y, z)
#define memcpy(s1, s2, n)
struct _DD_GETDRIVERINFODATA DD_GETDRIVERINFODATA
struct _DDPIXELFORMAT DDPIXELFORMAT
#define DDCAPS2_AUTOFLIPOVERLAY
D3D9_CALLBACKS D3D9Callbacks
D3D9_DRIVERCAPS DriverCaps
struct _D3D9_Unknown6BC * pUnknown6BC
CHAR szDeviceName[CCHDEVICENAME]
D3DDISPLAYMODE * pSupportedExtendedModes
D3DQUERYTYPE * pSupportedQueriesList
LPDDSURFACEDESC pSupportedFormatOps
DWORD NumSupportedFormatOps
DWORD NumSupportedExtendedModes
D3DFORMAT RawDisplayFormat
DWORD NumSupportedQueries
ULONG ulUniqueAdapterGroupId
DWORD bForceDriverFlagsOn
DWORD bForceDriverFlagsOff
CHAR szDeviceName[CCHDEVICENAME]
HLOCAL swDDICreateDirectDrawObject
D3DFORMAT RawDisplayFormat
DWORD VertexProcessingCaps
DWORD dwNumTextureFormats
D3DNTHALDEVICEDESC_V1 hwCaps
DDPIXELFORMAT ddpfDisplay
LPD3D9_GETAVAILDRIVERMEMORY DdGetAvailDriverMemory
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
BOOL WINAPI EnumDisplaySettingsA(LPCSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEA lpDevMode)
BOOL WINAPI GetMonitorInfoA(_In_ HMONITOR, _Inout_ LPMONITORINFO)
struct tagMONITORINFO MONITORINFO