static HRESULT WINAPI d3dadapter9_CreateDeviceEx( struct d3dadapter9 *This, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode, IDirect3DDevice9Ex **ppReturnedDeviceInterface ) { ID3DPresentGroup *present; HRESULT hr; SDL_Window* sdl_win = (SDL_Window*)hFocusWindow; if (Adapter >= d3dadapter9_GetAdapterCount(This)) { WARN("Adapter %u does not exist.\n", Adapter); return D3DERR_INVALIDCALL; } if (!sdl_win) { ERR("no SDL_Window specified\n"); return D3DERR_INVALIDCALL; } { UINT nparams = 1; UINT ordinal = 0; hr = dri3_create_present_group(sdl_win, ordinal, pPresentationParameters, nparams, &present); } if (FAILED(hr)) { WARN("Failed to create PresentGroup.\n"); return hr; } if (This->ex) { hr = ADAPTER_PROC(CreateDeviceEx, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, (IDirect3D9Ex *)This, present, ppReturnedDeviceInterface); } else { /* CreateDevice on non-ex */ hr = ADAPTER_PROC(CreateDevice, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, (IDirect3D9 *)This, present, (IDirect3DDevice9 **)ppReturnedDeviceInterface); } if (FAILED(hr)) { WARN("ADAPTER_PROC failed.\n"); ID3DPresentGroup_Release(present); } return hr; }
static HRESULT WINAPI d3dadapter9_CheckDeviceFormatConversion( struct d3dadapter9 *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat ) { if (Adapter >= d3dadapter9_GetAdapterCount(This)) { return D3DERR_INVALIDCALL; } return ADAPTER_PROC(CheckDeviceFormatConversion, DeviceType, SourceFormat, TargetFormat); }
static HRESULT WINAPI d3dadapter9_CheckDepthStencilMatch( struct d3dadapter9 *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat ) { if (Adapter >= d3dadapter9_GetAdapterCount(This)) { return D3DERR_INVALIDCALL; } return ADAPTER_PROC(CheckDepthStencilMatch, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat); }
static HRESULT WINAPI d3dadapter9_CheckDeviceType( struct d3dadapter9 *This, UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed ) { if (Adapter >= d3dadapter9_GetAdapterCount(This)) { return D3DERR_INVALIDCALL; } return ADAPTER_PROC(CheckDeviceType, DevType, AdapterFormat, BackBufferFormat, bWindowed); }
static HRESULT WINAPI d3dadapter9_CheckDeviceMultiSampleType( struct d3dadapter9 *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels ) { if (Adapter >= d3dadapter9_GetAdapterCount(This)) { return D3DERR_INVALIDCALL; } return ADAPTER_PROC(CheckDeviceMultiSampleType, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels); }
static HRESULT WINAPI d3dadapter9_CheckDeviceFormat( struct d3dadapter9 *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat ) { if (Adapter >= d3dadapter9_GetAdapterCount(This)) { return D3DERR_INVALIDCALL; } return ADAPTER_PROC(CheckDeviceFormat, DeviceType, AdapterFormat, Usage, RType, CheckFormat); }
static HRESULT WINAPI d3dadapter9_GetAdapterIdentifier( struct d3dadapter9 *This, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier ) { HRESULT hr; if (Adapter >= d3dadapter9_GetAdapterCount(This)) { return D3DERR_INVALIDCALL; } hr = ADAPTER_PROC(GetAdapterIdentifier, Flags, pIdentifier); return hr; }
static HRESULT WINAPI d3dadapter9_GetAdapterIdentifier( struct d3dadapter9 *This, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier ) { HRESULT hr; HKEY regkey; if (Adapter >= d3dadapter9_GetAdapterCount(This)) { return D3DERR_INVALIDCALL; } hr = ADAPTER_PROC(GetAdapterIdentifier, Flags, pIdentifier); if (SUCCEEDED(hr)) { /* Override the driver provided DeviceName with what Wine provided */ ZeroMemory(pIdentifier->DeviceName, sizeof(pIdentifier->DeviceName)); if (!WideCharToMultiByte(CP_ACP, 0, ADAPTER_GROUP.devname, -1, pIdentifier->DeviceName, sizeof(pIdentifier->DeviceName), NULL, NULL)) { /* Wine does it */ return D3DERR_INVALIDCALL; } TRACE("DeviceName overriden: %s\n", pIdentifier->DeviceName); /* Override PCI IDs when wined3d registry keys are set */ if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Direct3D", ®key)) { DWORD type, data; DWORD size = sizeof(DWORD); if (!RegQueryValueExA(regkey, "VideoPciDeviceID", 0, &type, (BYTE *)&data, &size) && (type == REG_DWORD) && (size == sizeof(DWORD))) pIdentifier->DeviceId = data; if(size != sizeof(DWORD)) { ERR("VideoPciDeviceID is not a DWORD\n"); size = sizeof(DWORD); } if (!RegQueryValueExA(regkey, "VideoPciVendorID", 0, &type, (BYTE *)&data, &size) && (type == REG_DWORD) && (size == sizeof(DWORD))) pIdentifier->VendorId = data; if(size != sizeof(DWORD)) ERR("VideoPciVendorID is not a DWORD\n"); RegCloseKey(regkey); TRACE("DeviceId:VendorId overridden: %04X:%04X\n", pIdentifier->DeviceId, pIdentifier->VendorId); } } return hr; }
static HRESULT WINAPI d3dadapter9_GetDeviceCaps( struct d3dadapter9 *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps ) { HRESULT hr; if (Adapter >= d3dadapter9_GetAdapterCount(This)) { return D3DERR_INVALIDCALL; } hr = ADAPTER_PROC(GetDeviceCaps, DeviceType, pCaps); if (FAILED(hr)) { return hr; } pCaps->MasterAdapterOrdinal = 0; pCaps->AdapterOrdinalInGroup = 0; pCaps->NumberOfAdaptersInGroup = 1; return hr; }
static HRESULT WINAPI DECLSPEC_HOTPATCH d3dadapter9_CreateDeviceEx( struct d3dadapter9 *This, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode, IDirect3DDevice9Ex **ppReturnedDeviceInterface ) { ID3DPresentGroup *present; HRESULT hr; boolean no_window_changes; if (Adapter >= d3dadapter9_GetAdapterCount(This)) { WARN("Adapter %u does not exist.\n", Adapter); return D3DERR_INVALIDCALL; } { struct adapter_group *group = &ADAPTER_GROUP; unsigned nparams, ordinal; if (BehaviorFlags & D3DCREATE_ADAPTERGROUP_DEVICE) { nparams = group->noutputs; ordinal = 0; } else { nparams = 1; ordinal = Adapter - This->map[Adapter].master; } no_window_changes = !!(BehaviorFlags & D3DCREATE_NOWINDOWCHANGES); hr = present_create_present_group(This->gdi_display, group->devname, ordinal, hFocusWindow, pPresentationParameters, nparams, &present, This->ex, no_window_changes); } if (FAILED(hr)) { WARN("Failed to create PresentGroup.\n"); return hr; } if (This->ex) { hr = ADAPTER_PROC(CreateDeviceEx, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, (IDirect3D9Ex *)This, present, ppReturnedDeviceInterface); } else { /* CreateDevice on non-ex */ hr = ADAPTER_PROC(CreateDevice, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, (IDirect3D9 *)This, present, (IDirect3DDevice9 **)ppReturnedDeviceInterface); } if (FAILED(hr)) { WARN("ADAPTER_PROC failed.\n"); ID3DPresentGroup_Release(present); } /* Nine returns different vtables for Ex, non Ex and * if you use the multithread flag or not. This prevents * things like Steam overlay to work, in addition to the problem * that functions nine side are not recognized by wine as * hotpatch-able. If possible, we use our vtable wrapper, * which solves the problem described above. */ if (enable_device_vtable_wrapper()) (*ppReturnedDeviceInterface)->lpVtbl = get_device_vtable(); return hr; }