ReactOS  0.4.15-dev-489-g75a0787
adapter.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BOOL GetAdapterInfo (LPCSTR lpszDeviceName, D3DADAPTER_IDENTIFIER9 *pIdentifier)
 
BOOL GetAdapterMode (LPCSTR lpszDeviceName, D3DDISPLAYMODE *pMode)
 
HRESULT GetAdapterCaps (const LPDIRECT3D9_DISPLAYADAPTER pDisplayAdapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pDstCaps)
 
HMONITOR GetAdapterMonitor (LPCSTR lpszDeviceName)
 
UINT GetDisplayFormatCount (D3DFORMAT Format, const D3DDISPLAYMODE *pSupportedDisplayModes, UINT NumDisplayModes)
 
const D3DDISPLAYMODEFindDisplayFormat (D3DFORMAT Format, UINT ModeIndex, const D3DDISPLAYMODE *pSupportedDisplayModes, UINT NumDisplayModes)
 

Function Documentation

◆ 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 }
smooth NULL
Definition: ftsmooth.c:416
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8

Referenced by IDirect3D9Impl_EnumAdapterModes().

◆ GetAdapterCaps()

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

Definition at line 240 of file adapter.c.

241 {
242  HRESULT hResult = D3DERR_INVALIDDEVICE;
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:
256  case D3DDEVTYPE_NULLREF:
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 }
DeviceType
Definition: mmdrv.h:41
#define ZeroMemory
Definition: winbase.h:1648
UINT NumberOfAdaptersInGroup
Definition: d3d9caps.h:322
#define D3DERR_INVALIDDEVICE
Definition: d3d8.h:86
UINT AdapterOrdinalInGroup
Definition: d3d9caps.h:321
smooth NULL
Definition: ftsmooth.c:416
D3DDEVTYPE DeviceType
Definition: d3d9caps.h:264
LONG HRESULT
Definition: typedefs.h:78
static void CopyDriverCaps(const D3DCAPS9 *pSrcCaps, D3DCAPS9 *pDstCaps)
Definition: adapter.c:207
UINT MasterAdapterOrdinal
Definition: d3d9caps.h:320
D3DCAPS9 DriverCaps9
Definition: d3d9_private.h:68
#define D3D_OK
Definition: d3d.h:106
#define DPRINT1
Definition: precomp.h:8
#define UNIMPLEMENTED
Definition: debug.h:115
#define SUCCEEDED(hr)
Definition: intsafe.h:57

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 
176  lstrcpynA(pIdentifier->Description, DisplayDevice.DeviceString, MAX_DEVICE_IDENTIFIER_STRING);
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 TRUE
Definition: types.h:120
CHAR DeviceString[128]
Definition: wingdi.h:2810
CHAR DeviceName[32]
Definition: wingdi.h:2809
char Description[MAX_DEVICE_IDENTIFIER_STRING]
Definition: d3d9types.h:1230
static void GenerateDeviceIdentifier(D3DADAPTER_IDENTIFIER9 *pIdentifier)
Definition: adapter.c:136
#define _stricmp
Definition: cat.c:22
#define MAX_DEVICE_IDENTIFIER_STRING
Definition: d3d8types.h:109
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI EnumDisplayDevicesA(LPCSTR lpDevice, DWORD iDevNum, PDISPLAY_DEVICEA lpDisplayDevice, DWORD dwFlags)
Definition: display.c:23
static BOOL GetDriverName(LPDISPLAY_DEVICEA pDisplayDevice, D3DADAPTER_IDENTIFIER9 *pIdentifier)
Definition: adapter.c:47
smooth NULL
Definition: ftsmooth.c:416
struct _DISPLAY_DEVICEA DISPLAY_DEVICEA
static void GetDeviceId(LPCSTR lpszDeviceKey, D3DADAPTER_IDENTIFIER9 *pIdentifier)
Definition: adapter.c:128
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CCHDEVICENAME
Definition: ddrawi.h:63
CHAR DeviceID[128]
Definition: wingdi.h:2812
#define lstrcpynA
Definition: compat.h:417
static void GetDriverVersion(LPDISPLAY_DEVICEA pDisplayDevice, D3DADAPTER_IDENTIFIER9 *pIdentifier)
Definition: adapter.c:70
#define memset(x, y, z)
Definition: compat.h:39

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 }
#define TRUE
Definition: types.h:120
WORD dmSize
Definition: wingdi.h:1567
DWORD dmDisplayFrequency
Definition: wingdi.h:1601
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179
static D3DFORMAT Get16BitD3DFormat(LPCSTR lpszDeviceName)
Definition: adapter.c:284
BOOL WINAPI EnumDisplaySettingsA(LPCSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEA lpDevMode)
Definition: display.c:312
DWORD dmPelsHeight
Definition: wingdi.h:1596
DWORD dmBitsPerPel
Definition: wingdi.h:1594
D3DFORMAT Format
Definition: d3d8types.h:1042
struct _devicemodeA DEVMODEA
#define memset(x, y, z)
Definition: compat.h:39
DWORD dmPelsWidth
Definition: wingdi.h:1595

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 }
LPCSTR lpszDeviceName
Definition: adapter.c:42
BOOL WINAPI EnumDisplayMonitors(_In_opt_ HDC, _In_opt_ LPCRECT, _In_ MONITORENUMPROC, _In_ LPARAM)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
HMONITOR hMonitor
Definition: adapter.c:43
static BOOL CALLBACK AdapterMonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
Definition: adapter.c:374

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

◆ 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 }
unsigned int UINT
Definition: ndis.h:50

Referenced by IDirect3D9Impl_GetAdapterModeCount().