ReactOS 0.4.15-dev-7924-g5949c20
adapter.c File Reference
#include "d3d9_common.h"
#include <d3d9.h>
#include <ddraw.h>
#include <debug.h>
#include <d3dhal.h>
#include "d3d9_private.h"
#include "d3d9_helpers.h"
#include "adapter.h"
Include dependency graph for adapter.c:

Go to the source code of this file.

Classes

struct  _ADAPTERMONITOR
 

Macros

#define D3D9_CAPS1   (D3DCAPS_READ_SCANLINE)
 
#define D3D9_PRE_XP_CAPS2   (D3DCAPS2_CANAUTOGENMIPMAP | D3DCAPS2_DYNAMICTEXTURES | D3DCAPS2_RESERVED | D3DCAPS2_FULLSCREENGAMMA)
 
#define D3D9_XP_OR_LATER_CAPS2   (D3D9_PRE_XP_CAPS2 | D3DCAPS2_CANMANAGERESOURCE)
 
#define D3D9_CAPS3   (D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD | D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION | D3DCAPS3_COPY_TO_VIDMEM | D3DCAPS3_COPY_TO_SYSTEMMEM)
 
#define D3D9_DEVCAPS
 
#define D3DCAPS2_PRESENT_INTERVAL_SEVERAL   0x00200000
 
#define D3DCAPS2_PRESENT_INTERVAL_IMMEDIATE   0x00400000
 
#define D3DVTXPCAPS_FOGVERTEX   0x00000004
 

Typedefs

typedef BOOL(WINAPILPFN_ISWOW64PROCESS) (HANDLE, PBOOL)
 
typedef BOOL(WINAPILPFN_DISABLEWOW64FSREDIRECTION) (PVOID *)
 
typedef BOOL(WINAPILPFN_REVERTWOW64FSREDIRECTION) (PVOID)
 
typedef struct _ADAPTERMONITOR ADAPTERMONITOR
 
typedef struct _ADAPTERMONITORLPADAPTERMONITOR
 

Functions

static BOOL GetDriverName (LPDISPLAY_DEVICEA pDisplayDevice, D3DADAPTER_IDENTIFIER9 *pIdentifier)
 
static void GetDriverVersion (LPDISPLAY_DEVICEA pDisplayDevice, D3DADAPTER_IDENTIFIER9 *pIdentifier)
 
static void ParseField (LPCSTR lpszDeviceKey, LPDWORD pField, LPCSTR lpszSubString)
 
static void GetDeviceId (LPCSTR lpszDeviceKey, D3DADAPTER_IDENTIFIER9 *pIdentifier)
 
static void GenerateDeviceIdentifier (D3DADAPTER_IDENTIFIER9 *pIdentifier)
 
BOOL GetAdapterInfo (LPCSTR lpszDeviceName, D3DADAPTER_IDENTIFIER9 *pIdentifier)
 
static BOOL IsWindowsXPorLaterCompatible ()
 
static void CopyDriverCaps (const D3DCAPS9 *pSrcCaps, D3DCAPS9 *pDstCaps)
 
HRESULT GetAdapterCaps (const LPDIRECT3D9_DISPLAYADAPTER pDisplayAdapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pDstCaps)
 
static D3DFORMAT Get16BitD3DFormat (LPCSTR lpszDeviceName)
 
BOOL GetAdapterMode (LPCSTR lpszDeviceName, D3DDISPLAYMODE *pMode)
 
