kernel32: Add a stub for GetCurrentProcessorNumberEx.
[wine.git] / dlls / d3d10_1 / d3d10_1_main.c
bloba619004cabbc0b0ea060c528c7f824f06b5ce0d8
1 /*
2 * Copyright 2014 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "config.h"
21 #include "wine/port.h"
22 #include "wine/debug.h"
24 #define COBJMACROS
25 #include "d3d10_1.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
29 HRESULT WINAPI D3D10CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapter,
30 UINT flags, void *unknown0, ID3D10Device **device);
32 #define WINE_D3D10_TO_STR(x) case x: return #x
34 static const char *debug_d3d10_driver_type(D3D10_DRIVER_TYPE driver_type)
36 switch (driver_type)
38 WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_HARDWARE);
39 WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_REFERENCE);
40 WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_NULL);
41 WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_SOFTWARE);
42 WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_WARP);
43 default:
44 FIXME("Unrecognized D3D10_DRIVER_TYPE %#x.\n", driver_type);
45 return "unrecognized";
49 static const char *debug_d3d10_feature_level(D3D10_FEATURE_LEVEL1 feature_level)
51 switch (feature_level)
53 WINE_D3D10_TO_STR(D3D10_FEATURE_LEVEL_10_0);
54 WINE_D3D10_TO_STR(D3D10_FEATURE_LEVEL_10_1);
55 WINE_D3D10_TO_STR(D3D10_FEATURE_LEVEL_9_1);
56 WINE_D3D10_TO_STR(D3D10_FEATURE_LEVEL_9_2);
57 WINE_D3D10_TO_STR(D3D10_FEATURE_LEVEL_9_3);
58 default:
59 FIXME("Unrecognized D3D10_FEATURE_LEVEL1 %#x.\n", feature_level);
60 return "unrecognized";
64 #undef WINE_D3D10_TO_STR
66 HRESULT WINAPI D3D10CreateDevice1(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type, HMODULE swrast,
67 UINT flags, D3D10_FEATURE_LEVEL1 hw_level, UINT sdk_version, ID3D10Device1 **device)
69 IDXGIFactory *factory;
70 HRESULT hr;
72 TRACE("adapter %p, driver_type %s, swrast %p, flags %#x, hw_level %s, sdk_version %d, device %p.\n",
73 adapter, debug_d3d10_driver_type(driver_type), swrast, flags,
74 debug_d3d10_feature_level(hw_level), sdk_version, device);
76 if (adapter)
78 IDXGIAdapter_AddRef(adapter);
79 if (FAILED(hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory)))
81 WARN("Failed to get dxgi factory, hr %#x.\n", hr);
82 return hr;
85 else
87 if (FAILED(hr = CreateDXGIFactory(&IID_IDXGIFactory, (void **)&factory)))
89 WARN("Failed to create dxgi factory, hr %#x.\n", hr);
90 return hr;
93 switch (driver_type)
95 case D3D10_DRIVER_TYPE_WARP:
96 FIXME("WARP driver not implemented, falling back to hardware.\n");
97 case D3D10_DRIVER_TYPE_HARDWARE:
99 if (FAILED(hr = IDXGIFactory_EnumAdapters(factory, 0, &adapter)))
101 WARN("No adapters found, hr %#x.\n", hr);
102 IDXGIFactory_Release(factory);
103 return hr;
105 break;
108 case D3D10_DRIVER_TYPE_NULL:
109 FIXME("NULL device not implemented, falling back to refrast.\n");
110 /* Fall through, for now. */
111 case D3D10_DRIVER_TYPE_REFERENCE:
113 HMODULE refrast;
115 if (!(refrast = LoadLibraryA("d3d10ref.dll")))
117 WARN("Failed to load refrast, returning E_FAIL.\n");
118 IDXGIFactory_Release(factory);
119 return E_FAIL;
121 hr = IDXGIFactory_CreateSoftwareAdapter(factory, refrast, &adapter);
122 FreeLibrary(refrast);
123 if (FAILED(hr))
125 WARN("Failed to create a software adapter, hr %#x.\n", hr);
126 IDXGIFactory_Release(factory);
127 return hr;
129 break;
132 case D3D10_DRIVER_TYPE_SOFTWARE:
134 if (!swrast)
136 WARN("Software device requested, but NULL swrast passed, returning E_FAIL.\n");
137 IDXGIFactory_Release(factory);
138 return E_FAIL;
140 if (FAILED(hr = IDXGIFactory_CreateSoftwareAdapter(factory, swrast, &adapter)))
142 WARN("Failed to create a software adapter, hr %#x.\n", hr);
143 IDXGIFactory_Release(factory);
144 return hr;
146 break;
149 default:
150 FIXME("Unhandled driver type %#x.\n", driver_type);
151 IDXGIFactory_Release(factory);
152 return E_FAIL;
156 FIXME("Ignoring feature level %s.\n", debug_d3d10_feature_level(hw_level));
158 hr = D3D10CoreCreateDevice(factory, adapter, flags, NULL, (ID3D10Device **)device);
159 IDXGIAdapter_Release(adapter);
160 IDXGIFactory_Release(factory);
161 if (FAILED(hr))
163 WARN("Failed to create a device, hr %#x.\n", hr);
164 return hr;
167 TRACE("Created device %p.\n", *device);
169 return hr;