kernel32/tests: Ensure that pipe tests read the full pipe content.
[wine/wine-gecko.git] / dlls / d3d10 / d3d10_main.c
blob12c97cec4ecf7a91ab84356407dafeaa445aac22
1 /*
2 * Direct3D 10
4 * Copyright 2007 Andras Kovacs
5 * Copyright 2009 Henri Verbeet for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
24 #include "wine/port.h"
26 #include "d3d10_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
30 HRESULT WINAPI D3D10CreateDevice(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type,
31 HMODULE swrast, UINT flags, UINT sdk_version, ID3D10Device **device)
33 IDXGIFactory *factory;
34 HRESULT hr;
36 TRACE("adapter %p, driver_type %s, swrast %p, flags %#x, sdk_version %d, device %p\n",
37 adapter, debug_d3d10_driver_type(driver_type), swrast, flags, sdk_version, device);
39 if (adapter)
41 IDXGIAdapter_AddRef(adapter);
42 hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory);
43 if (FAILED(hr))
45 WARN("Failed to get dxgi factory, returning %#x\n", hr);
46 return hr;
49 else
51 hr = CreateDXGIFactory(&IID_IDXGIFactory, (void **)&factory);
52 if (FAILED(hr))
54 WARN("Failed to create dxgi factory, returning %#x\n", hr);
55 return hr;
58 switch(driver_type)
60 case D3D10_DRIVER_TYPE_HARDWARE:
62 hr = IDXGIFactory_EnumAdapters(factory, 0, &adapter);
63 if (FAILED(hr))
65 WARN("No adapters found, returning %#x\n", hr);
66 IDXGIFactory_Release(factory);
67 return hr;
69 break;
72 case D3D10_DRIVER_TYPE_NULL:
73 FIXME("NULL device not implemented, falling back to refrast\n");
74 /* fall through, for now */
75 case D3D10_DRIVER_TYPE_REFERENCE:
77 HMODULE refrast = LoadLibraryA("d3d10ref.dll");
78 if (!refrast)
80 WARN("Failed to load refrast, returning E_FAIL\n");
81 IDXGIFactory_Release(factory);
82 return E_FAIL;
84 hr = IDXGIFactory_CreateSoftwareAdapter(factory, refrast, &adapter);
85 FreeLibrary(refrast);
86 if (FAILED(hr))
88 WARN("Failed to create a software adapter, returning %#x\n", hr);
89 IDXGIFactory_Release(factory);
90 return hr;
92 break;
95 case D3D10_DRIVER_TYPE_SOFTWARE:
97 if (!swrast)
99 WARN("Software device requested, but NULL swrast passed, returning E_FAIL\n");
100 IDXGIFactory_Release(factory);
101 return E_FAIL;
103 hr = IDXGIFactory_CreateSoftwareAdapter(factory, swrast, &adapter);
104 if (FAILED(hr))
106 WARN("Failed to create a software adapter, returning %#x\n", hr);
107 IDXGIFactory_Release(factory);
108 return hr;
110 break;
113 default:
114 FIXME("Unhandled driver type %#x.\n", driver_type);
115 IDXGIFactory_Release(factory);
116 return E_FAIL;
120 hr = D3D10CoreCreateDevice(factory, adapter, flags, NULL, device);
121 IDXGIAdapter_Release(adapter);
122 IDXGIFactory_Release(factory);
123 if (FAILED(hr))
125 WARN("Failed to create a device, returning %#x\n", hr);
126 return hr;
129 TRACE("Created ID3D10Device %p\n", *device);
131 return hr;
134 HRESULT WINAPI D3D10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type,
135 HMODULE swrast, UINT flags, UINT sdk_version, DXGI_SWAP_CHAIN_DESC *swapchain_desc,
136 IDXGISwapChain **swapchain, ID3D10Device **device)
138 IDXGIDevice *dxgi_device;
139 IDXGIFactory *factory;
140 HRESULT hr;
142 TRACE("adapter %p, driver_type %s, swrast %p, flags %#x, sdk_version %d,\n"
143 "\tswapchain_desc %p, swapchain %p, device %p\n",
144 adapter, debug_d3d10_driver_type(driver_type), swrast, flags, sdk_version,
145 swapchain_desc, swapchain, device);
147 hr = D3D10CreateDevice(adapter, driver_type, swrast, flags, sdk_version, device);
148 if (FAILED(hr))
150 WARN("Failed to create a device, returning %#x\n", hr);
151 *device = NULL;
152 return hr;
155 TRACE("Created ID3D10Device %p\n", *device);
157 hr = ID3D10Device_QueryInterface(*device, &IID_IDXGIDevice, (void **)&dxgi_device);
158 if (FAILED(hr))
160 ERR("Failed to get a dxgi device from the d3d10 device, returning %#x\n", hr);
161 ID3D10Device_Release(*device);
162 *device = NULL;
163 return hr;
166 hr = IDXGIDevice_GetAdapter(dxgi_device, &adapter);
167 IDXGIDevice_Release(dxgi_device);
168 if (FAILED(hr))
170 ERR("Failed to get the device adapter, returning %#x\n", hr);
171 ID3D10Device_Release(*device);
172 *device = NULL;
173 return hr;
176 hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory);
177 IDXGIAdapter_Release(adapter);
178 if (FAILED(hr))
180 ERR("Failed to get the adapter factory, returning %#x\n", hr);
181 ID3D10Device_Release(*device);
182 *device = NULL;
183 return hr;
186 hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)*device, swapchain_desc, swapchain);
187 IDXGIFactory_Release(factory);
188 if (FAILED(hr))
190 ID3D10Device_Release(*device);
191 *device = NULL;
193 WARN("Failed to create a swapchain, returning %#x\n", hr);
194 return hr;
197 TRACE("Created IDXGISwapChain %p\n", *swapchain);
199 return S_OK;
202 HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT flags,
203 ID3D10Device *device, ID3D10EffectPool *effect_pool, ID3D10Effect **effect)
205 struct d3d10_effect *object;
206 HRESULT hr;
208 FIXME("data %p, data_size %lu, flags %#x, device %p, effect_pool %p, effect %p stub!\n",
209 data, data_size, flags, device, effect_pool, effect);
211 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
212 if (!object)
214 ERR("Failed to allocate D3D10 effect object memory\n");
215 return E_OUTOFMEMORY;
218 object->ID3D10Effect_iface.lpVtbl = &d3d10_effect_vtbl;
219 object->refcount = 1;
220 ID3D10Device_AddRef(device);
221 object->device = device;
223 hr = d3d10_effect_parse(object, data, data_size);
224 if (FAILED(hr))
226 ERR("Failed to parse effect\n");
227 IUnknown_Release(&object->ID3D10Effect_iface);
228 return hr;
231 *effect = &object->ID3D10Effect_iface;
233 TRACE("Created ID3D10Effect %p\n", object);
235 return S_OK;
238 HRESULT WINAPI D3D10CompileEffectFromMemory(void *data, SIZE_T data_size, const char *filename,
239 const D3D10_SHADER_MACRO *defines, ID3D10Include *include, UINT hlsl_flags, UINT fx_flags,
240 ID3D10Blob **effect, ID3D10Blob **errors)
242 FIXME("data %p, data_size %lu, filename %s, defines %p, include %p,"
243 " hlsl_flags %#x, fx_flags %#x, effect %p, errors %p stub!\n",
244 data, data_size, wine_dbgstr_a(filename), defines, include,
245 hlsl_flags, fx_flags, effect, errors);
247 if (effect)
248 *effect = NULL;
249 if (errors)
250 *errors = NULL;
252 return E_NOTIMPL;
256 const char * WINAPI D3D10GetVertexShaderProfile(ID3D10Device *device)
258 FIXME("device %p stub!\n", device);
260 return "vs_4_0";
263 const char * WINAPI D3D10GetGeometryShaderProfile(ID3D10Device *device)
265 FIXME("device %p stub!\n", device);
267 return "gs_4_0";
270 const char * WINAPI D3D10GetPixelShaderProfile(ID3D10Device *device)
272 FIXME("device %p stub!\n", device);
274 return "ps_4_0";
277 HRESULT WINAPI D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10ShaderReflection **reflector)
279 struct d3d10_shader_reflection *object;
281 FIXME("data %p, data_size %lu, reflector %p stub!\n", data, data_size, reflector);
283 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
284 if (!object)
286 ERR("Failed to allocate D3D10 shader reflection object memory\n");
287 return E_OUTOFMEMORY;
290 object->ID3D10ShaderReflection_iface.lpVtbl = &d3d10_shader_reflection_vtbl;
291 object->refcount = 1;
293 *reflector = &object->ID3D10ShaderReflection_iface;
295 TRACE("Created ID3D10ShaderReflection %p\n", object);
297 return S_OK;