static BOOL CALLBACK AdapterMonitorEnumProc (HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
 
HMONITOR GetAdapterMonitor (LPCSTR lpszDeviceName)
 
UINT GetDisplayFormatCount (D3DFORMAT Format, const D3DDISPLAYMODE *pSupportedDisplayModes, UINT NumDisplayModes)
 
const D3DDISPLAYMODEFindDisplayFormat (D3DFORMAT Format, UINT ModeIndex, const D3DDISPLAYMODE *pSupportedDisplayModes, UINT NumDisplayModes)
 

Macro Definition Documentation

◆ D3D9_CAPS1

#define D3D9_CAPS1   (D3DCAPS_READ_SCANLINE)

Definition at line 18 of file adapter.c.

◆ D3D9_CAPS3

◆ D3D9_DEVCAPS

#define D3D9_DEVCAPS
Value:
#define D3DDEVCAPS_EXECUTESYSTEMMEMORY
Definition: d3d8caps.h:36
#define D3DDEVCAPS_CANRENDERAFTERFLIP
Definition: d3d8caps.h:43
#define D3DDEVCAPS_HWTRANSFORMANDLIGHT
Definition: d3d8caps.h:48
#define D3DDEVCAPS_TEXTUREVIDEOMEMORY
Definition: d3d8caps.h:41
#define D3DDEVCAPS_DRAWPRIMITIVES2
Definition: d3d8caps.h:45
#define D3DDEVCAPS_TEXTURESYSTEMMEMORY
Definition: d3d8caps.h:40
#define D3DDEVCAPS_QUINTICRTPATCHES
Definition: d3d8caps.h:52
#define D3DDEVCAPS_DRAWPRIMITIVES2EX
Definition: d3d8caps.h:47
#define D3DDEVCAPS_EXECUTEVIDEOMEMORY
Definition: d3d8caps.h:37
#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES
Definition: d3d8caps.h:46
#define D3DDEVCAPS_DRAWPRIMTLVERTEX
Definition: d3d8caps.h:42
#define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY
Definition: d3d8caps.h:38
#define D3DDEVCAPS_RTPATCHES
Definition: d3d8caps.h:53
#define D3DDEVCAPS_NPATCHES
Definition: d3d8caps.h:55
#define D3DDEVCAPS_RTPATCHHANDLEZERO
Definition: d3d8caps.h:54
#define D3DDEVCAPS_HWRASTERIZATION
Definition: d3d8caps.h:50
#define D3DDEVCAPS_TEXTURENONLOCALVIDMEM
Definition: d3d8caps.h:44
#define D3DDEVCAPS_CANBLTSYSTONONLOCAL
Definition: d3d8caps.h:49
#define D3DDEVCAPS_TLVERTEXVIDEOMEMORY
Definition: d3d8caps.h:39
#define D3DDEVCAPS_PUREDEVICE
Definition: d3d8caps.h:51

Definition at line 22 of file adapter.c.

◆ D3D9_PRE_XP_CAPS2

◆ D3D9_XP_OR_LATER_CAPS2

#define D3D9_XP_OR_LATER_CAPS2   (D3D9_PRE_XP_CAPS2 | D3DCAPS2_CANMANAGERESOURCE)

Definition at line 20 of file adapter.c.

◆ D3DCAPS2_PRESENT_INTERVAL_IMMEDIATE

#define D3DCAPS2_PRESENT_INTERVAL_IMMEDIATE   0x00400000

Definition at line 31 of file adapter.c.

◆ D3DCAPS2_PRESENT_INTERVAL_SEVERAL

#define D3DCAPS2_PRESENT_INTERVAL_SEVERAL   0x00200000

Definition at line 30 of file adapter.c.

◆ D3DVTXPCAPS_FOGVERTEX

#define D3DVTXPCAPS_FOGVERTEX   0x00000004

Definition at line 33 of file adapter.c.

Typedef Documentation

◆ ADAPTERMONITOR

◆ LPADAPTERMONITOR

◆ LPFN_DISABLEWOW64FSREDIRECTION

typedef BOOL(WINAPI * LPFN_DISABLEWOW64FSREDIRECTION) (PVOID *)

Definition at line 36 of file adapter.c.

◆ LPFN_ISWOW64PROCESS

typedef BOOL(WINAPI * LPFN_ISWOW64PROCESS) (HANDLE, PBOOL)

Definition at line 35 of file adapter.c.

◆ LPFN_REVERTWOW64FSREDIRECTION

typedef BOOL(WINAPI * LPFN_REVERTWOW64FSREDIRECTION) (PVOID)

Definition at line 37 of file adapter.c.

Function Documentation

◆ AdapterMonitorEnumProc()

static BOOL CALLBACK AdapterMonitorEnumProc ( HMONITOR  hMonitor,
HDC  hdcMonitor,
LPRECT  lprcMonitor,
LPARAM  dwData 
)
static

Definition at line 374 of file adapter.c.

375{
376 MONITORINFOEXA MonitorInfoEx;
377 LPADAPTERMONITOR lpAdapterMonitor = (LPADAPTERMONITOR)dwData;
378
379 memset(&MonitorInfoEx, 0, sizeof(MONITORINFOEXA));
380 MonitorInfoEx.cbSize = sizeof(MONITORINFOEXA);
381
382 GetMonitorInfoA(hMonitor, (LPMONITORINFO)&MonitorInfoEx);
383
384 if (_stricmp(lpAdapterMonitor->lpszDeviceName, MonitorInfoEx.szDevice) == 0)
385 {
386 lpAdapterMonitor->hMonitor = hMonitor;
387 return FALSE;
388 }
389
390 return TRUE;
391}
#define _stricmp
Definition: cat.c:22
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
struct _ADAPTERMONITOR * LPADAPTERMONITOR
static HANDLE ULONG_PTR dwData
Definition: file.c:35
#define memset(x, y, z)
Definition: compat.h:39
HMONITOR hMonitor
Definition: adapter.c:43
LPCSTR lpszDeviceName
Definition: adapter.c:42
CHAR szDevice[CCHDEVICENAME]
Definition: winuser.h:3796
struct tagMONITORINFOEXA MONITORINFOEXA
BOOL WINAPI GetMonitorInfoA(_In_ HMONITOR, _Inout_ LPMONITORINFO)

Referenced by GetAdapterMonitor().

◆ CopyDriverCaps()

static void CopyDriverCaps ( const D3DCAPS9 pSrcCaps,
D3DCAPS9 pDstCaps 
)
static

Definition at line 207 of file adapter.c.

208{
209 *pDstCaps = *pSrcCaps;
210
211 pDstCaps->Caps = pSrcCaps->Caps & D3D9_CAPS1;
212
213 /* TODO: Fit in D3DCAPS2_CANCALIBRATEGAMMA somewhere here */
215 pDstCaps->Caps2 = pSrcCaps->Caps2 & D3D9_XP_OR_LATER_CAPS2;
216 else
217 pDstCaps->Caps2 = pSrcCaps->Caps2 & D3D9_PRE_XP_CAPS2;
218
219 pDstCaps->Caps3 = pSrcCaps->Caps3 & D3D9_CAPS3;
220 pDstCaps->DevCaps = pSrcCaps->DevCaps & D3D9_DEVCAPS;
221
227
228 pDstCaps->PrimitiveMiscCaps = pSrcCaps->PrimitiveMiscCaps & ~D3DPMISCCAPS_FOGINFVF;
229
231 {
233 pDstCaps->VertexProcessingCaps &= ~D3DVTXPCAPS_FOGVERTEX;
234 }
235
236 if (pSrcCaps->MaxPointSize < 0.0f)
237 pDstCaps->MaxPointSize = 1.0f;
238}
#define D3DPRESENT_INTERVAL_THREE
Definition: d3d8caps.h:31
#define D3DPRESENT_INTERVAL_TWO
Definition: d3d8caps.h:30
#define D3DPRESENT_INTERVAL_FOUR
Definition: d3d8caps.h:32
#define D3DPRESENT_INTERVAL_IMMEDIATE
Definition: d3d8caps.h:33
#define D3DPRESENT_INTERVAL_ONE
Definition: d3d8caps.h:29
#define D3DPRASTERCAPS_FOGVERTEX
Definition: d3d8caps.h:75
#define D3D9_DEVCAPS
Definition: adapter.c:22
#define D3DCAPS2_PRESENT_INTERVAL_IMMEDIATE
Definition: adapter.c:31
#define D3DVTXPCAPS_FOGVERTEX
Definition: adapter.c:33
#define D3D9_XP_OR_LATER_CAPS2
Definition: adapter.c:20
static BOOL IsWindowsXPorLaterCompatible()
Definition: adapter.c:191
#define D3D9_PRE_XP_CAPS2
Definition: adapter.c:19
#define D3DCAPS2_PRESENT_INTERVAL_SEVERAL
Definition: adapter.c:30
#define D3D9_CAPS3
Definition: adapter.c:21
#define D3D9_CAPS1
Definition: adapter.c:18
DWORD Caps3
Definition: d3d9caps.h:268
DWORD VertexProcessingCaps
Definition: d3d9caps.h:303
DWORD DevCaps
Definition: d3d9caps.h:271
DWORD RasterCaps
Definition: d3d9caps.h:273
DWORD Caps2
Definition: d3d9caps.h:267
DWORD PrimitiveMiscCaps
Definition: d3d9caps.h:272
DWORD Caps
Definition: d3d9caps.h:266
float MaxPointSize
Definition: d3d9caps.h:308
DWORD PresentationIntervals
Definition: d3d9caps.h:269

Referenced by GetAdapterCaps().

◆ FindDisplayFormat()

const D3DDISPLAYMODE * FindDisplayFormat ( D3DFORMAT  Format,
UINT  ModeIndex,
const D3DDISPLAYMODE pSupportedDisplayModes,
UINT  NumDisplayModes 
)

Definition at line 422 of file adapter.c.

423{
424 UINT DisplayModeIndex;
425 UINT FormatIndex = 0;
426
427 for (DisplayModeIndex = 0; DisplayModeIndex < NumDisplayModes; DisplayModeIndex++)
428 {
429 if (pSupportedDisplayModes[DisplayModeIndex].Format == Format)
430 {
431 if (ModeIndex == FormatIndex)
432 return &pSupportedDisplayModes[DisplayModeIndex];
433
434 ++FormatIndex;
435 }
436 }
437
438 if (FormatIndex == 0)
439 {
440 DPRINT1("No modes with the specified format found");
441 }
442 else if (FormatIndex < ModeIndex)
443 {
444 DPRINT1("Invalid mode index");
445 }
446
447 return NULL;
448}
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
unsigned int UINT
Definition: ndis.h:50

Referenced by IDirect3D9Impl_EnumAdapterModes().

◆ GenerateDeviceIdentifier()

static void GenerateDeviceIdentifier ( D3DADAPTER_IDENTIFIER9 pIdentifier)
static

Definition at line 136 of file adapter.c.

137{
138 DWORD* dwIdentifier = (DWORD*)&pIdentifier->DeviceIdentifier;
139
140 pIdentifier->DeviceIdentifier = CLSID_DirectDraw;
141
142 dwIdentifier[0] ^= pIdentifier->VendorId;
143 dwIdentifier[1] ^= pIdentifier->DeviceId;
144 dwIdentifier[2] ^= pIdentifier->SubSysId;
145 dwIdentifier[3] ^= pIdentifier->Revision;
146 dwIdentifier[2] ^= pIdentifier->DriverVersion.LowPart;
147 dwIdentifier[3] ^= pIdentifier->DriverVersion.HighPart;
148}
unsigned long DWORD
Definition: ntddk_ex.h:95
LARGE_INTEGER DriverVersion
Definition: d3d9types.h:1232
ULONG LowPart
Definition: typedefs.h:106

Referenced by GetAdapterInfo().

◆ Get16BitD3DFormat()

static D3DFORMAT Get16BitD3DFormat ( LPCSTR  lpszDeviceName)
static

Definition at line 284 of file adapter.c.

285{
286 HDC hDC;
288 LPBITMAPINFO pBitmapInfo;
290
291 if (NULL == (hDC = CreateDCA(NULL, lpszDeviceName, NULL, NULL)))
292 {
293 return Format;
294 }
295
296 if (NULL == (hBitmap = CreateCompatibleBitmap(hDC, 1, 1)))
297 {
298 DeleteDC(hDC);
299 return Format;
300 }
301
302 pBitmapInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER) + 4 * sizeof(RGBQUAD));
303 if (NULL == pBitmapInfo)
304 {
306 DeleteDC(hDC);
307 return Format;
308 }
309
310 pBitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
311 if (GetDIBits(hDC, hBitmap, 0, 0, NULL, pBitmapInfo, DIB_RGB_COLORS) > 0)
312 {
313 if (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS)
314 {
315 if (GetDIBits(hDC, hBitmap, 0, pBitmapInfo->bmiHeader.biHeight, NULL, pBitmapInfo, DIB_RGB_COLORS) > 0)
316 {
317 /* Check if the green field is 6 bits long */
318 if (*(DWORD*)(&pBitmapInfo->bmiColors[1]) == 0x000003E0)
319 {
321 }
322 }
323 }
324 }
325
326 HeapFree(GetProcessHeap(), 0, pBitmapInfo);
328 DeleteDC(hDC);
329
330 return Format;
331}
static HDC hDC
Definition: 3dtext.c:33
@ D3DFMT_X1R5G5B5
Definition: d3d8types.h:607
@ D3DFMT_R5G6B5
Definition: d3d8types.h:606
enum _D3DFORMAT D3DFORMAT
static HBITMAP hBitmap
Definition: timezone.c:26
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
ULONG RGBQUAD
Definition: precomp.h:59
pKey DeleteObject()
#define BI_BITFIELDS
Definition: mmreg.h:507
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
ULONG biCompression
Definition: precomp.h:47
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
RGBQUAD bmiColors[1]
Definition: wingdi.h:1477
#define DIB_RGB_COLORS
Definition: wingdi.h:367
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
HDC WINAPI CreateDCA(_In_opt_ LPCSTR pszDriver, _In_opt_ LPCSTR pszDevice, _In_opt_ LPCSTR pszOutput, _In_opt_ const DEVMODEA *pdmInit)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by GetAdapterMode().

