ReactOS  0.4.15-dev-1171-gab82533
d3d9_impl.c File Reference
#include "d3d9_common.h"
#include <d3d9.h>
#include <debug.h>
#include "d3d9_helpers.h"
#include "adapter.h"
#include "device.h"
#include "format.h"
Include dependency graph for d3d9_impl.c:

Go to the source code of this file.

Macros

#define LOCK_D3D9()   EnterCriticalSection(&This->d3d9_cs);
 
#define UNLOCK_D3D9()   LeaveCriticalSection(&This->d3d9_cs);
 

Functions

static LPDIRECT3D9_INT IDirect3D9ToImpl (LPDIRECT3D9 iface)
 
static HRESULT WINAPI IDirect3D9Impl_QueryInterface (LPDIRECT3D9 iface, REFIID riid, LPVOID *ppvObject)
 
static ULONG WINAPI IDirect3D9Impl_AddRef (LPDIRECT3D9 iface)
 
static ULONG WINAPI IDirect3D9Impl_Release (LPDIRECT3D9 iface)
 
static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice (LPDIRECT3D9 iface, void *pInitializeFunction)
 
static UINT WINAPI IDirect3D9Impl_GetAdapterCount (LPDIRECT3D9 iface)
 
HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier (LPDIRECT3D9 iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier)
 
static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount (LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format)
 
static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes (LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE *pMode)
 
static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode (LPDIRECT3D9 iface, UINT Adapter, D3DDISPLAYMODE *pMode)
 
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType (LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed)
 
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat (LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat)
 
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType (LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels)
 
