/** * It creates a Direct3D device usable for DXVA 2 */ static int D3dCreateDevice(vlc_va_t *va) { vlc_va_sys_t *sys = va->sys; /* */ LPDIRECT3D9 (WINAPI *Create9)(UINT SDKVersion); Create9 = (void *)GetProcAddress(sys->hd3d9_dll, "Direct3DCreate9"); if (!Create9) { msg_Err(va, "Cannot locate reference to Direct3DCreate9 ABI in DLL"); return VLC_EGENERIC; } /* */ LPDIRECT3D9 d3dobj; d3dobj = Create9(D3D_SDK_VERSION); if (!d3dobj) { msg_Err(va, "Direct3DCreate9 failed"); return VLC_EGENERIC; } sys->d3dobj = d3dobj; /* */ D3DADAPTER_IDENTIFIER9 *d3dai = &sys->d3dai; if (FAILED(IDirect3D9_GetAdapterIdentifier(sys->d3dobj, D3DADAPTER_DEFAULT, 0, d3dai))) { msg_Warn(va, "IDirect3D9_GetAdapterIdentifier failed"); ZeroMemory(d3dai, sizeof(*d3dai)); } /* */ D3DPRESENT_PARAMETERS *d3dpp = &sys->d3dpp; ZeroMemory(d3dpp, sizeof(*d3dpp)); d3dpp->Flags = D3DPRESENTFLAG_VIDEO; d3dpp->Windowed = TRUE; d3dpp->hDeviceWindow = NULL; d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp->MultiSampleType = D3DMULTISAMPLE_NONE; d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; d3dpp->BackBufferCount = 0; /* FIXME what to put here */ d3dpp->BackBufferFormat = D3DFMT_X8R8G8B8; /* FIXME what to put here */ d3dpp->BackBufferWidth = 0; d3dpp->BackBufferHeight = 0; d3dpp->EnableAutoDepthStencil = FALSE; /* Direct3D needs a HWND to create a device, even without using ::Present this HWND is used to alert Direct3D when there's a change of focus window. For now, use GetDesktopWindow, as it looks harmless */ LPDIRECT3DDEVICE9 d3ddev; if (FAILED(IDirect3D9_CreateDevice(d3dobj, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetDesktopWindow(), D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, d3dpp, &d3ddev))) { msg_Err(va, "IDirect3D9_CreateDevice failed"); return VLC_EGENERIC; } sys->d3ddev = d3ddev; return VLC_SUCCESS; }
static UINT D3D_FindAdapter(IDirect3D9 * d3d, SDL_VideoDisplay * display) { SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; UINT adapter, count; count = IDirect3D9_GetAdapterCount(d3d); for (adapter = 0; adapter < count; ++adapter) { HRESULT result; D3DADAPTER_IDENTIFIER9 info; char *name; result = IDirect3D9_GetAdapterIdentifier(d3d, adapter, 0, &info); if (FAILED(result)) { continue; } name = WIN_StringToUTF8(displaydata->DeviceName); if (SDL_strcmp(name, info.DeviceName) == 0) { SDL_free(name); return adapter; } SDL_free(name); } /* This should never happen, but just in case... */ return D3DADAPTER_DEFAULT; }
/** * It creates a DirectX video service */ static int hb_d3d_create_device( hb_va_dxva2_t *dxva2 ) { LPDIRECT3D9 (WINAPI *Create9)( UINT SDKVersion ); Create9 = (void*)GetProcAddress( dxva2->hd3d9_dll, TEXT( "Direct3DCreate9" )); if( !Create9 ) { hb_log( "dxva2:Cannot locate reference to Direct3DCreate9 ABI in DLL" ); return HB_WORK_ERROR; } LPDIRECT3D9 d3dobj; d3dobj = Create9( D3D_SDK_VERSION ); if( !d3dobj ) { hb_log( "dxva2:Direct3DCreate9 failed" ); return HB_WORK_ERROR; } dxva2->d3dobj = d3dobj; D3DADAPTER_IDENTIFIER9 *d3dai = &dxva2->d3dai; if( FAILED( IDirect3D9_GetAdapterIdentifier( dxva2->d3dobj, D3DADAPTER_DEFAULT, 0, d3dai ))) { hb_log( "dxva2:IDirect3D9_GetAdapterIdentifier failed" ); memset( d3dai, 0, sizeof(*d3dai)); } PROCGETSHELLWND GetShellWindow; HMODULE hUser32 = GetModuleHandle( "user32" ); GetShellWindow = (PROCGETSHELLWND) GetProcAddress( hUser32, "GetShellWindow" ); D3DPRESENT_PARAMETERS *d3dpp = &dxva2->d3dpp; memset( d3dpp, 0, sizeof(*d3dpp)); d3dpp->Flags = D3DPRESENTFLAG_VIDEO; d3dpp->Windowed = TRUE; d3dpp->hDeviceWindow = NULL; d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp->MultiSampleType = D3DMULTISAMPLE_NONE; d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; d3dpp->BackBufferCount = 0; /* FIXME what to put here */ d3dpp->BackBufferFormat = D3DFMT_X8R8G8B8; /* FIXME what to put here */ d3dpp->BackBufferWidth = 0; d3dpp->BackBufferHeight = 0; d3dpp->EnableAutoDepthStencil = FALSE; LPDIRECT3DDEVICE9 d3ddev; //if (FAILED(IDirect3D9_CreateDevice(d3dobj, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetShellWindow(), D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, d3dpp, &d3ddev))) if( FAILED( IDirect3D9_CreateDevice( d3dobj, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetShellWindow(), D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, d3dpp, &d3ddev ))) { hb_log( "dxva2:IDirect3D9_CreateDevice failed" ); return HB_WORK_ERROR; } dxva2->d3ddev = d3ddev; return HB_WORK_OK; }
static void get_display_device_id(WCHAR *szIdentifierBuffer) { static const WCHAR szNA[] = {'n','/','a',0}; HRESULT hr = E_FAIL; HMODULE d3d9_handle; IDirect3D9 *(WINAPI *pDirect3DCreate9)(UINT) = NULL; IDirect3D9 *pD3d = NULL; D3DADAPTER_IDENTIFIER9 adapter_ident; /* Retrieves the display device identifier from the d3d9 implementation. */ d3d9_handle = LoadLibraryA("d3d9.dll"); if(d3d9_handle) pDirect3DCreate9 = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9"); if(pDirect3DCreate9) pD3d = pDirect3DCreate9(D3D_SDK_VERSION); if(pD3d) hr = IDirect3D9_GetAdapterIdentifier(pD3d, D3DADAPTER_DEFAULT, 0, &adapter_ident); if(SUCCEEDED(hr)) { StringFromGUID2(&adapter_ident.DeviceIdentifier, szIdentifierBuffer, 39); } else { memcpy(szIdentifierBuffer, szNA, sizeof(szNA)); } if (pD3d) IDirect3D9_Release(pD3d); if (d3d9_handle) FreeLibrary(d3d9_handle); }
/** * It creates a Direct3D device and the associated resources. */ static int Direct3DOpen(vout_display_t *vd, video_format_t *fmt) { vout_display_sys_t *sys = vd->sys; LPDIRECT3D9 d3dobj = sys->d3dobj; if (Direct3DFillPresentationParameters(vd)) return VLC_EGENERIC; // Create the D3DDevice LPDIRECT3DDEVICE9 d3ddev; UINT AdapterToUse = D3DADAPTER_DEFAULT; D3DDEVTYPE DeviceType = D3DDEVTYPE_HAL; #ifndef NDEBUG // Look for 'NVIDIA PerfHUD' adapter // If it is present, override default settings for (UINT Adapter=0; Adapter< IDirect3D9_GetAdapterCount(d3dobj); ++Adapter) { D3DADAPTER_IDENTIFIER9 Identifier; HRESULT Res; Res = IDirect3D9_GetAdapterIdentifier(d3dobj,Adapter,0,&Identifier); if (strstr(Identifier.Description,"PerfHUD") != 0) { AdapterToUse = Adapter; DeviceType = D3DDEVTYPE_REF; break; } } #endif HRESULT hr = IDirect3D9_CreateDevice(d3dobj, AdapterToUse, DeviceType, sys->hvideownd, D3DCREATE_SOFTWARE_VERTEXPROCESSING| D3DCREATE_MULTITHREADED, &sys->d3dpp, &d3ddev); if (FAILED(hr)) { msg_Err(vd, "Could not create the D3D device! (hr=0x%lX)", hr); return VLC_EGENERIC; } sys->d3ddev = d3ddev; UpdateRects(vd, NULL, NULL, true); if (Direct3DCreateResources(vd, fmt)) { msg_Err(vd, "Failed to allocate resources"); return VLC_EGENERIC; } /* Change the window title bar text */ EventThreadUpdateTitle(sys->event, VOUT_TITLE " (Direct3D output)"); msg_Dbg(vd, "Direct3D device adapter successfully initialized"); return VLC_SUCCESS; }
void fullscreen_getmodes_dx9(void) { int adapter, numAdapter, mode, numAdapterModes; D3DADAPTER_IDENTIFIER9 d3didentifier; D3DDISPLAYMODE displayMode; DirectDrawDeviceList *new_device; DirectDrawDeviceList *search_device; DirectDrawModeList *new_mode; DirectDrawModeList *search_mode; numAdapter = 0; while (D3D_OK == IDirect3D9_GetAdapterIdentifier(d3d, numAdapter, 0, &d3didentifier)) { new_device = lib_malloc(sizeof(DirectDrawDeviceList)); new_device->next = NULL; new_device->desc = util_concat(d3didentifier.DeviceName, " - ", d3didentifier.Description, NULL); if (dx9_devices == NULL) { dx9_devices = new_device; } else { search_device = dx9_devices; while (search_device->next != NULL) { search_device = search_device->next; } search_device->next = new_device; } numAdapter++; } for (adapter = 0; adapter < numAdapter; adapter++) { numAdapterModes = IDirect3D9_GetAdapterModeCount(d3d, adapter, D3DFMT_X8R8G8B8); for (mode = 0; mode < numAdapterModes; mode++) { if (S_OK == IDirect3D9_EnumAdapterModes(d3d, adapter, D3DFMT_X8R8G8B8, mode, &displayMode)) { new_mode = lib_malloc(sizeof(DirectDrawModeList)); new_mode->next = NULL; new_mode->devicenumber = adapter; new_mode->width = displayMode.Width; new_mode->height = displayMode.Height; new_mode->bitdepth = 32; new_mode->refreshrate = displayMode.RefreshRate; if (dx9_modes == NULL) { dx9_modes = new_mode; } else { search_mode = dx9_modes; while (search_mode->next != NULL) { search_mode = search_mode->next; } search_mode->next = new_mode; } } } } }
static HRESULT get_adapter_identifier(base *d3dptr, UINT adapter, DWORD flags, adapter_identifier *identifier) { IDirect3D9 *d3d9 = (IDirect3D9 *)d3dptr->d3dobj; D3DADAPTER_IDENTIFIER9 id; HRESULT result = IDirect3D9_GetAdapterIdentifier(d3d9, adapter, flags, &id); memcpy(identifier->Driver, id.Driver, sizeof(identifier->Driver)); memcpy(identifier->Description, id.Description, sizeof(identifier->Description)); identifier->DriverVersion = id.DriverVersion; identifier->VendorId = id.VendorId; identifier->DeviceId = id.DeviceId; identifier->SubSysId = id.SubSysId; identifier->Revision = id.Revision; identifier->DeviceIdentifier = id.DeviceIdentifier; identifier->WHQLLevel = id.WHQLLevel; return result; }
int SDL_Direct3D9GetAdapterIndex( int displayIndex ) { void *pD3DDLL; IDirect3D9 *pD3D; if (!D3D_LoadDLL(&pD3DDLL, &pD3D)) { SDL_SetError("Unable to create Direct3D interface"); return D3DADAPTER_DEFAULT; } else { SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex); int adapterIndex = D3DADAPTER_DEFAULT; if (!pData) { SDL_SetError("Invalid display index"); adapterIndex = -1; /* make sure we return something invalid */ } else { char *displayName = WIN_StringToUTF8(pData->DeviceName); unsigned int count = IDirect3D9_GetAdapterCount(pD3D); unsigned int i; for (i=0; i<count; i++) { D3DADAPTER_IDENTIFIER9 id; IDirect3D9_GetAdapterIdentifier(pD3D, i, 0, &id); if (SDL_strcmp(id.DeviceName, displayName) == 0) { adapterIndex = i; break; } } SDL_free(displayName); } /* free up the D3D stuff we inited */ IDirect3D9_Release(pD3D); SDL_UnloadObject(pD3DDLL); return adapterIndex; } }
static BOOL InitializeDialog(HWND hwndDlg, PDISPLAY_DEVICEW pDispDevice) { WCHAR szText[100]; WCHAR szFormat[30]; HKEY hKey; HWND hDlgCtrls[5]; DWORD dwMemory; DEVMODEW DevMode; IDirect3D9 * ppObj = NULL; D3DADAPTER_IDENTIFIER9 Identifier; HRESULT hResult; szText[0] = L'\0'; /* fix wine */ //ppObj = Direct3DCreate9(D3D_SDK_VERSION); if (ppObj) { hResult = IDirect3D9_GetAdapterIdentifier(ppObj, D3DADAPTER_DEFAULT , 2/*D3DENUM_WHQL_LEVEL*/, &Identifier); if (hResult == D3D_OK) { if (Identifier.WHQLLevel) { /* adapter is WHQL certified */ LoadStringW(hInst, IDS_OPTION_YES, szText, sizeof(szText)/sizeof(WCHAR)); } else { LoadStringW(hInst, IDS_OPTION_NO, szText, sizeof(szText)/sizeof(WCHAR)); } } IDirect3D9_Release(ppObj); } else { LoadStringW(hInst, IDS_DEVICE_STATUS_UNKNOWN, szText, sizeof(szText)/sizeof(WCHAR)); } szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0'; SendDlgItemMessageW(hwndDlg, IDC_STATIC_ADAPTER_LOGO, WM_SETTEXT, 0, (LPARAM)szText); if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, &pDispDevice->DeviceKey[18], 0, KEY_READ, &hKey) != ERROR_SUCCESS) return FALSE; if (GetRegValue(hKey, NULL, L"HardwareInformation.ChipType", REG_BINARY, szText, sizeof(szText))) { /* set chip type */ SendDlgItemMessageW(hwndDlg, IDC_STATIC_ADAPTER_CHIP, WM_SETTEXT, 0, (LPARAM)szText); } if (GetRegValue(hKey, NULL, L"HardwareInformation.DacType", REG_BINARY, szText, sizeof(szText))) { /* set DAC type */ SendDlgItemMessageW(hwndDlg, IDC_STATIC_ADAPTER_DAC, WM_SETTEXT, 0, (LPARAM)szText); } if (GetRegValue(hKey, NULL, L"HardwareInformation.MemorySize", REG_BINARY, (LPWSTR)&dwMemory, sizeof(dwMemory))) { /* set chip memory size */ if (dwMemory > (1048576)) { /* buggy ATI driver requires that */ dwMemory /= 1048576; } szFormat[0] = L'\0'; if (LoadStringW(hInst, IDS_FORMAT_ADAPTER_MEM, szFormat, sizeof(szFormat)/sizeof(WCHAR))) szFormat[(sizeof(szFormat)/sizeof(WCHAR))-1] = L'\0'; wsprintfW(szText, szFormat, dwMemory); SendDlgItemMessageW(hwndDlg, IDC_STATIC_ADAPTER_MEM, WM_SETTEXT, 0, (LPARAM)szText); } /* retrieve current display mode */ DevMode.dmSize = sizeof(DEVMODEW); if (EnumDisplaySettingsW(pDispDevice->DeviceName, ENUM_CURRENT_SETTINGS, &DevMode)) { szFormat[0] = L'\0'; if (LoadStringW(hInst, IDS_FORMAT_ADAPTER_MODE, szFormat, sizeof(szFormat)/sizeof(WCHAR))) szFormat[(sizeof(szFormat)/sizeof(WCHAR))-1] = L'\0'; wsprintfW(szText, szFormat, DevMode.dmPelsWidth, DevMode.dmPelsHeight, DevMode.dmBitsPerPel, DevMode.dmDisplayFrequency); SendDlgItemMessageW(hwndDlg, IDC_STATIC_ADAPTER_MODE, WM_SETTEXT, 0, (LPARAM)szText); } /* query attached monitor */ wcscpy(szText, pDispDevice->DeviceName); ZeroMemory(pDispDevice, sizeof(DISPLAY_DEVICEW)); pDispDevice->cb = sizeof(DISPLAY_DEVICEW); if (EnumDisplayDevicesW(szText, 0, pDispDevice, 0)) { /* set monitor name */ SendDlgItemMessageW(hwndDlg, IDC_STATIC_ADAPTER_MONITOR, WM_SETTEXT, 0, (LPARAM)pDispDevice->DeviceString); } hDlgCtrls[0] = GetDlgItem(hwndDlg, IDC_STATIC_ADAPTER_ID); hDlgCtrls[1] = GetDlgItem(hwndDlg, IDC_STATIC_ADAPTER_VENDOR); hDlgCtrls[2] = GetDlgItem(hwndDlg, IDC_STATIC_ADAPTER_DRIVER); hDlgCtrls[3] = GetDlgItem(hwndDlg, IDC_STATIC_ADAPTER_VERSION); hDlgCtrls[4] = GetDlgItem(hwndDlg, IDC_STATIC_ADAPTER_DATE); SetDeviceDetails(hDlgCtrls, &GUID_DEVCLASS_DISPLAY, NULL); return TRUE; }
void initD3D9() { #ifdef __WIN32__ static HMODULE d3d9_handle = 0; IDirect3D9 *(__stdcall * d3d9_create)(UINT SDKVersion) = NULL; D3DPRESENT_PARAMETERS present_parameters; D3DADAPTER_IDENTIFIER9 identifier; HRESULT hr; HWND hwnd; d3d9_handle = LoadLibraryA("d3d9.dll"); if (!d3d9_handle) { fprintf(stderr, "Could not load d3d9.dll\n"); return; } d3d9_create = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9"); if (!d3d9_create) { fprintf(stderr, "Could not get address of Direct3DCreate9\n"); return; } gD3D9Ptr = d3d9_create(D3D_SDK_VERSION); if (!gD3D9Ptr) { fprintf(stderr, "could not create D3D9\n"); return; } hwnd = createWindowWin32(); ZeroMemory(&present_parameters, sizeof(present_parameters)); present_parameters.Windowed = FALSE; present_parameters.hDeviceWindow = hwnd; present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; present_parameters.BackBufferWidth = DEFAULT_WINDOW_WIDTH;; present_parameters.BackBufferHeight = DEFAULT_WINDOW_HEIGHT; present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8; present_parameters.EnableAutoDepthStencil = TRUE; present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8; present_parameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; memset(&identifier, 0, sizeof(identifier)); IDirect3D9_GetAdapterIdentifier(gD3D9Ptr, 0, 0, &identifier); printf("Driver string: \"%s\"\n", identifier.Driver); printf("Description string: \"%s\"\n", identifier.Description); printf("Device name string: \"%s\"\n", identifier.DeviceName); printf("Driver version %d.%d.%d.%d\n", HIWORD(identifier.DriverVersion.HighPart), LOWORD(identifier.DriverVersion.HighPart), HIWORD(identifier.DriverVersion.LowPart), LOWORD(identifier.DriverVersion.LowPart)); hr = IDirect3D9_CreateDevice(gD3D9Ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, present_parameters.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &gDevicePtr); if(FAILED(hr)) { present_parameters.AutoDepthStencilFormat = D3DFMT_D16; hr = IDirect3D9_CreateDevice(gD3D9Ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, present_parameters.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &gDevicePtr); if(FAILED(hr)) { hr = IDirect3D9_CreateDevice(gD3D9Ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, present_parameters.hDeviceWindow, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &gDevicePtr); } } if (FAILED(hr) || !gDevicePtr) { fprintf(stderr, "Creating the device failed\n"); return; } /* Not yet being used */ if (0) createDummyTexD3D9(); createShadersD3D9(); createVertexBuffersD3D9(); IDirect3DDevice9_GetBackBuffer(gDevicePtr, 0, 0, D3DBACKBUFFER_TYPE_MONO, &gDeviceBackBufferPtr); ShowWindow(hwnd, TRUE); UpdateWindow(hwnd); while (!gIsQuitting) { MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } displayD3D9(); } #else fprintf(stderr, "ERROR: D3D9 not supported on this platform\n"); #endif }
HRESULT D3D9_CreateDevice(vlc_object_t *o, d3d9_handle_t *hd3d, HWND hwnd, const video_format_t *source, d3d9_device_t *out) { HRESULT hr; UINT AdapterToUse = D3DADAPTER_DEFAULT; D3DDEVTYPE DeviceType = D3DDEVTYPE_HAL; #ifndef NDEBUG // Look for 'NVIDIA PerfHUD' adapter // If it is present, override default settings for (UINT Adapter=0; Adapter< IDirect3D9_GetAdapterCount(hd3d->obj); ++Adapter) { D3DADAPTER_IDENTIFIER9 Identifier; hr = IDirect3D9_GetAdapterIdentifier(hd3d->obj,Adapter,0,&Identifier); if (SUCCEEDED(hr) && strstr(Identifier.Description,"PerfHUD") != 0) { AdapterToUse = Adapter; DeviceType = D3DDEVTYPE_REF; break; } } #endif /* ** Get device capabilities */ ZeroMemory(&out->caps, sizeof(out->caps)); hr = IDirect3D9_GetDeviceCaps(hd3d->obj, AdapterToUse, DeviceType, &out->caps); if (FAILED(hr)) { msg_Err(o, "Could not read adapter capabilities. (hr=0x%0lx)", hr); return hr; } msg_Dbg(o, "D3D9 device caps 0x%0lX / 0x%0lX", out->caps.DevCaps, out->caps.DevCaps2); /* TODO: need to test device capabilities and select the right render function */ if (!(out->caps.DevCaps2 & D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES)) { msg_Err(o, "Device does not support stretching from textures."); return E_INVALIDARG; } if ( source->i_width > out->caps.MaxTextureWidth || source->i_height > out->caps.MaxTextureHeight ) { msg_Err(o, "Textures too large %ux%u max possible: %ux%u", source->i_width, source->i_height, (unsigned) out->caps.MaxTextureWidth, (unsigned) out->caps.MaxTextureHeight); return E_INVALIDARG; } out->adapterId = AdapterToUse; out->hwnd = hwnd; if (D3D9_FillPresentationParameters(hd3d, source, out)) { msg_Err(o, "Could not presentation parameters"); return E_INVALIDARG; } /* */ D3DADAPTER_IDENTIFIER9 d3dai; if (FAILED(IDirect3D9_GetAdapterIdentifier(hd3d->obj, AdapterToUse,0, &d3dai))) { msg_Warn(o, "IDirect3D9_GetAdapterIdentifier failed"); } else { msg_Dbg(o, "Direct3d9 Device: %s %lx %lx %lx", d3dai.Description, d3dai.VendorId, d3dai.DeviceId, d3dai.Revision ); } DWORD thread_modes[] = { D3DCREATE_MULTITHREADED, 0 }; DWORD vertex_modes[] = { D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE, D3DCREATE_HARDWARE_VERTEXPROCESSING, D3DCREATE_MIXED_VERTEXPROCESSING, D3DCREATE_SOFTWARE_VERTEXPROCESSING }; for (size_t t = 0; t < ARRAY_SIZE(thread_modes); t++) { for (size_t v = 0; v < ARRAY_SIZE(vertex_modes); v++) { DWORD creationFlags = thread_modes[t] | vertex_modes[v]; if (hd3d->use_ex) hr = IDirect3D9Ex_CreateDeviceEx(hd3d->objex, AdapterToUse, DeviceType, hwnd, creationFlags, &out->pp, NULL, &out->devex); else hr = IDirect3D9_CreateDevice(hd3d->obj, AdapterToUse, DeviceType, hwnd, creationFlags, &out->pp, &out->dev); if (SUCCEEDED(hr)) { out->owner = true; return hr; } } } msg_Err(o, "failed to create the D3D9%s device %d/%d. (hr=0x%lX)", hd3d->use_ex?"Ex":"", AdapterToUse, DeviceType, hr); return hr; }