◆ GetAdapterCaps()

HRESULT GetAdapterCaps ( const LPDIRECT3D9_DISPLAYADAPTER  pDisplayAdapter,
D3DDEVTYPE  DeviceType,
D3DCAPS9 pDstCaps 
)

Definition at line 240 of file adapter.c.

241{
243 D3DCAPS9* pDriverCaps = NULL;
244
245 ZeroMemory(pDstCaps, sizeof(D3DCAPS9));
246
247 switch (DeviceType)
248 {
249 case D3DDEVTYPE_HAL:
250 pDriverCaps = &pDisplayAdapter->DriverCaps.DriverCaps9;
251 hResult = D3D_OK;
252 break;
253
254 case D3DDEVTYPE_REF:
255 case D3DDEVTYPE_SW:
258 hResult = D3D_OK;
259 break;
260
261 default:
262 DPRINT1("Unknown DeviceType argument");
263 break;
264 }
265
266 if (pDriverCaps != NULL)
267 {
268 CopyDriverCaps(pDriverCaps, pDstCaps);
269 }
270
271 if (SUCCEEDED(hResult))
272 {
273 pDstCaps->DeviceType = DeviceType;
274 pDstCaps->MasterAdapterOrdinal = pDisplayAdapter->MasterAdapterIndex;
275 pDstCaps->AdapterOrdinalInGroup = pDisplayAdapter->AdapterIndexInGroup;
276 pDstCaps->NumberOfAdaptersInGroup = pDisplayAdapter->NumAdaptersInGroup;
277 }
278
279 return hResult;
280}
#define UNIMPLEMENTED
Definition: debug.h:115
@ D3DDEVTYPE_SW
Definition: d3d8types.h:578
@ D3DDEVTYPE_HAL
Definition: d3d8types.h:576
@ D3DDEVTYPE_REF
Definition: d3d8types.h:577
@ D3DDEVTYPE_NULLREF
Definition: d3d9types.h:739
#define D3D_OK
Definition: d3d.h:106
static void CopyDriverCaps(const D3DCAPS9 *pSrcCaps, D3DCAPS9 *pDstCaps)
Definition: adapter.c:207
#define SUCCEEDED(hr)
Definition: intsafe.h:50
DeviceType
Definition: mmdrv.h:42
#define D3DERR_INVALIDDEVICE
Definition: d3d8.h:86
D3DCAPS9 DriverCaps9
Definition: d3d9_private.h:68
D3DDEVTYPE DeviceType
Definition: d3d9caps.h:264
UINT MasterAdapterOrdinal
Definition: d3d9caps.h:320
UINT AdapterOrdinalInGroup
Definition: d3d9caps.h:321
UINT NumberOfAdaptersInGroup
Definition: d3d9caps.h:322
#define ZeroMemory
Definition: winbase.h:1712

