4 * Copyright 2007 Andras Kovacs
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
25 #include "d3d10_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
29 /* At process attach */
30 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
32 TRACE("fdwReason=%d\n", fdwReason);
35 case DLL_PROCESS_ATTACH:
36 DisableThreadLibraryCalls( hInstDLL );
42 HRESULT WINAPI D3D10CreateDevice(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type,
43 HMODULE swrast, UINT flags, UINT sdk_version, ID3D10Device **device)
45 IDXGIFactory *factory;
48 TRACE("adapter %p, driver_type %s, swrast %p, flags %#x, sdk_version %d, device %p\n",
49 adapter, debug_d3d10_driver_type(driver_type), swrast, flags, sdk_version, device);
53 IDXGIAdapter_AddRef(adapter);
54 hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory);
57 WARN("Failed to get dxgi factory, returning %#x\n", hr);
63 hr = CreateDXGIFactory(&IID_IDXGIFactory, (void **)&factory);
66 WARN("Failed to create dxgi factory, returning %#x\n", hr);
72 case D3D10_DRIVER_TYPE_HARDWARE:
74 hr = IDXGIFactory_EnumAdapters(factory, 0, &adapter);
77 WARN("No adapters found, returning %#x\n", hr);
78 IDXGIFactory_Release(factory);
84 case D3D10_DRIVER_TYPE_NULL:
85 FIXME("NULL device not implemented, falling back to refrast\n");
86 case D3D10_DRIVER_TYPE_REFERENCE:
88 HMODULE refrast = LoadLibraryA("d3d10ref.dll");
91 WARN("Failed to load refrast, returning E_FAIL\n");
92 IDXGIFactory_Release(factory);
95 hr = IDXGIFactory_CreateSoftwareAdapter(factory, refrast, &adapter);
99 WARN("Failed to create a software adapter, returning %#x\n", hr);
100 IDXGIFactory_Release(factory);
106 case D3D10_DRIVER_TYPE_SOFTWARE:
110 WARN("Software device requested, but NULL swrast passed, returning E_FAIL\n");
111 IDXGIFactory_Release(factory);
114 hr = IDXGIFactory_CreateSoftwareAdapter(factory, swrast, &adapter);
117 WARN("Failed to create a software adapter, returning %#x\n", hr);
118 IDXGIFactory_Release(factory);
126 hr = D3D10CoreCreateDevice(factory, adapter, flags, 0, device);
127 IDXGIAdapter_Release(adapter);
128 IDXGIFactory_Release(factory);
131 WARN("Failed to create a device, returning %#x\n", hr);
135 TRACE("Created ID3D10Device %p\n", *device);
140 HRESULT WINAPI D3D10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type,
141 HMODULE swrast, UINT flags, UINT sdk_version, DXGI_SWAP_CHAIN_DESC *swapchain_desc,
142 IDXGISwapChain **swapchain, ID3D10Device **device)
144 IDXGIDevice *dxgi_device;
145 IDXGIFactory *factory;
148 TRACE("adapter %p, driver_type %s, swrast %p, flags %#x, sdk_version %d,\n"
149 "\tswapchain_desc %p, swapchain %p, device %p\n",
150 adapter, debug_d3d10_driver_type(driver_type), swrast, flags, sdk_version,
151 swapchain_desc, swapchain, device);
153 hr = D3D10CreateDevice(adapter, driver_type, swrast, flags, sdk_version, device);
156 WARN("Failed to create a device, returning %#x\n", hr);
161 TRACE("Created ID3D10Device %p\n", *device);
163 hr = ID3D10Device_QueryInterface(*device, &IID_IDXGIDevice, (void **)&dxgi_device);
166 ERR("Failed to get a dxgi device from the d3d10 device, returning %#x\n", hr);
167 ID3D10Device_Release(*device);
172 hr = IDXGIDevice_GetAdapter(dxgi_device, &adapter);
173 IDXGIDevice_Release(dxgi_device);
176 ERR("Failed to get the device adapter, returning %#x\n", hr);
177 ID3D10Device_Release(*device);
182 hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory);
183 IDXGIAdapter_Release(adapter);
186 ERR("Failed to get the adapter factory, returning %#x\n", hr);
187 ID3D10Device_Release(*device);
192 hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)*device, swapchain_desc, swapchain);
193 IDXGIFactory_Release(factory);
196 ID3D10Device_Release(*device);
199 WARN("Failed to create a swapchain, returning %#x\n", hr);
203 TRACE("Created IDXGISwapChain %p\n", *swapchain);