static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch (LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
 
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion (LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat)
 
static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps (LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps)
 
static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor (LPDIRECT3D9 iface, UINT Adapter)
 
static HRESULT WINAPI IDirect3D9Impl_CreateDevice (LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviourFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, struct IDirect3DDevice9 **ppReturnedDeviceInterface)
 

Variables

IDirect3D9Vtbl Direct3D9_Vtbl
 

Macro Definition Documentation

◆ LOCK_D3D9

#define LOCK_D3D9 ( )    EnterCriticalSection(&This->d3d9_cs);

Definition at line 17 of file d3d9_impl.c.

◆ UNLOCK_D3D9

#define UNLOCK_D3D9 ( )    LeaveCriticalSection(&This->d3d9_cs);

Definition at line 18 of file d3d9_impl.c.

Function Documentation

◆ IDirect3D9Impl_AddRef()

static ULONG WINAPI IDirect3D9Impl_AddRef ( LPDIRECT3D9  iface)
static

Definition at line 45 of file d3d9_impl.c.

46 {
48  ULONG ref = InterlockedIncrement(&This->lRefCnt);
49 
50  return ref;
51 }
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ IDirect3D9Impl_CheckDepthStencilMatch()

static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch ( LPDIRECT3D9  iface,
UINT  Adapter,
D3DDEVTYPE  DeviceType,
D3DFORMAT  AdapterFormat,
D3DFORMAT  RenderTargetFormat,
D3DFORMAT  DepthStencilFormat 
)
static

Definition at line 684 of file d3d9_impl.c.

687 {
688  HRESULT hResult;
689 
691  LOCK_D3D9();
692 
693  if (Adapter >= This->NumDisplayAdapters)
694  {
695  DPRINT1("Invalid Adapter number specified");
696  UNLOCK_D3D9();
697  return D3DERR_INVALIDCALL;
698  }
699 
700  if (DeviceType != D3DDEVTYPE_HAL &&
703  {
704  DPRINT1("Invalid DeviceType specified");
705  UNLOCK_D3D9();
706  return D3DERR_INVALIDCALL;
707  }
708 
709  if (AdapterFormat == D3DFMT_UNKNOWN ||
710  RenderTargetFormat == D3DFMT_UNKNOWN ||
711  DepthStencilFormat == D3DFMT_UNKNOWN)
712  {
713  DPRINT1("Invalid D3DFORMAT specified");
714  UNLOCK_D3D9();
715  return D3DERR_INVALIDCALL;
716  }
717 
718  hResult = CheckDepthStencilMatch(&This->DisplayAdapters[Adapter].DriverCaps, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
719 
720  UNLOCK_D3D9();
721  return hResult;
722 }
DeviceType
Definition: mmdrv.h:41
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
#define D3DERR_INVALIDCALL
HRESULT CheckDepthStencilMatch(LPD3D9_DRIVERCAPS pDriverCaps, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
Definition: format.c:539
#define UNLOCK_D3D9()
Definition: d3d9_impl.c:18
LONG HRESULT
Definition: typedefs.h:79
#define LOCK_D3D9()
Definition: d3d9_impl.c:17
#define DPRINT1
Definition: precomp.h:8

◆ IDirect3D9Impl_CheckDeviceFormat()

static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat ( LPDIRECT3D9  iface,
UINT  Adapter,
D3DDEVTYPE  DeviceType,
D3DFORMAT  AdapterFormat,
DWORD  Usage,
D3DRESOURCETYPE  RType,
D3DFORMAT  CheckFormat 
)
static

Definition at line 488 of file d3d9_impl.c.

491 {
492  LPD3D9_DRIVERCAPS pDriverCaps;
493  BOOL bIsTextureRType = FALSE;
494  HRESULT hResult;
495 
497  LOCK_D3D9();
498 
499  if (Adapter >= This->NumDisplayAdapters)
500  {
501  DPRINT1("Invalid Adapter number specified");
502  UNLOCK_D3D9();
503  return D3DERR_INVALIDCALL;
504  }
505 
506  if (DeviceType != D3DDEVTYPE_HAL &&
509  {
510  DPRINT1("Invalid DeviceType specified");
511  UNLOCK_D3D9();
512  return D3DERR_INVALIDCALL;
513  }
514 
515  if (AdapterFormat == D3DFMT_UNKNOWN ||
516  CheckFormat == D3DFMT_UNKNOWN)
517  {
518  DPRINT1("Invalid D3DFORMAT specified");
519  UNLOCK_D3D9();
520  return D3DERR_INVALIDCALL;
521  }
522 
524  {
525  DPRINT1("Invalid Usage specified");
526  UNLOCK_D3D9();
527  return D3DERR_INVALIDCALL;
528  }
529 
530  if (RType == D3DRTYPE_TEXTURE ||
531  RType == D3DRTYPE_VOLUMETEXTURE ||
532  RType == D3DRTYPE_CUBETEXTURE)
533  {
534  bIsTextureRType = TRUE;
535  }
536  else if (RType == D3DRTYPE_SURFACE &&
538  Usage != 0)
539  {
540  DPRINT1("When RType is set to D3DRTYPE_SURFACE, Usage must be 0 or have set D3DUSAGE_DEPTHSTENCIL or D3DUSAGE_RENDERTARGET");
541  UNLOCK_D3D9();
542  return D3DERR_INVALIDCALL;
543  }
544 
545  if ((Usage & D3DUSAGE_DEPTHSTENCIL) != 0)
546  {
547  if (FALSE == IsZBufferFormat(CheckFormat))
548  {
549  DPRINT1("Invalid CheckFormat Z-Buffer format");
550  UNLOCK_D3D9();
551  return D3DERR_INVALIDCALL;
552  }
553 
554  if ((Usage & D3DUSAGE_AUTOGENMIPMAP) != 0)
555  {
556  DPRINT1("Invalid Usage specified, D3DUSAGE_DEPTHSTENCIL and D3DUSAGE_AUTOGENMIPMAP can't be combined.");
557  UNLOCK_D3D9();
558  return D3DERR_INVALIDCALL;
559  }
560  }
561 
562  if (FALSE == bIsTextureRType &&
563  RType != D3DRTYPE_SURFACE &&
564  RType != D3DRTYPE_VOLUME)
565  {
566  DPRINT1("Invalid RType specified");
567  UNLOCK_D3D9();
568  return D3DERR_INVALIDCALL;
569  }
570 
572  {
573  if (RType == D3DRTYPE_VOLUME || RType == D3DRTYPE_VOLUMETEXTURE)
574  {
575  DPRINT1("Invalid Usage specified, D3DUSAGE_AUTOGENMIPMAP, D3DUSAGE_DEPTHSTENCIL and D3DUSAGE_RENDERTARGET can't be combined with RType D3DRTYPE_VOLUME or D3DRTYPE_VOLUMETEXTURE");
576  UNLOCK_D3D9();
577  return D3DERR_INVALIDCALL;
578  }
579  }
580 
581  if (FALSE == bIsTextureRType &&
583  {
584  DPRINT1("Invalid Usage specified, D3DUSAGE_QUERY_VERTEXTEXTURE can only be used with a texture RType");
585  UNLOCK_D3D9();
586  return D3DERR_INVALIDCALL;
587  }
588 
589  if ((Usage & D3DUSAGE_AUTOGENMIPMAP) != 0 &&
590  TRUE == IsMultiElementFormat(CheckFormat))
591  {
592  DPRINT1("Invalid Usage specified, D3DUSAGE_AUTOGENMIPMAP can't be used with a multi-element format");
593  UNLOCK_D3D9();
594  return D3DERR_INVALIDCALL;
595  }
596 
597  pDriverCaps = &This->DisplayAdapters[Adapter].DriverCaps;
598  if (((Usage & D3DUSAGE_DYNAMIC) != 0) && (bIsTextureRType != FALSE))
599  {
600  if ((pDriverCaps->DriverCaps9.Caps2 & D3DCAPS2_DYNAMICTEXTURES) == 0)
601  {
602  DPRINT1("Driver doesn't support dynamic textures");
603  UNLOCK_D3D9();
604  return D3DERR_NOTAVAILABLE;
605  }
606 
608  {
609  DPRINT1("Invalid Usage specified, D3DUSAGE_DEPTHSTENCIL and D3DUSAGE_RENDERTARGET can't be combined with D3DUSAGE_DYNAMIC and a texture RType");
610  UNLOCK_D3D9();
611  return D3DERR_INVALIDCALL;
612  }
613  }
614 
615  if ((Usage & D3DUSAGE_DMAP) != 0)
616  {
618  {
619  DPRINT1("Driver doesn't support displacement mapping");
620  UNLOCK_D3D9();
621  return D3DERR_NOTAVAILABLE;
622  }
623 
624  if (RType != D3DRTYPE_TEXTURE)
625  {
626  DPRINT1("Invalid Usage specified, D3DUSAGE_DMAP must be combined with RType D3DRTYPE_TEXTURE");
627  UNLOCK_D3D9();
628  return D3DERR_INVALIDCALL;
629  }
630  }
631 
632  hResult = CheckDeviceFormat(pDriverCaps, AdapterFormat, Usage, RType, CheckFormat);
633 
634  UNLOCK_D3D9();
635  return hResult;
636 }
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
#define D3DUSAGE_QUERY_VERTEXTEXTURE
Definition: d3d9types.h:121
BOOL IsZBufferFormat(D3DFORMAT Format)
Definition: format.c:25
#define TRUE
Definition: types.h:120
#define D3DDEVCAPS2_DMAPNPATCH
Definition: d3d9caps.h:202
DeviceType
Definition: mmdrv.h:41
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
#define D3DUSAGE_AUTOGENMIPMAP
Definition: d3d9types.h:113
#define D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH
Definition: d3d9caps.h:206
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
#define D3DUSAGE_POINTS
Definition: d3d8types.h:96
#define D3DUSAGE_DONOTCLIP
Definition: d3d8types.h:95
#define D3DERR_INVALIDCALL
#define D3DUSAGE_WRITEONLY
Definition: d3d8types.h:93
DWORD DevCaps2
Definition: d3d9caps.h:317
#define D3DUSAGE_DEPTHSTENCIL
Definition: d3d8types.h:92
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define D3DERR_NOTAVAILABLE
Definition: d3d8.h:84
#define D3DUSAGE_DMAP
Definition: d3d9types.h:114
#define D3DUSAGE_NPATCHES
Definition: d3d8types.h:98
#define UNLOCK_D3D9()
Definition: d3d9_impl.c:18
DWORD Caps2
Definition: d3d9caps.h:267
LONG HRESULT
Definition: typedefs.h:79
#define D3DUSAGE_RENDERTARGET
Definition: d3d8types.h:91
#define D3DUSAGE_RTPATCHES
Definition: d3d8types.h:97
#define LOCK_D3D9()
Definition: d3d9_impl.c:17
D3DCAPS9 DriverCaps9
Definition: d3d9_private.h:68
HRESULT CheckDeviceFormat(LPD3D9_DRIVERCAPS pDriverCaps, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat)
Definition: format.c:326
#define DPRINT1
Definition: precomp.h:8
BOOL IsMultiElementFormat(D3DFORMAT Format)
Definition: format.c:32
#define D3DCAPS2_DYNAMICTEXTURES
Definition: d3d8caps.h:25

◆ IDirect3D9Impl_CheckDeviceFormatConversion()

static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion ( LPDIRECT3D9  iface,
UINT  Adapter,
D3DDEVTYPE  DeviceType,
D3DFORMAT  SourceFormat,
D3DFORMAT  TargetFormat 
)
static

Definition at line 755 of file d3d9_impl.c.

757 {
758  HRESULT hResult;
760  LOCK_D3D9();
761 
762  if (Adapter >= This->NumDisplayAdapters)
763  {
764  DPRINT1("Invalid Adapter number specified");
765  UNLOCK_D3D9();
766  return D3DERR_INVALIDCALL;
767  }
768 
769  if (DeviceType != D3DDEVTYPE_HAL &&
772  {
773  DPRINT1("Invalid DeviceType specified");
774  UNLOCK_D3D9();
775  return D3DERR_INVALIDCALL;
776  }
777 
778  if (SourceFormat == D3DFMT_UNKNOWN ||
779  TargetFormat == D3DFMT_UNKNOWN)
780  {
781  DPRINT1("Invalid D3DFORMAT specified");
782  UNLOCK_D3D9();
783  return D3DERR_NOTAVAILABLE;
784  }
785 
786  if (DeviceType == D3DDEVTYPE_HAL)
787  {
788  hResult = CheckDeviceFormatConversion(&This->DisplayAdapters[Adapter].DriverCaps, SourceFormat, TargetFormat);
789  }
790  else
791  {
792  hResult = D3DERR_NOTAVAILABLE;
793  }
794 
795  UNLOCK_D3D9();
796  return hResult;
797 }
DeviceType
Definition: mmdrv.h:41
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
#define D3DERR_INVALIDCALL
#define D3DERR_NOTAVAILABLE
Definition: d3d8.h:84
#define UNLOCK_D3D9()
Definition: d3d9_impl.c:18
LONG HRESULT
Definition: typedefs.h:79
HRESULT CheckDeviceFormatConversion(LPD3D9_DRIVERCAPS pDriverCaps, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat)
Definition: format.c:495
#define LOCK_D3D9()
Definition: d3d9_impl.c:17
#define DPRINT1
Definition: precomp.h:8

◆ IDirect3D9Impl_CheckDeviceMultiSampleType()

static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType ( LPDIRECT3D9  iface,
UINT  Adapter,
D3DDEVTYPE  DeviceType,
D3DFORMAT  SurfaceFormat,
BOOL  Windowed,
D3DMULTISAMPLE_TYPE  MultiSampleType,
DWORD pQualityLevels 
)
static

Definition at line 638 of file d3d9_impl.c.

641 {
643 
644  return D3D_OK;
645 }
#define D3D_OK
Definition: d3d.h:106
#define UNIMPLEMENTED
Definition: debug.h:115

◆ IDirect3D9Impl_CheckDeviceType()

static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType ( LPDIRECT3D9  iface,
UINT  Adapter,
D3DDEVTYPE  DeviceType,
D3DFORMAT  DisplayFormat,
D3DFORMAT  BackBufferFormat,
BOOL  Windowed 
)
static

Definition at line 391 of file d3d9_impl.c.

393 {
394  HRESULT hResult;
395 
397  LOCK_D3D9();
398 
399  if (Adapter >= This->NumDisplayAdapters)
400  {
401  DPRINT1("Invalid Adapter number specified");
402  UNLOCK_D3D9();
403  return D3DERR_INVALIDCALL;
404  }
405 
406  if (DeviceType != D3DDEVTYPE_HAL &&
409  {
410  DPRINT1("Invalid DeviceType specified");
411  UNLOCK_D3D9();
412  return D3DERR_INVALIDCALL;
413  }
414 
415  if ((BackBufferFormat == D3DFMT_UNKNOWN) &&
416  (Windowed != FALSE))
417  {
418  BackBufferFormat = DisplayFormat;
419  }
420 
421  if (DisplayFormat == D3DFMT_UNKNOWN && BackBufferFormat == D3DFMT_UNKNOWN)
422  {
423  DPRINT1("Invalid D3DFORMAT specified");
424  UNLOCK_D3D9();
425  return D3DERR_INVALIDCALL;
426  }
427 
428  if (FALSE == IsBackBufferFormat(BackBufferFormat))
429  {
430  DPRINT1("Invalid D3DFORMAT specified");
431  UNLOCK_D3D9();
432  return D3DERR_NOTAVAILABLE;
433  }
434 
435  if (TRUE == Windowed && TRUE == IsExtendedFormat(DisplayFormat))
436  {
437  DPRINT1("Extended display modes can only be used in fullscreen mode");
438  UNLOCK_D3D9();
439  return D3DERR_NOTAVAILABLE;
440  }
441 
442  hResult = CheckDeviceType(&This->DisplayAdapters[Adapter].DriverCaps, DisplayFormat, BackBufferFormat, Windowed);
443 
444  UNLOCK_D3D9();
445  return hResult;
446 }
#define TRUE
Definition: types.h:120
DeviceType
Definition: mmdrv.h:41
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
#define D3DERR_INVALIDCALL
#define FALSE
Definition: types.h:117
#define D3DERR_NOTAVAILABLE
Definition: d3d8.h:84
#define UNLOCK_D3D9()
Definition: d3d9_impl.c:18
LONG HRESULT
Definition: typedefs.h:79
#define LOCK_D3D9()
Definition: d3d9_impl.c:17
BOOL IsExtendedFormat(D3DFORMAT Format)
Definition: format.c:20
#define DPRINT1
Definition: precomp.h:8
BOOL IsBackBufferFormat(D3DFORMAT Format)
Definition: format.c:14
HRESULT CheckDeviceType(LPD3D9_DRIVERCAPS pDriverCaps, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed)
Definition: format.c:224

◆ IDirect3D9Impl_CreateDevice()

static HRESULT WINAPI IDirect3D9Impl_CreateDevice ( LPDIRECT3D9  iface,
UINT  Adapter,
D3DDEVTYPE  DeviceType,
HWND  hFocusWindow,
DWORD  BehaviourFlags,
D3DPRESENT_PARAMETERS pPresentationParameters,
struct IDirect3DDevice9 **  ppReturnedDeviceInterface 
)
static

Definition at line 932 of file d3d9_impl.c.

936 {
937  DWORD NumAdaptersToCreate;
938  HRESULT Ret;
939 
941  LOCK_D3D9();
942 
943  if (Adapter >= This->NumDisplayAdapters)
944  {
945  DPRINT1("Invalid Adapter number specified");
946  UNLOCK_D3D9();
947  return D3DERR_INVALIDCALL;
948  }
949 
950  if (DeviceType != D3DDEVTYPE_HAL &&
953  {
954  DPRINT1("Invalid DeviceType specified");
955  UNLOCK_D3D9();
956  return D3DERR_INVALIDCALL;
957  }
958 
959  if (DeviceType != D3DDEVTYPE_HAL)
960  {
962  DPRINT1("Sorry, only D3DDEVTYPE_HAL is implemented at this time...");
963  return D3DERR_INVALIDCALL;
964  }
965 
966  if (hFocusWindow != NULL && FALSE == IsWindow(hFocusWindow))
967  {
968  DPRINT1("Invalid hFocusWindow parameter specified, expected NULL or a valid HWND");
969  UNLOCK_D3D9();
970  return D3DERR_INVALIDCALL;
971  }
972 
973  if (NULL == pPresentationParameters)
974  {
975  DPRINT1("Invalid pPresentationParameters parameter specified");
976  UNLOCK_D3D9();
977  return D3DERR_INVALIDCALL;
978  }
979 
980  if (pPresentationParameters->hDeviceWindow != NULL && FALSE == IsWindow(pPresentationParameters->hDeviceWindow))
981  {
982  DPRINT1("Invalid pPresentationParameters->hDeviceWindow parameter specified, expected NULL or a valid HWND");
983  UNLOCK_D3D9();
984  return D3DERR_INVALIDCALL;
985  }
986 
987  if (FALSE == pPresentationParameters->Windowed && hFocusWindow == NULL)
988  {
989  DPRINT1("When pPresentationParameters->Windowed is not set, hFocusWindow must be a valid HWND");
990  UNLOCK_D3D9();
991  return D3DERR_INVALIDCALL;
992  }
993 
994  if (NULL == hFocusWindow && NULL == pPresentationParameters->hDeviceWindow)
995  {
996  DPRINT1("Any of pPresentationParameters->Windowed and hFocusWindow must be set to a valid HWND");
997  UNLOCK_D3D9();
998  return D3DERR_INVALIDCALL;
999  }
1000 
1001  if (Adapter > 0 && NULL == pPresentationParameters->hDeviceWindow)
1002  {
1003  DPRINT1("Invalid pPresentationParameters->hDeviceWindow, must be set to a valid unique HWND when Adapter is greater than 0");
1004  UNLOCK_D3D9();
1005  return D3DERR_INVALIDCALL;
1006  }
1007 
1008  if (NULL == ppReturnedDeviceInterface)
1009  {
1010  DPRINT1("Invalid ppReturnedDeviceInterface parameter specified");
1011  UNLOCK_D3D9();
1012  return D3DERR_INVALIDCALL;
1013  }
1014 
1015  if ((BehaviourFlags & D3DCREATE_ADAPTERGROUP_DEVICE) != 0)
1016  NumAdaptersToCreate = This->DisplayAdapters[Adapter].NumAdaptersInGroup;
1017  else
1018  NumAdaptersToCreate = 1;
1019 
1020  *ppReturnedDeviceInterface = 0;
1021 
1022  Ret = CreateD3D9HalDevice(This, Adapter, hFocusWindow, BehaviourFlags, pPresentationParameters, NumAdaptersToCreate, ppReturnedDeviceInterface);
1023 
1024  UNLOCK_D3D9();
1025  return Ret;
1026 }
#define D3DCREATE_ADAPTERGROUP_DEVICE
Definition: d3d9.h:49
BOOL WINAPI IsWindow(_In_opt_ HWND)
DeviceType
Definition: mmdrv.h:41
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
#define D3DERR_INVALIDCALL
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define UNLOCK_D3D9()
Definition: d3d9_impl.c:18
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LOCK_D3D9()
Definition: d3d9_impl.c:17
#define DPRINT1
Definition: precomp.h:8
#define UNIMPLEMENTED
Definition: debug.h:115
HRESULT CreateD3D9HalDevice(LPDIRECT3D9_INT pDirect3D9, UINT Adapter, HWND hFocusWindow, DWORD BehaviourFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, DWORD NumAdaptersToCreate, struct IDirect3DDevice9 **ppReturnedDeviceInterface)
Definition: device.c:95

◆ IDirect3D9Impl_EnumAdapterModes()

static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes ( LPDIRECT3D9  iface,
UINT  Adapter,
D3DFORMAT  Format,
UINT  Mode,
D3DDISPLAYMODE pMode 
)
static

Definition at line 257 of file d3d9_impl.c.

259 {
260  const D3DDISPLAYMODE* pMatchingDisplayFormat;
262  LOCK_D3D9();
263 
264  if (Adapter >= This->NumDisplayAdapters)
265  {
266  DPRINT1("Invalid Adapter number specified");
267  UNLOCK_D3D9();
268  return D3DERR_INVALIDCALL;
269  }
270 
271  if (NULL == pMode)
272  {
273  DPRINT1("Invalid pMode parameter specified");
274  UNLOCK_D3D9();
275  return D3DERR_INVALIDCALL;
276  }
277 
278  if (Format != D3DFMT_A2R10G10B10)
279  {
280  pMatchingDisplayFormat = FindDisplayFormat(
281  Format,
282  Mode,
283  This->DisplayAdapters[Adapter].pSupportedD3DFormats,
284  This->DisplayAdapters[Adapter].NumSupportedD3DFormats);
285  }
286  else
287  {
288  pMatchingDisplayFormat = FindDisplayFormat(
289  Format,
290  Mode,
291  This->DisplayAdapters[Adapter].pSupportedD3DExtendedFormats,
292  This->DisplayAdapters[Adapter].NumSupportedD3DExtendedFormats);
293  }
294 
295  if (pMatchingDisplayFormat != NULL)
296  {
297  *pMode = *pMatchingDisplayFormat;
298  }
299  UNLOCK_D3D9();
300 
301 
302  if (pMatchingDisplayFormat == NULL)
303  return D3DERR_INVALIDCALL;
304 
305  return D3D_OK;
306 }
_In_ ULONG Mode
Definition: hubbusif.h:303
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
#define D3DERR_INVALIDCALL
const D3DDISPLAYMODE * FindDisplayFormat(D3DFORMAT Format, UINT ModeIndex, const D3DDISPLAYMODE *pSupportedDisplayModes, UINT NumDisplayModes)
Definition: adapter.c:422
smooth NULL
Definition: ftsmooth.c:416
#define UNLOCK_D3D9()
Definition: d3d9_impl.c:18
#define LOCK_D3D9()
Definition: d3d9_impl.c:17
#define D3D_OK
Definition: d3d.h:106
#define DPRINT1
Definition: precomp.h:8

◆ IDirect3D9Impl_GetAdapterCount()

static UINT WINAPI IDirect3D9Impl_GetAdapterCount ( LPDIRECT3D9  iface)
static

Definition at line 90 of file d3d9_impl.c.

91 {
92  UINT NumDisplayAdapters;
93 
95  LOCK_D3D9();
96 
97  NumDisplayAdapters = This->NumDisplayAdapters;
98 
99  UNLOCK_D3D9();
100  return NumDisplayAdapters;
101 }
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
#define UNLOCK_D3D9()
Definition: d3d9_impl.c:18
#define LOCK_D3D9()
Definition: d3d9_impl.c:17
unsigned int UINT
Definition: ndis.h:50

◆ IDirect3D9Impl_GetAdapterDisplayMode()

static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode ( LPDIRECT3D9  iface,
UINT  Adapter,
D3DDISPLAYMODE pMode 
)
static

Definition at line 330 of file d3d9_impl.c.

331 {
333  LOCK_D3D9();
334 
335  if (Adapter >= This->NumDisplayAdapters)
336  {
337  DPRINT1("Invalid Adapter number specified");
338  UNLOCK_D3D9();
339  return D3DERR_INVALIDCALL;
340  }
341 
342  if (NULL == pMode)
343  {
344  DPRINT1("Invalid pMode parameter specified");
345  UNLOCK_D3D9();
346  return D3DERR_INVALIDCALL;
347  }
348 
349  /* TODO: Handle (This->DisplayAdapters[Adapter].bInUseFlag == FALSE) */
350  if (FALSE == GetAdapterMode(This->DisplayAdapters[Adapter].szDeviceName, pMode))
351  DPRINT1("Internal error, GetAdapterMode() failed.");
352 
353  UNLOCK_D3D9();
354  return D3D_OK;
355 }
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
#define D3DERR_INVALIDCALL
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define UNLOCK_D3D9()
Definition: d3d9_impl.c:18
BOOL GetAdapterMode(LPCSTR lpszDeviceName, D3DDISPLAYMODE *pMode)
Definition: adapter.c:333
#define LOCK_D3D9()
Definition: d3d9_impl.c:17
#define D3D_OK
Definition: d3d.h:106
#define DPRINT1
Definition: precomp.h:8

◆ IDirect3D9Impl_GetAdapterIdentifier()

HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier ( LPDIRECT3D9  iface,
UINT  Adapter,
DWORD  Flags,
D3DADAPTER_IDENTIFIER9 pIdentifier 
)

Definition at line 130 of file d3d9_impl.c.

132 {
134  LOCK_D3D9();
135 
136  if (Adapter >= This->NumDisplayAdapters)
137  {
138  DPRINT1("Invalid Adapter number specified");
139  UNLOCK_D3D9();
140  return D3DERR_INVALIDCALL;
141  }
142 
143  if (Flags & ~D3DENUM_WHQL_LEVEL)
144  {
145  DPRINT1("Invalid Flags specified");
146  UNLOCK_D3D9();
147  return D3DERR_INVALIDCALL;
148  }
149 
150  if (NULL == pIdentifier)
151  {
152  DPRINT1("Invalid pIdentifier parameter specified");
153  UNLOCK_D3D9();
154  return D3DERR_INVALIDCALL;
155  }
156 
157  memset(pIdentifier, 0, sizeof(D3DADAPTER_IDENTIFIER9));
158 
159  if (FALSE == GetAdapterInfo(This->DisplayAdapters[Adapter].szDeviceName, pIdentifier))
160  {
161  DPRINT1("Internal error: Couldn't get the adapter info for device (%d): %s", Adapter, This->DisplayAdapters[Adapter].szDeviceName);
162  UNLOCK_D3D9();
163  return D3DERR_INVALIDCALL;
164  }
165 
166  UNLOCK_D3D9();
167  return D3D_OK;
168 }
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
#define D3DERR_INVALIDCALL
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define FALSE
Definition: types.h:117
BOOL GetAdapterInfo(LPCSTR lpszDeviceName, D3DADAPTER_IDENTIFIER9 *pIdentifier)
Definition: adapter.c:150
smooth NULL
Definition: ftsmooth.c:416
#define UNLOCK_D3D9()
Definition: d3d9_impl.c:18
#define LOCK_D3D9()
Definition: d3d9_impl.c:17
#define D3D_OK
Definition: d3d.h:106
#define DPRINT1
Definition: precomp.h:8
#define memset(x, y, z)
Definition: compat.h:39

◆ IDirect3D9Impl_GetAdapterModeCount()

static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount ( LPDIRECT3D9  iface,
UINT  Adapter,
D3DFORMAT  Format 
)
static

Definition at line 192 of file d3d9_impl.c.

193 {
194  UINT AdapterModeCount;
195 
197  LOCK_D3D9();
198 
199  if (Adapter >= This->NumDisplayAdapters)
200  {
201  DPRINT1("Invalid Adapter number specified");
202  UNLOCK_D3D9();
203  return D3DERR_INVALIDCALL;
204  }
205 
206  if (Format != D3DFMT_A2R10G10B10)
207  {
208  AdapterModeCount = GetDisplayFormatCount(
209  Format,
210  This->DisplayAdapters[Adapter].pSupportedD3DFormats,
211  This->DisplayAdapters[Adapter].NumSupportedD3DFormats);
212  }
213  else
214  {
215  AdapterModeCount = GetDisplayFormatCount(
216  Format,
217  This->DisplayAdapters[Adapter].pSupportedD3DExtendedFormats,
218  This->DisplayAdapters[Adapter].NumSupportedD3DExtendedFormats);
219  }
220 
221  UNLOCK_D3D9();
222  return AdapterModeCount;
223 }
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
#define D3DERR_INVALIDCALL
#define UNLOCK_D3D9()
Definition: d3d9_impl.c:18
UINT GetDisplayFormatCount(D3DFORMAT Format, const D3DDISPLAYMODE *pSupportedDisplayModes, UINT NumDisplayModes)
Definition: adapter.c:406
#define LOCK_D3D9()
Definition: d3d9_impl.c:17
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8

◆ IDirect3D9Impl_GetAdapterMonitor()

static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor ( LPDIRECT3D9  iface,
UINT  Adapter 
)
static

Definition at line 872 of file d3d9_impl.c.

873 {
874  HMONITOR hAdapterMonitor = NULL;
875 
877  LOCK_D3D9();
878 
879  if (Adapter < This->NumDisplayAdapters)
880  {
881  hAdapterMonitor = GetAdapterMonitor(This->DisplayAdapters[Adapter].szDeviceName);
882  }
883  else
884  {
885  DPRINT1("Invalid Adapter number specified");
886  }
887 
888  UNLOCK_D3D9();
889  return hAdapterMonitor;
890 }
HMONITOR GetAdapterMonitor(LPCSTR lpszDeviceName)
Definition: adapter.c:393
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
smooth NULL
Definition: ftsmooth.c:416
#define UNLOCK_D3D9()
Definition: d3d9_impl.c:18
#define LOCK_D3D9()
Definition: d3d9_impl.c:17
#define DPRINT1
Definition: precomp.h:8

◆ IDirect3D9Impl_GetDeviceCaps()

static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps ( LPDIRECT3D9  iface,
UINT  Adapter,
D3DDEVTYPE  DeviceType,
D3DCAPS9 pCaps 
)
static

Definition at line 827 of file d3d9_impl.c.

828 {
829  HRESULT hResult;
831  LOCK_D3D9();
832 
833  if (Adapter >= This->NumDisplayAdapters)
834  {
835  DPRINT1("Invalid Adapter number specified");
836  UNLOCK_D3D9();
837  return D3DERR_INVALIDCALL;
838  }
839 
840  if (NULL == pCaps)
841  {
842  DPRINT1("Invalid pCaps parameter specified");
843  UNLOCK_D3D9();
844  return D3DERR_INVALIDCALL;
845  }
846 
847  hResult = GetAdapterCaps(&This->DisplayAdapters[Adapter], DeviceType, pCaps);
848 
849  UNLOCK_D3D9();
850  return hResult;
851 }
DeviceType
Definition: mmdrv.h:41
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
#define D3DERR_INVALIDCALL
smooth NULL
Definition: ftsmooth.c:416
#define UNLOCK_D3D9()
Definition: d3d9_impl.c:18
LONG HRESULT
Definition: typedefs.h:79
#define LOCK_D3D9()
Definition: d3d9_impl.c:17
HRESULT GetAdapterCaps(const LPDIRECT3D9_DISPLAYADAPTER pDisplayAdapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pDstCaps)
Definition: adapter.c:240
#define DPRINT1
Definition: precomp.h:8

◆ IDirect3D9Impl_QueryInterface()

static HRESULT WINAPI IDirect3D9Impl_QueryInterface ( LPDIRECT3D9  iface,
REFIID  riid,
LPVOID ppvObject 
)
static

Definition at line 30 of file d3d9_impl.c.

31 {
33 
34  if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirect3D9))
35  {
36  IUnknown_AddRef(iface);
37  *ppvObject = &This->lpVtbl;
38  return S_OK;
39  }
40 
41  *ppvObject = NULL;
42  return E_NOINTERFACE;
43 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
smooth NULL
Definition: ftsmooth.c:416
const GUID IID_IUnknown
REFIID LPVOID * ppvObject
Definition: precomp.h:44
#define S_OK
Definition: intsafe.h:51
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ IDirect3D9Impl_RegisterSoftwareDevice()

static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice ( LPDIRECT3D9  iface,
void pInitializeFunction 
)
static

Definition at line 70 of file d3d9_impl.c.

71 {
73 
74  return D3D_OK;
75 }
#define D3D_OK
Definition: d3d.h:106
#define UNIMPLEMENTED
Definition: debug.h:115

◆ IDirect3D9Impl_Release()

static ULONG WINAPI IDirect3D9Impl_Release ( LPDIRECT3D9  iface)
static

Definition at line 53 of file d3d9_impl.c.

54 {
56  ULONG ref = InterlockedDecrement(&This->lRefCnt);
57 
58  if (ref == 0)
59  {
60  EnterCriticalSection(&This->d3d9_cs);
61  /* TODO: Free resources here */
62  LeaveCriticalSection(&This->d3d9_cs);
64  }
65 
66  return ref;
67 }
VOID AlignedFree(IN OUT LPVOID pObject)
Definition: d3d9_helpers.c:130
static LPDIRECT3D9_INT IDirect3D9ToImpl(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:21
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ IDirect3D9ToImpl()

Variable Documentation

◆ Direct3D9_Vtbl

IDirect3D9Vtbl Direct3D9_Vtbl
Initial value:
=
{
}
static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9 iface, void *pInitializeFunction)
Definition: d3d9_impl.c:70
static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9 iface, UINT Adapter, D3DDISPLAYMODE *pMode)
Definition: d3d9_impl.c:330
static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:53
HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9 iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier)
Definition: d3d9_impl.c:130
static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE *pMode)
Definition: d3d9_impl.c:257
static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface, UINT Adapter)
Definition: d3d9_impl.c:872
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels)
Definition: d3d9_impl.c:638
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat)
Definition: d3d9_impl.c:755
static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps)
Definition: d3d9_impl.c:827
static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:45
static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
Definition: d3d9_impl.c:684
static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviourFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, struct IDirect3DDevice9 **ppReturnedDeviceInterface)
Definition: d3d9_impl.c:932
static UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9 iface)
Definition: d3d9_impl.c:90
static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9 iface, REFIID riid, LPVOID *ppvObject)
Definition: d3d9_impl.c:30
static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format)
Definition: d3d9_impl.c:192
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed)
Definition: d3d9_impl.c:391
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat)
Definition: d3d9_impl.c:488

Definition at line 1028 of file d3d9_impl.c.

Referenced by CreateD3D9().