Referenced by IDirect3D9Impl_GetDeviceCaps(), and IDirect3DDevice9Base_GetDeviceCaps().

◆ GetAdapterInfo()

BOOL GetAdapterInfo ( LPCSTR  lpszDeviceName,
D3DADAPTER_IDENTIFIER9 pIdentifier 
)

Definition at line 150 of file adapter.c.

151{
152 DISPLAY_DEVICEA DisplayDevice;
153 DWORD AdapterIndex;
154 BOOL FoundDisplayDevice;
155
156 memset(&DisplayDevice, 0, sizeof(DISPLAY_DEVICEA));
157 DisplayDevice.cb = sizeof(DISPLAY_DEVICEA);
158
159 AdapterIndex = 0;
160 FoundDisplayDevice = FALSE;
161 while (EnumDisplayDevicesA(NULL, AdapterIndex, &DisplayDevice, 0) != FALSE)
162 {
163 if (_stricmp(lpszDeviceName, DisplayDevice.DeviceName) == 0)
164 {
165 FoundDisplayDevice = TRUE;
166 break;
167 }
168
169 ++AdapterIndex;
170 }
171
172 /* No matching display device found? */
173 if (FALSE == FoundDisplayDevice)
174 return FALSE;
175
177 lstrcpynA(pIdentifier->DeviceName, DisplayDevice.DeviceName, CCHDEVICENAME);
178
179 if (GetDriverName(&DisplayDevice, pIdentifier) != FALSE)
180 GetDriverVersion(&DisplayDevice, pIdentifier);
181
182 GetDeviceId(DisplayDevice.DeviceID, pIdentifier);
183
184 GenerateDeviceIdentifier(pIdentifier);
185
186 return TRUE;
187}
#define MAX_DEVICE_IDENTIFIER_STRING
Definition: d3d8types.h:109
#define CCHDEVICENAME
Definition: ddrawi.h:63
static BOOL GetDriverName(LPDISPLAY_DEVICEA pDisplayDevice, D3DADAPTER_IDENTIFIER9 *pIdentifier)
Definition: adapter.c:47
static void GenerateDeviceIdentifier(D3DADAPTER_IDENTIFIER9 *pIdentifier)
Definition: adapter.c:136
static void GetDriverVersion(LPDISPLAY_DEVICEA pDisplayDevice, D3DADAPTER_IDENTIFIER9 *pIdentifier)
Definition: adapter.c:70
static void GetDeviceId(LPCSTR lpszDeviceKey, D3DADAPTER_IDENTIFIER9 *pIdentifier)
Definition: adapter.c:128
#define lstrcpynA
Definition: compat.h:751
unsigned int BOOL
Definition: ntddk_ex.h:94
char Description[MAX_DEVICE_IDENTIFIER_STRING]
Definition: d3d9types.h:1230
CHAR DeviceString[128]
Definition: wingdi.h:2811
CHAR DeviceName[32]
Definition: wingdi.h:2810
CHAR DeviceID[128]
Definition: wingdi.h:2813
BOOL WINAPI EnumDisplayDevicesA(LPCSTR lpDevice, DWORD iDevNum, PDISPLAY_DEVICEA lpDisplayDevice, DWORD dwFlags)
Definition: display.c:23
struct _DISPLAY_DEVICEA DISPLAY_DEVICEA

