wined3d: Get resource info from the texture in wined3d_surface_blt().
[wine.git] / dlls / d3d11 / device.c
blob8b7d2f88ca09483549ef909a90842d7f566e8142
1 /*
2 * Copyright 2008-2012 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"
23 #define NONAMELESSUNION
24 #include "d3d11_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d11);
28 static void STDMETHODCALLTYPE d3d_null_wined3d_object_destroyed(void *parent) {}
30 const struct wined3d_parent_ops d3d_null_wined3d_parent_ops =
32 d3d_null_wined3d_object_destroyed,
35 /* ID3D11DeviceContext - immediate context methods */
37 static inline struct d3d11_immediate_context *impl_from_ID3D11DeviceContext(ID3D11DeviceContext *iface)
39 return CONTAINING_RECORD(iface, struct d3d11_immediate_context, ID3D11DeviceContext_iface);
42 static inline struct d3d_device *device_from_immediate_ID3D11DeviceContext(ID3D11DeviceContext *iface)
44 struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext(iface);
45 return CONTAINING_RECORD(context, struct d3d_device, immediate_context);
48 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_QueryInterface(ID3D11DeviceContext *iface,
49 REFIID riid, void **out)
51 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
53 if (IsEqualGUID(riid, &IID_ID3D11DeviceContext)
54 || IsEqualGUID(riid, &IID_ID3D11DeviceChild)
55 || IsEqualGUID(riid, &IID_IUnknown))
57 ID3D11DeviceContext_AddRef(iface);
58 *out = iface;
59 return S_OK;
62 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
63 *out = NULL;
64 return E_NOINTERFACE;
67 static ULONG STDMETHODCALLTYPE d3d11_immediate_context_AddRef(ID3D11DeviceContext *iface)
69 struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext(iface);
70 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
71 ULONG refcount = InterlockedIncrement(&context->refcount);
73 TRACE("%p increasing refcount to %u.\n", context, refcount);
75 if (refcount == 1)
77 ID3D11Device_AddRef(&device->ID3D11Device_iface);
80 return refcount;
83 static ULONG STDMETHODCALLTYPE d3d11_immediate_context_Release(ID3D11DeviceContext *iface)
85 struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext(iface);
86 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
87 ULONG refcount = InterlockedDecrement(&context->refcount);
89 TRACE("%p decreasing refcount to %u.\n", context, refcount);
91 if (!refcount)
93 ID3D11Device_Release(&device->ID3D11Device_iface);
96 return refcount;
99 static void STDMETHODCALLTYPE d3d11_immediate_context_GetDevice(ID3D11DeviceContext *iface, ID3D11Device **device)
101 struct d3d_device *device_object = device_from_immediate_ID3D11DeviceContext(iface);
103 TRACE("iface %p, device %p.\n", iface, device);
105 *device = &device_object->ID3D11Device_iface;
106 ID3D11Device_AddRef(*device);
109 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_GetPrivateData(ID3D11DeviceContext *iface, REFGUID guid,
110 UINT *data_size, void *data)
112 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
114 return E_NOTIMPL;
117 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_SetPrivateData(ID3D11DeviceContext *iface, REFGUID guid,
118 UINT data_size, const void *data)
120 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
122 return E_NOTIMPL;
125 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_SetPrivateDataInterface(ID3D11DeviceContext *iface,
126 REFGUID guid, const IUnknown *data)
128 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
130 return E_NOTIMPL;
133 static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetConstantBuffers(ID3D11DeviceContext *iface,
134 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
136 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
137 unsigned int i;
139 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
140 iface, start_slot, buffer_count, buffers);
142 wined3d_mutex_lock();
143 for (i = 0; i < buffer_count; ++i)
145 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
147 wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i,
148 buffer ? buffer->wined3d_buffer : NULL);
150 wined3d_mutex_unlock();
153 static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetShaderResources(ID3D11DeviceContext *iface,
154 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
156 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
157 unsigned int i;
159 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
160 iface, start_slot, view_count, views);
162 wined3d_mutex_lock();
163 for (i = 0; i < view_count; ++i)
165 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]);
167 wined3d_device_set_ps_resource_view(device->wined3d_device, start_slot + i,
168 view ? view->wined3d_view : NULL);
170 wined3d_mutex_unlock();
173 static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetShader(ID3D11DeviceContext *iface,
174 ID3D11PixelShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
176 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
177 struct d3d_pixel_shader *ps = unsafe_impl_from_ID3D11PixelShader(shader);
179 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
180 iface, shader, class_instances, class_instance_count);
182 if (class_instances)
183 FIXME("Dynamic linking is not implemented yet.\n");
185 wined3d_mutex_lock();
186 wined3d_device_set_pixel_shader(device->wined3d_device, ps ? ps->wined3d_shader : NULL);
187 wined3d_mutex_unlock();
190 static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetSamplers(ID3D11DeviceContext *iface,
191 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
193 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
194 unsigned int i;
196 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
197 iface, start_slot, sampler_count, samplers);
199 wined3d_mutex_lock();
200 for (i = 0; i < sampler_count; ++i)
202 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D11SamplerState(samplers[i]);
204 wined3d_device_set_ps_sampler(device->wined3d_device, start_slot + i,
205 sampler ? sampler->wined3d_sampler : NULL);
207 wined3d_mutex_unlock();
210 static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShader(ID3D11DeviceContext *iface,
211 ID3D11VertexShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
213 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
214 struct d3d_vertex_shader *vs = unsafe_impl_from_ID3D11VertexShader(shader);
216 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
217 iface, shader, class_instances, class_instance_count);
219 if (class_instances)
220 FIXME("Dynamic linking is not implemented yet.\n");
222 wined3d_mutex_lock();
223 wined3d_device_set_vertex_shader(device->wined3d_device, vs ? vs->wined3d_shader : NULL);
224 wined3d_mutex_unlock();
227 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexed(ID3D11DeviceContext *iface,
228 UINT index_count, UINT start_index_location, INT base_vertex_location)
230 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
232 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
233 iface, index_count, start_index_location, base_vertex_location);
235 wined3d_mutex_lock();
236 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
237 wined3d_device_draw_indexed_primitive(device->wined3d_device, start_index_location, index_count);
238 wined3d_mutex_unlock();
241 static void STDMETHODCALLTYPE d3d11_immediate_context_Draw(ID3D11DeviceContext *iface,
242 UINT vertex_count, UINT start_vertex_location)
244 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
246 TRACE("iface %p, vertex_count %u, start_vertex_location %u.\n",
247 iface, vertex_count, start_vertex_location);
249 wined3d_mutex_lock();
250 wined3d_device_draw_primitive(device->wined3d_device, start_vertex_location, vertex_count);
251 wined3d_mutex_unlock();
254 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_Map(ID3D11DeviceContext *iface, ID3D11Resource *resource,
255 UINT subresource_idx, D3D11_MAP map_type, UINT map_flags, D3D11_MAPPED_SUBRESOURCE *mapped_subresource)
257 struct wined3d_resource *wined3d_resource;
258 struct wined3d_map_desc map_desc;
259 HRESULT hr;
261 TRACE("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p.\n",
262 iface, resource, subresource_idx, map_type, map_flags, mapped_subresource);
264 if (map_flags)
265 FIXME("Ignoring map_flags %#x.\n", map_flags);
267 wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
269 wined3d_mutex_lock();
270 hr = wined3d_resource_map(wined3d_resource, subresource_idx,
271 &map_desc, NULL, wined3d_map_flags_from_d3d11_map_type(map_type));
272 wined3d_mutex_unlock();
274 mapped_subresource->pData = map_desc.data;
275 mapped_subresource->RowPitch = map_desc.row_pitch;
276 mapped_subresource->DepthPitch = map_desc.slice_pitch;
278 return hr;
281 static void STDMETHODCALLTYPE d3d11_immediate_context_Unmap(ID3D11DeviceContext *iface, ID3D11Resource *resource,
282 UINT subresource_idx)
284 struct wined3d_resource *wined3d_resource;
286 TRACE("iface %p, resource %p, subresource_idx %u.\n", iface, resource, subresource_idx);
288 wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
290 wined3d_mutex_lock();
291 wined3d_resource_unmap(wined3d_resource, subresource_idx);
292 wined3d_mutex_unlock();
295 static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetConstantBuffers(ID3D11DeviceContext *iface,
296 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
298 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
299 unsigned int i;
301 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
302 iface, start_slot, buffer_count, buffers);
304 wined3d_mutex_lock();
305 for (i = 0; i < buffer_count; ++i)
307 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
309 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
310 buffer ? buffer->wined3d_buffer : NULL);
312 wined3d_mutex_unlock();
315 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetInputLayout(ID3D11DeviceContext *iface,
316 ID3D11InputLayout *input_layout)
318 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
319 struct d3d_input_layout *layout = unsafe_impl_from_ID3D11InputLayout(input_layout);
321 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
323 wined3d_mutex_lock();
324 wined3d_device_set_vertex_declaration(device->wined3d_device, layout ? layout->wined3d_decl : NULL);
325 wined3d_mutex_unlock();
328 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetVertexBuffers(ID3D11DeviceContext *iface,
329 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers, const UINT *strides, const UINT *offsets)
331 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
332 unsigned int i;
334 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
335 iface, start_slot, buffer_count, buffers, strides, offsets);
337 wined3d_mutex_lock();
338 for (i = 0; i < buffer_count; ++i)
340 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
342 wined3d_device_set_stream_source(device->wined3d_device, start_slot + i,
343 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
345 wined3d_mutex_unlock();
348 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetIndexBuffer(ID3D11DeviceContext *iface,
349 ID3D11Buffer *buffer, DXGI_FORMAT format, UINT offset)
351 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
352 struct d3d_buffer *buffer_impl = unsafe_impl_from_ID3D11Buffer(buffer);
354 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
355 iface, buffer, debug_dxgi_format(format), offset);
357 if (offset)
358 FIXME("offset %u not supported.\n", offset);
360 wined3d_mutex_lock();
361 wined3d_device_set_index_buffer(device->wined3d_device,
362 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
363 wined3dformat_from_dxgi_format(format));
364 wined3d_mutex_unlock();
367 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstanced(ID3D11DeviceContext *iface,
368 UINT instance_index_count, UINT instance_count, UINT start_index_location, INT base_vertex_location,
369 UINT start_instance_location)
371 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
373 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
374 "base_vertex_location %d, start_instance_location %u.\n",
375 iface, instance_index_count, instance_count, start_index_location,
376 base_vertex_location, start_instance_location);
378 wined3d_mutex_lock();
379 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
380 wined3d_device_draw_indexed_primitive_instanced(device->wined3d_device, start_index_location,
381 instance_index_count, start_instance_location, instance_count);
382 wined3d_mutex_unlock();
385 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawInstanced(ID3D11DeviceContext *iface,
386 UINT instance_vertex_count, UINT instance_count, UINT start_vertex_location, UINT start_instance_location)
388 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
390 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
391 "start_instance_location %u.\n",
392 iface, instance_vertex_count, instance_count, start_vertex_location,
393 start_instance_location);
395 wined3d_mutex_lock();
396 wined3d_device_draw_primitive_instanced(device->wined3d_device, start_vertex_location,
397 instance_vertex_count, start_instance_location, instance_count);
398 wined3d_mutex_unlock();
401 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetConstantBuffers(ID3D11DeviceContext *iface,
402 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
404 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
405 unsigned int i;
407 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
408 iface, start_slot, buffer_count, buffers);
410 wined3d_mutex_lock();
411 for (i = 0; i < buffer_count; ++i)
413 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
415 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
416 buffer ? buffer->wined3d_buffer : NULL);
418 wined3d_mutex_unlock();
421 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShader(ID3D11DeviceContext *iface,
422 ID3D11GeometryShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
424 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
425 struct d3d_geometry_shader *gs = unsafe_impl_from_ID3D11GeometryShader(shader);
427 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
428 iface, shader, class_instances, class_instance_count);
430 if (class_instances)
431 FIXME("Dynamic linking is not implemented yet.\n");
433 wined3d_mutex_lock();
434 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
435 wined3d_mutex_unlock();
438 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetPrimitiveTopology(ID3D11DeviceContext *iface,
439 D3D11_PRIMITIVE_TOPOLOGY topology)
441 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
443 TRACE("iface %p, topology %u.\n", iface, topology);
445 wined3d_mutex_lock();
446 wined3d_device_set_primitive_type(device->wined3d_device, (enum wined3d_primitive_type)topology);
447 wined3d_mutex_unlock();
450 static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShaderResources(ID3D11DeviceContext *iface,
451 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
453 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
454 unsigned int i;
456 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
458 wined3d_mutex_lock();
459 for (i = 0; i < view_count; ++i)
461 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]);
463 wined3d_device_set_vs_resource_view(device->wined3d_device, start_slot + i,
464 view ? view->wined3d_view : NULL);
466 wined3d_mutex_unlock();
469 static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetSamplers(ID3D11DeviceContext *iface,
470 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
472 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
473 unsigned int i;
475 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
476 iface, start_slot, sampler_count, samplers);
478 wined3d_mutex_lock();
479 for (i = 0; i < sampler_count; ++i)
481 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D11SamplerState(samplers[i]);
483 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
484 sampler ? sampler->wined3d_sampler : NULL);
486 wined3d_mutex_unlock();
489 static void STDMETHODCALLTYPE d3d11_immediate_context_Begin(ID3D11DeviceContext *iface,
490 ID3D11Asynchronous *asynchronous)
492 FIXME("iface %p, asynchronous %p stub!\n", iface, asynchronous);
495 static void STDMETHODCALLTYPE d3d11_immediate_context_End(ID3D11DeviceContext *iface,
496 ID3D11Asynchronous *asynchronous)
498 FIXME("iface %p, asynchronous %p stub!\n", iface, asynchronous);
501 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_GetData(ID3D11DeviceContext *iface,
502 ID3D11Asynchronous *asynchronous, void *data, UINT data_size, UINT data_flags)
504 FIXME("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x stub!\n",
505 iface, asynchronous, data, data_size, data_flags);
507 return E_NOTIMPL;
510 static void STDMETHODCALLTYPE d3d11_immediate_context_SetPredication(ID3D11DeviceContext *iface,
511 ID3D11Predicate *predicate, BOOL value)
513 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
514 struct d3d_query *query;
516 TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value);
518 query = unsafe_impl_from_ID3D11Query((ID3D11Query *)predicate);
520 wined3d_mutex_lock();
521 wined3d_device_set_predication(device->wined3d_device, query ? query->wined3d_query : NULL, value);
522 wined3d_mutex_unlock();
525 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext *iface,
526 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
528 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
529 unsigned int i;
531 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
533 wined3d_mutex_lock();
534 for (i = 0; i < view_count; ++i)
536 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]);
538 wined3d_device_set_gs_resource_view(device->wined3d_device, start_slot + i,
539 view ? view->wined3d_view : NULL);
541 wined3d_mutex_unlock();
544 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext *iface,
545 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
547 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
548 unsigned int i;
550 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
551 iface, start_slot, sampler_count, samplers);
553 wined3d_mutex_lock();
554 for (i = 0; i < sampler_count; ++i)
556 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D11SamplerState(samplers[i]);
558 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
559 sampler ? sampler->wined3d_sampler : NULL);
561 wined3d_mutex_unlock();
564 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext *iface,
565 UINT render_target_view_count, ID3D11RenderTargetView *const *render_target_views,
566 ID3D11DepthStencilView *depth_stencil_view)
568 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
569 struct d3d_depthstencil_view *dsv;
570 unsigned int i;
572 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
573 iface, render_target_view_count, render_target_views, depth_stencil_view);
575 wined3d_mutex_lock();
576 for (i = 0; i < render_target_view_count; ++i)
578 struct d3d_rendertarget_view *rtv = unsafe_impl_from_ID3D11RenderTargetView(render_target_views[i]);
579 wined3d_device_set_rendertarget_view(device->wined3d_device, i, rtv ? rtv->wined3d_view : NULL, FALSE);
581 for (; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
583 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
586 dsv = unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view);
587 wined3d_device_set_depth_stencil_view(device->wined3d_device, dsv ? dsv->wined3d_view : NULL);
588 wined3d_mutex_unlock();
591 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews(
592 ID3D11DeviceContext *iface, UINT render_target_view_count,
593 ID3D11RenderTargetView *const *render_target_views, ID3D11DepthStencilView *depth_stencil_view,
594 UINT unordered_access_view_start_slot, UINT unordered_access_view_count,
595 ID3D11UnorderedAccessView *const *unordered_access_views, const UINT *initial_counts)
597 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
598 "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, "
599 "initial_counts %p stub!\n",
600 iface, render_target_view_count, render_target_views, depth_stencil_view,
601 unordered_access_view_start_slot, unordered_access_view_count, unordered_access_views,
602 initial_counts);
605 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext *iface,
606 ID3D11BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
608 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
609 static const float default_blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f};
610 const D3D11_BLEND_DESC *desc;
612 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask 0x%08x.\n",
613 iface, blend_state, blend_factor, sample_mask);
615 if (!blend_factor)
616 blend_factor = default_blend_factor;
618 if (blend_factor[0] != 1.0f || blend_factor[1] != 1.0f || blend_factor[2] != 1.0f || blend_factor[3] != 1.0f)
619 FIXME("Ignoring blend factor {%.8e %.8e %.8e %.8e}.\n",
620 blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3]);
622 wined3d_mutex_lock();
623 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
624 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK, sample_mask);
625 if (!(device->blend_state = unsafe_impl_from_ID3D11BlendState(blend_state)))
627 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE, FALSE);
628 wined3d_device_set_render_state(device->wined3d_device,
629 WINED3D_RS_COLORWRITEENABLE, D3D11_COLOR_WRITE_ENABLE_ALL);
630 wined3d_device_set_render_state(device->wined3d_device,
631 WINED3D_RS_COLORWRITEENABLE1, D3D11_COLOR_WRITE_ENABLE_ALL);
632 wined3d_device_set_render_state(device->wined3d_device,
633 WINED3D_RS_COLORWRITEENABLE2, D3D11_COLOR_WRITE_ENABLE_ALL);
634 wined3d_device_set_render_state(device->wined3d_device,
635 WINED3D_RS_COLORWRITEENABLE3, D3D11_COLOR_WRITE_ENABLE_ALL);
636 wined3d_mutex_unlock();
637 return;
640 desc = &device->blend_state->desc;
641 /* glSampleCoverage() */
642 if (desc->AlphaToCoverageEnable)
643 FIXME("Ignoring AlphaToCoverageEnable %#x.\n", desc->AlphaToCoverageEnable);
644 /* glEnableIndexedEXT(GL_BLEND, ...) */
645 FIXME("Per-rendertarget blend not implemented.\n");
646 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE,
647 desc->RenderTarget[0].BlendEnable);
648 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SRCBLEND, desc->RenderTarget[0].SrcBlend);
649 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DESTBLEND, desc->RenderTarget[0].DestBlend);
650 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_BLENDOP, desc->RenderTarget[0].BlendOp);
651 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SEPARATEALPHABLENDENABLE, TRUE);
652 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SRCBLENDALPHA,
653 desc->RenderTarget[0].SrcBlendAlpha);
654 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DESTBLENDALPHA,
655 desc->RenderTarget[0].DestBlendAlpha);
656 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_BLENDOPALPHA,
657 desc->RenderTarget[0].BlendOpAlpha);
658 FIXME("Color mask > 3 not implemented.\n");
659 wined3d_device_set_render_state(device->wined3d_device,
660 WINED3D_RS_COLORWRITEENABLE, desc->RenderTarget[0].RenderTargetWriteMask);
661 wined3d_device_set_render_state(device->wined3d_device,
662 WINED3D_RS_COLORWRITEENABLE1, desc->RenderTarget[1].RenderTargetWriteMask);
663 wined3d_device_set_render_state(device->wined3d_device,
664 WINED3D_RS_COLORWRITEENABLE2, desc->RenderTarget[2].RenderTargetWriteMask);
665 wined3d_device_set_render_state(device->wined3d_device,
666 WINED3D_RS_COLORWRITEENABLE3, desc->RenderTarget[3].RenderTargetWriteMask);
667 wined3d_mutex_unlock();
670 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext *iface,
671 ID3D11DepthStencilState *depth_stencil_state, UINT stencil_ref)
673 FIXME("iface %p, depth_stencil_state %p, stencil_ref %u stub!\n", iface, depth_stencil_state, stencil_ref);
676 static void STDMETHODCALLTYPE d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext *iface, UINT buffer_count,
677 ID3D11Buffer *const *buffers, const UINT *offsets)
679 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
680 unsigned int count, i;
682 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface, buffer_count, buffers, offsets);
684 count = min(buffer_count, D3D11_SO_BUFFER_SLOT_COUNT);
685 wined3d_mutex_lock();
686 for (i = 0; i < count; ++i)
688 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
690 wined3d_device_set_stream_output(device->wined3d_device, i,
691 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
693 for (; i < D3D11_SO_BUFFER_SLOT_COUNT; ++i)
695 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
697 wined3d_mutex_unlock();
700 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawAuto(ID3D11DeviceContext *iface)
702 FIXME("iface %p stub!\n", iface);
705 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext *iface,
706 ID3D11Buffer *buffer, UINT offset)
708 FIXME("iface %p, buffer %p, offset %u stub!\n", iface, buffer, offset);
711 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext *iface,
712 ID3D11Buffer *buffer, UINT offset)
714 FIXME("iface %p, buffer %p, offset %u stub!\n", iface, buffer, offset);
717 static void STDMETHODCALLTYPE d3d11_immediate_context_Dispatch(ID3D11DeviceContext *iface,
718 UINT thread_group_count_x, UINT thread_group_count_y, UINT thread_group_count_z)
720 FIXME("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u stub!\n",
721 iface, thread_group_count_x, thread_group_count_y, thread_group_count_z);
724 static void STDMETHODCALLTYPE d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext *iface,
725 ID3D11Buffer *buffer, UINT offset)
727 FIXME("iface %p, buffer %p, offset %u stub!\n", iface, buffer, offset);
730 static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceContext *iface,
731 ID3D11RasterizerState *rasterizer_state)
733 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
734 const D3D11_RASTERIZER_DESC *desc;
736 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
738 wined3d_mutex_lock();
739 if (!(device->rasterizer_state = unsafe_impl_from_ID3D11RasterizerState(rasterizer_state)))
741 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, WINED3D_FILL_SOLID);
742 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, WINED3D_CULL_CCW);
743 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE);
744 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE);
745 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ANTIALIASEDLINEENABLE, FALSE);
746 wined3d_mutex_unlock();
747 return;
750 desc = &device->rasterizer_state->desc;
751 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, desc->FillMode);
752 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, desc->CullMode);
753 /* glFrontFace() */
754 if (desc->FrontCounterClockwise)
755 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc->FrontCounterClockwise);
756 /* OpenGL style depth bias. */
757 if (desc->DepthBias || desc->SlopeScaledDepthBias)
758 FIXME("Ignoring depth bias.\n");
759 /* GL_DEPTH_CLAMP */
760 if (!desc->DepthClipEnable)
761 FIXME("Ignoring DepthClipEnable %#x.\n", desc->DepthClipEnable);
762 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable);
763 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable);
764 wined3d_device_set_render_state(device->wined3d_device,
765 WINED3D_RS_ANTIALIASEDLINEENABLE, desc->AntialiasedLineEnable);
766 wined3d_mutex_unlock();
769 static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext *iface,
770 UINT viewport_count, const D3D11_VIEWPORT *viewports)
772 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
773 struct wined3d_viewport wined3d_vp;
775 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
777 if (viewport_count > 1)
778 FIXME("Multiple viewports not implemented.\n");
780 if (!viewport_count)
781 return;
783 if (viewports[0].TopLeftX != (UINT)viewports[0].TopLeftX
784 || viewports[0].TopLeftY != (UINT)viewports[0].TopLeftY
785 || viewports[0].Width != (UINT)viewports[0].Width
786 || viewports[0].Height != (UINT)viewports[0].Height)
787 FIXME("Floating-point viewports not implemented.\n");
789 wined3d_vp.x = viewports[0].TopLeftX;
790 wined3d_vp.y = viewports[0].TopLeftY;
791 wined3d_vp.width = viewports[0].Width;
792 wined3d_vp.height = viewports[0].Height;
793 wined3d_vp.min_z = viewports[0].MinDepth;
794 wined3d_vp.max_z = viewports[0].MaxDepth;
796 wined3d_mutex_lock();
797 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
798 wined3d_mutex_unlock();
801 static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext *iface,
802 UINT rect_count, const D3D11_RECT *rects)
804 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
806 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
808 if (rect_count > 1)
809 FIXME("Multiple scissor rects not implemented.\n");
811 if (!rect_count)
812 return;
814 wined3d_mutex_lock();
815 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
816 wined3d_mutex_unlock();
819 static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext *iface,
820 ID3D11Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
821 ID3D11Resource *src_resource, UINT src_subresource_idx, const D3D11_BOX *src_box)
823 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
824 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
825 struct wined3d_box wined3d_src_box;
827 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
828 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
829 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
830 src_resource, src_subresource_idx, src_box);
832 if (src_box)
834 wined3d_src_box.left = src_box->left;
835 wined3d_src_box.top = src_box->top;
836 wined3d_src_box.front = src_box->front;
837 wined3d_src_box.right = src_box->right;
838 wined3d_src_box.bottom = src_box->bottom;
839 wined3d_src_box.back = src_box->back;
842 wined3d_dst_resource = wined3d_resource_from_d3d11_resource(dst_resource);
843 wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource);
844 wined3d_mutex_lock();
845 wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx,
846 dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL);
847 wined3d_mutex_unlock();
850 static void STDMETHODCALLTYPE d3d11_immediate_context_CopyResource(ID3D11DeviceContext *iface,
851 ID3D11Resource *dst_resource, ID3D11Resource *src_resource)
853 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
854 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
856 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
858 wined3d_dst_resource = wined3d_resource_from_d3d11_resource(dst_resource);
859 wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource);
860 wined3d_mutex_lock();
861 wined3d_device_copy_resource(device->wined3d_device, wined3d_dst_resource, wined3d_src_resource);
862 wined3d_mutex_unlock();
865 static void STDMETHODCALLTYPE d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext *iface,
866 ID3D11Resource *resource, UINT subresource_idx, const D3D11_BOX *box,
867 const void *data, UINT row_pitch, UINT depth_pitch)
869 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
870 struct wined3d_resource *wined3d_resource;
871 struct wined3d_box wined3d_box;
873 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
874 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
876 if (box)
878 wined3d_box.left = box->left;
879 wined3d_box.top = box->top;
880 wined3d_box.front = box->front;
881 wined3d_box.right = box->right;
882 wined3d_box.bottom = box->bottom;
883 wined3d_box.back = box->back;
886 wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
887 wined3d_mutex_lock();
888 wined3d_device_update_sub_resource(device->wined3d_device, wined3d_resource,
889 subresource_idx, box ? &wined3d_box : NULL, data, row_pitch, depth_pitch);
890 wined3d_mutex_unlock();
893 static void STDMETHODCALLTYPE d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext *iface,
894 ID3D11Buffer *dst_buffer, UINT dst_offset, ID3D11UnorderedAccessView *src_view)
896 FIXME("iface %p, dst_buffer %p, dst_offset %u, src_view %p stub!\n",
897 iface, dst_buffer, dst_offset, src_view);
900 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext *iface,
901 ID3D11RenderTargetView *render_target_view, const FLOAT color_rgba[4])
903 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
904 struct d3d_rendertarget_view *view = unsafe_impl_from_ID3D11RenderTargetView(render_target_view);
905 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
906 HRESULT hr;
908 TRACE("iface %p, render_target_view %p, color_rgba {%.8e %.8e %.8e %.8e}.\n",
909 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
911 wined3d_mutex_lock();
912 if (FAILED(hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, view->wined3d_view, NULL, &color)))
913 ERR("Failed to clear view, hr %#x.\n", hr);
914 wined3d_mutex_unlock();
917 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext *iface,
918 ID3D11UnorderedAccessView *unordered_access_view, const UINT values[4])
920 FIXME("iface %p, unordered_access_view %p, values {%u %u %u %u} stub!\n",
921 iface, unordered_access_view, values[0], values[1], values[2], values[3]);
924 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext *iface,
925 ID3D11UnorderedAccessView *unordered_access_view, const FLOAT values[4])
927 FIXME("iface %p, unordered_access_view %p, values {%.8e %.8e %.8e %.8e} stub!\n",
928 iface, unordered_access_view, values[0], values[1], values[2], values[3]);
931 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext *iface,
932 ID3D11DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
934 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
935 iface, depth_stencil_view, flags, depth, stencil);
938 static void STDMETHODCALLTYPE d3d11_immediate_context_GenerateMips(ID3D11DeviceContext *iface,
939 ID3D11ShaderResourceView *view)
941 FIXME("iface %p, view %p stub!\n", iface, view);
944 static void STDMETHODCALLTYPE d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext *iface,
945 ID3D11Resource *resource, FLOAT min_lod)
947 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface, resource, min_lod);
950 static FLOAT STDMETHODCALLTYPE d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext *iface,
951 ID3D11Resource *resource)
953 FIXME("iface %p, resource %p stub!\n", iface, resource);
955 return 0.0f;
958 static void STDMETHODCALLTYPE d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext *iface,
959 ID3D11Resource *dst_resource, UINT dst_subresource_idx,
960 ID3D11Resource *src_resource, UINT src_subresource_idx,
961 DXGI_FORMAT format)
963 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
964 "format %s stub!\n",
965 iface, dst_resource, dst_subresource_idx, src_resource, src_subresource_idx,
966 debug_dxgi_format(format));
969 static void STDMETHODCALLTYPE d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext *iface,
970 ID3D11CommandList *command_list, BOOL restore_state)
972 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface, command_list, restore_state);
975 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext *iface,
976 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
978 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
979 iface, start_slot, view_count, views);
982 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShader(ID3D11DeviceContext *iface,
983 ID3D11HullShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
985 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
986 iface, shader, class_instances, class_instance_count);
989 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext *iface,
990 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
992 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
993 iface, start_slot, sampler_count, samplers);
996 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext *iface,
997 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
999 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1000 iface, start_slot, buffer_count, buffers);
1003 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext *iface,
1004 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
1006 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1007 iface, start_slot, view_count, views);
1010 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShader(ID3D11DeviceContext *iface,
1011 ID3D11DomainShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
1013 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1014 iface, shader, class_instances, class_instance_count);
1017 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext *iface,
1018 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
1020 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1021 iface, start_slot, sampler_count, samplers);
1024 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext *iface,
1025 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
1027 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1028 iface, start_slot, buffer_count, buffers);
1031 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext *iface,
1032 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
1034 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1035 iface, start_slot, view_count, views);
1038 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext *iface,
1039 UINT start_slot, UINT view_count, ID3D11UnorderedAccessView *const *views, const UINT *initial_counts)
1041 FIXME("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p stub!\n",
1042 iface, start_slot, view_count, views, initial_counts);
1045 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShader(ID3D11DeviceContext *iface,
1046 ID3D11ComputeShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
1048 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
1049 iface, shader, class_instances, class_instance_count);
1052 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext *iface,
1053 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
1055 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1056 iface, start_slot, sampler_count, samplers);
1059 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext *iface,
1060 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
1062 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1063 iface, start_slot, buffer_count, buffers);
1066 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext *iface,
1067 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1069 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1070 unsigned int i;
1072 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1073 iface, start_slot, buffer_count, buffers);
1075 wined3d_mutex_lock();
1076 for (i = 0; i < buffer_count; ++i)
1078 struct wined3d_buffer *wined3d_buffer;
1079 struct d3d_buffer *buffer_impl;
1081 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
1083 buffers[i] = NULL;
1084 continue;
1087 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1088 buffers[i] = &buffer_impl->ID3D11Buffer_iface;
1089 ID3D11Buffer_AddRef(buffers[i]);
1091 wined3d_mutex_unlock();
1094 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext *iface,
1095 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1097 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1098 unsigned int i;
1100 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
1101 iface, start_slot, view_count, views);
1103 wined3d_mutex_lock();
1104 for (i = 0; i < view_count; ++i)
1106 struct wined3d_shader_resource_view *wined3d_view;
1107 struct d3d_shader_resource_view *view_impl;
1109 if (!(wined3d_view = wined3d_device_get_ps_resource_view(device->wined3d_device, start_slot + i)))
1111 views[i] = NULL;
1112 continue;
1115 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
1116 views[i] = &view_impl->ID3D11ShaderResourceView_iface;
1117 ID3D11ShaderResourceView_AddRef(views[i]);
1119 wined3d_mutex_unlock();
1122 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetShader(ID3D11DeviceContext *iface,
1123 ID3D11PixelShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1125 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1126 struct wined3d_shader *wined3d_shader;
1127 struct d3d_pixel_shader *shader_impl;
1129 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1130 iface, shader, class_instances, class_instance_count);
1132 if (class_instances || class_instance_count)
1133 FIXME("Dynamic linking not implemented yet.\n");
1135 wined3d_mutex_lock();
1136 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
1138 wined3d_mutex_unlock();
1139 *shader = NULL;
1140 return;
1143 shader_impl = wined3d_shader_get_parent(wined3d_shader);
1144 wined3d_mutex_unlock();
1145 *shader = &shader_impl->ID3D11PixelShader_iface;
1146 ID3D11PixelShader_AddRef(*shader);
1149 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext *iface,
1150 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1152 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1153 unsigned int i;
1155 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1156 iface, start_slot, sampler_count, samplers);
1158 wined3d_mutex_lock();
1159 for (i = 0; i < sampler_count; ++i)
1161 struct wined3d_sampler *wined3d_sampler;
1162 struct d3d_sampler_state *sampler_impl;
1164 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
1166 samplers[i] = NULL;
1167 continue;
1170 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1171 samplers[i] = &sampler_impl->ID3D11SamplerState_iface;
1172 ID3D11SamplerState_AddRef(samplers[i]);
1174 wined3d_mutex_unlock();
1177 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShader(ID3D11DeviceContext *iface,
1178 ID3D11VertexShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1180 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1181 struct d3d_vertex_shader *shader_impl;
1182 struct wined3d_shader *wined3d_shader;
1184 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1185 iface, shader, class_instances, class_instance_count);
1187 if (class_instances || class_instance_count)
1188 FIXME("Dynamic linking not implemented yet.\n");
1190 wined3d_mutex_lock();
1191 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
1193 wined3d_mutex_unlock();
1194 *shader = NULL;
1195 return;
1198 shader_impl = wined3d_shader_get_parent(wined3d_shader);
1199 wined3d_mutex_unlock();
1200 *shader = &shader_impl->ID3D11VertexShader_iface;
1201 ID3D11VertexShader_AddRef(*shader);
1204 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext *iface,
1205 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1207 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1208 unsigned int i;
1210 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1211 iface, start_slot, buffer_count, buffers);
1213 wined3d_mutex_lock();
1214 for (i = 0; i < buffer_count; ++i)
1216 struct wined3d_buffer *wined3d_buffer;
1217 struct d3d_buffer *buffer_impl;
1219 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
1221 buffers[i] = NULL;
1222 continue;
1225 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1226 buffers[i] = &buffer_impl->ID3D11Buffer_iface;
1227 ID3D11Buffer_AddRef(buffers[i]);
1229 wined3d_mutex_unlock();
1232 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext *iface,
1233 ID3D11InputLayout **input_layout)
1235 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1236 struct wined3d_vertex_declaration *wined3d_declaration;
1237 struct d3d_input_layout *input_layout_impl;
1239 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
1241 wined3d_mutex_lock();
1242 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
1244 wined3d_mutex_unlock();
1245 *input_layout = NULL;
1246 return;
1249 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
1250 wined3d_mutex_unlock();
1251 *input_layout = &input_layout_impl->ID3D11InputLayout_iface;
1252 ID3D11InputLayout_AddRef(*input_layout);
1255 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext *iface,
1256 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers, UINT *strides, UINT *offsets)
1258 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p stub!\n",
1259 iface, start_slot, buffer_count, buffers, strides, offsets);
1262 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext *iface,
1263 ID3D11Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
1265 FIXME("iface %p, buffer %p, format %p, offset %p stub!\n", iface, buffer, format, offset);
1268 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext *iface,
1269 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1271 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1272 unsigned int i;
1274 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1275 iface, start_slot, buffer_count, buffers);
1277 wined3d_mutex_lock();
1278 for (i = 0; i < buffer_count; ++i)
1280 struct wined3d_buffer *wined3d_buffer;
1281 struct d3d_buffer *buffer_impl;
1283 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
1285 buffers[i] = NULL;
1286 continue;
1289 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1290 buffers[i] = &buffer_impl->ID3D11Buffer_iface;
1291 ID3D11Buffer_AddRef(buffers[i]);
1293 wined3d_mutex_unlock();
1296 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShader(ID3D11DeviceContext *iface,
1297 ID3D11GeometryShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1299 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1300 struct d3d_geometry_shader *shader_impl;
1301 struct wined3d_shader *wined3d_shader;
1303 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %p.\n",
1304 iface, shader, class_instances, class_instance_count);
1306 if (class_instances || class_instance_count)
1307 FIXME("Dynamic linking not implemented yet.\n");
1309 wined3d_mutex_lock();
1310 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
1312 wined3d_mutex_unlock();
1313 *shader = NULL;
1314 return;
1317 shader_impl = wined3d_shader_get_parent(wined3d_shader);
1318 wined3d_mutex_unlock();
1319 *shader = &shader_impl->ID3D11GeometryShader_iface;
1320 ID3D11GeometryShader_AddRef(*shader);
1323 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext *iface,
1324 D3D11_PRIMITIVE_TOPOLOGY *topology)
1326 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1328 TRACE("iface %p, topology %p.\n", iface, topology);
1330 wined3d_mutex_lock();
1331 wined3d_device_get_primitive_type(device->wined3d_device, (enum wined3d_primitive_type *)topology);
1332 wined3d_mutex_unlock();
1335 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext *iface,
1336 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1338 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1339 unsigned int i;
1341 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
1343 wined3d_mutex_lock();
1344 for (i = 0; i < view_count; ++i)
1346 struct wined3d_shader_resource_view *wined3d_view;
1347 struct d3d_shader_resource_view *view_impl;
1349 if (!(wined3d_view = wined3d_device_get_vs_resource_view(device->wined3d_device, start_slot + i)))
1351 views[i] = NULL;
1352 continue;
1355 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
1356 views[i] = &view_impl->ID3D11ShaderResourceView_iface;
1357 ID3D11ShaderResourceView_AddRef(views[i]);
1359 wined3d_mutex_unlock();
1362 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext *iface,
1363 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1365 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1366 unsigned int i;
1368 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1369 iface, start_slot, sampler_count, samplers);
1371 wined3d_mutex_lock();
1372 for (i = 0; i < sampler_count; ++i)
1374 struct wined3d_sampler *wined3d_sampler;
1375 struct d3d_sampler_state *sampler_impl;
1377 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
1379 samplers[i] = NULL;
1380 continue;
1383 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1384 samplers[i] = &sampler_impl->ID3D11SamplerState_iface;
1385 ID3D11SamplerState_AddRef(samplers[i]);
1387 wined3d_mutex_unlock();
1390 static void STDMETHODCALLTYPE d3d11_immediate_context_GetPredication(ID3D11DeviceContext *iface,
1391 ID3D11Predicate **predicate, BOOL *value)
1393 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1394 struct wined3d_query *wined3d_predicate;
1395 struct d3d_query *predicate_impl;
1397 TRACE("iface %p, predicate %p, value %p.\n", iface, predicate, value);
1399 wined3d_mutex_lock();
1400 if (!(wined3d_predicate = wined3d_device_get_predication(device->wined3d_device, value)))
1402 wined3d_mutex_unlock();
1403 *predicate = NULL;
1404 return;
1407 predicate_impl = wined3d_query_get_parent(wined3d_predicate);
1408 wined3d_mutex_unlock();
1409 *predicate = (ID3D11Predicate *)&predicate_impl->ID3D11Query_iface;
1410 ID3D11Predicate_AddRef(*predicate);
1413 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext *iface,
1414 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1416 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1417 unsigned int i;
1419 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
1421 wined3d_mutex_lock();
1422 for (i = 0; i < view_count; ++i)
1424 struct wined3d_shader_resource_view *wined3d_view;
1425 struct d3d_shader_resource_view *view_impl;
1427 if (!(wined3d_view = wined3d_device_get_gs_resource_view(device->wined3d_device, start_slot + i)))
1429 views[i] = NULL;
1430 continue;
1433 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
1434 views[i] = &view_impl->ID3D11ShaderResourceView_iface;
1435 ID3D11ShaderResourceView_AddRef(views[i]);
1437 wined3d_mutex_unlock();
1440 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext *iface,
1441 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1443 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1444 unsigned int i;
1446 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1447 iface, start_slot, sampler_count, samplers);
1449 wined3d_mutex_lock();
1450 for (i = 0; i < sampler_count; ++i)
1452 struct d3d_sampler_state *sampler_impl;
1453 struct wined3d_sampler *wined3d_sampler;
1455 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
1457 samplers[i] = NULL;
1458 continue;
1461 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1462 samplers[i] = &sampler_impl->ID3D11SamplerState_iface;
1463 ID3D11SamplerState_AddRef(samplers[i]);
1465 wined3d_mutex_unlock();
1468 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext *iface,
1469 UINT render_target_view_count, ID3D11RenderTargetView **render_target_views,
1470 ID3D11DepthStencilView **depth_stencil_view)
1472 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1473 struct wined3d_rendertarget_view *wined3d_view;
1475 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1476 iface, render_target_view_count, render_target_views, depth_stencil_view);
1478 wined3d_mutex_lock();
1479 if (render_target_views)
1481 struct d3d_rendertarget_view *view_impl;
1482 unsigned int i;
1484 for (i = 0; i < render_target_view_count; ++i)
1486 if (!(wined3d_view = wined3d_device_get_rendertarget_view(device->wined3d_device, i))
1487 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
1489 render_target_views[i] = NULL;
1490 continue;
1493 render_target_views[i] = &view_impl->ID3D11RenderTargetView_iface;
1494 ID3D11RenderTargetView_AddRef(render_target_views[i]);
1498 if (depth_stencil_view)
1500 struct d3d_depthstencil_view *view_impl;
1502 if (!(wined3d_view = wined3d_device_get_depth_stencil_view(device->wined3d_device))
1503 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
1505 *depth_stencil_view = NULL;
1507 else
1509 *depth_stencil_view = &view_impl->ID3D11DepthStencilView_iface;
1510 ID3D11DepthStencilView_AddRef(*depth_stencil_view);
1513 wined3d_mutex_unlock();
1516 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1517 ID3D11DeviceContext *iface,
1518 UINT render_target_view_count, ID3D11RenderTargetView **render_target_views,
1519 ID3D11DepthStencilView **depth_stencil_view,
1520 UINT unordered_access_view_start_slot, UINT unordered_access_view_count,
1521 ID3D11UnorderedAccessView **unordered_access_views)
1523 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1524 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1525 "unordered_access_views %p stub!\n",
1526 iface, render_target_view_count, render_target_views, depth_stencil_view,
1527 unordered_access_view_start_slot, unordered_access_view_count, unordered_access_views);
1530 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext *iface,
1531 ID3D11BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
1533 FIXME("iface %p, blend_state %p, blend_factor %p, sample_mask %p stub!\n",
1534 iface, blend_state, blend_factor, sample_mask);
1537 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext *iface,
1538 ID3D11DepthStencilState **depth_stencil_state, UINT *stencil_ref)
1540 FIXME("iface %p, depth_stencil_state %p, stencil_ref %p stub!\n", iface, depth_stencil_state, stencil_ref);
1543 static void STDMETHODCALLTYPE d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext *iface,
1544 UINT buffer_count, ID3D11Buffer **buffers)
1546 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1547 unsigned int i;
1549 TRACE("iface %p, buffer_count %u, buffers %p.\n", iface, buffer_count, buffers);
1551 wined3d_mutex_lock();
1552 for (i = 0; i < buffer_count; ++i)
1554 struct wined3d_buffer *wined3d_buffer;
1555 struct d3d_buffer *buffer_impl;
1557 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, NULL)))
1559 buffers[i] = NULL;
1560 continue;
1563 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1564 buffers[i] = &buffer_impl->ID3D11Buffer_iface;
1565 ID3D11Buffer_AddRef(buffers[i]);
1567 wined3d_mutex_unlock();
1570 static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetState(ID3D11DeviceContext *iface,
1571 ID3D11RasterizerState **rasterizer_state)
1573 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1575 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
1577 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D11RasterizerState_iface : NULL))
1578 ID3D11RasterizerState_AddRef(*rasterizer_state);
1581 static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext *iface,
1582 UINT *viewport_count, D3D11_VIEWPORT *viewports)
1584 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1585 struct wined3d_viewport wined3d_vp;
1587 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
1589 if (!viewports)
1591 *viewport_count = 1;
1592 return;
1595 if (!*viewport_count)
1596 return;
1598 wined3d_mutex_lock();
1599 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
1600 wined3d_mutex_unlock();
1602 viewports[0].TopLeftX = wined3d_vp.x;
1603 viewports[0].TopLeftY = wined3d_vp.y;
1604 viewports[0].Width = wined3d_vp.width;
1605 viewports[0].Height = wined3d_vp.height;
1606 viewports[0].MinDepth = wined3d_vp.min_z;
1607 viewports[0].MaxDepth = wined3d_vp.max_z;
1609 if (*viewport_count > 1)
1610 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
1613 static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext *iface,
1614 UINT *rect_count, D3D11_RECT *rects)
1616 FIXME("iface %p, rect_count %p, rects %p stub!\n", iface, rect_count, rects);
1619 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext *iface,
1620 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1622 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1625 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShader(ID3D11DeviceContext *iface,
1626 ID3D11HullShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1628 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1629 iface, shader, class_instances, class_instance_count);
1632 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext *iface,
1633 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1635 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1636 iface, start_slot, sampler_count, samplers);
1639 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext *iface,
1640 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1642 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1643 iface, start_slot, buffer_count, buffers);
1646 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext *iface,
1647 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1649 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1650 iface, start_slot, view_count, views);
1653 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShader(ID3D11DeviceContext *iface,
1654 ID3D11DomainShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1656 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1657 iface, shader, class_instances, class_instance_count);
1660 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext *iface,
1661 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1663 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1664 iface, start_slot, sampler_count, samplers);
1667 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext *iface,
1668 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1670 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1671 iface, start_slot, buffer_count, buffers);
1674 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext *iface,
1675 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1677 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1680 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext *iface,
1681 UINT start_slot, UINT view_count, ID3D11UnorderedAccessView **views)
1683 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1686 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShader(ID3D11DeviceContext *iface,
1687 ID3D11ComputeShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1689 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1690 iface, shader, class_instances, class_instance_count);
1693 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext *iface,
1694 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1696 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1697 iface, start_slot, sampler_count, samplers);
1700 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext *iface,
1701 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1703 FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
1704 iface, start_slot, buffer_count, buffers);
1707 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceContext *iface)
1709 FIXME("iface %p stub!\n", iface);
1712 static void STDMETHODCALLTYPE d3d11_immediate_context_Flush(ID3D11DeviceContext *iface)
1714 FIXME("iface %p stub!\n", iface);
1717 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE d3d11_immediate_context_GetType(ID3D11DeviceContext *iface)
1719 TRACE("iface %p.\n", iface);
1721 return D3D11_DEVICE_CONTEXT_IMMEDIATE;
1724 static UINT STDMETHODCALLTYPE d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext *iface)
1726 FIXME("iface %p stub!\n", iface);
1728 return 0;
1731 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext *iface,
1732 BOOL restore, ID3D11CommandList **command_list)
1734 FIXME("iface %p, restore %#x, command_list %p stub!\n", iface, restore, command_list);
1736 return E_NOTIMPL;
1739 static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl =
1741 /* IUnknown methods */
1742 d3d11_immediate_context_QueryInterface,
1743 d3d11_immediate_context_AddRef,
1744 d3d11_immediate_context_Release,
1745 /* ID3D11DeviceChild methods */
1746 d3d11_immediate_context_GetDevice,
1747 d3d11_immediate_context_GetPrivateData,
1748 d3d11_immediate_context_SetPrivateData,
1749 d3d11_immediate_context_SetPrivateDataInterface,
1750 /* ID3D11DeviceContext methods */
1751 d3d11_immediate_context_VSSetConstantBuffers,
1752 d3d11_immediate_context_PSSetShaderResources,
1753 d3d11_immediate_context_PSSetShader,
1754 d3d11_immediate_context_PSSetSamplers,
1755 d3d11_immediate_context_VSSetShader,
1756 d3d11_immediate_context_DrawIndexed,
1757 d3d11_immediate_context_Draw,
1758 d3d11_immediate_context_Map,
1759 d3d11_immediate_context_Unmap,
1760 d3d11_immediate_context_PSSetConstantBuffers,
1761 d3d11_immediate_context_IASetInputLayout,
1762 d3d11_immediate_context_IASetVertexBuffers,
1763 d3d11_immediate_context_IASetIndexBuffer,
1764 d3d11_immediate_context_DrawIndexedInstanced,
1765 d3d11_immediate_context_DrawInstanced,
1766 d3d11_immediate_context_GSSetConstantBuffers,
1767 d3d11_immediate_context_GSSetShader,
1768 d3d11_immediate_context_IASetPrimitiveTopology,
1769 d3d11_immediate_context_VSSetShaderResources,
1770 d3d11_immediate_context_VSSetSamplers,
1771 d3d11_immediate_context_Begin,
1772 d3d11_immediate_context_End,
1773 d3d11_immediate_context_GetData,
1774 d3d11_immediate_context_SetPredication,
1775 d3d11_immediate_context_GSSetShaderResources,
1776 d3d11_immediate_context_GSSetSamplers,
1777 d3d11_immediate_context_OMSetRenderTargets,
1778 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews,
1779 d3d11_immediate_context_OMSetBlendState,
1780 d3d11_immediate_context_OMSetDepthStencilState,
1781 d3d11_immediate_context_SOSetTargets,
1782 d3d11_immediate_context_DrawAuto,
1783 d3d11_immediate_context_DrawIndexedInstancedIndirect,
1784 d3d11_immediate_context_DrawInstancedIndirect,
1785 d3d11_immediate_context_Dispatch,
1786 d3d11_immediate_context_DispatchIndirect,
1787 d3d11_immediate_context_RSSetState,
1788 d3d11_immediate_context_RSSetViewports,
1789 d3d11_immediate_context_RSSetScissorRects,
1790 d3d11_immediate_context_CopySubresourceRegion,
1791 d3d11_immediate_context_CopyResource,
1792 d3d11_immediate_context_UpdateSubresource,
1793 d3d11_immediate_context_CopyStructureCount,
1794 d3d11_immediate_context_ClearRenderTargetView,
1795 d3d11_immediate_context_ClearUnorderedAccessViewUint,
1796 d3d11_immediate_context_ClearUnorderedAccessViewFloat,
1797 d3d11_immediate_context_ClearDepthStencilView,
1798 d3d11_immediate_context_GenerateMips,
1799 d3d11_immediate_context_SetResourceMinLOD,
1800 d3d11_immediate_context_GetResourceMinLOD,
1801 d3d11_immediate_context_ResolveSubresource,
1802 d3d11_immediate_context_ExecuteCommandList,
1803 d3d11_immediate_context_HSSetShaderResources,
1804 d3d11_immediate_context_HSSetShader,
1805 d3d11_immediate_context_HSSetSamplers,
1806 d3d11_immediate_context_HSSetConstantBuffers,
1807 d3d11_immediate_context_DSSetShaderResources,
1808 d3d11_immediate_context_DSSetShader,
1809 d3d11_immediate_context_DSSetSamplers,
1810 d3d11_immediate_context_DSSetConstantBuffers,
1811 d3d11_immediate_context_CSSetShaderResources,
1812 d3d11_immediate_context_CSSetUnorderedAccessViews,
1813 d3d11_immediate_context_CSSetShader,
1814 d3d11_immediate_context_CSSetSamplers,
1815 d3d11_immediate_context_CSSetConstantBuffers,
1816 d3d11_immediate_context_VSGetConstantBuffers,
1817 d3d11_immediate_context_PSGetShaderResources,
1818 d3d11_immediate_context_PSGetShader,
1819 d3d11_immediate_context_PSGetSamplers,
1820 d3d11_immediate_context_VSGetShader,
1821 d3d11_immediate_context_PSGetConstantBuffers,
1822 d3d11_immediate_context_IAGetInputLayout,
1823 d3d11_immediate_context_IAGetVertexBuffers,
1824 d3d11_immediate_context_IAGetIndexBuffer,
1825 d3d11_immediate_context_GSGetConstantBuffers,
1826 d3d11_immediate_context_GSGetShader,
1827 d3d11_immediate_context_IAGetPrimitiveTopology,
1828 d3d11_immediate_context_VSGetShaderResources,
1829 d3d11_immediate_context_VSGetSamplers,
1830 d3d11_immediate_context_GetPredication,
1831 d3d11_immediate_context_GSGetShaderResources,
1832 d3d11_immediate_context_GSGetSamplers,
1833 d3d11_immediate_context_OMGetRenderTargets,
1834 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews,
1835 d3d11_immediate_context_OMGetBlendState,
1836 d3d11_immediate_context_OMGetDepthStencilState,
1837 d3d11_immediate_context_SOGetTargets,
1838 d3d11_immediate_context_RSGetState,
1839 d3d11_immediate_context_RSGetViewports,
1840 d3d11_immediate_context_RSGetScissorRects,
1841 d3d11_immediate_context_HSGetShaderResources,
1842 d3d11_immediate_context_HSGetShader,
1843 d3d11_immediate_context_HSGetSamplers,
1844 d3d11_immediate_context_HSGetConstantBuffers,
1845 d3d11_immediate_context_DSGetShaderResources,
1846 d3d11_immediate_context_DSGetShader,
1847 d3d11_immediate_context_DSGetSamplers,
1848 d3d11_immediate_context_DSGetConstantBuffers,
1849 d3d11_immediate_context_CSGetShaderResources,
1850 d3d11_immediate_context_CSGetUnorderedAccessViews,
1851 d3d11_immediate_context_CSGetShader,
1852 d3d11_immediate_context_CSGetSamplers,
1853 d3d11_immediate_context_CSGetConstantBuffers,
1854 d3d11_immediate_context_ClearState,
1855 d3d11_immediate_context_Flush,
1856 d3d11_immediate_context_GetType,
1857 d3d11_immediate_context_GetContextFlags,
1858 d3d11_immediate_context_FinishCommandList,
1861 static HRESULT d3d11_immediate_context_init(struct d3d11_immediate_context *context, struct d3d_device *device)
1863 context->ID3D11DeviceContext_iface.lpVtbl = &d3d11_immediate_context_vtbl;
1864 context->refcount = 1;
1866 ID3D11Device_AddRef(&device->ID3D11Device_iface);
1868 return S_OK;
1871 /* ID3D11Device methods */
1873 static HRESULT STDMETHODCALLTYPE d3d11_device_QueryInterface(ID3D11Device *iface, REFIID riid, void **out)
1875 struct d3d_device *device = impl_from_ID3D11Device(iface);
1876 return IUnknown_QueryInterface(device->outer_unk, riid, out);
1879 static ULONG STDMETHODCALLTYPE d3d11_device_AddRef(ID3D11Device *iface)
1881 struct d3d_device *device = impl_from_ID3D11Device(iface);
1882 return IUnknown_AddRef(device->outer_unk);
1885 static ULONG STDMETHODCALLTYPE d3d11_device_Release(ID3D11Device *iface)
1887 struct d3d_device *device = impl_from_ID3D11Device(iface);
1888 return IUnknown_Release(device->outer_unk);
1891 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBuffer(ID3D11Device *iface, const D3D11_BUFFER_DESC *desc,
1892 const D3D11_SUBRESOURCE_DATA *data, ID3D11Buffer **buffer)
1894 struct d3d_device *device = impl_from_ID3D11Device(iface);
1895 struct d3d_buffer *object;
1896 HRESULT hr;
1898 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface, desc, data, buffer);
1900 if (FAILED(hr = d3d_buffer_create(device, desc, data, &object)))
1901 return hr;
1903 *buffer = &object->ID3D11Buffer_iface;
1905 return S_OK;
1908 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture1D(ID3D11Device *iface,
1909 const D3D11_TEXTURE1D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture1D **texture)
1911 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1913 return E_NOTIMPL;
1916 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture2D(ID3D11Device *iface,
1917 const D3D11_TEXTURE2D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture2D **texture)
1919 struct d3d_device *device = impl_from_ID3D11Device(iface);
1920 struct d3d_texture2d *object;
1921 HRESULT hr;
1923 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1925 if (FAILED(hr = d3d_texture2d_create(device, desc, data, &object)))
1926 return hr;
1928 *texture = &object->ID3D11Texture2D_iface;
1930 return S_OK;
1933 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture3D(ID3D11Device *iface,
1934 const D3D11_TEXTURE3D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture3D **texture)
1936 struct d3d_device *device = impl_from_ID3D11Device(iface);
1937 struct d3d_texture3d *object;
1938 HRESULT hr;
1940 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1942 if (FAILED(hr = d3d_texture3d_create(device, desc, data, &object)))
1943 return hr;
1945 *texture = &object->ID3D11Texture3D_iface;
1947 return S_OK;
1950 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateShaderResourceView(ID3D11Device *iface,
1951 ID3D11Resource *resource, const D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11ShaderResourceView **view)
1953 struct d3d_device *device = impl_from_ID3D11Device(iface);
1954 struct d3d_shader_resource_view *object;
1955 HRESULT hr;
1957 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1959 if (FAILED(hr = d3d_shader_resource_view_create(device, resource, desc, &object)))
1960 return hr;
1962 *view = &object->ID3D11ShaderResourceView_iface;
1964 return S_OK;
1967 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateUnorderedAccessView(ID3D11Device *iface,
1968 ID3D11Resource *resource, const D3D11_UNORDERED_ACCESS_VIEW_DESC *desc, ID3D11UnorderedAccessView **view)
1970 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1972 return E_NOTIMPL;
1975 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRenderTargetView(ID3D11Device *iface,
1976 ID3D11Resource *resource, const D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11RenderTargetView **view)
1978 struct d3d_device *device = impl_from_ID3D11Device(iface);
1979 struct d3d_rendertarget_view *object;
1980 HRESULT hr;
1982 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1984 if (FAILED(hr = d3d_rendertarget_view_create(device, resource, desc, &object)))
1985 return hr;
1987 *view = &object->ID3D11RenderTargetView_iface;
1989 return S_OK;
1992 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilView(ID3D11Device *iface,
1993 ID3D11Resource *resource, const D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11DepthStencilView **view)
1995 struct d3d_device *device = impl_from_ID3D11Device(iface);
1996 struct d3d_depthstencil_view *object;
1997 HRESULT hr;
1999 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
2001 if (FAILED(hr = d3d_depthstencil_view_create(device, resource, desc, &object)))
2002 return hr;
2004 *view = &object->ID3D11DepthStencilView_iface;
2006 return S_OK;
2009 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateInputLayout(ID3D11Device *iface,
2010 const D3D11_INPUT_ELEMENT_DESC *element_descs, UINT element_count, const void *shader_byte_code,
2011 SIZE_T shader_byte_code_length, ID3D11InputLayout **input_layout)
2013 struct d3d_device *device = impl_from_ID3D11Device(iface);
2014 struct d3d_input_layout *object;
2015 HRESULT hr;
2017 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
2018 "input_layout %p.\n", iface, element_descs, element_count, shader_byte_code,
2019 shader_byte_code_length, input_layout);
2021 if (FAILED(hr = d3d_input_layout_create(device, element_descs, element_count,
2022 shader_byte_code, shader_byte_code_length, &object)))
2023 return hr;
2025 *input_layout = &object->ID3D11InputLayout_iface;
2027 return S_OK;
2030 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateVertexShader(ID3D11Device *iface, const void *byte_code,
2031 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11VertexShader **shader)
2033 struct d3d_device *device = impl_from_ID3D11Device(iface);
2034 struct d3d_vertex_shader *object;
2035 HRESULT hr;
2037 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2038 iface, byte_code, byte_code_length, class_linkage, shader);
2040 if (class_linkage)
2041 FIXME("Class linkage is not implemented yet.\n");
2043 if (FAILED(hr = d3d_vertex_shader_create(device, byte_code, byte_code_length, &object)))
2044 return hr;
2046 *shader = &object->ID3D11VertexShader_iface;
2048 return S_OK;
2051 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShader(ID3D11Device *iface, const void *byte_code,
2052 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11GeometryShader **shader)
2054 struct d3d_device *device = impl_from_ID3D11Device(iface);
2055 struct d3d_geometry_shader *object;
2056 HRESULT hr;
2058 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2059 iface, byte_code, byte_code_length, class_linkage, shader);
2061 if (class_linkage)
2062 FIXME("Class linkage is not implemented yet.\n");
2064 if (FAILED(hr = d3d_geometry_shader_create(device, byte_code, byte_code_length, &object)))
2065 return hr;
2067 *shader = &object->ID3D11GeometryShader_iface;
2069 return S_OK;
2072 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device *iface,
2073 const void *byte_code, SIZE_T byte_code_length, const D3D11_SO_DECLARATION_ENTRY *so_entries,
2074 UINT entry_count, const UINT *buffer_strides, UINT strides_count, UINT rasterized_stream,
2075 ID3D11ClassLinkage *class_linkage, ID3D11GeometryShader **shader)
2077 FIXME("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
2078 "buffer_strides %p, strides_count %u, rasterized_stream %u, class_linkage %p, shader %p stub!\n",
2079 iface, byte_code, byte_code_length, so_entries, entry_count, buffer_strides, strides_count,
2080 rasterized_stream, class_linkage, shader);
2082 return E_NOTIMPL;
2085 static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePixelShader(ID3D11Device *iface, const void *byte_code,
2086 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11PixelShader **shader)
2088 struct d3d_device *device = impl_from_ID3D11Device(iface);
2089 struct d3d_pixel_shader *object;
2090 HRESULT hr;
2092 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
2093 iface, byte_code, byte_code_length, class_linkage, shader);
2095 if (class_linkage)
2096 FIXME("Class linkage is not implemented yet.\n");
2098 if (FAILED(hr = d3d_pixel_shader_create(device, byte_code, byte_code_length, &object)))
2099 return hr;
2101 *shader = &object->ID3D11PixelShader_iface;
2103 return S_OK;
2106 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateHullShader(ID3D11Device *iface, const void *byte_code,
2107 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11HullShader **shader)
2109 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2110 iface, byte_code, byte_code_length, class_linkage, shader);
2112 return E_NOTIMPL;
2115 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDomainShader(ID3D11Device *iface, const void *byte_code,
2116 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11DomainShader **shader)
2118 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2119 iface, byte_code, byte_code_length, class_linkage, shader);
2121 return E_NOTIMPL;
2124 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateComputeShader(ID3D11Device *iface, const void *byte_code,
2125 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11ComputeShader **shader)
2127 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
2128 iface, byte_code, byte_code_length, class_linkage, shader);
2130 return E_NOTIMPL;
2133 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateClassLinkage(ID3D11Device *iface,
2134 ID3D11ClassLinkage **class_linkage)
2136 FIXME("iface %p, class_linkage %p stub!\n", iface, class_linkage);
2138 return E_NOTIMPL;
2141 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBlendState(ID3D11Device *iface,
2142 const D3D11_BLEND_DESC *desc, ID3D11BlendState **blend_state)
2144 struct d3d_device *device = impl_from_ID3D11Device(iface);
2145 struct d3d_blend_state *object;
2146 struct wine_rb_entry *entry;
2147 D3D11_BLEND_DESC tmp_desc;
2148 unsigned int i, j;
2149 HRESULT hr;
2151 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
2153 if (!desc)
2154 return E_INVALIDARG;
2156 /* D3D11_RENDER_TARGET_BLEND_DESC has a hole, which is a problem because we use
2157 * D3D11_BLEND_DESC as a key in the rbtree. */
2158 memset(&tmp_desc, 0, sizeof(tmp_desc));
2159 tmp_desc.AlphaToCoverageEnable = desc->AlphaToCoverageEnable;
2160 tmp_desc.IndependentBlendEnable = desc->IndependentBlendEnable;
2161 for (i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
2163 j = desc->IndependentBlendEnable ? i : 0;
2164 tmp_desc.RenderTarget[i].BlendEnable = desc->RenderTarget[j].BlendEnable;
2165 tmp_desc.RenderTarget[i].SrcBlend = desc->RenderTarget[j].SrcBlend;
2166 tmp_desc.RenderTarget[i].DestBlend = desc->RenderTarget[j].DestBlend;
2167 tmp_desc.RenderTarget[i].BlendOp = desc->RenderTarget[j].BlendOp;
2168 tmp_desc.RenderTarget[i].SrcBlendAlpha = desc->RenderTarget[j].SrcBlendAlpha;
2169 tmp_desc.RenderTarget[i].DestBlendAlpha = desc->RenderTarget[j].DestBlendAlpha;
2170 tmp_desc.RenderTarget[i].BlendOpAlpha = desc->RenderTarget[j].BlendOpAlpha;
2171 tmp_desc.RenderTarget[i].RenderTargetWriteMask = desc->RenderTarget[j].RenderTargetWriteMask;
2174 wined3d_mutex_lock();
2175 if ((entry = wine_rb_get(&device->blend_states, &tmp_desc)))
2177 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_blend_state, entry);
2179 TRACE("Returning existing blend state %p.\n", object);
2180 *blend_state = &object->ID3D11BlendState_iface;
2181 ID3D11BlendState_AddRef(*blend_state);
2182 wined3d_mutex_unlock();
2184 return S_OK;
2186 wined3d_mutex_unlock();
2188 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2189 return E_OUTOFMEMORY;
2191 if (FAILED(hr = d3d_blend_state_init(object, device, &tmp_desc)))
2193 WARN("Failed to initialize blend state, hr %#x.\n", hr);
2194 HeapFree(GetProcessHeap(), 0, object);
2195 return hr;
2198 TRACE("Created blend state %p.\n", object);
2199 *blend_state = &object->ID3D11BlendState_iface;
2201 return S_OK;
2204 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilState(ID3D11Device *iface,
2205 const D3D11_DEPTH_STENCIL_DESC *desc, ID3D11DepthStencilState **depth_stencil_state)
2207 struct d3d_device *device = impl_from_ID3D11Device(iface);
2208 struct d3d_depthstencil_state *object;
2209 D3D11_DEPTH_STENCIL_DESC tmp_desc;
2210 struct wine_rb_entry *entry;
2211 HRESULT hr;
2213 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
2215 if (!desc)
2216 return E_INVALIDARG;
2218 /* D3D11_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
2219 * it as a key in the rbtree. */
2220 memset(&tmp_desc, 0, sizeof(tmp_desc));
2221 tmp_desc.DepthEnable = desc->DepthEnable;
2222 tmp_desc.DepthWriteMask = desc->DepthWriteMask;
2223 tmp_desc.DepthFunc = desc->DepthFunc;
2224 tmp_desc.StencilEnable = desc->StencilEnable;
2225 tmp_desc.StencilReadMask = desc->StencilReadMask;
2226 tmp_desc.StencilWriteMask = desc->StencilWriteMask;
2227 tmp_desc.FrontFace = desc->FrontFace;
2228 tmp_desc.BackFace = desc->BackFace;
2230 wined3d_mutex_lock();
2231 if ((entry = wine_rb_get(&device->depthstencil_states, &tmp_desc)))
2233 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_depthstencil_state, entry);
2235 TRACE("Returning existing depthstencil state %p.\n", object);
2236 *depth_stencil_state = &object->ID3D11DepthStencilState_iface;
2237 ID3D11DepthStencilState_AddRef(*depth_stencil_state);
2238 wined3d_mutex_unlock();
2240 return S_OK;
2242 wined3d_mutex_unlock();
2244 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2245 return E_OUTOFMEMORY;
2247 if (FAILED(hr = d3d_depthstencil_state_init(object, device, &tmp_desc)))
2249 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
2250 HeapFree(GetProcessHeap(), 0, object);
2251 return hr;
2254 TRACE("Created depthstencil state %p.\n", object);
2255 *depth_stencil_state = &object->ID3D11DepthStencilState_iface;
2257 return S_OK;
2260 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState(ID3D11Device *iface,
2261 const D3D11_RASTERIZER_DESC *desc, ID3D11RasterizerState **rasterizer_state)
2263 struct d3d_device *device = impl_from_ID3D11Device(iface);
2264 struct d3d_rasterizer_state *object;
2265 struct wine_rb_entry *entry;
2266 HRESULT hr;
2268 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
2270 if (!desc)
2271 return E_INVALIDARG;
2273 wined3d_mutex_lock();
2274 if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
2276 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_rasterizer_state, entry);
2278 TRACE("Returning existing rasterizer state %p.\n", object);
2279 *rasterizer_state = &object->ID3D11RasterizerState_iface;
2280 ID3D11RasterizerState_AddRef(*rasterizer_state);
2281 wined3d_mutex_unlock();
2283 return S_OK;
2285 wined3d_mutex_unlock();
2287 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2288 return E_OUTOFMEMORY;
2290 if (FAILED(hr = d3d_rasterizer_state_init(object, device, desc)))
2292 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
2293 HeapFree(GetProcessHeap(), 0, object);
2294 return hr;
2297 TRACE("Created rasterizer state %p.\n", object);
2298 *rasterizer_state = &object->ID3D11RasterizerState_iface;
2300 return S_OK;
2303 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateSamplerState(ID3D11Device *iface,
2304 const D3D11_SAMPLER_DESC *desc, ID3D11SamplerState **sampler_state)
2306 struct d3d_device *device = impl_from_ID3D11Device(iface);
2307 D3D11_SAMPLER_DESC normalized_desc;
2308 struct d3d_sampler_state *object;
2309 struct wine_rb_entry *entry;
2310 HRESULT hr;
2312 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
2314 if (!desc)
2315 return E_INVALIDARG;
2317 normalized_desc = *desc;
2318 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(normalized_desc.Filter))
2319 normalized_desc.MaxAnisotropy = 0;
2320 if (!D3D11_DECODE_IS_COMPARISON_FILTER(normalized_desc.Filter))
2321 normalized_desc.ComparisonFunc = D3D11_COMPARISON_NEVER;
2322 if (normalized_desc.AddressU != D3D11_TEXTURE_ADDRESS_BORDER
2323 && normalized_desc.AddressV != D3D11_TEXTURE_ADDRESS_BORDER
2324 && normalized_desc.AddressW != D3D11_TEXTURE_ADDRESS_BORDER)
2325 memset(&normalized_desc.BorderColor, 0, sizeof(normalized_desc.BorderColor));
2327 wined3d_mutex_lock();
2328 if ((entry = wine_rb_get(&device->sampler_states, &normalized_desc)))
2330 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_sampler_state, entry);
2332 TRACE("Returning existing sampler state %p.\n", object);
2333 *sampler_state = &object->ID3D11SamplerState_iface;
2334 ID3D11SamplerState_AddRef(*sampler_state);
2335 wined3d_mutex_unlock();
2337 return S_OK;
2339 wined3d_mutex_unlock();
2341 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2342 return E_OUTOFMEMORY;
2344 if (FAILED(hr = d3d_sampler_state_init(object, device, &normalized_desc)))
2346 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
2347 HeapFree(GetProcessHeap(), 0, object);
2348 return hr;
2351 TRACE("Created sampler state %p.\n", object);
2352 *sampler_state = &object->ID3D11SamplerState_iface;
2354 return S_OK;
2357 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateQuery(ID3D11Device *iface,
2358 const D3D11_QUERY_DESC *desc, ID3D11Query **query)
2360 struct d3d_device *device = impl_from_ID3D11Device(iface);
2361 struct d3d_query *object;
2362 HRESULT hr;
2364 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
2366 if (FAILED(hr = d3d_query_create(device, desc, FALSE, &object)))
2367 return hr;
2369 *query = &object->ID3D11Query_iface;
2371 return S_OK;
2374 static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePredicate(ID3D11Device *iface, const D3D11_QUERY_DESC *desc,
2375 ID3D11Predicate **predicate)
2377 struct d3d_device *device = impl_from_ID3D11Device(iface);
2378 struct d3d_query *object;
2379 HRESULT hr;
2381 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
2383 if (FAILED(hr = d3d_query_create(device, desc, TRUE, &object)))
2384 return hr;
2386 *predicate = (ID3D11Predicate *)&object->ID3D11Query_iface;
2388 return S_OK;
2391 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateCounter(ID3D11Device *iface, const D3D11_COUNTER_DESC *desc,
2392 ID3D11Counter **counter)
2394 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
2396 return E_NOTIMPL;
2399 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDeferredContext(ID3D11Device *iface, UINT flags,
2400 ID3D11DeviceContext **context)
2402 FIXME("iface %p, flags %#x, context %p stub!\n", iface, flags, context);
2404 return E_NOTIMPL;
2407 static HRESULT STDMETHODCALLTYPE d3d11_device_OpenSharedResource(ID3D11Device *iface, HANDLE resource, REFIID riid,
2408 void **out)
2410 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface, resource, debugstr_guid(riid), out);
2412 return E_NOTIMPL;
2415 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFormatSupport(ID3D11Device *iface, DXGI_FORMAT format,
2416 UINT *format_support)
2418 FIXME("iface %p, format %u, format_support %p stub!\n", iface, format, format_support);
2420 return E_NOTIMPL;
2423 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckMultisampleQualityLevels(ID3D11Device *iface,
2424 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
2426 struct d3d_device *device = impl_from_ID3D11Device(iface);
2427 struct wined3d_device_creation_parameters params;
2428 struct wined3d *wined3d;
2429 HRESULT hr;
2431 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
2432 iface, debug_dxgi_format(format), sample_count, quality_level_count);
2434 if (!quality_level_count)
2435 return E_INVALIDARG;
2437 *quality_level_count = 0;
2439 if (!sample_count)
2440 return E_FAIL;
2441 if (sample_count == 1)
2443 *quality_level_count = 1;
2444 return S_OK;
2446 if (sample_count > D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT)
2447 return E_FAIL;
2449 wined3d_mutex_lock();
2450 wined3d = wined3d_device_get_wined3d(device->wined3d_device);
2451 wined3d_device_get_creation_parameters(device->wined3d_device, &params);
2452 hr = wined3d_check_device_multisample_type(wined3d, params.adapter_idx, params.device_type,
2453 wined3dformat_from_dxgi_format(format), TRUE, sample_count, quality_level_count);
2454 wined3d_mutex_unlock();
2456 if (hr == WINED3DERR_INVALIDCALL)
2457 return E_INVALIDARG;
2458 if (hr == WINED3DERR_NOTAVAILABLE)
2459 return S_OK;
2460 return hr;
2463 static void STDMETHODCALLTYPE d3d11_device_CheckCounterInfo(ID3D11Device *iface, D3D11_COUNTER_INFO *info)
2465 FIXME("iface %p, info %p stub!\n", iface, info);
2468 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckCounter(ID3D11Device *iface, const D3D11_COUNTER_DESC *desc,
2469 D3D11_COUNTER_TYPE *type, UINT *active_counter_count, char *name, UINT *name_length,
2470 char *units, UINT *units_length, char *description, UINT *description_length)
2472 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
2473 "units %p, units_length %p, description %p, description_length %p stub!\n",
2474 iface, desc, type, active_counter_count, name, name_length,
2475 units, units_length, description, description_length);
2477 return E_NOTIMPL;
2480 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFeatureSupport(ID3D11Device *iface, D3D11_FEATURE feature,
2481 void *feature_support_data, UINT feature_support_data_size)
2483 FIXME("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u stub!\n",
2484 iface, feature, feature_support_data, feature_support_data_size);
2486 return E_NOTIMPL;
2489 static HRESULT STDMETHODCALLTYPE d3d11_device_GetPrivateData(ID3D11Device *iface, REFGUID guid,
2490 UINT *data_size, void *data)
2492 IDXGIDevice *dxgi_device;
2493 HRESULT hr;
2495 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
2497 if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
2498 return hr;
2499 hr = IDXGIDevice_GetPrivateData(dxgi_device, guid, data_size, data);
2500 IDXGIDevice_Release(dxgi_device);
2502 return hr;
2505 static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateData(ID3D11Device *iface, REFGUID guid,
2506 UINT data_size, const void *data)
2508 IDXGIDevice *dxgi_device;
2509 HRESULT hr;
2511 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
2513 if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
2514 return hr;
2515 hr = IDXGIDevice_SetPrivateData(dxgi_device, guid, data_size, data);
2516 IDXGIDevice_Release(dxgi_device);
2518 return hr;
2521 static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateDataInterface(ID3D11Device *iface, REFGUID guid,
2522 const IUnknown *data)
2524 IDXGIDevice *dxgi_device;
2525 HRESULT hr;
2527 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
2529 if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
2530 return hr;
2531 hr = IDXGIDevice_SetPrivateDataInterface(dxgi_device, guid, data);
2532 IDXGIDevice_Release(dxgi_device);
2534 return hr;
2537 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE d3d11_device_GetFeatureLevel(ID3D11Device *iface)
2539 FIXME("iface %p stub!\n", iface);
2541 return D3D_FEATURE_LEVEL_10_0;
2544 static UINT STDMETHODCALLTYPE d3d11_device_GetCreationFlags(ID3D11Device *iface)
2546 FIXME("iface %p stub!\n", iface);
2548 return 0;
2551 static HRESULT STDMETHODCALLTYPE d3d11_device_GetDeviceRemovedReason(ID3D11Device *iface)
2553 FIXME("iface %p stub!\n", iface);
2555 return S_OK;
2558 static void STDMETHODCALLTYPE d3d11_device_GetImmediateContext(ID3D11Device *iface,
2559 ID3D11DeviceContext **immediate_context)
2561 struct d3d_device *device = impl_from_ID3D11Device(iface);
2563 TRACE("iface %p, immediate_context %p.\n", iface, immediate_context);
2565 *immediate_context = &device->immediate_context.ID3D11DeviceContext_iface;
2566 ID3D11DeviceContext_AddRef(*immediate_context);
2569 static HRESULT STDMETHODCALLTYPE d3d11_device_SetExceptionMode(ID3D11Device *iface, UINT flags)
2571 FIXME("iface %p, flags %#x stub!\n", iface, flags);
2573 return E_NOTIMPL;
2576 static UINT STDMETHODCALLTYPE d3d11_device_GetExceptionMode(ID3D11Device *iface)
2578 FIXME("iface %p stub!\n", iface);
2580 return 0;
2583 static const struct ID3D11DeviceVtbl d3d11_device_vtbl =
2585 /* IUnknown methods */
2586 d3d11_device_QueryInterface,
2587 d3d11_device_AddRef,
2588 d3d11_device_Release,
2589 /* ID3D11Device methods */
2590 d3d11_device_CreateBuffer,
2591 d3d11_device_CreateTexture1D,
2592 d3d11_device_CreateTexture2D,
2593 d3d11_device_CreateTexture3D,
2594 d3d11_device_CreateShaderResourceView,
2595 d3d11_device_CreateUnorderedAccessView,
2596 d3d11_device_CreateRenderTargetView,
2597 d3d11_device_CreateDepthStencilView,
2598 d3d11_device_CreateInputLayout,
2599 d3d11_device_CreateVertexShader,
2600 d3d11_device_CreateGeometryShader,
2601 d3d11_device_CreateGeometryShaderWithStreamOutput,
2602 d3d11_device_CreatePixelShader,
2603 d3d11_device_CreateHullShader,
2604 d3d11_device_CreateDomainShader,
2605 d3d11_device_CreateComputeShader,
2606 d3d11_device_CreateClassLinkage,
2607 d3d11_device_CreateBlendState,
2608 d3d11_device_CreateDepthStencilState,
2609 d3d11_device_CreateRasterizerState,
2610 d3d11_device_CreateSamplerState,
2611 d3d11_device_CreateQuery,
2612 d3d11_device_CreatePredicate,
2613 d3d11_device_CreateCounter,
2614 d3d11_device_CreateDeferredContext,
2615 d3d11_device_OpenSharedResource,
2616 d3d11_device_CheckFormatSupport,
2617 d3d11_device_CheckMultisampleQualityLevels,
2618 d3d11_device_CheckCounterInfo,
2619 d3d11_device_CheckCounter,
2620 d3d11_device_CheckFeatureSupport,
2621 d3d11_device_GetPrivateData,
2622 d3d11_device_SetPrivateData,
2623 d3d11_device_SetPrivateDataInterface,
2624 d3d11_device_GetFeatureLevel,
2625 d3d11_device_GetCreationFlags,
2626 d3d11_device_GetDeviceRemovedReason,
2627 d3d11_device_GetImmediateContext,
2628 d3d11_device_SetExceptionMode,
2629 d3d11_device_GetExceptionMode,
2632 /* Inner IUnknown methods */
2634 static inline struct d3d_device *impl_from_IUnknown(IUnknown *iface)
2636 return CONTAINING_RECORD(iface, struct d3d_device, IUnknown_inner);
2639 static HRESULT STDMETHODCALLTYPE d3d_device_inner_QueryInterface(IUnknown *iface, REFIID riid, void **out)
2641 struct d3d_device *device = impl_from_IUnknown(iface);
2643 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
2645 if (IsEqualGUID(riid, &IID_ID3D11Device)
2646 || IsEqualGUID(riid, &IID_IUnknown))
2648 *out = &device->ID3D11Device_iface;
2650 else if (IsEqualGUID(riid, &IID_ID3D10Device1)
2651 || IsEqualGUID(riid, &IID_ID3D10Device))
2653 *out = &device->ID3D10Device1_iface;
2655 else if (IsEqualGUID(riid, &IID_ID3D10Multithread))
2657 *out = &device->ID3D10Multithread_iface;
2659 else if (IsEqualGUID(riid, &IID_IWineDXGIDeviceParent))
2661 *out = &device->IWineDXGIDeviceParent_iface;
2663 else
2665 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
2666 *out = NULL;
2667 return E_NOINTERFACE;
2670 IUnknown_AddRef((IUnknown *)*out);
2671 return S_OK;
2674 static ULONG STDMETHODCALLTYPE d3d_device_inner_AddRef(IUnknown *iface)
2676 struct d3d_device *device = impl_from_IUnknown(iface);
2677 ULONG refcount = InterlockedIncrement(&device->refcount);
2679 TRACE("%p increasing refcount to %u.\n", device, refcount);
2681 return refcount;
2684 static ULONG STDMETHODCALLTYPE d3d_device_inner_Release(IUnknown *iface)
2686 struct d3d_device *device = impl_from_IUnknown(iface);
2687 ULONG refcount = InterlockedDecrement(&device->refcount);
2689 TRACE("%p decreasing refcount to %u.\n", device, refcount);
2691 if (!refcount)
2693 if (device->wined3d_device)
2695 wined3d_mutex_lock();
2696 wined3d_device_decref(device->wined3d_device);
2697 wined3d_mutex_unlock();
2699 wine_rb_destroy(&device->sampler_states, NULL, NULL);
2700 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
2701 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2702 wine_rb_destroy(&device->blend_states, NULL, NULL);
2705 return refcount;
2708 /* IUnknown methods */
2710 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device1 *iface, REFIID riid,
2711 void **ppv)
2713 struct d3d_device *This = impl_from_ID3D10Device(iface);
2714 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
2717 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device1 *iface)
2719 struct d3d_device *This = impl_from_ID3D10Device(iface);
2720 return IUnknown_AddRef(This->outer_unk);
2723 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device1 *iface)
2725 struct d3d_device *This = impl_from_ID3D10Device(iface);
2726 return IUnknown_Release(This->outer_unk);
2729 /* ID3D10Device methods */
2731 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *iface,
2732 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
2734 struct d3d_device *device = impl_from_ID3D10Device(iface);
2735 unsigned int i;
2737 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2738 iface, start_slot, buffer_count, buffers);
2740 wined3d_mutex_lock();
2741 for (i = 0; i < buffer_count; ++i)
2743 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2745 wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i,
2746 buffer ? buffer->wined3d_buffer : NULL);
2748 wined3d_mutex_unlock();
2751 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device1 *iface,
2752 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
2754 struct d3d_device *device = impl_from_ID3D10Device(iface);
2755 unsigned int i;
2757 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2758 iface, start_slot, view_count, views);
2760 wined3d_mutex_lock();
2761 for (i = 0; i < view_count; ++i)
2763 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
2765 wined3d_device_set_ps_resource_view(device->wined3d_device, start_slot + i,
2766 view ? view->wined3d_view : NULL);
2768 wined3d_mutex_unlock();
2771 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device1 *iface,
2772 ID3D10PixelShader *shader)
2774 struct d3d_device *This = impl_from_ID3D10Device(iface);
2775 struct d3d_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader);
2777 TRACE("iface %p, shader %p\n", iface, shader);
2779 wined3d_mutex_lock();
2780 wined3d_device_set_pixel_shader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
2781 wined3d_mutex_unlock();
2784 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device1 *iface,
2785 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
2787 struct d3d_device *device = impl_from_ID3D10Device(iface);
2788 unsigned int i;
2790 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2791 iface, start_slot, sampler_count, samplers);
2793 wined3d_mutex_lock();
2794 for (i = 0; i < sampler_count; ++i)
2796 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
2798 wined3d_device_set_ps_sampler(device->wined3d_device, start_slot + i,
2799 sampler ? sampler->wined3d_sampler : NULL);
2801 wined3d_mutex_unlock();
2804 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device1 *iface,
2805 ID3D10VertexShader *shader)
2807 struct d3d_device *This = impl_from_ID3D10Device(iface);
2808 struct d3d_vertex_shader *vs = unsafe_impl_from_ID3D10VertexShader(shader);
2810 TRACE("iface %p, shader %p\n", iface, shader);
2812 wined3d_mutex_lock();
2813 wined3d_device_set_vertex_shader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
2814 wined3d_mutex_unlock();
2817 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device1 *iface, UINT index_count,
2818 UINT start_index_location, INT base_vertex_location)
2820 struct d3d_device *This = impl_from_ID3D10Device(iface);
2822 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
2823 iface, index_count, start_index_location, base_vertex_location);
2825 wined3d_mutex_lock();
2826 wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
2827 wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
2828 wined3d_mutex_unlock();
2831 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device1 *iface, UINT vertex_count,
2832 UINT start_vertex_location)
2834 struct d3d_device *This = impl_from_ID3D10Device(iface);
2836 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
2837 iface, vertex_count, start_vertex_location);
2839 wined3d_mutex_lock();
2840 wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
2841 wined3d_mutex_unlock();
2844 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device1 *iface,
2845 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
2847 struct d3d_device *device = impl_from_ID3D10Device(iface);
2848 unsigned int i;
2850 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2851 iface, start_slot, buffer_count, buffers);
2853 wined3d_mutex_lock();
2854 for (i = 0; i < buffer_count; ++i)
2856 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2858 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
2859 buffer ? buffer->wined3d_buffer : NULL);
2861 wined3d_mutex_unlock();
2864 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device1 *iface,
2865 ID3D10InputLayout *input_layout)
2867 struct d3d_device *This = impl_from_ID3D10Device(iface);
2868 struct d3d_input_layout *layout = unsafe_impl_from_ID3D10InputLayout(input_layout);
2870 TRACE("iface %p, input_layout %p\n", iface, input_layout);
2872 wined3d_mutex_lock();
2873 wined3d_device_set_vertex_declaration(This->wined3d_device,
2874 layout ? layout->wined3d_decl : NULL);
2875 wined3d_mutex_unlock();
2878 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device1 *iface, UINT start_slot,
2879 UINT buffer_count, ID3D10Buffer *const *buffers, const UINT *strides, const UINT *offsets)
2881 struct d3d_device *This = impl_from_ID3D10Device(iface);
2882 unsigned int i;
2884 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
2885 iface, start_slot, buffer_count, buffers, strides, offsets);
2887 wined3d_mutex_lock();
2888 for (i = 0; i < buffer_count; ++i)
2890 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2892 wined3d_device_set_stream_source(This->wined3d_device, start_slot + i,
2893 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
2895 wined3d_mutex_unlock();
2898 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device1 *iface,
2899 ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
2901 struct d3d_device *This = impl_from_ID3D10Device(iface);
2902 struct d3d_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
2904 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
2905 iface, buffer, debug_dxgi_format(format), offset);
2907 wined3d_mutex_lock();
2908 wined3d_device_set_index_buffer(This->wined3d_device,
2909 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
2910 wined3dformat_from_dxgi_format(format));
2911 wined3d_mutex_unlock();
2912 if (offset) FIXME("offset %u not supported.\n", offset);
2915 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device1 *iface,
2916 UINT instance_index_count, UINT instance_count, UINT start_index_location,
2917 INT base_vertex_location, UINT start_instance_location)
2919 struct d3d_device *device = impl_from_ID3D10Device(iface);
2921 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
2922 "base_vertex_location %d, start_instance_location %u.\n",
2923 iface, instance_index_count, instance_count, start_index_location,
2924 base_vertex_location, start_instance_location);
2926 wined3d_mutex_lock();
2927 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
2928 wined3d_device_draw_indexed_primitive_instanced(device->wined3d_device, start_index_location,
2929 instance_index_count, start_instance_location, instance_count);
2930 wined3d_mutex_unlock();
2933 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device1 *iface,
2934 UINT instance_vertex_count, UINT instance_count,
2935 UINT start_vertex_location, UINT start_instance_location)
2937 struct d3d_device *device = impl_from_ID3D10Device(iface);
2939 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
2940 "start_instance_location %u.\n", iface, instance_vertex_count, instance_count,
2941 start_vertex_location, start_instance_location);
2943 wined3d_mutex_lock();
2944 wined3d_device_draw_primitive_instanced(device->wined3d_device, start_vertex_location,
2945 instance_vertex_count, start_instance_location, instance_count);
2946 wined3d_mutex_unlock();
2949 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device1 *iface,
2950 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
2952 struct d3d_device *device = impl_from_ID3D10Device(iface);
2953 unsigned int i;
2955 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2956 iface, start_slot, buffer_count, buffers);
2958 wined3d_mutex_lock();
2959 for (i = 0; i < buffer_count; ++i)
2961 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2963 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
2964 buffer ? buffer->wined3d_buffer : NULL);
2966 wined3d_mutex_unlock();
2969 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device1 *iface, ID3D10GeometryShader *shader)
2971 struct d3d_device *device = impl_from_ID3D10Device(iface);
2972 struct d3d_geometry_shader *gs = unsafe_impl_from_ID3D10GeometryShader(shader);
2974 TRACE("iface %p, shader %p.\n", iface, shader);
2976 wined3d_mutex_lock();
2977 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
2978 wined3d_mutex_unlock();
2981 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device1 *iface,
2982 D3D10_PRIMITIVE_TOPOLOGY topology)
2984 struct d3d_device *This = impl_from_ID3D10Device(iface);
2986 TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
2988 wined3d_mutex_lock();
2989 wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
2990 wined3d_mutex_unlock();
2993 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device1 *iface,
2994 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
2996 struct d3d_device *device = impl_from_ID3D10Device(iface);
2997 unsigned int i;
2999 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3000 iface, start_slot, view_count, views);
3002 wined3d_mutex_lock();
3003 for (i = 0; i < view_count; ++i)
3005 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
3007 wined3d_device_set_vs_resource_view(device->wined3d_device, start_slot + i,
3008 view ? view->wined3d_view : NULL);
3010 wined3d_mutex_unlock();
3013 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device1 *iface,
3014 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
3016 struct d3d_device *device = impl_from_ID3D10Device(iface);
3017 unsigned int i;
3019 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3020 iface, start_slot, sampler_count, samplers);
3022 wined3d_mutex_lock();
3023 for (i = 0; i < sampler_count; ++i)
3025 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
3027 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
3028 sampler ? sampler->wined3d_sampler : NULL);
3030 wined3d_mutex_unlock();
3033 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device1 *iface, ID3D10Predicate *predicate, BOOL value)
3035 struct d3d_device *device = impl_from_ID3D10Device(iface);
3036 struct d3d_query *query;
3038 TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value);
3040 query = unsafe_impl_from_ID3D10Query((ID3D10Query *)predicate);
3041 wined3d_mutex_lock();
3042 wined3d_device_set_predication(device->wined3d_device, query ? query->wined3d_query : NULL, value);
3043 wined3d_mutex_unlock();
3046 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device1 *iface,
3047 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
3049 struct d3d_device *device = impl_from_ID3D10Device(iface);
3050 unsigned int i;
3052 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3053 iface, start_slot, view_count, views);
3055 wined3d_mutex_lock();
3056 for (i = 0; i < view_count; ++i)
3058 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
3060 wined3d_device_set_gs_resource_view(device->wined3d_device, start_slot + i,
3061 view ? view->wined3d_view : NULL);
3063 wined3d_mutex_unlock();
3066 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device1 *iface,
3067 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
3069 struct d3d_device *device = impl_from_ID3D10Device(iface);
3070 unsigned int i;
3072 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3073 iface, start_slot, sampler_count, samplers);
3075 wined3d_mutex_lock();
3076 for (i = 0; i < sampler_count; ++i)
3078 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
3080 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
3081 sampler ? sampler->wined3d_sampler : NULL);
3083 wined3d_mutex_unlock();
3086 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device1 *iface,
3087 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
3088 ID3D10DepthStencilView *depth_stencil_view)
3090 struct d3d_device *device = impl_from_ID3D10Device(iface);
3091 struct d3d_depthstencil_view *dsv;
3092 unsigned int i;
3094 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3095 iface, render_target_view_count, render_target_views, depth_stencil_view);
3097 wined3d_mutex_lock();
3098 for (i = 0; i < render_target_view_count; ++i)
3100 struct d3d_rendertarget_view *rtv = unsafe_impl_from_ID3D10RenderTargetView(render_target_views[i]);
3102 wined3d_device_set_rendertarget_view(device->wined3d_device, i,
3103 rtv ? rtv->wined3d_view : NULL, FALSE);
3105 for (; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
3107 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
3110 dsv = unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view);
3111 wined3d_device_set_depth_stencil_view(device->wined3d_device,
3112 dsv ? dsv->wined3d_view : NULL);
3113 wined3d_mutex_unlock();
3116 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface,
3117 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
3119 struct d3d_device *device = impl_from_ID3D10Device(iface);
3120 struct d3d_blend_state *blend_state_object;
3122 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask 0x%08x.\n",
3123 iface, blend_state, blend_factor, sample_mask);
3125 blend_state_object = unsafe_impl_from_ID3D10BlendState(blend_state);
3126 d3d11_immediate_context_OMSetBlendState(&device->immediate_context.ID3D11DeviceContext_iface,
3127 blend_state_object ? &blend_state_object->ID3D11BlendState_iface : NULL, blend_factor, sample_mask);
3130 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1 *iface,
3131 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
3133 struct d3d_device *device = impl_from_ID3D10Device(iface);
3135 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
3136 iface, depth_stencil_state, stencil_ref);
3138 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
3139 device->stencil_ref = stencil_ref;
3142 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface,
3143 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
3145 struct d3d_device *device = impl_from_ID3D10Device(iface);
3146 unsigned int count, i;
3148 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
3150 count = min(target_count, 4);
3151 wined3d_mutex_lock();
3152 for (i = 0; i < count; ++i)
3154 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
3156 wined3d_device_set_stream_output(device->wined3d_device, i,
3157 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
3160 for (i = count; i < 4; ++i)
3162 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
3164 wined3d_mutex_unlock();
3167 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device1 *iface)
3169 FIXME("iface %p stub!\n", iface);
3172 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device1 *iface, ID3D10RasterizerState *rasterizer_state)
3174 struct d3d_device *device = impl_from_ID3D10Device(iface);
3175 struct d3d_rasterizer_state *rasterizer_state_object;
3177 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
3179 rasterizer_state_object = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state);
3180 d3d11_immediate_context_RSSetState(&device->immediate_context.ID3D11DeviceContext_iface,
3181 rasterizer_state_object ? &rasterizer_state_object->ID3D11RasterizerState_iface : NULL);
3184 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface,
3185 UINT viewport_count, const D3D10_VIEWPORT *viewports)
3187 struct d3d_device *device = impl_from_ID3D10Device(iface);
3188 struct wined3d_viewport wined3d_vp;
3190 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
3192 if (viewport_count > 1)
3193 FIXME("Multiple viewports not implemented.\n");
3195 if (!viewport_count)
3196 return;
3198 wined3d_vp.x = viewports[0].TopLeftX;
3199 wined3d_vp.y = viewports[0].TopLeftY;
3200 wined3d_vp.width = viewports[0].Width;
3201 wined3d_vp.height = viewports[0].Height;
3202 wined3d_vp.min_z = viewports[0].MinDepth;
3203 wined3d_vp.max_z = viewports[0].MaxDepth;
3205 wined3d_mutex_lock();
3206 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
3207 wined3d_mutex_unlock();
3210 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *iface,
3211 UINT rect_count, const D3D10_RECT *rects)
3213 struct d3d_device *device = impl_from_ID3D10Device(iface);
3215 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
3217 if (rect_count > 1)
3218 FIXME("Multiple scissor rects not implemented.\n");
3220 if (!rect_count)
3221 return;
3223 wined3d_mutex_lock();
3224 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
3225 wined3d_mutex_unlock();
3228 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *iface,
3229 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
3230 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
3232 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
3233 struct d3d_device *device = impl_from_ID3D10Device(iface);
3234 struct wined3d_box wined3d_src_box;
3236 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
3237 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
3238 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
3239 src_resource, src_subresource_idx, src_box);
3241 if (src_box)
3243 wined3d_src_box.left = src_box->left;
3244 wined3d_src_box.top = src_box->top;
3245 wined3d_src_box.front = src_box->front;
3246 wined3d_src_box.right = src_box->right;
3247 wined3d_src_box.bottom = src_box->bottom;
3248 wined3d_src_box.back = src_box->back;
3251 wined3d_dst_resource = wined3d_resource_from_d3d10_resource(dst_resource);
3252 wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource);
3253 wined3d_mutex_lock();
3254 wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx,
3255 dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL);
3256 wined3d_mutex_unlock();
3259 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,
3260 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
3262 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
3263 struct d3d_device *device = impl_from_ID3D10Device(iface);
3265 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
3267 wined3d_dst_resource = wined3d_resource_from_d3d10_resource(dst_resource);
3268 wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource);
3269 wined3d_mutex_lock();
3270 wined3d_device_copy_resource(device->wined3d_device, wined3d_dst_resource, wined3d_src_resource);
3271 wined3d_mutex_unlock();
3274 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface,
3275 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
3276 const void *data, UINT row_pitch, UINT depth_pitch)
3278 struct d3d_device *device = impl_from_ID3D10Device(iface);
3279 ID3D11Resource *d3d11_resource;
3281 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
3282 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
3284 ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource);
3285 d3d11_immediate_context_UpdateSubresource(&device->immediate_context.ID3D11DeviceContext_iface,
3286 d3d11_resource, subresource_idx, (const D3D11_BOX *)box, data, row_pitch, depth_pitch);
3287 ID3D11Resource_Release(d3d11_resource);
3290 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 *iface,
3291 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
3293 struct d3d_device *device = impl_from_ID3D10Device(iface);
3294 struct d3d_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
3295 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
3296 HRESULT hr;
3298 TRACE("iface %p, render_target_view %p, color_rgba {%.8e, %.8e, %.8e, %.8e}.\n",
3299 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
3301 wined3d_mutex_lock();
3302 if (FAILED(hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, view->wined3d_view, NULL, &color)))
3303 ERR("Failed to clear view, hr %#x.\n", hr);
3304 wined3d_mutex_unlock();
3307 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *iface,
3308 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
3310 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
3311 iface, depth_stencil_view, flags, depth, stencil);
3314 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
3315 ID3D10ShaderResourceView *shader_resource_view)
3317 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
3320 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *iface,
3321 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
3322 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
3324 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
3325 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
3326 iface, dst_resource, dst_subresource_idx,
3327 src_resource, src_subresource_idx, debug_dxgi_format(format));
3330 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device1 *iface,
3331 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
3333 struct d3d_device *device = impl_from_ID3D10Device(iface);
3334 unsigned int i;
3336 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3337 iface, start_slot, buffer_count, buffers);
3339 wined3d_mutex_lock();
3340 for (i = 0; i < buffer_count; ++i)
3342 struct wined3d_buffer *wined3d_buffer;
3343 struct d3d_buffer *buffer_impl;
3345 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
3347 buffers[i] = NULL;
3348 continue;
3351 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3352 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3353 ID3D10Buffer_AddRef(buffers[i]);
3355 wined3d_mutex_unlock();
3358 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device1 *iface,
3359 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
3361 struct d3d_device *device = impl_from_ID3D10Device(iface);
3362 unsigned int i;
3364 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3365 iface, start_slot, view_count, views);
3367 wined3d_mutex_lock();
3368 for (i = 0; i < view_count; ++i)
3370 struct wined3d_shader_resource_view *wined3d_view;
3371 struct d3d_shader_resource_view *view_impl;
3373 if (!(wined3d_view = wined3d_device_get_ps_resource_view(device->wined3d_device, start_slot + i)))
3375 views[i] = NULL;
3376 continue;
3379 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
3380 views[i] = (ID3D10ShaderResourceView *)&view_impl->ID3D10ShaderResourceView1_iface;
3381 ID3D10ShaderResourceView_AddRef(views[i]);
3383 wined3d_mutex_unlock();
3386 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device1 *iface, ID3D10PixelShader **shader)
3388 struct d3d_device *device = impl_from_ID3D10Device(iface);
3389 struct d3d_pixel_shader *shader_impl;
3390 struct wined3d_shader *wined3d_shader;
3392 TRACE("iface %p, shader %p.\n", iface, shader);
3394 wined3d_mutex_lock();
3395 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
3397 wined3d_mutex_unlock();
3398 *shader = NULL;
3399 return;
3402 shader_impl = wined3d_shader_get_parent(wined3d_shader);
3403 wined3d_mutex_unlock();
3404 *shader = &shader_impl->ID3D10PixelShader_iface;
3405 ID3D10PixelShader_AddRef(*shader);
3408 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device1 *iface,
3409 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
3411 struct d3d_device *device = impl_from_ID3D10Device(iface);
3412 unsigned int i;
3414 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3415 iface, start_slot, sampler_count, samplers);
3417 wined3d_mutex_lock();
3418 for (i = 0; i < sampler_count; ++i)
3420 struct d3d_sampler_state *sampler_impl;
3421 struct wined3d_sampler *wined3d_sampler;
3423 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
3425 samplers[i] = NULL;
3426 continue;
3429 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
3430 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
3431 ID3D10SamplerState_AddRef(samplers[i]);
3433 wined3d_mutex_unlock();
3436 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device1 *iface, ID3D10VertexShader **shader)
3438 struct d3d_device *device = impl_from_ID3D10Device(iface);
3439 struct d3d_vertex_shader *shader_impl;
3440 struct wined3d_shader *wined3d_shader;
3442 TRACE("iface %p, shader %p.\n", iface, shader);
3444 wined3d_mutex_lock();
3445 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
3447 wined3d_mutex_unlock();
3448 *shader = NULL;
3449 return;
3452 shader_impl = wined3d_shader_get_parent(wined3d_shader);
3453 wined3d_mutex_unlock();
3454 *shader = &shader_impl->ID3D10VertexShader_iface;
3455 ID3D10VertexShader_AddRef(*shader);
3458 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device1 *iface,
3459 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
3461 struct d3d_device *device = impl_from_ID3D10Device(iface);
3462 unsigned int i;
3464 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3465 iface, start_slot, buffer_count, buffers);
3467 wined3d_mutex_lock();
3468 for (i = 0; i < buffer_count; ++i)
3470 struct wined3d_buffer *wined3d_buffer;
3471 struct d3d_buffer *buffer_impl;
3473 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
3475 buffers[i] = NULL;
3476 continue;
3479 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3480 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3481 ID3D10Buffer_AddRef(buffers[i]);
3483 wined3d_mutex_unlock();
3486 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device1 *iface, ID3D10InputLayout **input_layout)
3488 struct d3d_device *device = impl_from_ID3D10Device(iface);
3489 struct wined3d_vertex_declaration *wined3d_declaration;
3490 struct d3d_input_layout *input_layout_impl;
3492 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
3494 wined3d_mutex_lock();
3495 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
3497 wined3d_mutex_unlock();
3498 *input_layout = NULL;
3499 return;
3502 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
3503 wined3d_mutex_unlock();
3504 *input_layout = &input_layout_impl->ID3D10InputLayout_iface;
3505 ID3D10InputLayout_AddRef(*input_layout);
3508 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device1 *iface,
3509 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
3511 struct d3d_device *device = impl_from_ID3D10Device(iface);
3512 unsigned int i;
3514 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
3515 iface, start_slot, buffer_count, buffers, strides, offsets);
3517 wined3d_mutex_lock();
3518 for (i = 0; i < buffer_count; ++i)
3520 struct wined3d_buffer *wined3d_buffer;
3521 struct d3d_buffer *buffer_impl;
3523 if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
3524 &wined3d_buffer, &offsets[i], &strides[i])))
3525 ERR("Failed to get vertex buffer.\n");
3527 if (!wined3d_buffer)
3529 buffers[i] = NULL;
3530 continue;
3533 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3534 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3535 ID3D10Buffer_AddRef(buffers[i]);
3537 wined3d_mutex_unlock();
3540 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device1 *iface,
3541 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
3543 struct d3d_device *device = impl_from_ID3D10Device(iface);
3544 enum wined3d_format_id wined3d_format;
3545 struct wined3d_buffer *wined3d_buffer;
3546 struct d3d_buffer *buffer_impl;
3548 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
3550 wined3d_mutex_lock();
3551 wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
3552 *format = dxgi_format_from_wined3dformat(wined3d_format);
3553 *offset = 0; /* FIXME */
3554 if (!wined3d_buffer)
3556 wined3d_mutex_unlock();
3557 *buffer = NULL;
3558 return;
3561 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3562 wined3d_mutex_unlock();
3563 *buffer = &buffer_impl->ID3D10Buffer_iface;
3564 ID3D10Buffer_AddRef(*buffer);
3567 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device1 *iface,
3568 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
3570 struct d3d_device *device = impl_from_ID3D10Device(iface);
3571 unsigned int i;
3573 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3574 iface, start_slot, buffer_count, buffers);
3576 wined3d_mutex_lock();
3577 for (i = 0; i < buffer_count; ++i)
3579 struct wined3d_buffer *wined3d_buffer;
3580 struct d3d_buffer *buffer_impl;
3582 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
3584 buffers[i] = NULL;
3585 continue;
3588 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3589 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3590 ID3D10Buffer_AddRef(buffers[i]);
3592 wined3d_mutex_unlock();
3595 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device1 *iface, ID3D10GeometryShader **shader)
3597 struct d3d_device *device = impl_from_ID3D10Device(iface);
3598 struct d3d_geometry_shader *shader_impl;
3599 struct wined3d_shader *wined3d_shader;
3601 TRACE("iface %p, shader %p.\n", iface, shader);
3603 wined3d_mutex_lock();
3604 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
3606 wined3d_mutex_unlock();
3607 *shader = NULL;
3608 return;
3611 shader_impl = wined3d_shader_get_parent(wined3d_shader);
3612 wined3d_mutex_unlock();
3613 *shader = &shader_impl->ID3D10GeometryShader_iface;
3614 ID3D10GeometryShader_AddRef(*shader);
3617 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device1 *iface,
3618 D3D10_PRIMITIVE_TOPOLOGY *topology)
3620 struct d3d_device *This = impl_from_ID3D10Device(iface);
3622 TRACE("iface %p, topology %p\n", iface, topology);
3624 wined3d_mutex_lock();
3625 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
3626 wined3d_mutex_unlock();
3629 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device1 *iface,
3630 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
3632 struct d3d_device *device = impl_from_ID3D10Device(iface);
3633 unsigned int i;
3635 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3636 iface, start_slot, view_count, views);
3638 wined3d_mutex_lock();
3639 for (i = 0; i < view_count; ++i)
3641 struct wined3d_shader_resource_view *wined3d_view;
3642 struct d3d_shader_resource_view *view_impl;
3644 if (!(wined3d_view = wined3d_device_get_vs_resource_view(device->wined3d_device, start_slot + i)))
3646 views[i] = NULL;
3647 continue;
3650 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
3651 views[i] = (ID3D10ShaderResourceView *)&view_impl->ID3D10ShaderResourceView1_iface;
3652 ID3D10ShaderResourceView_AddRef(views[i]);
3654 wined3d_mutex_unlock();
3657 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device1 *iface,
3658 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
3660 struct d3d_device *device = impl_from_ID3D10Device(iface);
3661 unsigned int i;
3663 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3664 iface, start_slot, sampler_count, samplers);
3666 wined3d_mutex_lock();
3667 for (i = 0; i < sampler_count; ++i)
3669 struct d3d_sampler_state *sampler_impl;
3670 struct wined3d_sampler *wined3d_sampler;
3672 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
3674 samplers[i] = NULL;
3675 continue;
3678 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
3679 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
3680 ID3D10SamplerState_AddRef(samplers[i]);
3682 wined3d_mutex_unlock();
3685 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device1 *iface,
3686 ID3D10Predicate **predicate, BOOL *value)
3688 struct d3d_device *device = impl_from_ID3D10Device(iface);
3689 struct wined3d_query *wined3d_predicate;
3690 struct d3d_query *predicate_impl;
3692 TRACE("iface %p, predicate %p, value %p.\n", iface, predicate, value);
3694 wined3d_mutex_lock();
3695 if (!(wined3d_predicate = wined3d_device_get_predication(device->wined3d_device, value)))
3697 wined3d_mutex_unlock();
3698 *predicate = NULL;
3699 return;
3702 predicate_impl = wined3d_query_get_parent(wined3d_predicate);
3703 wined3d_mutex_unlock();
3704 *predicate = (ID3D10Predicate *)&predicate_impl->ID3D10Query_iface;
3705 ID3D10Predicate_AddRef(*predicate);
3708 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device1 *iface,
3709 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
3711 struct d3d_device *device = impl_from_ID3D10Device(iface);
3712 unsigned int i;
3714 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3715 iface, start_slot, view_count, views);
3717 wined3d_mutex_lock();
3718 for (i = 0; i < view_count; ++i)
3720 struct wined3d_shader_resource_view *wined3d_view;
3721 struct d3d_shader_resource_view *view_impl;
3723 if (!(wined3d_view = wined3d_device_get_gs_resource_view(device->wined3d_device, start_slot + i)))
3725 views[i] = NULL;
3726 continue;
3729 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
3730 views[i] = (ID3D10ShaderResourceView *)&view_impl->ID3D10ShaderResourceView1_iface;
3731 ID3D10ShaderResourceView_AddRef(views[i]);
3733 wined3d_mutex_unlock();
3736 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device1 *iface,
3737 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
3739 struct d3d_device *device = impl_from_ID3D10Device(iface);
3740 unsigned int i;
3742 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3743 iface, start_slot, sampler_count, samplers);
3745 wined3d_mutex_lock();
3746 for (i = 0; i < sampler_count; ++i)
3748 struct d3d_sampler_state *sampler_impl;
3749 struct wined3d_sampler *wined3d_sampler;
3751 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
3753 samplers[i] = NULL;
3754 continue;
3757 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
3758 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
3759 ID3D10SamplerState_AddRef(samplers[i]);
3761 wined3d_mutex_unlock();
3764 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device1 *iface,
3765 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
3767 struct d3d_device *device = impl_from_ID3D10Device(iface);
3768 struct wined3d_rendertarget_view *wined3d_view;
3770 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3771 iface, view_count, render_target_views, depth_stencil_view);
3773 wined3d_mutex_lock();
3774 if (render_target_views)
3776 struct d3d_rendertarget_view *view_impl;
3777 unsigned int i;
3779 for (i = 0; i < view_count; ++i)
3781 if (!(wined3d_view = wined3d_device_get_rendertarget_view(device->wined3d_device, i))
3782 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
3784 render_target_views[i] = NULL;
3785 continue;
3788 render_target_views[i] = &view_impl->ID3D10RenderTargetView_iface;
3789 ID3D10RenderTargetView_AddRef(render_target_views[i]);
3793 if (depth_stencil_view)
3795 struct d3d_depthstencil_view *view_impl;
3797 if (!(wined3d_view = wined3d_device_get_depth_stencil_view(device->wined3d_device))
3798 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
3800 *depth_stencil_view = NULL;
3802 else
3804 *depth_stencil_view = &view_impl->ID3D10DepthStencilView_iface;
3805 ID3D10DepthStencilView_AddRef(*depth_stencil_view);
3808 wined3d_mutex_unlock();
3811 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface,
3812 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
3814 struct d3d_device *device = impl_from_ID3D10Device(iface);
3816 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
3817 iface, blend_state, blend_factor, sample_mask);
3819 if ((*blend_state = device->blend_state ? (ID3D10BlendState *)&device->blend_state->ID3D10BlendState1_iface : NULL))
3820 ID3D10BlendState_AddRef(*blend_state);
3821 wined3d_mutex_lock();
3822 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
3823 *sample_mask = wined3d_device_get_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK);
3824 wined3d_mutex_unlock();
3827 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
3828 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
3830 struct d3d_device *device = impl_from_ID3D10Device(iface);
3832 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
3833 iface, depth_stencil_state, stencil_ref);
3835 if ((*depth_stencil_state = device->depth_stencil_state
3836 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
3837 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
3838 *stencil_ref = device->stencil_ref;
3841 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device1 *iface,
3842 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
3844 struct d3d_device *device = impl_from_ID3D10Device(iface);
3845 unsigned int i;
3847 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
3848 iface, buffer_count, buffers, offsets);
3850 wined3d_mutex_lock();
3851 for (i = 0; i < buffer_count; ++i)
3853 struct wined3d_buffer *wined3d_buffer;
3854 struct d3d_buffer *buffer_impl;
3856 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
3858 buffers[i] = NULL;
3859 continue;
3862 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3863 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3864 ID3D10Buffer_AddRef(buffers[i]);
3866 wined3d_mutex_unlock();
3869 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device1 *iface, ID3D10RasterizerState **rasterizer_state)
3871 struct d3d_device *device = impl_from_ID3D10Device(iface);
3873 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
3875 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
3876 ID3D10RasterizerState_AddRef(*rasterizer_state);
3879 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface,
3880 UINT *viewport_count, D3D10_VIEWPORT *viewports)
3882 struct d3d_device *device = impl_from_ID3D10Device(iface);
3883 struct wined3d_viewport wined3d_vp;
3885 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
3887 if (!viewports)
3889 *viewport_count = 1;
3890 return;
3893 if (!*viewport_count)
3894 return;
3896 wined3d_mutex_lock();
3897 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
3898 wined3d_mutex_unlock();
3900 viewports[0].TopLeftX = wined3d_vp.x;
3901 viewports[0].TopLeftY = wined3d_vp.y;
3902 viewports[0].Width = wined3d_vp.width;
3903 viewports[0].Height = wined3d_vp.height;
3904 viewports[0].MinDepth = wined3d_vp.min_z;
3905 viewports[0].MaxDepth = wined3d_vp.max_z;
3907 if (*viewport_count > 1)
3908 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
3911 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects)
3913 struct d3d_device *device = impl_from_ID3D10Device(iface);
3915 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
3917 if (!rects)
3919 *rect_count = 1;
3920 return;
3923 if (!*rect_count)
3924 return;
3926 wined3d_mutex_lock();
3927 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
3928 wined3d_mutex_unlock();
3929 if (*rect_count > 1)
3930 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
3933 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device1 *iface)
3935 TRACE("iface %p.\n", iface);
3937 /* In the current implementation the device is never removed, so we can
3938 * just return S_OK here. */
3940 return S_OK;
3943 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device1 *iface, UINT flags)
3945 FIXME("iface %p, flags %#x stub!\n", iface, flags);
3947 return E_NOTIMPL;
3950 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device1 *iface)
3952 FIXME("iface %p stub!\n", iface);
3954 return 0;
3957 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *iface,
3958 REFGUID guid, UINT *data_size, void *data)
3960 struct d3d_device *device = impl_from_ID3D10Device(iface);
3962 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
3964 return d3d11_device_GetPrivateData(&device->ID3D11Device_iface, guid, data_size, data);
3967 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface,
3968 REFGUID guid, UINT data_size, const void *data)
3970 struct d3d_device *device = impl_from_ID3D10Device(iface);
3972 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
3974 return d3d11_device_SetPrivateData(&device->ID3D11Device_iface, guid, data_size, data);
3977 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface,
3978 REFGUID guid, const IUnknown *data)
3980 struct d3d_device *device = impl_from_ID3D10Device(iface);
3982 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
3984 return d3d11_device_SetPrivateDataInterface(&device->ID3D11Device_iface, guid, data);
3987 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface)
3989 static const float blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f};
3990 struct d3d_device *device = impl_from_ID3D10Device(iface);
3991 unsigned int i;
3993 TRACE("iface %p.\n", iface);
3995 wined3d_mutex_lock();
3996 wined3d_device_set_vertex_shader(device->wined3d_device, NULL);
3997 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
3999 wined3d_device_set_vs_sampler(device->wined3d_device, i, NULL);
4001 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
4003 wined3d_device_set_vs_resource_view(device->wined3d_device, i, NULL);
4005 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
4007 wined3d_device_set_vs_cb(device->wined3d_device, i, NULL);
4009 wined3d_device_set_geometry_shader(device->wined3d_device, NULL);
4010 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
4012 wined3d_device_set_gs_sampler(device->wined3d_device, i, NULL);
4014 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
4016 wined3d_device_set_gs_resource_view(device->wined3d_device, i, NULL);
4018 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
4020 wined3d_device_set_gs_cb(device->wined3d_device, i, NULL);
4022 wined3d_device_set_pixel_shader(device->wined3d_device, NULL);
4023 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
4025 wined3d_device_set_ps_sampler(device->wined3d_device, i, NULL);
4027 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
4029 wined3d_device_set_ps_resource_view(device->wined3d_device, i, NULL);
4031 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
4033 wined3d_device_set_ps_cb(device->wined3d_device, i, NULL);
4035 for (i = 0; i < D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; ++i)
4037 wined3d_device_set_stream_source(device->wined3d_device, i, NULL, 0, 0);
4039 wined3d_device_set_index_buffer(device->wined3d_device, NULL, WINED3DFMT_UNKNOWN);
4040 wined3d_device_set_vertex_declaration(device->wined3d_device, NULL);
4041 wined3d_device_set_primitive_type(device->wined3d_device, WINED3D_PT_UNDEFINED);
4042 for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
4044 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
4046 wined3d_device_set_depth_stencil_view(device->wined3d_device, NULL);
4047 ID3D10Device1_OMSetDepthStencilState(iface, NULL, 0);
4048 ID3D10Device1_OMSetBlendState(iface, NULL, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
4049 ID3D10Device1_RSSetViewports(iface, 0, NULL);
4050 ID3D10Device1_RSSetScissorRects(iface, 0, NULL);
4051 ID3D10Device1_RSSetState(iface, NULL);
4052 for (i = 0; i < D3D10_SO_BUFFER_SLOT_COUNT; ++i)
4054 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
4056 wined3d_device_set_predication(device->wined3d_device, NULL, FALSE);
4057 wined3d_mutex_unlock();
4060 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
4062 FIXME("iface %p stub!\n", iface);
4065 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
4066 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
4068 struct d3d_device *device = impl_from_ID3D10Device(iface);
4069 D3D11_BUFFER_DESC d3d11_desc;
4070 struct d3d_buffer *object;
4071 HRESULT hr;
4073 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface, desc, data, buffer);
4075 d3d11_desc.ByteWidth = desc->ByteWidth;
4076 d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
4077 d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
4078 d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
4079 d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
4080 d3d11_desc.StructureByteStride = 0;
4082 if (FAILED(hr = d3d_buffer_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
4083 return hr;
4085 *buffer = &object->ID3D10Buffer_iface;
4087 return S_OK;
4090 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface,
4091 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
4093 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
4095 return E_NOTIMPL;
4098 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface,
4099 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
4100 ID3D10Texture2D **texture)
4102 struct d3d_device *device = impl_from_ID3D10Device(iface);
4103 D3D11_TEXTURE2D_DESC d3d11_desc;
4104 struct d3d_texture2d *object;
4105 HRESULT hr;
4107 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
4109 d3d11_desc.Width = desc->Width;
4110 d3d11_desc.Height = desc->Height;
4111 d3d11_desc.MipLevels = desc->MipLevels;
4112 d3d11_desc.ArraySize = desc->ArraySize;
4113 d3d11_desc.Format = desc->Format;
4114 d3d11_desc.SampleDesc = desc->SampleDesc;
4115 d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
4116 d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
4117 d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
4118 d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
4120 if (FAILED(hr = d3d_texture2d_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
4121 return hr;
4123 *texture = &object->ID3D10Texture2D_iface;
4125 return S_OK;
4128 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device1 *iface,
4129 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
4130 ID3D10Texture3D **texture)
4132 struct d3d_device *device = impl_from_ID3D10Device(iface);
4133 D3D11_TEXTURE3D_DESC d3d11_desc;
4134 struct d3d_texture3d *object;
4135 HRESULT hr;
4137 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
4139 d3d11_desc.Width = desc->Width;
4140 d3d11_desc.Height = desc->Height;
4141 d3d11_desc.Depth = desc->Depth;
4142 d3d11_desc.MipLevels = desc->MipLevels;
4143 d3d11_desc.Format = desc->Format;
4144 d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
4145 d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
4146 d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
4147 d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
4149 if (FAILED(hr = d3d_texture3d_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
4150 return hr;
4152 *texture = &object->ID3D10Texture3D_iface;
4154 return S_OK;
4157 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView1(ID3D10Device1 *iface,
4158 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc, ID3D10ShaderResourceView1 **view)
4160 struct d3d_device *device = impl_from_ID3D10Device(iface);
4161 struct d3d_shader_resource_view *object;
4162 ID3D11Resource *d3d11_resource;
4163 HRESULT hr;
4165 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
4167 if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
4169 ERR("Resource does not implement ID3D11Resource.\n");
4170 return E_FAIL;
4173 hr = d3d_shader_resource_view_create(device, d3d11_resource, (const D3D11_SHADER_RESOURCE_VIEW_DESC *)desc,
4174 &object);
4175 ID3D11Resource_Release(d3d11_resource);
4176 if (FAILED(hr))
4177 return hr;
4179 *view = &object->ID3D10ShaderResourceView1_iface;
4181 return S_OK;
4184 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
4185 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
4187 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
4189 return d3d10_device_CreateShaderResourceView1(iface, resource,
4190 (const D3D10_SHADER_RESOURCE_VIEW_DESC1 *)desc, (ID3D10ShaderResourceView1 **)view);
4193 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device1 *iface,
4194 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
4196 struct d3d_device *device = impl_from_ID3D10Device(iface);
4197 struct d3d_rendertarget_view *object;
4198 ID3D11Resource *d3d11_resource;
4199 HRESULT hr;
4201 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
4203 if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
4205 ERR("Resource does not implement ID3D11Resource.\n");
4206 return E_FAIL;
4209 hr = d3d_rendertarget_view_create(device, d3d11_resource, (const D3D11_RENDER_TARGET_VIEW_DESC *)desc, &object);
4210 ID3D11Resource_Release(d3d11_resource);
4211 if (FAILED(hr))
4212 return hr;
4214 *view = &object->ID3D10RenderTargetView_iface;
4216 return S_OK;
4219 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device1 *iface,
4220 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
4222 struct d3d_device *device = impl_from_ID3D10Device(iface);
4223 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc;
4224 struct d3d_depthstencil_view *object;
4225 ID3D11Resource *d3d11_resource;
4226 HRESULT hr;
4228 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
4230 if (desc)
4232 d3d11_desc.Format = desc->Format;
4233 d3d11_desc.ViewDimension = desc->ViewDimension;
4234 d3d11_desc.Flags = 0;
4235 memcpy(&d3d11_desc.u, &desc->u, sizeof(d3d11_desc.u));
4238 if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
4240 ERR("Resource does not implement ID3D11Resource.\n");
4241 return E_FAIL;
4244 hr = d3d_depthstencil_view_create(device, d3d11_resource, desc ? &d3d11_desc : NULL, &object);
4245 ID3D11Resource_Release(d3d11_resource);
4246 if (FAILED(hr))
4247 return hr;
4249 *view = &object->ID3D10DepthStencilView_iface;
4251 return S_OK;
4254 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *iface,
4255 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
4256 const void *shader_byte_code, SIZE_T shader_byte_code_length,
4257 ID3D10InputLayout **input_layout)
4259 struct d3d_device *device = impl_from_ID3D10Device(iface);
4260 struct d3d_input_layout *object;
4261 HRESULT hr;
4263 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
4264 "shader_byte_code_length %lu, input_layout %p\n",
4265 iface, element_descs, element_count, shader_byte_code,
4266 shader_byte_code_length, input_layout);
4268 if (FAILED(hr = d3d_input_layout_create(device, (const D3D11_INPUT_ELEMENT_DESC *)element_descs, element_count,
4269 shader_byte_code, shader_byte_code_length, &object)))
4270 return hr;
4272 *input_layout = &object->ID3D10InputLayout_iface;
4274 return S_OK;
4277 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device1 *iface,
4278 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
4280 struct d3d_device *device = impl_from_ID3D10Device(iface);
4281 struct d3d_vertex_shader *object;
4282 HRESULT hr;
4284 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4285 iface, byte_code, byte_code_length, shader);
4287 if (FAILED(hr = d3d_vertex_shader_create(device, byte_code, byte_code_length, &object)))
4288 return hr;
4290 *shader = &object->ID3D10VertexShader_iface;
4292 return S_OK;
4295 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device1 *iface,
4296 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
4298 struct d3d_device *device = impl_from_ID3D10Device(iface);
4299 struct d3d_geometry_shader *object;
4300 HRESULT hr;
4302 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4303 iface, byte_code, byte_code_length, shader);
4305 if (FAILED(hr = d3d_geometry_shader_create(device, byte_code, byte_code_length, &object)))
4306 return hr;
4308 *shader = &object->ID3D10GeometryShader_iface;
4310 return S_OK;
4313 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1 *iface,
4314 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
4315 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
4317 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
4318 "output_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
4319 iface, byte_code, byte_code_length, output_stream_decls,
4320 output_stream_decl_count, output_stream_stride, shader);
4322 return E_NOTIMPL;
4325 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device1 *iface,
4326 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
4328 struct d3d_device *device = impl_from_ID3D10Device(iface);
4329 struct d3d_pixel_shader *object;
4330 HRESULT hr;
4332 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
4333 iface, byte_code, byte_code_length, shader);
4335 if (FAILED(hr = d3d_pixel_shader_create(device, byte_code, byte_code_length, &object)))
4336 return hr;
4338 *shader = &object->ID3D10PixelShader_iface;
4340 return S_OK;
4343 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState1(ID3D10Device1 *iface,
4344 const D3D10_BLEND_DESC1 *desc, ID3D10BlendState1 **blend_state)
4346 struct d3d_device *device = impl_from_ID3D10Device(iface);
4347 ID3D11BlendState *d3d11_blend_state;
4348 HRESULT hr;
4350 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
4352 if (FAILED(hr = d3d11_device_CreateBlendState(&device->ID3D11Device_iface, (D3D11_BLEND_DESC *)desc,
4353 &d3d11_blend_state)))
4354 return hr;
4356 hr = ID3D11BlendState_QueryInterface(d3d11_blend_state, &IID_ID3D10BlendState1, (void **)blend_state);
4357 ID3D11BlendState_Release(d3d11_blend_state);
4358 return hr;
4361 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device1 *iface,
4362 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
4364 D3D10_BLEND_DESC1 d3d10_1_desc;
4365 unsigned int i;
4367 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
4369 if (!desc)
4370 return E_INVALIDARG;
4372 d3d10_1_desc.AlphaToCoverageEnable = desc->AlphaToCoverageEnable;
4373 d3d10_1_desc.IndependentBlendEnable = FALSE;
4374 for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT - 1; ++i)
4376 if (desc->BlendEnable[i] != desc->BlendEnable[i + 1]
4377 || desc->RenderTargetWriteMask[i] != desc->RenderTargetWriteMask[i + 1])
4378 d3d10_1_desc.IndependentBlendEnable = TRUE;
4381 for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
4383 d3d10_1_desc.RenderTarget[i].BlendEnable = desc->BlendEnable[i];
4384 d3d10_1_desc.RenderTarget[i].SrcBlend = desc->SrcBlend;
4385 d3d10_1_desc.RenderTarget[i].DestBlend = desc->DestBlend;
4386 d3d10_1_desc.RenderTarget[i].BlendOp = desc->BlendOp;
4387 d3d10_1_desc.RenderTarget[i].SrcBlendAlpha = desc->SrcBlendAlpha;
4388 d3d10_1_desc.RenderTarget[i].DestBlendAlpha = desc->DestBlendAlpha;
4389 d3d10_1_desc.RenderTarget[i].BlendOpAlpha = desc->BlendOpAlpha;
4390 d3d10_1_desc.RenderTarget[i].RenderTargetWriteMask = desc->RenderTargetWriteMask[i];
4393 return d3d10_device_CreateBlendState1(iface, &d3d10_1_desc, (ID3D10BlendState1 **)blend_state);
4396 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device1 *iface,
4397 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
4399 struct d3d_device *device = impl_from_ID3D10Device(iface);
4400 ID3D11DepthStencilState *d3d11_depth_stencil_state;
4401 HRESULT hr;
4403 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
4405 if (FAILED(hr = d3d11_device_CreateDepthStencilState(&device->ID3D11Device_iface,
4406 (const D3D11_DEPTH_STENCIL_DESC *)desc, &d3d11_depth_stencil_state)))
4407 return hr;
4409 hr = ID3D11DepthStencilState_QueryInterface(d3d11_depth_stencil_state, &IID_ID3D10DepthStencilState,
4410 (void **)depth_stencil_state);
4411 ID3D11DepthStencilState_Release(d3d11_depth_stencil_state);
4412 return hr;
4415 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device1 *iface,
4416 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
4418 struct d3d_device *device = impl_from_ID3D10Device(iface);
4419 ID3D11RasterizerState *d3d11_rasterizer_state;
4420 HRESULT hr;
4422 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
4424 if (FAILED(hr = d3d11_device_CreateRasterizerState(&device->ID3D11Device_iface,
4425 (const D3D11_RASTERIZER_DESC *)desc, &d3d11_rasterizer_state)))
4426 return hr;
4428 hr = ID3D11RasterizerState_QueryInterface(d3d11_rasterizer_state,
4429 &IID_ID3D10RasterizerState, (void **)rasterizer_state);
4430 ID3D11RasterizerState_Release(d3d11_rasterizer_state);
4431 return hr;
4434 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
4435 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
4437 struct d3d_device *device = impl_from_ID3D10Device(iface);
4438 ID3D11SamplerState *d3d11_sampler_state;
4439 HRESULT hr;
4441 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
4443 if (FAILED(hr = d3d11_device_CreateSamplerState(&device->ID3D11Device_iface,
4444 (const D3D11_SAMPLER_DESC *)desc, &d3d11_sampler_state)))
4445 return hr;
4447 hr = ID3D11SamplerState_QueryInterface(d3d11_sampler_state, &IID_ID3D10SamplerState, (void **)sampler_state);
4448 ID3D11SamplerState_Release(d3d11_sampler_state);
4449 return hr;
4452 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
4453 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
4455 struct d3d_device *device = impl_from_ID3D10Device(iface);
4456 struct d3d_query *object;
4457 HRESULT hr;
4459 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
4461 if (FAILED(hr = d3d_query_create(device, (const D3D11_QUERY_DESC *)desc, FALSE, &object)))
4462 return hr;
4464 *query = &object->ID3D10Query_iface;
4466 return S_OK;
4469 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *iface,
4470 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
4472 struct d3d_device *device = impl_from_ID3D10Device(iface);
4473 struct d3d_query *object;
4474 HRESULT hr;
4476 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
4478 if (FAILED(hr = d3d_query_create(device, (const D3D11_QUERY_DESC *)desc, TRUE, &object)))
4479 return hr;
4481 *predicate = (ID3D10Predicate *)&object->ID3D10Query_iface;
4483 return S_OK;
4486 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device1 *iface,
4487 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
4489 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
4491 return E_NOTIMPL;
4494 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 *iface,
4495 DXGI_FORMAT format, UINT *format_support)
4497 FIXME("iface %p, format %s, format_support %p stub!\n",
4498 iface, debug_dxgi_format(format), format_support);
4500 return E_NOTIMPL;
4503 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface,
4504 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
4506 struct d3d_device *device = impl_from_ID3D10Device(iface);
4508 TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n",
4509 iface, debug_dxgi_format(format), sample_count, quality_level_count);
4511 return d3d11_device_CheckMultisampleQualityLevels(&device->ID3D11Device_iface, format,
4512 sample_count, quality_level_count);
4515 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device1 *iface, D3D10_COUNTER_INFO *counter_info)
4517 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
4520 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device1 *iface,
4521 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, char *name,
4522 UINT *name_length, char *units, UINT *units_length, char *description, UINT *description_length)
4524 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
4525 "units %p, units_length %p, description %p, description_length %p stub!\n",
4526 iface, desc, type, active_counters, name, name_length,
4527 units, units_length, description, description_length);
4529 return E_NOTIMPL;
4532 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device1 *iface)
4534 FIXME("iface %p stub!\n", iface);
4536 return 0;
4539 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device1 *iface,
4540 HANDLE resource_handle, REFIID guid, void **resource)
4542 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
4543 iface, resource_handle, debugstr_guid(guid), resource);
4545 return E_NOTIMPL;
4548 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device1 *iface, UINT width, UINT height)
4550 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
4553 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device1 *iface, UINT *width, UINT *height)
4555 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
4558 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE d3d10_device_GetFeatureLevel(ID3D10Device1 *iface)
4560 FIXME("iface %p stub!\n", iface);
4562 return D3D10_FEATURE_LEVEL_10_1;
4565 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl =
4567 /* IUnknown methods */
4568 d3d10_device_QueryInterface,
4569 d3d10_device_AddRef,
4570 d3d10_device_Release,
4571 /* ID3D10Device methods */
4572 d3d10_device_VSSetConstantBuffers,
4573 d3d10_device_PSSetShaderResources,
4574 d3d10_device_PSSetShader,
4575 d3d10_device_PSSetSamplers,
4576 d3d10_device_VSSetShader,
4577 d3d10_device_DrawIndexed,
4578 d3d10_device_Draw,
4579 d3d10_device_PSSetConstantBuffers,
4580 d3d10_device_IASetInputLayout,
4581 d3d10_device_IASetVertexBuffers,
4582 d3d10_device_IASetIndexBuffer,
4583 d3d10_device_DrawIndexedInstanced,
4584 d3d10_device_DrawInstanced,
4585 d3d10_device_GSSetConstantBuffers,
4586 d3d10_device_GSSetShader,
4587 d3d10_device_IASetPrimitiveTopology,
4588 d3d10_device_VSSetShaderResources,
4589 d3d10_device_VSSetSamplers,
4590 d3d10_device_SetPredication,
4591 d3d10_device_GSSetShaderResources,
4592 d3d10_device_GSSetSamplers,
4593 d3d10_device_OMSetRenderTargets,
4594 d3d10_device_OMSetBlendState,
4595 d3d10_device_OMSetDepthStencilState,
4596 d3d10_device_SOSetTargets,
4597 d3d10_device_DrawAuto,
4598 d3d10_device_RSSetState,
4599 d3d10_device_RSSetViewports,
4600 d3d10_device_RSSetScissorRects,
4601 d3d10_device_CopySubresourceRegion,
4602 d3d10_device_CopyResource,
4603 d3d10_device_UpdateSubresource,
4604 d3d10_device_ClearRenderTargetView,
4605 d3d10_device_ClearDepthStencilView,
4606 d3d10_device_GenerateMips,
4607 d3d10_device_ResolveSubresource,
4608 d3d10_device_VSGetConstantBuffers,
4609 d3d10_device_PSGetShaderResources,
4610 d3d10_device_PSGetShader,
4611 d3d10_device_PSGetSamplers,
4612 d3d10_device_VSGetShader,
4613 d3d10_device_PSGetConstantBuffers,
4614 d3d10_device_IAGetInputLayout,
4615 d3d10_device_IAGetVertexBuffers,
4616 d3d10_device_IAGetIndexBuffer,
4617 d3d10_device_GSGetConstantBuffers,
4618 d3d10_device_GSGetShader,
4619 d3d10_device_IAGetPrimitiveTopology,
4620 d3d10_device_VSGetShaderResources,
4621 d3d10_device_VSGetSamplers,
4622 d3d10_device_GetPredication,
4623 d3d10_device_GSGetShaderResources,
4624 d3d10_device_GSGetSamplers,
4625 d3d10_device_OMGetRenderTargets,
4626 d3d10_device_OMGetBlendState,
4627 d3d10_device_OMGetDepthStencilState,
4628 d3d10_device_SOGetTargets,
4629 d3d10_device_RSGetState,
4630 d3d10_device_RSGetViewports,
4631 d3d10_device_RSGetScissorRects,
4632 d3d10_device_GetDeviceRemovedReason,
4633 d3d10_device_SetExceptionMode,
4634 d3d10_device_GetExceptionMode,
4635 d3d10_device_GetPrivateData,
4636 d3d10_device_SetPrivateData,
4637 d3d10_device_SetPrivateDataInterface,
4638 d3d10_device_ClearState,
4639 d3d10_device_Flush,
4640 d3d10_device_CreateBuffer,
4641 d3d10_device_CreateTexture1D,
4642 d3d10_device_CreateTexture2D,
4643 d3d10_device_CreateTexture3D,
4644 d3d10_device_CreateShaderResourceView,
4645 d3d10_device_CreateRenderTargetView,
4646 d3d10_device_CreateDepthStencilView,
4647 d3d10_device_CreateInputLayout,
4648 d3d10_device_CreateVertexShader,
4649 d3d10_device_CreateGeometryShader,
4650 d3d10_device_CreateGeometryShaderWithStreamOutput,
4651 d3d10_device_CreatePixelShader,
4652 d3d10_device_CreateBlendState,
4653 d3d10_device_CreateDepthStencilState,
4654 d3d10_device_CreateRasterizerState,
4655 d3d10_device_CreateSamplerState,
4656 d3d10_device_CreateQuery,
4657 d3d10_device_CreatePredicate,
4658 d3d10_device_CreateCounter,
4659 d3d10_device_CheckFormatSupport,
4660 d3d10_device_CheckMultisampleQualityLevels,
4661 d3d10_device_CheckCounterInfo,
4662 d3d10_device_CheckCounter,
4663 d3d10_device_GetCreationFlags,
4664 d3d10_device_OpenSharedResource,
4665 d3d10_device_SetTextFilterSize,
4666 d3d10_device_GetTextFilterSize,
4667 d3d10_device_CreateShaderResourceView1,
4668 d3d10_device_CreateBlendState1,
4669 d3d10_device_GetFeatureLevel,
4672 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl =
4674 /* IUnknown methods */
4675 d3d_device_inner_QueryInterface,
4676 d3d_device_inner_AddRef,
4677 d3d_device_inner_Release,
4680 /* ID3D10Multithread methods */
4682 static inline struct d3d_device *impl_from_ID3D10Multithread(ID3D10Multithread *iface)
4684 return CONTAINING_RECORD(iface, struct d3d_device, ID3D10Multithread_iface);
4687 static HRESULT STDMETHODCALLTYPE d3d10_multithread_QueryInterface(ID3D10Multithread *iface, REFIID iid, void **out)
4689 struct d3d_device *device = impl_from_ID3D10Multithread(iface);
4691 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
4693 return IUnknown_QueryInterface(device->outer_unk, iid, out);
4696 static ULONG STDMETHODCALLTYPE d3d10_multithread_AddRef(ID3D10Multithread *iface)
4698 struct d3d_device *device = impl_from_ID3D10Multithread(iface);
4700 TRACE("iface %p.\n", iface);
4702 return IUnknown_AddRef(device->outer_unk);
4705 static ULONG STDMETHODCALLTYPE d3d10_multithread_Release(ID3D10Multithread *iface)
4707 struct d3d_device *device = impl_from_ID3D10Multithread(iface);
4709 TRACE("iface %p.\n", iface);
4711 return IUnknown_Release(device->outer_unk);
4714 static void STDMETHODCALLTYPE d3d10_multithread_Enter(ID3D10Multithread *iface)
4716 TRACE("iface %p.\n", iface);
4718 wined3d_mutex_lock();
4721 static void STDMETHODCALLTYPE d3d10_multithread_Leave(ID3D10Multithread *iface)
4723 TRACE("iface %p.\n", iface);
4725 wined3d_mutex_unlock();
4728 static BOOL STDMETHODCALLTYPE d3d10_multithread_SetMultithreadProtected(ID3D10Multithread *iface, BOOL protect)
4730 FIXME("iface %p, protect %#x stub!\n", iface, protect);
4732 return TRUE;
4735 static BOOL STDMETHODCALLTYPE d3d10_multithread_GetMultithreadProtected(ID3D10Multithread *iface)
4737 FIXME("iface %p stub!\n", iface);
4739 return TRUE;
4742 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl =
4744 d3d10_multithread_QueryInterface,
4745 d3d10_multithread_AddRef,
4746 d3d10_multithread_Release,
4747 d3d10_multithread_Enter,
4748 d3d10_multithread_Leave,
4749 d3d10_multithread_SetMultithreadProtected,
4750 d3d10_multithread_GetMultithreadProtected,
4753 /* IWineDXGIDeviceParent IUnknown methods */
4755 static inline struct d3d_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
4757 return CONTAINING_RECORD(iface, struct d3d_device, IWineDXGIDeviceParent_iface);
4760 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
4761 REFIID riid, void **ppv)
4763 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4764 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
4767 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
4769 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4770 return IUnknown_AddRef(device->outer_unk);
4773 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
4775 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4776 return IUnknown_Release(device->outer_unk);
4779 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
4780 IWineDXGIDeviceParent *iface)
4782 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4783 return &device->device_parent;
4786 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl =
4788 /* IUnknown methods */
4789 dxgi_device_parent_QueryInterface,
4790 dxgi_device_parent_AddRef,
4791 dxgi_device_parent_Release,
4792 /* IWineDXGIDeviceParent methods */
4793 dxgi_device_parent_get_wined3d_device_parent,
4796 static inline struct d3d_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
4798 return CONTAINING_RECORD(device_parent, struct d3d_device, device_parent);
4801 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
4802 struct wined3d_device *wined3d_device)
4804 struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
4806 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
4808 wined3d_device_incref(wined3d_device);
4809 device->wined3d_device = wined3d_device;
4812 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
4814 TRACE("device_parent %p.\n", device_parent);
4817 static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate)
4819 TRACE("device_parent %p, activate %#x.\n", device_parent, activate);
4822 static HRESULT CDECL device_parent_sub_resource_created(struct wined3d_device_parent *device_parent,
4823 struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, void **parent,
4824 const struct wined3d_parent_ops **parent_ops)
4826 TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
4827 device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
4829 *parent = NULL;
4830 *parent_ops = &d3d_null_wined3d_parent_ops;
4832 return S_OK;
4835 static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_device_parent *device_parent,
4836 void *container_parent, const struct wined3d_resource_desc *wined3d_desc,
4837 struct wined3d_texture **wined3d_texture)
4839 struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
4840 struct d3d_texture2d *texture;
4841 ID3D10Texture2D *texture_iface;
4842 D3D10_TEXTURE2D_DESC desc;
4843 HRESULT hr;
4845 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, wined3d_texture %p partial stub!\n",
4846 device_parent, container_parent, wined3d_desc, wined3d_texture);
4848 FIXME("Implement DXGI<->wined3d usage conversion\n");
4850 desc.Width = wined3d_desc->width;
4851 desc.Height = wined3d_desc->height;
4852 desc.MipLevels = 1;
4853 desc.ArraySize = 1;
4854 desc.Format = dxgi_format_from_wined3dformat(wined3d_desc->format);
4855 desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1;
4856 desc.SampleDesc.Quality = wined3d_desc->multisample_quality;
4857 desc.Usage = D3D10_USAGE_DEFAULT;
4858 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
4859 desc.CPUAccessFlags = 0;
4860 desc.MiscFlags = 0;
4862 if (FAILED(hr = d3d10_device_CreateTexture2D(&device->ID3D10Device1_iface,
4863 &desc, NULL, &texture_iface)))
4865 ERR("CreateTexture2D failed, returning %#x\n", hr);
4866 return hr;
4869 texture = impl_from_ID3D10Texture2D(texture_iface);
4871 *wined3d_texture = texture->wined3d_texture;
4872 wined3d_texture_incref(*wined3d_texture);
4873 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
4875 return S_OK;
4878 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
4879 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
4881 struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
4882 IWineDXGIDevice *wine_device;
4883 HRESULT hr;
4885 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain);
4887 if (FAILED(hr = d3d10_device_QueryInterface(&device->ID3D10Device1_iface,
4888 &IID_IWineDXGIDevice, (void **)&wine_device)))
4890 ERR("Device should implement IWineDXGIDevice.\n");
4891 return E_FAIL;
4894 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
4895 IWineDXGIDevice_Release(wine_device);
4896 if (FAILED(hr))
4898 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
4899 return hr;
4902 return S_OK;
4905 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops =
4907 device_parent_wined3d_device_created,
4908 device_parent_mode_changed,
4909 device_parent_activate,
4910 device_parent_sub_resource_created,
4911 device_parent_sub_resource_created,
4912 device_parent_create_swapchain_texture,
4913 device_parent_create_swapchain,
4916 static void *d3d_rb_alloc(size_t size)
4918 return HeapAlloc(GetProcessHeap(), 0, size);
4921 static void *d3d_rb_realloc(void *ptr, size_t size)
4923 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
4926 static void d3d_rb_free(void *ptr)
4928 HeapFree(GetProcessHeap(), 0, ptr);
4931 static int d3d_sampler_state_compare(const void *key, const struct wine_rb_entry *entry)
4933 const D3D11_SAMPLER_DESC *ka = key;
4934 const D3D11_SAMPLER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_sampler_state, entry)->desc;
4936 return memcmp(ka, kb, sizeof(*ka));
4939 static const struct wine_rb_functions d3d_sampler_state_rb_ops =
4941 d3d_rb_alloc,
4942 d3d_rb_realloc,
4943 d3d_rb_free,
4944 d3d_sampler_state_compare,
4947 static int d3d_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
4949 const D3D11_BLEND_DESC *ka = key;
4950 const D3D11_BLEND_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_blend_state, entry)->desc;
4952 return memcmp(ka, kb, sizeof(*ka));
4955 static const struct wine_rb_functions d3d_blend_state_rb_ops =
4957 d3d_rb_alloc,
4958 d3d_rb_realloc,
4959 d3d_rb_free,
4960 d3d_blend_state_compare,
4963 static int d3d_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
4965 const D3D11_DEPTH_STENCIL_DESC *ka = key;
4966 const D3D11_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
4967 const struct d3d_depthstencil_state, entry)->desc;
4969 return memcmp(ka, kb, sizeof(*ka));
4972 static const struct wine_rb_functions d3d_depthstencil_state_rb_ops =
4974 d3d_rb_alloc,
4975 d3d_rb_realloc,
4976 d3d_rb_free,
4977 d3d_depthstencil_state_compare,
4980 static int d3d_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
4982 const D3D11_RASTERIZER_DESC *ka = key;
4983 const D3D11_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_rasterizer_state, entry)->desc;
4985 return memcmp(ka, kb, sizeof(*ka));
4988 static const struct wine_rb_functions d3d_rasterizer_state_rb_ops =
4990 d3d_rb_alloc,
4991 d3d_rb_realloc,
4992 d3d_rb_free,
4993 d3d_rasterizer_state_compare,
4996 HRESULT d3d_device_init(struct d3d_device *device, void *outer_unknown)
4998 device->IUnknown_inner.lpVtbl = &d3d_device_inner_unknown_vtbl;
4999 device->ID3D11Device_iface.lpVtbl = &d3d11_device_vtbl;
5000 device->ID3D10Device1_iface.lpVtbl = &d3d10_device1_vtbl;
5001 device->ID3D10Multithread_iface.lpVtbl = &d3d10_multithread_vtbl;
5002 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d_dxgi_device_parent_vtbl;
5003 device->device_parent.ops = &d3d_wined3d_device_parent_ops;
5004 device->refcount = 1;
5005 /* COM aggregation always takes place */
5006 device->outer_unk = outer_unknown;
5008 if (FAILED(d3d11_immediate_context_init(&device->immediate_context, device)))
5010 WARN("Failed to initialize immediate device context.\n");
5011 return E_FAIL;
5013 ID3D11DeviceContext_Release(&device->immediate_context.ID3D11DeviceContext_iface);
5015 if (wine_rb_init(&device->blend_states, &d3d_blend_state_rb_ops) == -1)
5017 WARN("Failed to initialize blend state rbtree.\n");
5018 return E_FAIL;
5020 device->blend_factor[0] = 1.0f;
5021 device->blend_factor[1] = 1.0f;
5022 device->blend_factor[2] = 1.0f;
5023 device->blend_factor[3] = 1.0f;
5025 if (wine_rb_init(&device->depthstencil_states, &d3d_depthstencil_state_rb_ops) == -1)
5027 WARN("Failed to initialize depthstencil state rbtree.\n");
5028 wine_rb_destroy(&device->blend_states, NULL, NULL);
5029 return E_FAIL;
5032 if (wine_rb_init(&device->rasterizer_states, &d3d_rasterizer_state_rb_ops) == -1)
5034 WARN("Failed to initialize rasterizer state rbtree.\n");
5035 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
5036 wine_rb_destroy(&device->blend_states, NULL, NULL);
5037 return E_FAIL;
5040 if (wine_rb_init(&device->sampler_states, &d3d_sampler_state_rb_ops) == -1)
5042 WARN("Failed to initialize sampler state rbtree.\n");
5043 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
5044 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
5045 wine_rb_destroy(&device->blend_states, NULL, NULL);
5046 return E_FAIL;
5049 return S_OK;