Referenced by IDirect3D9Impl_GetAdapterIdentifier().

◆ GetAdapterMode()

BOOL GetAdapterMode ( LPCSTR  lpszDeviceName,
D3DDISPLAYMODE pMode 
)

Definition at line 333 of file adapter.c.

334{
335 DEVMODEA DevMode;
336
337 memset(&DevMode, 0, sizeof(DEVMODEA));
338 DevMode.dmSize = sizeof(DEVMODEA);
339 if (FALSE == EnumDisplaySettingsA(lpszDeviceName, ENUM_CURRENT_SETTINGS, &DevMode))
340 return FALSE;
341
342 pMode->Width = DevMode.dmPelsWidth;
343 pMode->Height = DevMode.dmPelsHeight;
344 pMode->RefreshRate = DevMode.dmDisplayFrequency;
345
346 switch (DevMode.dmBitsPerPel)
347 {
348 case 8:
349 pMode->Format = D3DFMT_P8;
350 break;
351
352 case 16:
353 pMode->Format = Get16BitD3DFormat(lpszDeviceName);
354 break;
355
356 case 24:
357 pMode->Format = D3DFMT_R8G8B8;
358 break;
359
360 case 32:
361 pMode->Format = D3DFMT_X8R8G8B8;
362 break;
363
364 default:
365 pMode->Format = D3DFMT_UNKNOWN;
366 break;
367 }
368
369 return TRUE;
370}
@ D3DFMT_R8G8B8
Definition: d3d8types.h:603
@ D3DFMT_P8
Definition: d3d8types.h:618
@ D3DFMT_UNKNOWN
Definition: d3d8types.h:601
@ D3DFMT_X8R8G8B8
Definition: d3d8types.h:605
static D3DFORMAT Get16BitD3DFormat(LPCSTR lpszDeviceName)
Definition: adapter.c:284
D3DFORMAT Format
Definition: d3d8types.h:1042
DWORD dmDisplayFrequency
Definition: wingdi.h:1602
DWORD dmPelsWidth
Definition: wingdi.h:1596
DWORD dmPelsHeight
Definition: wingdi.h:1597
DWORD dmBitsPerPel
Definition: wingdi.h:1595
WORD dmSize
Definition: wingdi.h:1568
BOOL WINAPI EnumDisplaySettingsA(LPCSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEA lpDevMode)
Definition: display.c:312
struct _devicemodeA DEVMODEA
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179

Referenced by GetD3D9DriverInfo(), and IDirect3D9Impl_GetAdapterDisplayMode().

◆ GetAdapterMonitor()

HMONITOR GetAdapterMonitor ( LPCSTR  lpszDeviceName)

Definition at line 393 of file adapter.c.

394{
395 ADAPTERMONITOR AdapterMonitor;
396 AdapterMonitor.lpszDeviceName = lpszDeviceName;
397 AdapterMonitor.hMonitor = NULL;
398
400
401 return AdapterMonitor.hMonitor;
402}
static BOOL CALLBACK AdapterMonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
Definition: adapter.c:374
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI EnumDisplayMonitors(_In_opt_ HDC, _In_opt_ LPCRECT, _In_ MONITORENUMPROC, _In_ LPARAM)

Referenced by DECLARE_INTERFACE_(), GetD3D9DriverInfo(), and IDirect3D9Impl_GetAdapterMonitor().

◆ GetDeviceId()

static void GetDeviceId ( LPCSTR  lpszDeviceKey,
D3DADAPTER_IDENTIFIER9 pIdentifier 
)
static

Definition at line 128 of file adapter.c.

129{
130 ParseField(lpszDeviceKey, &pIdentifier->VendorId, "VEN_");
131 ParseField(lpszDeviceKey, &pIdentifier->DeviceId, "DEV_");
132 ParseField(lpszDeviceKey, &pIdentifier->SubSysId, "SUBSYS_");
133 ParseField(lpszDeviceKey, &pIdentifier->Revision, "REV_");
134}
static void ParseField(LPCSTR lpszDeviceKey, LPDWORD pField, LPCSTR lpszSubString)
Definition: adapter.c:118

Referenced by GetAdapterInfo().

◆ GetDisplayFormatCount()

UINT GetDisplayFormatCount ( D3DFORMAT  Format,
const D3DDISPLAYMODE pSupportedDisplayModes,
UINT  NumDisplayModes 
)

Definition at line 406 of file adapter.c.

407{
408 UINT DisplayModeIndex;
409 UINT FormatIndex = 0;
410
411 for (DisplayModeIndex = 0; DisplayModeIndex < NumDisplayModes; DisplayModeIndex++)
412 {
413 if (pSupportedDisplayModes[DisplayModeIndex].Format == Format)
414 {
415 ++FormatIndex;
416 }
417 }
418
419 return FormatIndex;
420}

Referenced by IDirect3D9Impl_GetAdapterModeCount().

◆ GetDriverName()

static BOOL GetDriverName ( LPDISPLAY_DEVICEA  pDisplayDevice,
D3DADAPTER_IDENTIFIER9 pIdentifier 
)
static

Definition at line 47 of file adapter.c.

48{
49 HKEY hKey;
50 BOOL bResult = FALSE;
51
52 if (ERROR_SUCCESS == RegOpenKeyExA(HKEY_LOCAL_MACHINE, pDisplayDevice->DeviceKey + strlen("\\Registry\\Machine\\"), 0, KEY_QUERY_VALUE, &hKey))
53 {
54 DWORD DriverNameLength = MAX_DEVICE_IDENTIFIER_STRING - (DWORD)strlen(".dll");
55 DWORD Type = 0;
56
57 if (ERROR_SUCCESS == RegQueryValueExA(hKey, "InstalledDisplayDrivers", 0, &Type, (LPBYTE)pIdentifier->Driver, &DriverNameLength))
58 {
59 pIdentifier->Driver[DriverNameLength] = '\0';
61 bResult = TRUE;
62 }
63
65 }
66
67 return bResult;
68}
Type
Definition: Type.h:7
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define RegCloseKey(hKey)
Definition: registry.h:49
HRESULT SafeAppendString(IN OUT LPSTR Dst, IN DWORD DstSize, IN LPCSTR Src)
Definition: d3d9_helpers.c:83
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define DWORD
Definition: nt_native.h:44
char Driver[MAX_DEVICE_IDENTIFIER_STRING]
Definition: d3d9types.h:1229
CHAR DeviceKey[128]
Definition: wingdi.h:2814
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by GetAdapterInfo().

◆ GetDriverVersion()

static void GetDriverVersion ( LPDISPLAY_DEVICEA  pDisplayDevice,
D3DADAPTER_IDENTIFIER9 pIdentifier 
)
static

Definition at line 70 of file adapter.c.

71{
73 LPFN_ISWOW64PROCESS fnIsWow64Process;
74 BOOL bIsWow64 = FALSE;
75 PVOID OldWow64RedirectValue;
76 UINT DriverFileSize;
77
78 hModule = GetModuleHandleA("KERNEL32");
79 fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(hModule, "IsWow64Process");
80 if (fnIsWow64Process)
81 {
82 fnIsWow64Process(GetCurrentProcess(), &bIsWow64);
83 if (bIsWow64)
84 {
85 LPFN_DISABLEWOW64FSREDIRECTION fnDisableWow64FsRedirection;
86 fnDisableWow64FsRedirection = (LPFN_DISABLEWOW64FSREDIRECTION)GetProcAddress(hModule, "Wow64DisableWow64FsRedirection");
87 fnDisableWow64FsRedirection(&OldWow64RedirectValue);
88 }
89 }
90
91 DriverFileSize = GetFileVersionInfoSizeA(pIdentifier->Driver, NULL);
92 if (DriverFileSize > 0)
93 {
94 VS_FIXEDFILEINFO* FixedFileInfo = NULL;
95 LPVOID pBlock = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, DriverFileSize);
96
97 if (TRUE == GetFileVersionInfoA(pIdentifier->Driver, 0, DriverFileSize, pBlock))
98 {
99 if (TRUE == VerQueryValueA(pBlock, "\\", (LPVOID*)&FixedFileInfo, &DriverFileSize))
100 {
101 pIdentifier->DriverVersion.HighPart = FixedFileInfo->dwFileVersionMS;
102 pIdentifier->DriverVersion.LowPart = FixedFileInfo->dwFileVersionLS;
103 }
104 }
105
106 HeapFree(GetProcessHeap(), 0, pBlock);
107 }
108
109 if (bIsWow64)
110 {
111 LPFN_REVERTWOW64FSREDIRECTION fnRevertWow64FsRedirection;
112 fnRevertWow64FsRedirection = (LPFN_REVERTWOW64FSREDIRECTION)GetProcAddress(hModule, "Wow64RevertWow64FsRedirection");
113 fnRevertWow64FsRedirection(&OldWow64RedirectValue);
114 }
115}
BOOL(WINAPI * LPFN_REVERTWOW64FSREDIRECTION)(PVOID)
Definition: adapter.c:37
BOOL(WINAPI * LPFN_ISWOW64PROCESS)(HANDLE, PBOOL)
Definition: adapter.c:35
BOOL(WINAPI * LPFN_DISABLEWOW64FSREDIRECTION)(PVOID *)
Definition: adapter.c:36
HMODULE hModule
Definition: animate.c:44
#define GetProcAddress(x, y)
Definition: compat.h:753
#define GetCurrentProcess()
Definition: compat.h:759
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
DWORD WINAPI GetFileVersionInfoSizeA(LPCSTR filename, LPDWORD handle)
Definition: version.c:619
BOOL WINAPI VerQueryValueA(LPCVOID pBlock, LPCSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:993
BOOL WINAPI GetFileVersionInfoA(LPCSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:853

Referenced by GetAdapterInfo().

◆ IsWindowsXPorLaterCompatible()

static BOOL IsWindowsXPorLaterCompatible ( )
static

Definition at line 191 of file adapter.c.

192{
194
195 ZeroMemory(&osvi, sizeof(OSVERSIONINFOA));
197
198 if (GetVersionExA(&osvi) != 0)
199 {
200 return ( (osvi.dwMajorVersion > 5) ||
201 ( (osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion >= 1) ));
202 }
203
204 return FALSE;
205}
BOOL WINAPI GetVersionExA(IN LPOSVERSIONINFOA lpVersionInformation)
Definition: version.c:69
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:237
ULONG dwMajorVersion
Definition: rtltypes.h:238
ULONG dwMinorVersion
Definition: rtltypes.h:239
OSVERSIONINFO osvi
Definition: ver.c:28
struct _OSVERSIONINFOA OSVERSIONINFOA

Referenced by CopyDriverCaps().

◆ ParseField()

static void ParseField ( LPCSTR  lpszDeviceKey,
LPDWORD  pField,
LPCSTR  lpszSubString 
)
static

Definition at line 118 of file adapter.c.

119{
120 const char* ResultStr;
121 ResultStr = strstr(lpszDeviceKey, lpszSubString);
122 if (ResultStr != NULL)
123 {
124 *pField = strtol(ResultStr + strlen(lpszSubString), NULL, 16);
125 }
126}
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
_Check_return_ long __cdecl strtol(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix)

Referenced by GetDeviceId().