d3d11: Implement d3d11_immediate_context_GSGetConstantBuffers().
[wine/multimedia.git] / dlls / d3d11 / device.c
blobc451514a79cc3a5e37a3102c1ef664ea33bdfc80
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 FIXME("iface %p, index_count %u, start_index_location %u, base_vertex_location %d stub!\n",
231 iface, index_count, start_index_location, base_vertex_location);
234 static void STDMETHODCALLTYPE d3d11_immediate_context_Draw(ID3D11DeviceContext *iface,
235 UINT vertex_count, UINT start_vertex_location)
237 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
239 TRACE("iface %p, vertex_count %u, start_vertex_location %u.\n",
240 iface, vertex_count, start_vertex_location);
242 wined3d_mutex_lock();
243 wined3d_device_draw_primitive(device->wined3d_device, start_vertex_location, vertex_count);
244 wined3d_mutex_unlock();
247 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_Map(ID3D11DeviceContext *iface, ID3D11Resource *resource,
248 UINT subresource_idx, D3D11_MAP map_type, UINT map_flags, D3D11_MAPPED_SUBRESOURCE *mapped_subresource)
250 struct wined3d_resource *wined3d_resource;
251 struct wined3d_map_desc map_desc;
252 HRESULT hr;
254 TRACE("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p.\n",
255 iface, resource, subresource_idx, map_type, map_flags, mapped_subresource);
257 if (map_flags)
258 FIXME("Ignoring map_flags %#x.\n", map_flags);
260 wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
262 wined3d_mutex_lock();
263 hr = wined3d_resource_map(wined3d_resource, subresource_idx,
264 &map_desc, NULL, wined3d_map_flags_from_d3d11_map_type(map_type));
265 wined3d_mutex_unlock();
267 mapped_subresource->pData = map_desc.data;
268 mapped_subresource->RowPitch = map_desc.row_pitch;
269 mapped_subresource->DepthPitch = map_desc.slice_pitch;
271 return hr;
274 static void STDMETHODCALLTYPE d3d11_immediate_context_Unmap(ID3D11DeviceContext *iface, ID3D11Resource *resource,
275 UINT subresource_idx)
277 struct wined3d_resource *wined3d_resource;
279 TRACE("iface %p, resource %p, subresource_idx %u.\n", iface, resource, subresource_idx);
281 wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
283 wined3d_mutex_lock();
284 wined3d_resource_unmap(wined3d_resource, subresource_idx);
285 wined3d_mutex_unlock();
288 static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetConstantBuffers(ID3D11DeviceContext *iface,
289 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
291 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
292 unsigned int i;
294 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
295 iface, start_slot, buffer_count, buffers);
297 wined3d_mutex_lock();
298 for (i = 0; i < buffer_count; ++i)
300 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
302 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
303 buffer ? buffer->wined3d_buffer : NULL);
305 wined3d_mutex_unlock();
308 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetInputLayout(ID3D11DeviceContext *iface,
309 ID3D11InputLayout *input_layout)
311 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
312 struct d3d_input_layout *layout = unsafe_impl_from_ID3D11InputLayout(input_layout);
314 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
316 wined3d_mutex_lock();
317 wined3d_device_set_vertex_declaration(device->wined3d_device, layout ? layout->wined3d_decl : NULL);
318 wined3d_mutex_unlock();
321 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetVertexBuffers(ID3D11DeviceContext *iface,
322 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers, const UINT *strides, const UINT *offsets)
324 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
325 unsigned int i;
327 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
328 iface, start_slot, buffer_count, buffers, strides, offsets);
330 wined3d_mutex_lock();
331 for (i = 0; i < buffer_count; ++i)
333 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
335 wined3d_device_set_stream_source(device->wined3d_device, start_slot + i,
336 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
338 wined3d_mutex_unlock();
341 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetIndexBuffer(ID3D11DeviceContext *iface,
342 ID3D11Buffer *buffer, DXGI_FORMAT format, UINT offset)
344 FIXME("iface %p, buffer %p, format %s, offset %u stub!\n",
345 iface, buffer, debug_dxgi_format(format), offset);
348 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstanced(ID3D11DeviceContext *iface,
349 UINT instance_index_count, UINT instance_count, UINT start_index_location, INT base_vertex_location,
350 UINT start_instance_location)
352 FIXME("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
353 "base_vertex_location %d, start_instance_location %u stub!\n",
354 iface, instance_index_count, instance_count, start_index_location,
355 base_vertex_location, start_instance_location);
358 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawInstanced(ID3D11DeviceContext *iface,
359 UINT instance_vertex_count, UINT instance_count, UINT start_vertex_location, UINT start_instance_location)
361 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
363 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
364 "start_instance_location %u.\n",
365 iface, instance_vertex_count, instance_count, start_vertex_location,
366 start_instance_location);
368 wined3d_mutex_lock();
369 wined3d_device_draw_primitive_instanced(device->wined3d_device, start_vertex_location,
370 instance_vertex_count, start_instance_location, instance_count);
371 wined3d_mutex_unlock();
374 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetConstantBuffers(ID3D11DeviceContext *iface,
375 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
377 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
378 unsigned int i;
380 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
381 iface, start_slot, buffer_count, buffers);
383 wined3d_mutex_lock();
384 for (i = 0; i < buffer_count; ++i)
386 struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
388 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
389 buffer ? buffer->wined3d_buffer : NULL);
391 wined3d_mutex_unlock();
394 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShader(ID3D11DeviceContext *iface,
395 ID3D11GeometryShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
397 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
398 struct d3d_geometry_shader *gs = unsafe_impl_from_ID3D11GeometryShader(shader);
400 TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
401 iface, shader, class_instances, class_instance_count);
403 if (class_instances)
404 FIXME("Dynamic linking is not implemented yet.\n");
406 wined3d_mutex_lock();
407 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
408 wined3d_mutex_unlock();
411 static void STDMETHODCALLTYPE d3d11_immediate_context_IASetPrimitiveTopology(ID3D11DeviceContext *iface,
412 D3D11_PRIMITIVE_TOPOLOGY topology)
414 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
416 TRACE("iface %p, topology %u.\n", iface, topology);
418 wined3d_mutex_lock();
419 wined3d_device_set_primitive_type(device->wined3d_device, (enum wined3d_primitive_type)topology);
420 wined3d_mutex_unlock();
423 static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShaderResources(ID3D11DeviceContext *iface,
424 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
426 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
427 unsigned int i;
429 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
431 wined3d_mutex_lock();
432 for (i = 0; i < view_count; ++i)
434 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]);
436 wined3d_device_set_vs_resource_view(device->wined3d_device, start_slot + i,
437 view ? view->wined3d_view : NULL);
439 wined3d_mutex_unlock();
442 static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetSamplers(ID3D11DeviceContext *iface,
443 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
445 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
446 unsigned int i;
448 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
449 iface, start_slot, sampler_count, samplers);
451 wined3d_mutex_lock();
452 for (i = 0; i < sampler_count; ++i)
454 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D11SamplerState(samplers[i]);
456 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
457 sampler ? sampler->wined3d_sampler : NULL);
459 wined3d_mutex_unlock();
462 static void STDMETHODCALLTYPE d3d11_immediate_context_Begin(ID3D11DeviceContext *iface,
463 ID3D11Asynchronous *asynchronous)
465 FIXME("iface %p, asynchronous %p stub!\n", iface, asynchronous);
468 static void STDMETHODCALLTYPE d3d11_immediate_context_End(ID3D11DeviceContext *iface,
469 ID3D11Asynchronous *asynchronous)
471 FIXME("iface %p, asynchronous %p stub!\n", iface, asynchronous);
474 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_GetData(ID3D11DeviceContext *iface,
475 ID3D11Asynchronous *asynchronous, void *data, UINT data_size, UINT data_flags)
477 FIXME("iface %p, asynchronous %p, data %p, data_size %u, data_flags %#x stub!\n",
478 iface, asynchronous, data, data_size, data_flags);
480 return E_NOTIMPL;
483 static void STDMETHODCALLTYPE d3d11_immediate_context_SetPredication(ID3D11DeviceContext *iface,
484 ID3D11Predicate *predicate, BOOL value)
486 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
487 struct d3d_query *query;
489 TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value);
491 query = unsafe_impl_from_ID3D11Query((ID3D11Query *)predicate);
493 wined3d_mutex_lock();
494 wined3d_device_set_predication(device->wined3d_device, query ? query->wined3d_query : NULL, value);
495 wined3d_mutex_unlock();
498 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext *iface,
499 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
501 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
502 unsigned int i;
504 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
506 wined3d_mutex_lock();
507 for (i = 0; i < view_count; ++i)
509 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]);
511 wined3d_device_set_gs_resource_view(device->wined3d_device, start_slot + i,
512 view ? view->wined3d_view : NULL);
514 wined3d_mutex_unlock();
517 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext *iface,
518 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
520 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
521 unsigned int i;
523 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
524 iface, start_slot, sampler_count, samplers);
526 wined3d_mutex_lock();
527 for (i = 0; i < sampler_count; ++i)
529 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D11SamplerState(samplers[i]);
531 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
532 sampler ? sampler->wined3d_sampler : NULL);
534 wined3d_mutex_unlock();
537 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext *iface,
538 UINT render_target_view_count, ID3D11RenderTargetView *const *render_target_views,
539 ID3D11DepthStencilView *depth_stencil_view)
541 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
542 struct d3d_depthstencil_view *dsv;
543 unsigned int i;
545 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
546 iface, render_target_view_count, render_target_views, depth_stencil_view);
548 wined3d_mutex_lock();
549 for (i = 0; i < render_target_view_count; ++i)
551 struct d3d_rendertarget_view *rtv = unsafe_impl_from_ID3D11RenderTargetView(render_target_views[i]);
552 wined3d_device_set_rendertarget_view(device->wined3d_device, i, rtv ? rtv->wined3d_view : NULL, FALSE);
554 for (; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
556 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
559 dsv = unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view);
560 wined3d_device_set_depth_stencil_view(device->wined3d_device, dsv ? dsv->wined3d_view : NULL);
561 wined3d_mutex_unlock();
564 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews(
565 ID3D11DeviceContext *iface, UINT render_target_view_count,
566 ID3D11RenderTargetView *const *render_target_views, ID3D11DepthStencilView *depth_stencil_view,
567 UINT unordered_access_view_start_slot, UINT unordered_access_view_count,
568 ID3D11UnorderedAccessView *const *unordered_access_views, const UINT *initial_counts)
570 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
571 "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, "
572 "initial_counts %p stub!\n",
573 iface, render_target_view_count, render_target_views, depth_stencil_view,
574 unordered_access_view_start_slot, unordered_access_view_count, unordered_access_views,
575 initial_counts);
578 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext *iface,
579 ID3D11BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
581 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
582 const D3D11_BLEND_DESC *desc;
584 TRACE("iface %p, blend_state %p, blend_factor {%.8e %.8e %.8e %.8e}, sample_mask 0x%08x.\n",
585 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
587 if (blend_factor[0] != 1.0f || blend_factor[1] != 1.0f || blend_factor[2] != 1.0f || blend_factor[3] != 1.0f)
588 FIXME("Ignoring blend factor {%.8e %.8e %.8e %.8e}.\n",
589 blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3]);
591 wined3d_mutex_lock();
592 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
593 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK, sample_mask);
594 if (!(device->blend_state = unsafe_impl_from_ID3D11BlendState(blend_state)))
596 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE, FALSE);
597 wined3d_device_set_render_state(device->wined3d_device,
598 WINED3D_RS_COLORWRITEENABLE, D3D11_COLOR_WRITE_ENABLE_ALL);
599 wined3d_device_set_render_state(device->wined3d_device,
600 WINED3D_RS_COLORWRITEENABLE1, D3D11_COLOR_WRITE_ENABLE_ALL);
601 wined3d_device_set_render_state(device->wined3d_device,
602 WINED3D_RS_COLORWRITEENABLE2, D3D11_COLOR_WRITE_ENABLE_ALL);
603 wined3d_device_set_render_state(device->wined3d_device,
604 WINED3D_RS_COLORWRITEENABLE3, D3D11_COLOR_WRITE_ENABLE_ALL);
605 wined3d_mutex_unlock();
606 return;
609 desc = &device->blend_state->desc;
610 /* glSampleCoverage() */
611 if (desc->AlphaToCoverageEnable)
612 FIXME("Ignoring AlphaToCoverageEnable %#x.\n", desc->AlphaToCoverageEnable);
613 /* glEnableIndexedEXT(GL_BLEND, ...) */
614 FIXME("Per-rendertarget blend not implemented.\n");
615 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE,
616 desc->RenderTarget[0].BlendEnable);
617 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SRCBLEND, desc->RenderTarget[0].SrcBlend);
618 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DESTBLEND, desc->RenderTarget[0].DestBlend);
619 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_BLENDOP, desc->RenderTarget[0].BlendOp);
620 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SEPARATEALPHABLENDENABLE, TRUE);
621 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SRCBLENDALPHA,
622 desc->RenderTarget[0].SrcBlendAlpha);
623 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DESTBLENDALPHA,
624 desc->RenderTarget[0].DestBlendAlpha);
625 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_BLENDOPALPHA,
626 desc->RenderTarget[0].BlendOpAlpha);
627 FIXME("Color mask > 3 not implemented.\n");
628 wined3d_device_set_render_state(device->wined3d_device,
629 WINED3D_RS_COLORWRITEENABLE, desc->RenderTarget[0].RenderTargetWriteMask);
630 wined3d_device_set_render_state(device->wined3d_device,
631 WINED3D_RS_COLORWRITEENABLE1, desc->RenderTarget[1].RenderTargetWriteMask);
632 wined3d_device_set_render_state(device->wined3d_device,
633 WINED3D_RS_COLORWRITEENABLE2, desc->RenderTarget[2].RenderTargetWriteMask);
634 wined3d_device_set_render_state(device->wined3d_device,
635 WINED3D_RS_COLORWRITEENABLE3, desc->RenderTarget[3].RenderTargetWriteMask);
636 wined3d_mutex_unlock();
639 static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext *iface,
640 ID3D11DepthStencilState *depth_stencil_state, UINT stencil_ref)
642 FIXME("iface %p, depth_stencil_state %p, stencil_ref %u stub!\n", iface, depth_stencil_state, stencil_ref);
645 static void STDMETHODCALLTYPE d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext *iface, UINT buffer_count,
646 ID3D11Buffer *const *buffers, const UINT *offsets)
648 FIXME("iface %p, buffer_count %u, buffers %p, offsets %p stub!\n", iface, buffer_count, buffers, offsets);
651 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawAuto(ID3D11DeviceContext *iface)
653 FIXME("iface %p stub!\n", iface);
656 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext *iface,
657 ID3D11Buffer *buffer, UINT offset)
659 FIXME("iface %p, buffer %p, offset %u stub!\n", iface, buffer, offset);
662 static void STDMETHODCALLTYPE d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext *iface,
663 ID3D11Buffer *buffer, UINT offset)
665 FIXME("iface %p, buffer %p, offset %u stub!\n", iface, buffer, offset);
668 static void STDMETHODCALLTYPE d3d11_immediate_context_Dispatch(ID3D11DeviceContext *iface,
669 UINT thread_group_count_x, UINT thread_group_count_y, UINT thread_group_count_z)
671 FIXME("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u stub!\n",
672 iface, thread_group_count_x, thread_group_count_y, thread_group_count_z);
675 static void STDMETHODCALLTYPE d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext *iface,
676 ID3D11Buffer *buffer, UINT offset)
678 FIXME("iface %p, buffer %p, offset %u stub!\n", iface, buffer, offset);
681 static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceContext *iface,
682 ID3D11RasterizerState *rasterizer_state)
684 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
685 const D3D11_RASTERIZER_DESC *desc;
687 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
689 wined3d_mutex_lock();
690 if (!(device->rasterizer_state = unsafe_impl_from_ID3D11RasterizerState(rasterizer_state)))
692 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, WINED3D_FILL_SOLID);
693 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, WINED3D_CULL_CCW);
694 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE);
695 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE);
696 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ANTIALIASEDLINEENABLE, FALSE);
697 wined3d_mutex_unlock();
698 return;
701 desc = &device->rasterizer_state->desc;
702 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, desc->FillMode);
703 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, desc->CullMode);
704 /* glFrontFace() */
705 if (desc->FrontCounterClockwise)
706 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc->FrontCounterClockwise);
707 /* OpenGL style depth bias. */
708 if (desc->DepthBias || desc->SlopeScaledDepthBias)
709 FIXME("Ignoring depth bias.\n");
710 /* GL_DEPTH_CLAMP */
711 if (!desc->DepthClipEnable)
712 FIXME("Ignoring DepthClipEnable %#x.\n", desc->DepthClipEnable);
713 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable);
714 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable);
715 wined3d_device_set_render_state(device->wined3d_device,
716 WINED3D_RS_ANTIALIASEDLINEENABLE, desc->AntialiasedLineEnable);
717 wined3d_mutex_unlock();
720 static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext *iface,
721 UINT viewport_count, const D3D11_VIEWPORT *viewports)
723 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
724 struct wined3d_viewport wined3d_vp;
726 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
728 if (viewport_count > 1)
729 FIXME("Multiple viewports not implemented.\n");
731 if (!viewport_count)
732 return;
734 if (viewports[0].TopLeftX != (UINT)viewports[0].TopLeftX
735 || viewports[0].TopLeftY != (UINT)viewports[0].TopLeftY
736 || viewports[0].Width != (UINT)viewports[0].Width
737 || viewports[0].Height != (UINT)viewports[0].Height)
738 FIXME("Floating-point viewports not implemented.\n");
740 wined3d_vp.x = viewports[0].TopLeftX;
741 wined3d_vp.y = viewports[0].TopLeftY;
742 wined3d_vp.width = viewports[0].Width;
743 wined3d_vp.height = viewports[0].Height;
744 wined3d_vp.min_z = viewports[0].MinDepth;
745 wined3d_vp.max_z = viewports[0].MaxDepth;
747 wined3d_mutex_lock();
748 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
749 wined3d_mutex_unlock();
752 static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext *iface,
753 UINT rect_count, const D3D11_RECT *rects)
755 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
757 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
759 if (rect_count > 1)
760 FIXME("Multiple scissor rects not implemented.\n");
762 if (!rect_count)
763 return;
765 wined3d_mutex_lock();
766 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
767 wined3d_mutex_unlock();
770 static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext *iface,
771 ID3D11Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
772 ID3D11Resource *src_resource, UINT src_subresource_idx, const D3D11_BOX *src_box)
774 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
775 "src_resource %p, src_subresource_idx %u, src_box %p stub!\n",
776 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
777 src_resource, src_subresource_idx, src_box);
780 static void STDMETHODCALLTYPE d3d11_immediate_context_CopyResource(ID3D11DeviceContext *iface,
781 ID3D11Resource *dst_resource, ID3D11Resource *src_resource)
783 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
784 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
786 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
788 wined3d_dst_resource = wined3d_resource_from_d3d11_resource(dst_resource);
789 wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource);
790 wined3d_mutex_lock();
791 wined3d_device_copy_resource(device->wined3d_device, wined3d_dst_resource, wined3d_src_resource);
792 wined3d_mutex_unlock();
795 static void STDMETHODCALLTYPE d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext *iface,
796 ID3D11Resource *resource, UINT subresource_idx, const D3D11_BOX *box,
797 const void *data, UINT row_pitch, UINT depth_pitch)
799 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
800 struct wined3d_resource *wined3d_resource;
801 struct wined3d_box wined3d_box;
803 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
804 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
806 if (box)
808 wined3d_box.left = box->left;
809 wined3d_box.top = box->top;
810 wined3d_box.front = box->front;
811 wined3d_box.right = box->right;
812 wined3d_box.bottom = box->bottom;
813 wined3d_box.back = box->back;
816 wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
817 wined3d_mutex_lock();
818 wined3d_device_update_sub_resource(device->wined3d_device, wined3d_resource,
819 subresource_idx, box ? &wined3d_box : NULL, data, row_pitch, depth_pitch);
820 wined3d_mutex_unlock();
823 static void STDMETHODCALLTYPE d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext *iface,
824 ID3D11Buffer *dst_buffer, UINT dst_offset, ID3D11UnorderedAccessView *src_view)
826 FIXME("iface %p, dst_buffer %p, dst_offset %u, src_view %p stub!\n",
827 iface, dst_buffer, dst_offset, src_view);
830 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext *iface,
831 ID3D11RenderTargetView *render_target_view, const FLOAT color_rgba[4])
833 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
834 struct d3d_rendertarget_view *view = unsafe_impl_from_ID3D11RenderTargetView(render_target_view);
835 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
836 HRESULT hr;
838 TRACE("iface %p, render_target_view %p, color_rgba {%.8e %.8e %.8e %.8e}.\n",
839 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
841 wined3d_mutex_lock();
842 if (FAILED(hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, view->wined3d_view, NULL, &color)))
843 ERR("Failed to clear view, hr %#x.\n", hr);
844 wined3d_mutex_unlock();
847 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext *iface,
848 ID3D11UnorderedAccessView *unordered_access_view, const UINT values[4])
850 FIXME("iface %p, unordered_access_view %p, values {%u %u %u %u} stub!\n",
851 iface, unordered_access_view, values[0], values[1], values[2], values[3]);
854 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext *iface,
855 ID3D11UnorderedAccessView *unordered_access_view, const FLOAT values[4])
857 FIXME("iface %p, unordered_access_view %p, values {%.8e %.8e %.8e %.8e} stub!\n",
858 iface, unordered_access_view, values[0], values[1], values[2], values[3]);
861 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext *iface,
862 ID3D11DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
864 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
865 iface, depth_stencil_view, flags, depth, stencil);
868 static void STDMETHODCALLTYPE d3d11_immediate_context_GenerateMips(ID3D11DeviceContext *iface,
869 ID3D11ShaderResourceView *view)
871 FIXME("iface %p, view %p stub!\n", iface, view);
874 static void STDMETHODCALLTYPE d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext *iface,
875 ID3D11Resource *resource, FLOAT min_lod)
877 FIXME("iface %p, resource %p, min_lod %f stub!\n", iface, resource, min_lod);
880 static FLOAT STDMETHODCALLTYPE d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext *iface,
881 ID3D11Resource *resource)
883 FIXME("iface %p, resource %p stub!\n", iface, resource);
885 return 0.0f;
888 static void STDMETHODCALLTYPE d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext *iface,
889 ID3D11Resource *dst_resource, UINT dst_subresource_idx,
890 ID3D11Resource *src_resource, UINT src_subresource_idx,
891 DXGI_FORMAT format)
893 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
894 "format %s stub!\n",
895 iface, dst_resource, dst_subresource_idx, src_resource, src_subresource_idx,
896 debug_dxgi_format(format));
899 static void STDMETHODCALLTYPE d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext *iface,
900 ID3D11CommandList *command_list, BOOL restore_state)
902 FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface, command_list, restore_state);
905 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext *iface,
906 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
908 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
909 iface, start_slot, view_count, views);
912 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShader(ID3D11DeviceContext *iface,
913 ID3D11HullShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
915 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
916 iface, shader, class_instances, class_instance_count);
919 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext *iface,
920 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
922 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
923 iface, start_slot, sampler_count, samplers);
926 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext *iface,
927 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
929 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
930 iface, start_slot, buffer_count, buffers);
933 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext *iface,
934 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
936 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
937 iface, start_slot, view_count, views);
940 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShader(ID3D11DeviceContext *iface,
941 ID3D11DomainShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
943 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
944 iface, shader, class_instances, class_instance_count);
947 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext *iface,
948 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
950 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
951 iface, start_slot, sampler_count, samplers);
954 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext *iface,
955 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
957 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
958 iface, start_slot, buffer_count, buffers);
961 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext *iface,
962 UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views)
964 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
965 iface, start_slot, view_count, views);
968 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext *iface,
969 UINT start_slot, UINT view_count, ID3D11UnorderedAccessView *const *views, const UINT *initial_counts)
971 FIXME("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p stub!\n",
972 iface, start_slot, view_count, views, initial_counts);
975 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShader(ID3D11DeviceContext *iface,
976 ID3D11ComputeShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
978 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
979 iface, shader, class_instances, class_instance_count);
982 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext *iface,
983 UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers)
985 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
986 iface, start_slot, sampler_count, samplers);
989 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext *iface,
990 UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers)
992 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
993 iface, start_slot, buffer_count, buffers);
996 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext *iface,
997 UINT start_slot, UINT buffer_count, ID3D11Buffer **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_PSGetShaderResources(ID3D11DeviceContext *iface,
1004 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **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_PSGetShader(ID3D11DeviceContext *iface,
1011 ID3D11PixelShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1013 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1014 iface, shader, class_instances, class_instance_count);
1017 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext *iface,
1018 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1020 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1021 unsigned int i;
1023 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1024 iface, start_slot, sampler_count, samplers);
1026 wined3d_mutex_lock();
1027 for (i = 0; i < sampler_count; ++i)
1029 struct wined3d_sampler *wined3d_sampler;
1030 struct d3d_sampler_state *sampler_impl;
1032 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
1034 samplers[i] = NULL;
1035 continue;
1038 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1039 samplers[i] = &sampler_impl->ID3D11SamplerState_iface;
1040 ID3D11SamplerState_AddRef(samplers[i]);
1042 wined3d_mutex_unlock();
1045 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShader(ID3D11DeviceContext *iface,
1046 ID3D11VertexShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1048 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1049 iface, shader, class_instances, class_instance_count);
1052 static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext *iface,
1053 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1055 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1056 iface, start_slot, buffer_count, buffers);
1059 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext *iface,
1060 ID3D11InputLayout **input_layout)
1062 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1063 struct wined3d_vertex_declaration *wined3d_declaration;
1064 struct d3d_input_layout *input_layout_impl;
1066 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
1068 wined3d_mutex_lock();
1069 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
1071 wined3d_mutex_unlock();
1072 *input_layout = NULL;
1073 return;
1076 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
1077 wined3d_mutex_unlock();
1078 *input_layout = &input_layout_impl->ID3D11InputLayout_iface;
1079 ID3D11InputLayout_AddRef(*input_layout);
1082 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext *iface,
1083 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers, UINT *strides, UINT *offsets)
1085 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p stub!\n",
1086 iface, start_slot, buffer_count, buffers, strides, offsets);
1089 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext *iface,
1090 ID3D11Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
1092 FIXME("iface %p, buffer %p, format %p, offset %p stub!\n", iface, buffer, format, offset);
1095 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext *iface,
1096 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1098 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1099 unsigned int i;
1101 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
1102 iface, start_slot, buffer_count, buffers);
1104 wined3d_mutex_lock();
1105 for (i = 0; i < buffer_count; ++i)
1107 struct wined3d_buffer *wined3d_buffer;
1108 struct d3d_buffer *buffer_impl;
1110 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
1112 buffers[i] = NULL;
1113 continue;
1116 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1117 buffers[i] = &buffer_impl->ID3D11Buffer_iface;
1118 ID3D11Buffer_AddRef(buffers[i]);
1120 wined3d_mutex_unlock();
1123 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShader(ID3D11DeviceContext *iface,
1124 ID3D11GeometryShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1126 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1127 iface, shader, class_instances, class_instance_count);
1130 static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext *iface,
1131 D3D11_PRIMITIVE_TOPOLOGY *topology)
1133 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1135 TRACE("iface %p, topology %p.\n", iface, topology);
1137 wined3d_mutex_lock();
1138 wined3d_device_get_primitive_type(device->wined3d_device, (enum wined3d_primitive_type *)topology);
1139 wined3d_mutex_unlock();
1142 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext *iface,
1143 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1145 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1148 static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext *iface,
1149 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1151 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1152 unsigned int i;
1154 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1155 iface, start_slot, sampler_count, samplers);
1157 wined3d_mutex_lock();
1158 for (i = 0; i < sampler_count; ++i)
1160 struct wined3d_sampler *wined3d_sampler;
1161 struct d3d_sampler_state *sampler_impl;
1163 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
1165 samplers[i] = NULL;
1166 continue;
1169 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1170 samplers[i] = &sampler_impl->ID3D11SamplerState_iface;
1171 ID3D11SamplerState_AddRef(samplers[i]);
1173 wined3d_mutex_unlock();
1176 static void STDMETHODCALLTYPE d3d11_immediate_context_GetPredication(ID3D11DeviceContext *iface,
1177 ID3D11Predicate **predicate, BOOL *value)
1179 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1180 struct wined3d_query *wined3d_predicate;
1181 struct d3d_query *predicate_impl;
1183 TRACE("iface %p, predicate %p, value %p.\n", iface, predicate, value);
1185 wined3d_mutex_lock();
1186 if (!(wined3d_predicate = wined3d_device_get_predication(device->wined3d_device, value)))
1188 wined3d_mutex_unlock();
1189 *predicate = NULL;
1190 return;
1193 predicate_impl = wined3d_query_get_parent(wined3d_predicate);
1194 wined3d_mutex_unlock();
1195 *predicate = (ID3D11Predicate *)&predicate_impl->ID3D11Query_iface;
1196 ID3D11Predicate_AddRef(*predicate);
1199 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext *iface,
1200 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1202 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1205 static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext *iface,
1206 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1208 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1209 unsigned int i;
1211 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
1212 iface, start_slot, sampler_count, samplers);
1214 wined3d_mutex_lock();
1215 for (i = 0; i < sampler_count; ++i)
1217 struct d3d_sampler_state *sampler_impl;
1218 struct wined3d_sampler *wined3d_sampler;
1220 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
1222 samplers[i] = NULL;
1223 continue;
1226 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
1227 samplers[i] = &sampler_impl->ID3D11SamplerState_iface;
1228 ID3D11SamplerState_AddRef(samplers[i]);
1230 wined3d_mutex_unlock();
1233 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext *iface,
1234 UINT render_target_view_count, ID3D11RenderTargetView **render_target_views,
1235 ID3D11DepthStencilView **depth_stencil_view)
1237 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p stub!\n",
1238 iface, render_target_view_count, render_target_views, depth_stencil_view);
1241 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews(
1242 ID3D11DeviceContext *iface,
1243 UINT render_target_view_count, ID3D11RenderTargetView **render_target_views,
1244 ID3D11DepthStencilView **depth_stencil_view,
1245 UINT unordered_access_view_start_slot, UINT unordered_access_view_count,
1246 ID3D11UnorderedAccessView **unordered_access_views)
1248 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, "
1249 "unordered_access_view_start_slot %u, unordered_access_view_count %u, "
1250 "unordered_access_views %p stub!\n",
1251 iface, render_target_view_count, render_target_views, depth_stencil_view,
1252 unordered_access_view_start_slot, unordered_access_view_count, unordered_access_views);
1255 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext *iface,
1256 ID3D11BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
1258 FIXME("iface %p, blend_state %p, blend_factor %p, sample_mask %p stub!\n",
1259 iface, blend_state, blend_factor, sample_mask);
1262 static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext *iface,
1263 ID3D11DepthStencilState **depth_stencil_state, UINT *stencil_ref)
1265 FIXME("iface %p, depth_stencil_state %p, stencil_ref %p stub!\n", iface, depth_stencil_state, stencil_ref);
1268 static void STDMETHODCALLTYPE d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext *iface,
1269 UINT buffer_count, ID3D11Buffer **buffers)
1271 FIXME("iface %p, buffer_count %u, buffers %p stub!\n", iface, buffer_count, buffers);
1275 static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetState(ID3D11DeviceContext *iface,
1276 ID3D11RasterizerState **rasterizer_state)
1278 struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
1280 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
1282 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D11RasterizerState_iface : NULL))
1283 ID3D11RasterizerState_AddRef(*rasterizer_state);
1286 static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext *iface,
1287 UINT *viewport_count, D3D11_VIEWPORT *viewports)
1289 FIXME("iface %p, viewport_count %p, viewports %p stub!\n", iface, viewport_count, viewports);
1292 static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext *iface,
1293 UINT *rect_count, D3D11_RECT *rects)
1295 FIXME("iface %p, rect_count %p, rects %p stub!\n", iface, rect_count, rects);
1298 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext *iface,
1299 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1301 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1304 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShader(ID3D11DeviceContext *iface,
1305 ID3D11HullShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1307 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1308 iface, shader, class_instances, class_instance_count);
1311 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext *iface,
1312 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1314 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1315 iface, start_slot, sampler_count, samplers);
1318 static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext *iface,
1319 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1321 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1322 iface, start_slot, buffer_count, buffers);
1325 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext *iface,
1326 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1328 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
1329 iface, start_slot, view_count, views);
1332 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShader(ID3D11DeviceContext *iface,
1333 ID3D11DomainShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1335 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1336 iface, shader, class_instances, class_instance_count);
1339 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext *iface,
1340 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1342 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1343 iface, start_slot, sampler_count, samplers);
1346 static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext *iface,
1347 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1349 FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p stub!\n",
1350 iface, start_slot, buffer_count, buffers);
1353 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext *iface,
1354 UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views)
1356 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1359 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext *iface,
1360 UINT start_slot, UINT view_count, ID3D11UnorderedAccessView **views)
1362 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views);
1365 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShader(ID3D11DeviceContext *iface,
1366 ID3D11ComputeShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count)
1368 FIXME("iface %p, shader %p, class_instances %p, class_instance_count %p stub!\n",
1369 iface, shader, class_instances, class_instance_count);
1372 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext *iface,
1373 UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers)
1375 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
1376 iface, start_slot, sampler_count, samplers);
1379 static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext *iface,
1380 UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers)
1382 FIXME("iface %p, start_slot %u, buffer_count %u, buffer %p stub!\n",
1383 iface, start_slot, buffer_count, buffers);
1386 static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceContext *iface)
1388 FIXME("iface %p stub!\n", iface);
1391 static void STDMETHODCALLTYPE d3d11_immediate_context_Flush(ID3D11DeviceContext *iface)
1393 FIXME("iface %p stub!\n", iface);
1396 static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE d3d11_immediate_context_GetType(ID3D11DeviceContext *iface)
1398 TRACE("iface %p.\n", iface);
1400 return D3D11_DEVICE_CONTEXT_IMMEDIATE;
1403 static UINT STDMETHODCALLTYPE d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext *iface)
1405 FIXME("iface %p stub!\n", iface);
1407 return 0;
1410 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext *iface,
1411 BOOL restore, ID3D11CommandList **command_list)
1413 FIXME("iface %p, restore %#x, command_list %p stub!\n", iface, restore, command_list);
1415 return E_NOTIMPL;
1418 static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl =
1420 /* IUnknown methods */
1421 d3d11_immediate_context_QueryInterface,
1422 d3d11_immediate_context_AddRef,
1423 d3d11_immediate_context_Release,
1424 /* ID3D11DeviceChild methods */
1425 d3d11_immediate_context_GetDevice,
1426 d3d11_immediate_context_GetPrivateData,
1427 d3d11_immediate_context_SetPrivateData,
1428 d3d11_immediate_context_SetPrivateDataInterface,
1429 /* ID3D11DeviceContext methods */
1430 d3d11_immediate_context_VSSetConstantBuffers,
1431 d3d11_immediate_context_PSSetShaderResources,
1432 d3d11_immediate_context_PSSetShader,
1433 d3d11_immediate_context_PSSetSamplers,
1434 d3d11_immediate_context_VSSetShader,
1435 d3d11_immediate_context_DrawIndexed,
1436 d3d11_immediate_context_Draw,
1437 d3d11_immediate_context_Map,
1438 d3d11_immediate_context_Unmap,
1439 d3d11_immediate_context_PSSetConstantBuffers,
1440 d3d11_immediate_context_IASetInputLayout,
1441 d3d11_immediate_context_IASetVertexBuffers,
1442 d3d11_immediate_context_IASetIndexBuffer,
1443 d3d11_immediate_context_DrawIndexedInstanced,
1444 d3d11_immediate_context_DrawInstanced,
1445 d3d11_immediate_context_GSSetConstantBuffers,
1446 d3d11_immediate_context_GSSetShader,
1447 d3d11_immediate_context_IASetPrimitiveTopology,
1448 d3d11_immediate_context_VSSetShaderResources,
1449 d3d11_immediate_context_VSSetSamplers,
1450 d3d11_immediate_context_Begin,
1451 d3d11_immediate_context_End,
1452 d3d11_immediate_context_GetData,
1453 d3d11_immediate_context_SetPredication,
1454 d3d11_immediate_context_GSSetShaderResources,
1455 d3d11_immediate_context_GSSetSamplers,
1456 d3d11_immediate_context_OMSetRenderTargets,
1457 d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews,
1458 d3d11_immediate_context_OMSetBlendState,
1459 d3d11_immediate_context_OMSetDepthStencilState,
1460 d3d11_immediate_context_SOSetTargets,
1461 d3d11_immediate_context_DrawAuto,
1462 d3d11_immediate_context_DrawIndexedInstancedIndirect,
1463 d3d11_immediate_context_DrawInstancedIndirect,
1464 d3d11_immediate_context_Dispatch,
1465 d3d11_immediate_context_DispatchIndirect,
1466 d3d11_immediate_context_RSSetState,
1467 d3d11_immediate_context_RSSetViewports,
1468 d3d11_immediate_context_RSSetScissorRects,
1469 d3d11_immediate_context_CopySubresourceRegion,
1470 d3d11_immediate_context_CopyResource,
1471 d3d11_immediate_context_UpdateSubresource,
1472 d3d11_immediate_context_CopyStructureCount,
1473 d3d11_immediate_context_ClearRenderTargetView,
1474 d3d11_immediate_context_ClearUnorderedAccessViewUint,
1475 d3d11_immediate_context_ClearUnorderedAccessViewFloat,
1476 d3d11_immediate_context_ClearDepthStencilView,
1477 d3d11_immediate_context_GenerateMips,
1478 d3d11_immediate_context_SetResourceMinLOD,
1479 d3d11_immediate_context_GetResourceMinLOD,
1480 d3d11_immediate_context_ResolveSubresource,
1481 d3d11_immediate_context_ExecuteCommandList,
1482 d3d11_immediate_context_HSSetShaderResources,
1483 d3d11_immediate_context_HSSetShader,
1484 d3d11_immediate_context_HSSetSamplers,
1485 d3d11_immediate_context_HSSetConstantBuffers,
1486 d3d11_immediate_context_DSSetShaderResources,
1487 d3d11_immediate_context_DSSetShader,
1488 d3d11_immediate_context_DSSetSamplers,
1489 d3d11_immediate_context_DSSetConstantBuffers,
1490 d3d11_immediate_context_CSSetShaderResources,
1491 d3d11_immediate_context_CSSetUnorderedAccessViews,
1492 d3d11_immediate_context_CSSetShader,
1493 d3d11_immediate_context_CSSetSamplers,
1494 d3d11_immediate_context_CSSetConstantBuffers,
1495 d3d11_immediate_context_VSGetConstantBuffers,
1496 d3d11_immediate_context_PSGetShaderResources,
1497 d3d11_immediate_context_PSGetShader,
1498 d3d11_immediate_context_PSGetSamplers,
1499 d3d11_immediate_context_VSGetShader,
1500 d3d11_immediate_context_PSGetConstantBuffers,
1501 d3d11_immediate_context_IAGetInputLayout,
1502 d3d11_immediate_context_IAGetVertexBuffers,
1503 d3d11_immediate_context_IAGetIndexBuffer,
1504 d3d11_immediate_context_GSGetConstantBuffers,
1505 d3d11_immediate_context_GSGetShader,
1506 d3d11_immediate_context_IAGetPrimitiveTopology,
1507 d3d11_immediate_context_VSGetShaderResources,
1508 d3d11_immediate_context_VSGetSamplers,
1509 d3d11_immediate_context_GetPredication,
1510 d3d11_immediate_context_GSGetShaderResources,
1511 d3d11_immediate_context_GSGetSamplers,
1512 d3d11_immediate_context_OMGetRenderTargets,
1513 d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews,
1514 d3d11_immediate_context_OMGetBlendState,
1515 d3d11_immediate_context_OMGetDepthStencilState,
1516 d3d11_immediate_context_SOGetTargets,
1517 d3d11_immediate_context_RSGetState,
1518 d3d11_immediate_context_RSGetViewports,
1519 d3d11_immediate_context_RSGetScissorRects,
1520 d3d11_immediate_context_HSGetShaderResources,
1521 d3d11_immediate_context_HSGetShader,
1522 d3d11_immediate_context_HSGetSamplers,
1523 d3d11_immediate_context_HSGetConstantBuffers,
1524 d3d11_immediate_context_DSGetShaderResources,
1525 d3d11_immediate_context_DSGetShader,
1526 d3d11_immediate_context_DSGetSamplers,
1527 d3d11_immediate_context_DSGetConstantBuffers,
1528 d3d11_immediate_context_CSGetShaderResources,
1529 d3d11_immediate_context_CSGetUnorderedAccessViews,
1530 d3d11_immediate_context_CSGetShader,
1531 d3d11_immediate_context_CSGetSamplers,
1532 d3d11_immediate_context_CSGetConstantBuffers,
1533 d3d11_immediate_context_ClearState,
1534 d3d11_immediate_context_Flush,
1535 d3d11_immediate_context_GetType,
1536 d3d11_immediate_context_GetContextFlags,
1537 d3d11_immediate_context_FinishCommandList,
1540 static HRESULT d3d11_immediate_context_init(struct d3d11_immediate_context *context, struct d3d_device *device)
1542 context->ID3D11DeviceContext_iface.lpVtbl = &d3d11_immediate_context_vtbl;
1543 context->refcount = 1;
1545 ID3D11Device_AddRef(&device->ID3D11Device_iface);
1547 return S_OK;
1550 /* ID3D11Device methods */
1552 static HRESULT STDMETHODCALLTYPE d3d11_device_QueryInterface(ID3D11Device *iface, REFIID riid, void **out)
1554 struct d3d_device *device = impl_from_ID3D11Device(iface);
1555 return IUnknown_QueryInterface(device->outer_unk, riid, out);
1558 static ULONG STDMETHODCALLTYPE d3d11_device_AddRef(ID3D11Device *iface)
1560 struct d3d_device *device = impl_from_ID3D11Device(iface);
1561 return IUnknown_AddRef(device->outer_unk);
1564 static ULONG STDMETHODCALLTYPE d3d11_device_Release(ID3D11Device *iface)
1566 struct d3d_device *device = impl_from_ID3D11Device(iface);
1567 return IUnknown_Release(device->outer_unk);
1570 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBuffer(ID3D11Device *iface, const D3D11_BUFFER_DESC *desc,
1571 const D3D11_SUBRESOURCE_DATA *data, ID3D11Buffer **buffer)
1573 struct d3d_device *device = impl_from_ID3D11Device(iface);
1574 struct d3d_buffer *object;
1575 HRESULT hr;
1577 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface, desc, data, buffer);
1579 if (FAILED(hr = d3d_buffer_create(device, desc, data, &object)))
1580 return hr;
1582 *buffer = &object->ID3D11Buffer_iface;
1584 return S_OK;
1587 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture1D(ID3D11Device *iface,
1588 const D3D11_TEXTURE1D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture1D **texture)
1590 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1592 return E_NOTIMPL;
1595 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture2D(ID3D11Device *iface,
1596 const D3D11_TEXTURE2D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture2D **texture)
1598 struct d3d_device *device = impl_from_ID3D11Device(iface);
1599 struct d3d_texture2d *object;
1600 HRESULT hr;
1602 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1604 if (FAILED(hr = d3d_texture2d_create(device, desc, data, &object)))
1605 return hr;
1607 *texture = &object->ID3D11Texture2D_iface;
1609 return S_OK;
1612 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture3D(ID3D11Device *iface,
1613 const D3D11_TEXTURE3D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture3D **texture)
1615 struct d3d_device *device = impl_from_ID3D11Device(iface);
1616 struct d3d_texture3d *object;
1617 HRESULT hr;
1619 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1621 if (FAILED(hr = d3d_texture3d_create(device, desc, data, &object)))
1622 return hr;
1624 *texture = &object->ID3D11Texture3D_iface;
1626 return S_OK;
1629 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateShaderResourceView(ID3D11Device *iface,
1630 ID3D11Resource *resource, const D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11ShaderResourceView **view)
1632 struct d3d_device *device = impl_from_ID3D11Device(iface);
1633 struct d3d_shader_resource_view *object;
1634 HRESULT hr;
1636 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1638 if (FAILED(hr = d3d_shader_resource_view_create(device, resource, desc, &object)))
1639 return hr;
1641 *view = &object->ID3D11ShaderResourceView_iface;
1643 return S_OK;
1646 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateUnorderedAccessView(ID3D11Device *iface,
1647 ID3D11Resource *resource, const D3D11_UNORDERED_ACCESS_VIEW_DESC *desc, ID3D11UnorderedAccessView **view)
1649 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1651 return E_NOTIMPL;
1654 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRenderTargetView(ID3D11Device *iface,
1655 ID3D11Resource *resource, const D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11RenderTargetView **view)
1657 struct d3d_device *device = impl_from_ID3D11Device(iface);
1658 struct d3d_rendertarget_view *object;
1659 HRESULT hr;
1661 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1663 if (FAILED(hr = d3d_rendertarget_view_create(device, resource, desc, &object)))
1664 return hr;
1666 *view = &object->ID3D11RenderTargetView_iface;
1668 return S_OK;
1671 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilView(ID3D11Device *iface,
1672 ID3D11Resource *resource, const D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11DepthStencilView **view)
1674 struct d3d_device *device = impl_from_ID3D11Device(iface);
1675 struct d3d_depthstencil_view *object;
1676 HRESULT hr;
1678 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1680 if (FAILED(hr = d3d_depthstencil_view_create(device, resource, desc, &object)))
1681 return hr;
1683 *view = &object->ID3D11DepthStencilView_iface;
1685 return S_OK;
1688 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateInputLayout(ID3D11Device *iface,
1689 const D3D11_INPUT_ELEMENT_DESC *element_descs, UINT element_count, const void *shader_byte_code,
1690 SIZE_T shader_byte_code_length, ID3D11InputLayout **input_layout)
1692 struct d3d_device *device = impl_from_ID3D11Device(iface);
1693 struct d3d_input_layout *object;
1694 HRESULT hr;
1696 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, "
1697 "input_layout %p.\n", iface, element_descs, element_count, shader_byte_code,
1698 shader_byte_code_length, input_layout);
1700 if (FAILED(hr = d3d_input_layout_create(device, element_descs, element_count,
1701 shader_byte_code, shader_byte_code_length, &object)))
1702 return hr;
1704 *input_layout = &object->ID3D11InputLayout_iface;
1706 return S_OK;
1709 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateVertexShader(ID3D11Device *iface, const void *byte_code,
1710 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11VertexShader **shader)
1712 struct d3d_device *device = impl_from_ID3D11Device(iface);
1713 struct d3d_vertex_shader *object;
1714 HRESULT hr;
1716 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
1717 iface, byte_code, byte_code_length, class_linkage, shader);
1719 if (class_linkage)
1720 FIXME("Class linkage is not implemented yet.\n");
1722 if (FAILED(hr = d3d_vertex_shader_create(device, byte_code, byte_code_length, &object)))
1723 return hr;
1725 *shader = &object->ID3D11VertexShader_iface;
1727 return S_OK;
1730 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShader(ID3D11Device *iface, const void *byte_code,
1731 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11GeometryShader **shader)
1733 struct d3d_device *device = impl_from_ID3D11Device(iface);
1734 struct d3d_geometry_shader *object;
1735 HRESULT hr;
1737 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
1738 iface, byte_code, byte_code_length, class_linkage, shader);
1740 if (class_linkage)
1741 FIXME("Class linkage is not implemented yet.\n");
1743 if (FAILED(hr = d3d_geometry_shader_create(device, byte_code, byte_code_length, &object)))
1744 return hr;
1746 *shader = &object->ID3D11GeometryShader_iface;
1748 return S_OK;
1751 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device *iface,
1752 const void *byte_code, SIZE_T byte_code_length, const D3D11_SO_DECLARATION_ENTRY *so_entries,
1753 UINT entry_count, const UINT *buffer_strides, UINT strides_count, UINT rasterized_stream,
1754 ID3D11ClassLinkage *class_linkage, ID3D11GeometryShader **shader)
1756 FIXME("iface %p, byte_code %p, byte_code_length %lu, so_entries %p, entry_count %u, "
1757 "buffer_strides %p, strides_count %u, rasterized_stream %u, class_linkage %p, shader %p stub!\n",
1758 iface, byte_code, byte_code_length, so_entries, entry_count, buffer_strides, strides_count,
1759 rasterized_stream, class_linkage, shader);
1761 return E_NOTIMPL;
1764 static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePixelShader(ID3D11Device *iface, const void *byte_code,
1765 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11PixelShader **shader)
1767 struct d3d_device *device = impl_from_ID3D11Device(iface);
1768 struct d3d_pixel_shader *object;
1769 HRESULT hr;
1771 TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
1772 iface, byte_code, byte_code_length, class_linkage, shader);
1774 if (class_linkage)
1775 FIXME("Class linkage is not implemented yet.\n");
1777 if (FAILED(hr = d3d_pixel_shader_create(device, byte_code, byte_code_length, &object)))
1778 return hr;
1780 *shader = &object->ID3D11PixelShader_iface;
1782 return S_OK;
1785 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateHullShader(ID3D11Device *iface, const void *byte_code,
1786 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11HullShader **shader)
1788 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
1789 iface, byte_code, byte_code_length, class_linkage, shader);
1791 return E_NOTIMPL;
1794 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDomainShader(ID3D11Device *iface, const void *byte_code,
1795 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11DomainShader **shader)
1797 FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
1798 iface, byte_code, byte_code_length, class_linkage, shader);
1800 return E_NOTIMPL;
1803 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateComputeShader(ID3D11Device *iface, const void *byte_code,
1804 SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11ComputeShader **shader)
1806 FIXME("iface %p, byte_code %p, byte_code_lenghth %lu, class_linkage %p, shader %p stub!\n",
1807 iface, byte_code, byte_code_length, class_linkage, shader);
1809 return E_NOTIMPL;
1812 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateClassLinkage(ID3D11Device *iface,
1813 ID3D11ClassLinkage **class_linkage)
1815 FIXME("iface %p, class_linkage %p stub!\n", iface, class_linkage);
1817 return E_NOTIMPL;
1820 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBlendState(ID3D11Device *iface,
1821 const D3D11_BLEND_DESC *desc, ID3D11BlendState **blend_state)
1823 struct d3d_device *device = impl_from_ID3D11Device(iface);
1824 struct d3d_blend_state *object;
1825 struct wine_rb_entry *entry;
1826 D3D11_BLEND_DESC tmp_desc;
1827 unsigned int i, j;
1828 HRESULT hr;
1830 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
1832 if (!desc)
1833 return E_INVALIDARG;
1835 /* D3D11_RENDER_TARGET_BLEND_DESC has a hole, which is a problem because we use
1836 * D3D11_BLEND_DESC as a key in the rbtree. */
1837 memset(&tmp_desc, 0, sizeof(tmp_desc));
1838 tmp_desc.AlphaToCoverageEnable = desc->AlphaToCoverageEnable;
1839 tmp_desc.IndependentBlendEnable = desc->IndependentBlendEnable;
1840 for (i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
1842 j = desc->IndependentBlendEnable ? i : 0;
1843 tmp_desc.RenderTarget[i].BlendEnable = desc->RenderTarget[j].BlendEnable;
1844 tmp_desc.RenderTarget[i].SrcBlend = desc->RenderTarget[j].SrcBlend;
1845 tmp_desc.RenderTarget[i].DestBlend = desc->RenderTarget[j].DestBlend;
1846 tmp_desc.RenderTarget[i].BlendOp = desc->RenderTarget[j].BlendOp;
1847 tmp_desc.RenderTarget[i].SrcBlendAlpha = desc->RenderTarget[j].SrcBlendAlpha;
1848 tmp_desc.RenderTarget[i].DestBlendAlpha = desc->RenderTarget[j].DestBlendAlpha;
1849 tmp_desc.RenderTarget[i].BlendOpAlpha = desc->RenderTarget[j].BlendOpAlpha;
1850 tmp_desc.RenderTarget[i].RenderTargetWriteMask = desc->RenderTarget[j].RenderTargetWriteMask;
1853 wined3d_mutex_lock();
1854 if ((entry = wine_rb_get(&device->blend_states, &tmp_desc)))
1856 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_blend_state, entry);
1858 TRACE("Returning existing blend state %p.\n", object);
1859 *blend_state = &object->ID3D11BlendState_iface;
1860 ID3D11BlendState_AddRef(*blend_state);
1861 wined3d_mutex_unlock();
1863 return S_OK;
1865 wined3d_mutex_unlock();
1867 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1868 return E_OUTOFMEMORY;
1870 if (FAILED(hr = d3d_blend_state_init(object, device, &tmp_desc)))
1872 WARN("Failed to initialize blend state, hr %#x.\n", hr);
1873 HeapFree(GetProcessHeap(), 0, object);
1874 return hr;
1877 TRACE("Created blend state %p.\n", object);
1878 *blend_state = &object->ID3D11BlendState_iface;
1880 return S_OK;
1883 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilState(ID3D11Device *iface,
1884 const D3D11_DEPTH_STENCIL_DESC *desc, ID3D11DepthStencilState **depth_stencil_state)
1886 struct d3d_device *device = impl_from_ID3D11Device(iface);
1887 struct d3d_depthstencil_state *object;
1888 D3D11_DEPTH_STENCIL_DESC tmp_desc;
1889 struct wine_rb_entry *entry;
1890 HRESULT hr;
1892 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
1894 if (!desc)
1895 return E_INVALIDARG;
1897 /* D3D11_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
1898 * it as a key in the rbtree. */
1899 memset(&tmp_desc, 0, sizeof(tmp_desc));
1900 tmp_desc.DepthEnable = desc->DepthEnable;
1901 tmp_desc.DepthWriteMask = desc->DepthWriteMask;
1902 tmp_desc.DepthFunc = desc->DepthFunc;
1903 tmp_desc.StencilEnable = desc->StencilEnable;
1904 tmp_desc.StencilReadMask = desc->StencilReadMask;
1905 tmp_desc.StencilWriteMask = desc->StencilWriteMask;
1906 tmp_desc.FrontFace = desc->FrontFace;
1907 tmp_desc.BackFace = desc->BackFace;
1909 wined3d_mutex_lock();
1910 if ((entry = wine_rb_get(&device->depthstencil_states, &tmp_desc)))
1912 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_depthstencil_state, entry);
1914 TRACE("Returning existing depthstencil state %p.\n", object);
1915 *depth_stencil_state = &object->ID3D11DepthStencilState_iface;
1916 ID3D11DepthStencilState_AddRef(*depth_stencil_state);
1917 wined3d_mutex_unlock();
1919 return S_OK;
1921 wined3d_mutex_unlock();
1923 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1924 return E_OUTOFMEMORY;
1926 if (FAILED(hr = d3d_depthstencil_state_init(object, device, &tmp_desc)))
1928 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1929 HeapFree(GetProcessHeap(), 0, object);
1930 return hr;
1933 TRACE("Created depthstencil state %p.\n", object);
1934 *depth_stencil_state = &object->ID3D11DepthStencilState_iface;
1936 return S_OK;
1939 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState(ID3D11Device *iface,
1940 const D3D11_RASTERIZER_DESC *desc, ID3D11RasterizerState **rasterizer_state)
1942 struct d3d_device *device = impl_from_ID3D11Device(iface);
1943 struct d3d_rasterizer_state *object;
1944 struct wine_rb_entry *entry;
1945 HRESULT hr;
1947 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1949 if (!desc)
1950 return E_INVALIDARG;
1952 wined3d_mutex_lock();
1953 if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
1955 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_rasterizer_state, entry);
1957 TRACE("Returning existing rasterizer state %p.\n", object);
1958 *rasterizer_state = &object->ID3D11RasterizerState_iface;
1959 ID3D11RasterizerState_AddRef(*rasterizer_state);
1960 wined3d_mutex_unlock();
1962 return S_OK;
1964 wined3d_mutex_unlock();
1966 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1967 return E_OUTOFMEMORY;
1969 if (FAILED(hr = d3d_rasterizer_state_init(object, device, desc)))
1971 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1972 HeapFree(GetProcessHeap(), 0, object);
1973 return hr;
1976 TRACE("Created rasterizer state %p.\n", object);
1977 *rasterizer_state = &object->ID3D11RasterizerState_iface;
1979 return S_OK;
1982 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateSamplerState(ID3D11Device *iface,
1983 const D3D11_SAMPLER_DESC *desc, ID3D11SamplerState **sampler_state)
1985 struct d3d_device *device = impl_from_ID3D11Device(iface);
1986 D3D11_SAMPLER_DESC normalized_desc;
1987 struct d3d_sampler_state *object;
1988 struct wine_rb_entry *entry;
1989 HRESULT hr;
1991 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
1993 if (!desc)
1994 return E_INVALIDARG;
1996 normalized_desc = *desc;
1997 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(normalized_desc.Filter))
1998 normalized_desc.MaxAnisotropy = 0;
1999 if (!D3D11_DECODE_IS_COMPARISON_FILTER(normalized_desc.Filter))
2000 normalized_desc.ComparisonFunc = D3D11_COMPARISON_NEVER;
2001 if (normalized_desc.AddressU != D3D11_TEXTURE_ADDRESS_BORDER
2002 && normalized_desc.AddressV != D3D11_TEXTURE_ADDRESS_BORDER
2003 && normalized_desc.AddressW != D3D11_TEXTURE_ADDRESS_BORDER)
2004 memset(&normalized_desc.BorderColor, 0, sizeof(normalized_desc.BorderColor));
2006 wined3d_mutex_lock();
2007 if ((entry = wine_rb_get(&device->sampler_states, &normalized_desc)))
2009 object = WINE_RB_ENTRY_VALUE(entry, struct d3d_sampler_state, entry);
2011 TRACE("Returning existing sampler state %p.\n", object);
2012 *sampler_state = &object->ID3D11SamplerState_iface;
2013 ID3D11SamplerState_AddRef(*sampler_state);
2014 wined3d_mutex_unlock();
2016 return S_OK;
2018 wined3d_mutex_unlock();
2020 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2021 return E_OUTOFMEMORY;
2023 if (FAILED(hr = d3d_sampler_state_init(object, device, &normalized_desc)))
2025 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
2026 HeapFree(GetProcessHeap(), 0, object);
2027 return hr;
2030 TRACE("Created sampler state %p.\n", object);
2031 *sampler_state = &object->ID3D11SamplerState_iface;
2033 return S_OK;
2036 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateQuery(ID3D11Device *iface,
2037 const D3D11_QUERY_DESC *desc, ID3D11Query **query)
2039 struct d3d_device *device = impl_from_ID3D11Device(iface);
2040 struct d3d_query *object;
2041 HRESULT hr;
2043 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
2045 if (FAILED(hr = d3d_query_create(device, desc, FALSE, &object)))
2046 return hr;
2048 *query = &object->ID3D11Query_iface;
2050 return S_OK;
2053 static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePredicate(ID3D11Device *iface, const D3D11_QUERY_DESC *desc,
2054 ID3D11Predicate **predicate)
2056 struct d3d_device *device = impl_from_ID3D11Device(iface);
2057 struct d3d_query *object;
2058 HRESULT hr;
2060 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
2062 if (FAILED(hr = d3d_query_create(device, desc, TRUE, &object)))
2063 return hr;
2065 *predicate = (ID3D11Predicate *)&object->ID3D11Query_iface;
2067 return S_OK;
2070 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateCounter(ID3D11Device *iface, const D3D11_COUNTER_DESC *desc,
2071 ID3D11Counter **counter)
2073 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
2075 return E_NOTIMPL;
2078 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDeferredContext(ID3D11Device *iface, UINT flags,
2079 ID3D11DeviceContext **context)
2081 FIXME("iface %p, flags %#x, context %p stub!\n", iface, flags, context);
2083 return E_NOTIMPL;
2086 static HRESULT STDMETHODCALLTYPE d3d11_device_OpenSharedResource(ID3D11Device *iface, HANDLE resource, REFIID riid,
2087 void **out)
2089 FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface, resource, debugstr_guid(riid), out);
2091 return E_NOTIMPL;
2094 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFormatSupport(ID3D11Device *iface, DXGI_FORMAT format,
2095 UINT *format_support)
2097 FIXME("iface %p, format %u, format_support %p stub!\n", iface, format, format_support);
2099 return E_NOTIMPL;
2102 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckMultisampleQualityLevels(ID3D11Device *iface,
2103 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
2105 FIXME("iface %p, format %u, sample_count %u, quality_level_count %p stub!\n",
2106 iface, format, sample_count, quality_level_count);
2108 return E_NOTIMPL;
2111 static void STDMETHODCALLTYPE d3d11_device_CheckCounterInfo(ID3D11Device *iface, D3D11_COUNTER_INFO *info)
2113 FIXME("iface %p, info %p stub!\n", iface, info);
2116 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckCounter(ID3D11Device *iface, const D3D11_COUNTER_DESC *desc,
2117 D3D11_COUNTER_TYPE *type, UINT *active_counter_count, char *name, UINT *name_length,
2118 char *units, UINT *units_length, char *description, UINT *description_length)
2120 FIXME("iface %p, desc %p, type %p, active_counter_count %p, name %p, name_length %p, "
2121 "units %p, units_length %p, description %p, description_length %p stub!\n",
2122 iface, desc, type, active_counter_count, name, name_length,
2123 units, units_length, description, description_length);
2125 return E_NOTIMPL;
2128 static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFeatureSupport(ID3D11Device *iface, D3D11_FEATURE feature,
2129 void *feature_support_data, UINT feature_support_data_size)
2131 FIXME("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u stub!\n",
2132 iface, feature, feature_support_data, feature_support_data_size);
2134 return E_NOTIMPL;
2137 static HRESULT STDMETHODCALLTYPE d3d11_device_GetPrivateData(ID3D11Device *iface, REFGUID guid,
2138 UINT *data_size, void *data)
2140 IDXGIDevice *dxgi_device;
2141 HRESULT hr;
2143 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
2145 if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
2146 return hr;
2147 hr = IDXGIDevice_GetPrivateData(dxgi_device, guid, data_size, data);
2148 IDXGIDevice_Release(dxgi_device);
2150 return hr;
2153 static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateData(ID3D11Device *iface, REFGUID guid,
2154 UINT data_size, const void *data)
2156 IDXGIDevice *dxgi_device;
2157 HRESULT hr;
2159 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
2161 if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
2162 return hr;
2163 hr = IDXGIDevice_SetPrivateData(dxgi_device, guid, data_size, data);
2164 IDXGIDevice_Release(dxgi_device);
2166 return hr;
2169 static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateDataInterface(ID3D11Device *iface, REFGUID guid,
2170 const IUnknown *data)
2172 IDXGIDevice *dxgi_device;
2173 HRESULT hr;
2175 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
2177 if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
2178 return hr;
2179 hr = IDXGIDevice_SetPrivateDataInterface(dxgi_device, guid, data);
2180 IDXGIDevice_Release(dxgi_device);
2182 return hr;
2185 static D3D_FEATURE_LEVEL STDMETHODCALLTYPE d3d11_device_GetFeatureLevel(ID3D11Device *iface)
2187 FIXME("iface %p stub!\n", iface);
2189 return D3D_FEATURE_LEVEL_10_0;
2192 static UINT STDMETHODCALLTYPE d3d11_device_GetCreationFlags(ID3D11Device *iface)
2194 FIXME("iface %p stub!\n", iface);
2196 return 0;
2199 static HRESULT STDMETHODCALLTYPE d3d11_device_GetDeviceRemovedReason(ID3D11Device *iface)
2201 FIXME("iface %p stub!\n", iface);
2203 return S_OK;
2206 static void STDMETHODCALLTYPE d3d11_device_GetImmediateContext(ID3D11Device *iface,
2207 ID3D11DeviceContext **immediate_context)
2209 struct d3d_device *device = impl_from_ID3D11Device(iface);
2211 TRACE("iface %p, immediate_context %p.\n", iface, immediate_context);
2213 *immediate_context = &device->immediate_context.ID3D11DeviceContext_iface;
2214 ID3D11DeviceContext_AddRef(*immediate_context);
2217 static HRESULT STDMETHODCALLTYPE d3d11_device_SetExceptionMode(ID3D11Device *iface, UINT flags)
2219 FIXME("iface %p, flags %#x stub!\n", iface, flags);
2221 return E_NOTIMPL;
2224 static UINT STDMETHODCALLTYPE d3d11_device_GetExceptionMode(ID3D11Device *iface)
2226 FIXME("iface %p stub!\n", iface);
2228 return 0;
2231 static const struct ID3D11DeviceVtbl d3d11_device_vtbl =
2233 /* IUnknown methods */
2234 d3d11_device_QueryInterface,
2235 d3d11_device_AddRef,
2236 d3d11_device_Release,
2237 /* ID3D11Device methods */
2238 d3d11_device_CreateBuffer,
2239 d3d11_device_CreateTexture1D,
2240 d3d11_device_CreateTexture2D,
2241 d3d11_device_CreateTexture3D,
2242 d3d11_device_CreateShaderResourceView,
2243 d3d11_device_CreateUnorderedAccessView,
2244 d3d11_device_CreateRenderTargetView,
2245 d3d11_device_CreateDepthStencilView,
2246 d3d11_device_CreateInputLayout,
2247 d3d11_device_CreateVertexShader,
2248 d3d11_device_CreateGeometryShader,
2249 d3d11_device_CreateGeometryShaderWithStreamOutput,
2250 d3d11_device_CreatePixelShader,
2251 d3d11_device_CreateHullShader,
2252 d3d11_device_CreateDomainShader,
2253 d3d11_device_CreateComputeShader,
2254 d3d11_device_CreateClassLinkage,
2255 d3d11_device_CreateBlendState,
2256 d3d11_device_CreateDepthStencilState,
2257 d3d11_device_CreateRasterizerState,
2258 d3d11_device_CreateSamplerState,
2259 d3d11_device_CreateQuery,
2260 d3d11_device_CreatePredicate,
2261 d3d11_device_CreateCounter,
2262 d3d11_device_CreateDeferredContext,
2263 d3d11_device_OpenSharedResource,
2264 d3d11_device_CheckFormatSupport,
2265 d3d11_device_CheckMultisampleQualityLevels,
2266 d3d11_device_CheckCounterInfo,
2267 d3d11_device_CheckCounter,
2268 d3d11_device_CheckFeatureSupport,
2269 d3d11_device_GetPrivateData,
2270 d3d11_device_SetPrivateData,
2271 d3d11_device_SetPrivateDataInterface,
2272 d3d11_device_GetFeatureLevel,
2273 d3d11_device_GetCreationFlags,
2274 d3d11_device_GetDeviceRemovedReason,
2275 d3d11_device_GetImmediateContext,
2276 d3d11_device_SetExceptionMode,
2277 d3d11_device_GetExceptionMode,
2280 /* Inner IUnknown methods */
2282 static inline struct d3d_device *impl_from_IUnknown(IUnknown *iface)
2284 return CONTAINING_RECORD(iface, struct d3d_device, IUnknown_inner);
2287 static HRESULT STDMETHODCALLTYPE d3d_device_inner_QueryInterface(IUnknown *iface, REFIID riid, void **out)
2289 struct d3d_device *device = impl_from_IUnknown(iface);
2291 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
2293 if (IsEqualGUID(riid, &IID_ID3D11Device)
2294 || IsEqualGUID(riid, &IID_IUnknown))
2296 *out = &device->ID3D11Device_iface;
2298 else if (IsEqualGUID(riid, &IID_ID3D10Device1)
2299 || IsEqualGUID(riid, &IID_ID3D10Device))
2301 *out = &device->ID3D10Device1_iface;
2303 else if (IsEqualGUID(riid, &IID_ID3D10Multithread))
2305 *out = &device->ID3D10Multithread_iface;
2307 else if (IsEqualGUID(riid, &IID_IWineDXGIDeviceParent))
2309 *out = &device->IWineDXGIDeviceParent_iface;
2311 else
2313 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
2314 *out = NULL;
2315 return E_NOINTERFACE;
2318 IUnknown_AddRef((IUnknown *)*out);
2319 return S_OK;
2322 static ULONG STDMETHODCALLTYPE d3d_device_inner_AddRef(IUnknown *iface)
2324 struct d3d_device *device = impl_from_IUnknown(iface);
2325 ULONG refcount = InterlockedIncrement(&device->refcount);
2327 TRACE("%p increasing refcount to %u.\n", device, refcount);
2329 return refcount;
2332 static ULONG STDMETHODCALLTYPE d3d_device_inner_Release(IUnknown *iface)
2334 struct d3d_device *device = impl_from_IUnknown(iface);
2335 ULONG refcount = InterlockedDecrement(&device->refcount);
2337 TRACE("%p decreasing refcount to %u.\n", device, refcount);
2339 if (!refcount)
2341 if (device->wined3d_device)
2343 wined3d_mutex_lock();
2344 wined3d_device_decref(device->wined3d_device);
2345 wined3d_mutex_unlock();
2347 wine_rb_destroy(&device->sampler_states, NULL, NULL);
2348 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
2349 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2350 wine_rb_destroy(&device->blend_states, NULL, NULL);
2353 return refcount;
2356 /* IUnknown methods */
2358 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device1 *iface, REFIID riid,
2359 void **ppv)
2361 struct d3d_device *This = impl_from_ID3D10Device(iface);
2362 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
2365 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device1 *iface)
2367 struct d3d_device *This = impl_from_ID3D10Device(iface);
2368 return IUnknown_AddRef(This->outer_unk);
2371 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device1 *iface)
2373 struct d3d_device *This = impl_from_ID3D10Device(iface);
2374 return IUnknown_Release(This->outer_unk);
2377 /* ID3D10Device methods */
2379 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *iface,
2380 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
2382 struct d3d_device *device = impl_from_ID3D10Device(iface);
2383 unsigned int i;
2385 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2386 iface, start_slot, buffer_count, buffers);
2388 wined3d_mutex_lock();
2389 for (i = 0; i < buffer_count; ++i)
2391 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2393 wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i,
2394 buffer ? buffer->wined3d_buffer : NULL);
2396 wined3d_mutex_unlock();
2399 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device1 *iface,
2400 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
2402 struct d3d_device *device = impl_from_ID3D10Device(iface);
2403 unsigned int i;
2405 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2406 iface, start_slot, view_count, views);
2408 wined3d_mutex_lock();
2409 for (i = 0; i < view_count; ++i)
2411 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
2413 wined3d_device_set_ps_resource_view(device->wined3d_device, start_slot + i,
2414 view ? view->wined3d_view : NULL);
2416 wined3d_mutex_unlock();
2419 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device1 *iface,
2420 ID3D10PixelShader *shader)
2422 struct d3d_device *This = impl_from_ID3D10Device(iface);
2423 struct d3d_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader);
2425 TRACE("iface %p, shader %p\n", iface, shader);
2427 wined3d_mutex_lock();
2428 wined3d_device_set_pixel_shader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
2429 wined3d_mutex_unlock();
2432 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device1 *iface,
2433 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
2435 struct d3d_device *device = impl_from_ID3D10Device(iface);
2436 unsigned int i;
2438 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2439 iface, start_slot, sampler_count, samplers);
2441 wined3d_mutex_lock();
2442 for (i = 0; i < sampler_count; ++i)
2444 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
2446 wined3d_device_set_ps_sampler(device->wined3d_device, start_slot + i,
2447 sampler ? sampler->wined3d_sampler : NULL);
2449 wined3d_mutex_unlock();
2452 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device1 *iface,
2453 ID3D10VertexShader *shader)
2455 struct d3d_device *This = impl_from_ID3D10Device(iface);
2456 struct d3d_vertex_shader *vs = unsafe_impl_from_ID3D10VertexShader(shader);
2458 TRACE("iface %p, shader %p\n", iface, shader);
2460 wined3d_mutex_lock();
2461 wined3d_device_set_vertex_shader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
2462 wined3d_mutex_unlock();
2465 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device1 *iface, UINT index_count,
2466 UINT start_index_location, INT base_vertex_location)
2468 struct d3d_device *This = impl_from_ID3D10Device(iface);
2470 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
2471 iface, index_count, start_index_location, base_vertex_location);
2473 wined3d_mutex_lock();
2474 wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
2475 wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
2476 wined3d_mutex_unlock();
2479 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device1 *iface, UINT vertex_count,
2480 UINT start_vertex_location)
2482 struct d3d_device *This = impl_from_ID3D10Device(iface);
2484 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
2485 iface, vertex_count, start_vertex_location);
2487 wined3d_mutex_lock();
2488 wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
2489 wined3d_mutex_unlock();
2492 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device1 *iface,
2493 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
2495 struct d3d_device *device = impl_from_ID3D10Device(iface);
2496 unsigned int i;
2498 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2499 iface, start_slot, buffer_count, buffers);
2501 wined3d_mutex_lock();
2502 for (i = 0; i < buffer_count; ++i)
2504 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2506 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
2507 buffer ? buffer->wined3d_buffer : NULL);
2509 wined3d_mutex_unlock();
2512 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device1 *iface,
2513 ID3D10InputLayout *input_layout)
2515 struct d3d_device *This = impl_from_ID3D10Device(iface);
2516 struct d3d_input_layout *layout = unsafe_impl_from_ID3D10InputLayout(input_layout);
2518 TRACE("iface %p, input_layout %p\n", iface, input_layout);
2520 wined3d_mutex_lock();
2521 wined3d_device_set_vertex_declaration(This->wined3d_device,
2522 layout ? layout->wined3d_decl : NULL);
2523 wined3d_mutex_unlock();
2526 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device1 *iface, UINT start_slot,
2527 UINT buffer_count, ID3D10Buffer *const *buffers, const UINT *strides, const UINT *offsets)
2529 struct d3d_device *This = impl_from_ID3D10Device(iface);
2530 unsigned int i;
2532 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
2533 iface, start_slot, buffer_count, buffers, strides, offsets);
2535 wined3d_mutex_lock();
2536 for (i = 0; i < buffer_count; ++i)
2538 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2540 wined3d_device_set_stream_source(This->wined3d_device, start_slot + i,
2541 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
2543 wined3d_mutex_unlock();
2546 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device1 *iface,
2547 ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
2549 struct d3d_device *This = impl_from_ID3D10Device(iface);
2550 struct d3d_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
2552 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
2553 iface, buffer, debug_dxgi_format(format), offset);
2555 wined3d_mutex_lock();
2556 wined3d_device_set_index_buffer(This->wined3d_device,
2557 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
2558 wined3dformat_from_dxgi_format(format));
2559 wined3d_mutex_unlock();
2560 if (offset) FIXME("offset %u not supported.\n", offset);
2563 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device1 *iface,
2564 UINT instance_index_count, UINT instance_count, UINT start_index_location,
2565 INT base_vertex_location, UINT start_instance_location)
2567 struct d3d_device *device = impl_from_ID3D10Device(iface);
2569 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, "
2570 "base_vertex_location %d, start_instance_location %u.\n",
2571 iface, instance_index_count, instance_count, start_index_location,
2572 base_vertex_location, start_instance_location);
2574 wined3d_mutex_lock();
2575 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
2576 wined3d_device_draw_indexed_primitive_instanced(device->wined3d_device, start_index_location,
2577 instance_index_count, start_instance_location, instance_count);
2578 wined3d_mutex_unlock();
2581 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device1 *iface,
2582 UINT instance_vertex_count, UINT instance_count,
2583 UINT start_vertex_location, UINT start_instance_location)
2585 struct d3d_device *device = impl_from_ID3D10Device(iface);
2587 TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, "
2588 "start_instance_location %u.\n", iface, instance_vertex_count, instance_count,
2589 start_vertex_location, start_instance_location);
2591 wined3d_mutex_lock();
2592 wined3d_device_draw_primitive_instanced(device->wined3d_device, start_vertex_location,
2593 instance_vertex_count, start_instance_location, instance_count);
2594 wined3d_mutex_unlock();
2597 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device1 *iface,
2598 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
2600 struct d3d_device *device = impl_from_ID3D10Device(iface);
2601 unsigned int i;
2603 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2604 iface, start_slot, buffer_count, buffers);
2606 wined3d_mutex_lock();
2607 for (i = 0; i < buffer_count; ++i)
2609 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
2611 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
2612 buffer ? buffer->wined3d_buffer : NULL);
2614 wined3d_mutex_unlock();
2617 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device1 *iface, ID3D10GeometryShader *shader)
2619 struct d3d_device *device = impl_from_ID3D10Device(iface);
2620 struct d3d_geometry_shader *gs = unsafe_impl_from_ID3D10GeometryShader(shader);
2622 TRACE("iface %p, shader %p.\n", iface, shader);
2624 wined3d_mutex_lock();
2625 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
2626 wined3d_mutex_unlock();
2629 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device1 *iface,
2630 D3D10_PRIMITIVE_TOPOLOGY topology)
2632 struct d3d_device *This = impl_from_ID3D10Device(iface);
2634 TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
2636 wined3d_mutex_lock();
2637 wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
2638 wined3d_mutex_unlock();
2641 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device1 *iface,
2642 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
2644 struct d3d_device *device = impl_from_ID3D10Device(iface);
2645 unsigned int i;
2647 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2648 iface, start_slot, view_count, views);
2650 wined3d_mutex_lock();
2651 for (i = 0; i < view_count; ++i)
2653 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
2655 wined3d_device_set_vs_resource_view(device->wined3d_device, start_slot + i,
2656 view ? view->wined3d_view : NULL);
2658 wined3d_mutex_unlock();
2661 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device1 *iface,
2662 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
2664 struct d3d_device *device = impl_from_ID3D10Device(iface);
2665 unsigned int i;
2667 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2668 iface, start_slot, sampler_count, samplers);
2670 wined3d_mutex_lock();
2671 for (i = 0; i < sampler_count; ++i)
2673 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
2675 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
2676 sampler ? sampler->wined3d_sampler : NULL);
2678 wined3d_mutex_unlock();
2681 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device1 *iface, ID3D10Predicate *predicate, BOOL value)
2683 struct d3d_device *device = impl_from_ID3D10Device(iface);
2684 struct d3d_query *query;
2686 TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value);
2688 query = unsafe_impl_from_ID3D10Query((ID3D10Query *)predicate);
2689 wined3d_mutex_lock();
2690 wined3d_device_set_predication(device->wined3d_device, query ? query->wined3d_query : NULL, value);
2691 wined3d_mutex_unlock();
2694 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device1 *iface,
2695 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
2697 struct d3d_device *device = impl_from_ID3D10Device(iface);
2698 unsigned int i;
2700 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
2701 iface, start_slot, view_count, views);
2703 wined3d_mutex_lock();
2704 for (i = 0; i < view_count; ++i)
2706 struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
2708 wined3d_device_set_gs_resource_view(device->wined3d_device, start_slot + i,
2709 view ? view->wined3d_view : NULL);
2711 wined3d_mutex_unlock();
2714 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device1 *iface,
2715 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
2717 struct d3d_device *device = impl_from_ID3D10Device(iface);
2718 unsigned int i;
2720 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
2721 iface, start_slot, sampler_count, samplers);
2723 wined3d_mutex_lock();
2724 for (i = 0; i < sampler_count; ++i)
2726 struct d3d_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
2728 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
2729 sampler ? sampler->wined3d_sampler : NULL);
2731 wined3d_mutex_unlock();
2734 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device1 *iface,
2735 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
2736 ID3D10DepthStencilView *depth_stencil_view)
2738 struct d3d_device *device = impl_from_ID3D10Device(iface);
2739 struct d3d_depthstencil_view *dsv;
2740 unsigned int i;
2742 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
2743 iface, render_target_view_count, render_target_views, depth_stencil_view);
2745 wined3d_mutex_lock();
2746 for (i = 0; i < render_target_view_count; ++i)
2748 struct d3d_rendertarget_view *rtv = unsafe_impl_from_ID3D10RenderTargetView(render_target_views[i]);
2750 wined3d_device_set_rendertarget_view(device->wined3d_device, i,
2751 rtv ? rtv->wined3d_view : NULL, FALSE);
2753 for (; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
2755 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
2758 dsv = unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view);
2759 wined3d_device_set_depth_stencil_view(device->wined3d_device,
2760 dsv ? dsv->wined3d_view : NULL);
2761 wined3d_mutex_unlock();
2764 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface,
2765 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
2767 struct d3d_device *device = impl_from_ID3D10Device(iface);
2768 struct d3d_blend_state *blend_state_object;
2770 TRACE("iface %p, blend_state %p, blend_factor {%.8e %.8e %.8e %.8e}, sample_mask 0x%08x.\n",
2771 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
2773 blend_state_object = unsafe_impl_from_ID3D10BlendState(blend_state);
2774 d3d11_immediate_context_OMSetBlendState(&device->immediate_context.ID3D11DeviceContext_iface,
2775 blend_state_object ? &blend_state_object->ID3D11BlendState_iface : NULL, blend_factor, sample_mask);
2778 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1 *iface,
2779 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
2781 struct d3d_device *device = impl_from_ID3D10Device(iface);
2783 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
2784 iface, depth_stencil_state, stencil_ref);
2786 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
2787 device->stencil_ref = stencil_ref;
2790 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface,
2791 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
2793 struct d3d_device *device = impl_from_ID3D10Device(iface);
2794 unsigned int count, i;
2796 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
2798 count = min(target_count, 4);
2799 wined3d_mutex_lock();
2800 for (i = 0; i < count; ++i)
2802 struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
2804 wined3d_device_set_stream_output(device->wined3d_device, i,
2805 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
2808 for (i = count; i < 4; ++i)
2810 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
2812 wined3d_mutex_unlock();
2815 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device1 *iface)
2817 FIXME("iface %p stub!\n", iface);
2820 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device1 *iface, ID3D10RasterizerState *rasterizer_state)
2822 struct d3d_device *device = impl_from_ID3D10Device(iface);
2823 struct d3d_rasterizer_state *rasterizer_state_object;
2825 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
2827 rasterizer_state_object = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state);
2828 d3d11_immediate_context_RSSetState(&device->immediate_context.ID3D11DeviceContext_iface,
2829 rasterizer_state_object ? &rasterizer_state_object->ID3D11RasterizerState_iface : NULL);
2832 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface,
2833 UINT viewport_count, const D3D10_VIEWPORT *viewports)
2835 struct d3d_device *device = impl_from_ID3D10Device(iface);
2836 struct wined3d_viewport wined3d_vp;
2838 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
2840 if (viewport_count > 1)
2841 FIXME("Multiple viewports not implemented.\n");
2843 if (!viewport_count)
2844 return;
2846 wined3d_vp.x = viewports[0].TopLeftX;
2847 wined3d_vp.y = viewports[0].TopLeftY;
2848 wined3d_vp.width = viewports[0].Width;
2849 wined3d_vp.height = viewports[0].Height;
2850 wined3d_vp.min_z = viewports[0].MinDepth;
2851 wined3d_vp.max_z = viewports[0].MaxDepth;
2853 wined3d_mutex_lock();
2854 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
2855 wined3d_mutex_unlock();
2858 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *iface,
2859 UINT rect_count, const D3D10_RECT *rects)
2861 struct d3d_device *device = impl_from_ID3D10Device(iface);
2863 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
2865 if (rect_count > 1)
2866 FIXME("Multiple scissor rects not implemented.\n");
2868 if (!rect_count)
2869 return;
2871 wined3d_mutex_lock();
2872 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
2873 wined3d_mutex_unlock();
2876 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *iface,
2877 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
2878 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
2880 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
2881 struct d3d_device *device = impl_from_ID3D10Device(iface);
2882 struct wined3d_box wined3d_src_box;
2884 TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
2885 "src_resource %p, src_subresource_idx %u, src_box %p.\n",
2886 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
2887 src_resource, src_subresource_idx, src_box);
2889 wined3d_dst_resource = wined3d_resource_from_d3d10_resource(dst_resource);
2890 wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource);
2891 wined3d_src_box.left = src_box->left;
2892 wined3d_src_box.top = src_box->top;
2893 wined3d_src_box.front = src_box->front;
2894 wined3d_src_box.right = src_box->right;
2895 wined3d_src_box.bottom = src_box->bottom;
2896 wined3d_src_box.back = src_box->back;
2897 wined3d_mutex_lock();
2898 wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx,
2899 dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, &wined3d_src_box);
2900 wined3d_mutex_unlock();
2903 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,
2904 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
2906 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
2907 struct d3d_device *device = impl_from_ID3D10Device(iface);
2909 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
2911 wined3d_dst_resource = wined3d_resource_from_d3d10_resource(dst_resource);
2912 wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource);
2913 wined3d_mutex_lock();
2914 wined3d_device_copy_resource(device->wined3d_device, wined3d_dst_resource, wined3d_src_resource);
2915 wined3d_mutex_unlock();
2918 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface,
2919 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
2920 const void *data, UINT row_pitch, UINT depth_pitch)
2922 struct d3d_device *device = impl_from_ID3D10Device(iface);
2923 ID3D11Resource *d3d11_resource;
2925 TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
2926 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
2928 ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource);
2929 d3d11_immediate_context_UpdateSubresource(&device->immediate_context.ID3D11DeviceContext_iface,
2930 d3d11_resource, subresource_idx, (const D3D11_BOX *)box, data, row_pitch, depth_pitch);
2931 ID3D11Resource_Release(d3d11_resource);
2934 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 *iface,
2935 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
2937 struct d3d_device *device = impl_from_ID3D10Device(iface);
2938 struct d3d_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
2939 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
2940 HRESULT hr;
2942 TRACE("iface %p, render_target_view %p, color_rgba {%.8e, %.8e, %.8e, %.8e}.\n",
2943 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
2945 wined3d_mutex_lock();
2946 if (FAILED(hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, view->wined3d_view, NULL, &color)))
2947 ERR("Failed to clear view, hr %#x.\n", hr);
2948 wined3d_mutex_unlock();
2951 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *iface,
2952 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
2954 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
2955 iface, depth_stencil_view, flags, depth, stencil);
2958 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
2959 ID3D10ShaderResourceView *shader_resource_view)
2961 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
2964 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *iface,
2965 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
2966 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
2968 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, "
2969 "src_resource %p, src_subresource_idx %u, format %s stub!\n",
2970 iface, dst_resource, dst_subresource_idx,
2971 src_resource, src_subresource_idx, debug_dxgi_format(format));
2974 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device1 *iface,
2975 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
2977 struct d3d_device *device = impl_from_ID3D10Device(iface);
2978 unsigned int i;
2980 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
2981 iface, start_slot, buffer_count, buffers);
2983 wined3d_mutex_lock();
2984 for (i = 0; i < buffer_count; ++i)
2986 struct wined3d_buffer *wined3d_buffer;
2987 struct d3d_buffer *buffer_impl;
2989 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
2991 buffers[i] = NULL;
2992 continue;
2995 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
2996 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
2997 ID3D10Buffer_AddRef(buffers[i]);
2999 wined3d_mutex_unlock();
3002 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device1 *iface,
3003 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
3005 struct d3d_device *device = impl_from_ID3D10Device(iface);
3006 unsigned int i;
3008 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3009 iface, start_slot, view_count, views);
3011 wined3d_mutex_lock();
3012 for (i = 0; i < view_count; ++i)
3014 struct wined3d_shader_resource_view *wined3d_view;
3015 struct d3d_shader_resource_view *view_impl;
3017 if (!(wined3d_view = wined3d_device_get_ps_resource_view(device->wined3d_device, start_slot + i)))
3019 views[i] = NULL;
3020 continue;
3023 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
3024 views[i] = (ID3D10ShaderResourceView *)&view_impl->ID3D10ShaderResourceView1_iface;
3025 ID3D10ShaderResourceView_AddRef(views[i]);
3027 wined3d_mutex_unlock();
3030 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device1 *iface, ID3D10PixelShader **shader)
3032 struct d3d_device *device = impl_from_ID3D10Device(iface);
3033 struct d3d_pixel_shader *shader_impl;
3034 struct wined3d_shader *wined3d_shader;
3036 TRACE("iface %p, shader %p.\n", iface, shader);
3038 wined3d_mutex_lock();
3039 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
3041 wined3d_mutex_unlock();
3042 *shader = NULL;
3043 return;
3046 shader_impl = wined3d_shader_get_parent(wined3d_shader);
3047 wined3d_mutex_unlock();
3048 *shader = &shader_impl->ID3D10PixelShader_iface;
3049 ID3D10PixelShader_AddRef(*shader);
3052 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device1 *iface,
3053 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
3055 struct d3d_device *device = impl_from_ID3D10Device(iface);
3056 unsigned int i;
3058 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3059 iface, start_slot, sampler_count, samplers);
3061 wined3d_mutex_lock();
3062 for (i = 0; i < sampler_count; ++i)
3064 struct d3d_sampler_state *sampler_impl;
3065 struct wined3d_sampler *wined3d_sampler;
3067 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
3069 samplers[i] = NULL;
3070 continue;
3073 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
3074 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
3075 ID3D10SamplerState_AddRef(samplers[i]);
3077 wined3d_mutex_unlock();
3080 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device1 *iface, ID3D10VertexShader **shader)
3082 struct d3d_device *device = impl_from_ID3D10Device(iface);
3083 struct d3d_vertex_shader *shader_impl;
3084 struct wined3d_shader *wined3d_shader;
3086 TRACE("iface %p, shader %p.\n", iface, shader);
3088 wined3d_mutex_lock();
3089 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
3091 wined3d_mutex_unlock();
3092 *shader = NULL;
3093 return;
3096 shader_impl = wined3d_shader_get_parent(wined3d_shader);
3097 wined3d_mutex_unlock();
3098 *shader = &shader_impl->ID3D10VertexShader_iface;
3099 ID3D10VertexShader_AddRef(*shader);
3102 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device1 *iface,
3103 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
3105 struct d3d_device *device = impl_from_ID3D10Device(iface);
3106 unsigned int i;
3108 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3109 iface, start_slot, buffer_count, buffers);
3111 wined3d_mutex_lock();
3112 for (i = 0; i < buffer_count; ++i)
3114 struct wined3d_buffer *wined3d_buffer;
3115 struct d3d_buffer *buffer_impl;
3117 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
3119 buffers[i] = NULL;
3120 continue;
3123 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3124 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3125 ID3D10Buffer_AddRef(buffers[i]);
3127 wined3d_mutex_unlock();
3130 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device1 *iface, ID3D10InputLayout **input_layout)
3132 struct d3d_device *device = impl_from_ID3D10Device(iface);
3133 struct wined3d_vertex_declaration *wined3d_declaration;
3134 struct d3d_input_layout *input_layout_impl;
3136 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
3138 wined3d_mutex_lock();
3139 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
3141 wined3d_mutex_unlock();
3142 *input_layout = NULL;
3143 return;
3146 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
3147 wined3d_mutex_unlock();
3148 *input_layout = &input_layout_impl->ID3D10InputLayout_iface;
3149 ID3D10InputLayout_AddRef(*input_layout);
3152 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device1 *iface,
3153 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
3155 struct d3d_device *device = impl_from_ID3D10Device(iface);
3156 unsigned int i;
3158 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
3159 iface, start_slot, buffer_count, buffers, strides, offsets);
3161 wined3d_mutex_lock();
3162 for (i = 0; i < buffer_count; ++i)
3164 struct wined3d_buffer *wined3d_buffer;
3165 struct d3d_buffer *buffer_impl;
3167 if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
3168 &wined3d_buffer, &offsets[i], &strides[i])))
3169 ERR("Failed to get vertex buffer.\n");
3171 if (!wined3d_buffer)
3173 buffers[i] = NULL;
3174 continue;
3177 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3178 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3179 ID3D10Buffer_AddRef(buffers[i]);
3181 wined3d_mutex_unlock();
3184 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device1 *iface,
3185 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
3187 struct d3d_device *device = impl_from_ID3D10Device(iface);
3188 enum wined3d_format_id wined3d_format;
3189 struct wined3d_buffer *wined3d_buffer;
3190 struct d3d_buffer *buffer_impl;
3192 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
3194 wined3d_mutex_lock();
3195 wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
3196 *format = dxgi_format_from_wined3dformat(wined3d_format);
3197 *offset = 0; /* FIXME */
3198 if (!wined3d_buffer)
3200 wined3d_mutex_unlock();
3201 *buffer = NULL;
3202 return;
3205 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3206 wined3d_mutex_unlock();
3207 *buffer = &buffer_impl->ID3D10Buffer_iface;
3208 ID3D10Buffer_AddRef(*buffer);
3211 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device1 *iface,
3212 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
3214 struct d3d_device *device = impl_from_ID3D10Device(iface);
3215 unsigned int i;
3217 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
3218 iface, start_slot, buffer_count, buffers);
3220 wined3d_mutex_lock();
3221 for (i = 0; i < buffer_count; ++i)
3223 struct wined3d_buffer *wined3d_buffer;
3224 struct d3d_buffer *buffer_impl;
3226 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
3228 buffers[i] = NULL;
3229 continue;
3232 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3233 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3234 ID3D10Buffer_AddRef(buffers[i]);
3236 wined3d_mutex_unlock();
3239 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device1 *iface, ID3D10GeometryShader **shader)
3241 struct d3d_device *device = impl_from_ID3D10Device(iface);
3242 struct d3d_geometry_shader *shader_impl;
3243 struct wined3d_shader *wined3d_shader;
3245 TRACE("iface %p, shader %p.\n", iface, shader);
3247 wined3d_mutex_lock();
3248 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
3250 wined3d_mutex_unlock();
3251 *shader = NULL;
3252 return;
3255 shader_impl = wined3d_shader_get_parent(wined3d_shader);
3256 wined3d_mutex_unlock();
3257 *shader = &shader_impl->ID3D10GeometryShader_iface;
3258 ID3D10GeometryShader_AddRef(*shader);
3261 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device1 *iface,
3262 D3D10_PRIMITIVE_TOPOLOGY *topology)
3264 struct d3d_device *This = impl_from_ID3D10Device(iface);
3266 TRACE("iface %p, topology %p\n", iface, topology);
3268 wined3d_mutex_lock();
3269 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
3270 wined3d_mutex_unlock();
3273 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device1 *iface,
3274 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
3276 struct d3d_device *device = impl_from_ID3D10Device(iface);
3277 unsigned int i;
3279 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3280 iface, start_slot, view_count, views);
3282 wined3d_mutex_lock();
3283 for (i = 0; i < view_count; ++i)
3285 struct wined3d_shader_resource_view *wined3d_view;
3286 struct d3d_shader_resource_view *view_impl;
3288 if (!(wined3d_view = wined3d_device_get_vs_resource_view(device->wined3d_device, start_slot + i)))
3290 views[i] = NULL;
3291 continue;
3294 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
3295 views[i] = (ID3D10ShaderResourceView *)&view_impl->ID3D10ShaderResourceView1_iface;
3296 ID3D10ShaderResourceView_AddRef(views[i]);
3298 wined3d_mutex_unlock();
3301 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device1 *iface,
3302 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
3304 struct d3d_device *device = impl_from_ID3D10Device(iface);
3305 unsigned int i;
3307 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3308 iface, start_slot, sampler_count, samplers);
3310 wined3d_mutex_lock();
3311 for (i = 0; i < sampler_count; ++i)
3313 struct d3d_sampler_state *sampler_impl;
3314 struct wined3d_sampler *wined3d_sampler;
3316 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
3318 samplers[i] = NULL;
3319 continue;
3322 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
3323 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
3324 ID3D10SamplerState_AddRef(samplers[i]);
3326 wined3d_mutex_unlock();
3329 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device1 *iface,
3330 ID3D10Predicate **predicate, BOOL *value)
3332 struct d3d_device *device = impl_from_ID3D10Device(iface);
3333 struct wined3d_query *wined3d_predicate;
3334 struct d3d_query *predicate_impl;
3336 TRACE("iface %p, predicate %p, value %p.\n", iface, predicate, value);
3338 wined3d_mutex_lock();
3339 if (!(wined3d_predicate = wined3d_device_get_predication(device->wined3d_device, value)))
3341 wined3d_mutex_unlock();
3342 *predicate = NULL;
3343 return;
3346 predicate_impl = wined3d_query_get_parent(wined3d_predicate);
3347 wined3d_mutex_unlock();
3348 *predicate = (ID3D10Predicate *)&predicate_impl->ID3D10Query_iface;
3349 ID3D10Predicate_AddRef(*predicate);
3352 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device1 *iface,
3353 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
3355 struct d3d_device *device = impl_from_ID3D10Device(iface);
3356 unsigned int i;
3358 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
3359 iface, start_slot, view_count, views);
3361 wined3d_mutex_lock();
3362 for (i = 0; i < view_count; ++i)
3364 struct wined3d_shader_resource_view *wined3d_view;
3365 struct d3d_shader_resource_view *view_impl;
3367 if (!(wined3d_view = wined3d_device_get_gs_resource_view(device->wined3d_device, start_slot + i)))
3369 views[i] = NULL;
3370 continue;
3373 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
3374 views[i] = (ID3D10ShaderResourceView *)&view_impl->ID3D10ShaderResourceView1_iface;
3375 ID3D10ShaderResourceView_AddRef(views[i]);
3377 wined3d_mutex_unlock();
3380 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device1 *iface,
3381 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
3383 struct d3d_device *device = impl_from_ID3D10Device(iface);
3384 unsigned int i;
3386 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
3387 iface, start_slot, sampler_count, samplers);
3389 wined3d_mutex_lock();
3390 for (i = 0; i < sampler_count; ++i)
3392 struct d3d_sampler_state *sampler_impl;
3393 struct wined3d_sampler *wined3d_sampler;
3395 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
3397 samplers[i] = NULL;
3398 continue;
3401 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
3402 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
3403 ID3D10SamplerState_AddRef(samplers[i]);
3405 wined3d_mutex_unlock();
3408 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device1 *iface,
3409 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
3411 struct d3d_device *device = impl_from_ID3D10Device(iface);
3412 struct wined3d_rendertarget_view *wined3d_view;
3414 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
3415 iface, view_count, render_target_views, depth_stencil_view);
3417 wined3d_mutex_lock();
3418 if (render_target_views)
3420 struct d3d_rendertarget_view *view_impl;
3421 unsigned int i;
3423 for (i = 0; i < view_count; ++i)
3425 if (!(wined3d_view = wined3d_device_get_rendertarget_view(device->wined3d_device, i))
3426 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
3428 render_target_views[i] = NULL;
3429 continue;
3432 render_target_views[i] = &view_impl->ID3D10RenderTargetView_iface;
3433 ID3D10RenderTargetView_AddRef(render_target_views[i]);
3437 if (depth_stencil_view)
3439 struct d3d_depthstencil_view *view_impl;
3441 if (!(wined3d_view = wined3d_device_get_depth_stencil_view(device->wined3d_device))
3442 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
3444 *depth_stencil_view = NULL;
3446 else
3448 *depth_stencil_view = &view_impl->ID3D10DepthStencilView_iface;
3449 ID3D10DepthStencilView_AddRef(*depth_stencil_view);
3452 wined3d_mutex_unlock();
3455 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface,
3456 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
3458 struct d3d_device *device = impl_from_ID3D10Device(iface);
3460 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
3461 iface, blend_state, blend_factor, sample_mask);
3463 if ((*blend_state = device->blend_state ? (ID3D10BlendState *)&device->blend_state->ID3D10BlendState1_iface : NULL))
3464 ID3D10BlendState_AddRef(*blend_state);
3465 wined3d_mutex_lock();
3466 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
3467 *sample_mask = wined3d_device_get_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK);
3468 wined3d_mutex_unlock();
3471 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
3472 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
3474 struct d3d_device *device = impl_from_ID3D10Device(iface);
3476 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
3477 iface, depth_stencil_state, stencil_ref);
3479 if ((*depth_stencil_state = device->depth_stencil_state
3480 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
3481 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
3482 *stencil_ref = device->stencil_ref;
3485 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device1 *iface,
3486 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
3488 struct d3d_device *device = impl_from_ID3D10Device(iface);
3489 unsigned int i;
3491 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
3492 iface, buffer_count, buffers, offsets);
3494 wined3d_mutex_lock();
3495 for (i = 0; i < buffer_count; ++i)
3497 struct wined3d_buffer *wined3d_buffer;
3498 struct d3d_buffer *buffer_impl;
3500 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
3502 buffers[i] = NULL;
3503 continue;
3506 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
3507 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
3508 ID3D10Buffer_AddRef(buffers[i]);
3510 wined3d_mutex_unlock();
3513 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device1 *iface, ID3D10RasterizerState **rasterizer_state)
3515 struct d3d_device *device = impl_from_ID3D10Device(iface);
3517 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
3519 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
3520 ID3D10RasterizerState_AddRef(*rasterizer_state);
3523 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface,
3524 UINT *viewport_count, D3D10_VIEWPORT *viewports)
3526 struct d3d_device *device = impl_from_ID3D10Device(iface);
3527 struct wined3d_viewport wined3d_vp;
3529 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
3531 if (!viewports)
3533 *viewport_count = 1;
3534 return;
3537 if (!*viewport_count)
3538 return;
3540 wined3d_mutex_lock();
3541 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
3542 wined3d_mutex_unlock();
3544 viewports[0].TopLeftX = wined3d_vp.x;
3545 viewports[0].TopLeftY = wined3d_vp.y;
3546 viewports[0].Width = wined3d_vp.width;
3547 viewports[0].Height = wined3d_vp.height;
3548 viewports[0].MinDepth = wined3d_vp.min_z;
3549 viewports[0].MaxDepth = wined3d_vp.max_z;
3551 if (*viewport_count > 1)
3552 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
3555 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects)
3557 struct d3d_device *device = impl_from_ID3D10Device(iface);
3559 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
3561 if (!rects)
3563 *rect_count = 1;
3564 return;
3567 if (!*rect_count)
3568 return;
3570 wined3d_mutex_lock();
3571 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
3572 wined3d_mutex_unlock();
3573 if (*rect_count > 1)
3574 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
3577 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device1 *iface)
3579 TRACE("iface %p.\n", iface);
3581 /* In the current implementation the device is never removed, so we can
3582 * just return S_OK here. */
3584 return S_OK;
3587 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device1 *iface, UINT flags)
3589 FIXME("iface %p, flags %#x stub!\n", iface, flags);
3591 return E_NOTIMPL;
3594 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device1 *iface)
3596 FIXME("iface %p stub!\n", iface);
3598 return 0;
3601 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *iface,
3602 REFGUID guid, UINT *data_size, void *data)
3604 struct d3d_device *device = impl_from_ID3D10Device(iface);
3606 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
3608 return d3d11_device_GetPrivateData(&device->ID3D11Device_iface, guid, data_size, data);
3611 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface,
3612 REFGUID guid, UINT data_size, const void *data)
3614 struct d3d_device *device = impl_from_ID3D10Device(iface);
3616 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
3618 return d3d11_device_SetPrivateData(&device->ID3D11Device_iface, guid, data_size, data);
3621 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface,
3622 REFGUID guid, const IUnknown *data)
3624 struct d3d_device *device = impl_from_ID3D10Device(iface);
3626 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
3628 return d3d11_device_SetPrivateDataInterface(&device->ID3D11Device_iface, guid, data);
3631 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface)
3633 static const float blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f};
3634 struct d3d_device *device = impl_from_ID3D10Device(iface);
3635 unsigned int i;
3637 TRACE("iface %p.\n", iface);
3639 wined3d_mutex_lock();
3640 wined3d_device_set_vertex_shader(device->wined3d_device, NULL);
3641 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
3643 wined3d_device_set_vs_sampler(device->wined3d_device, i, NULL);
3645 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
3647 wined3d_device_set_vs_resource_view(device->wined3d_device, i, NULL);
3649 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
3651 wined3d_device_set_vs_cb(device->wined3d_device, i, NULL);
3653 wined3d_device_set_geometry_shader(device->wined3d_device, NULL);
3654 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
3656 wined3d_device_set_gs_sampler(device->wined3d_device, i, NULL);
3658 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
3660 wined3d_device_set_gs_resource_view(device->wined3d_device, i, NULL);
3662 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
3664 wined3d_device_set_gs_cb(device->wined3d_device, i, NULL);
3666 wined3d_device_set_pixel_shader(device->wined3d_device, NULL);
3667 for (i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
3669 wined3d_device_set_ps_sampler(device->wined3d_device, i, NULL);
3671 for (i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
3673 wined3d_device_set_ps_resource_view(device->wined3d_device, i, NULL);
3675 for (i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
3677 wined3d_device_set_ps_cb(device->wined3d_device, i, NULL);
3679 for (i = 0; i < D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; ++i)
3681 wined3d_device_set_stream_source(device->wined3d_device, i, NULL, 0, 0);
3683 wined3d_device_set_index_buffer(device->wined3d_device, NULL, WINED3DFMT_UNKNOWN);
3684 wined3d_device_set_vertex_declaration(device->wined3d_device, NULL);
3685 wined3d_device_set_primitive_type(device->wined3d_device, WINED3D_PT_UNDEFINED);
3686 for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
3688 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
3690 wined3d_device_set_depth_stencil_view(device->wined3d_device, NULL);
3691 ID3D10Device1_OMSetDepthStencilState(iface, NULL, 0);
3692 ID3D10Device1_OMSetBlendState(iface, NULL, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
3693 ID3D10Device1_RSSetViewports(iface, 0, NULL);
3694 ID3D10Device1_RSSetScissorRects(iface, 0, NULL);
3695 ID3D10Device1_RSSetState(iface, NULL);
3696 for (i = 0; i < D3D10_SO_BUFFER_SLOT_COUNT; ++i)
3698 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
3700 wined3d_device_set_predication(device->wined3d_device, NULL, FALSE);
3701 wined3d_mutex_unlock();
3704 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
3706 FIXME("iface %p stub!\n", iface);
3709 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
3710 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
3712 struct d3d_device *device = impl_from_ID3D10Device(iface);
3713 D3D11_BUFFER_DESC d3d11_desc;
3714 struct d3d_buffer *object;
3715 HRESULT hr;
3717 TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface, desc, data, buffer);
3719 d3d11_desc.ByteWidth = desc->ByteWidth;
3720 d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
3721 d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
3722 d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
3723 d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
3724 d3d11_desc.StructureByteStride = 0;
3726 if (FAILED(hr = d3d_buffer_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
3727 return hr;
3729 *buffer = &object->ID3D10Buffer_iface;
3731 return S_OK;
3734 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface,
3735 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
3737 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
3739 return E_NOTIMPL;
3742 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface,
3743 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
3744 ID3D10Texture2D **texture)
3746 struct d3d_device *device = impl_from_ID3D10Device(iface);
3747 D3D11_TEXTURE2D_DESC d3d11_desc;
3748 struct d3d_texture2d *object;
3749 HRESULT hr;
3751 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
3753 d3d11_desc.Width = desc->Width;
3754 d3d11_desc.Height = desc->Height;
3755 d3d11_desc.MipLevels = desc->MipLevels;
3756 d3d11_desc.ArraySize = desc->ArraySize;
3757 d3d11_desc.Format = desc->Format;
3758 d3d11_desc.SampleDesc = desc->SampleDesc;
3759 d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
3760 d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
3761 d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
3762 d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
3764 if (FAILED(hr = d3d_texture2d_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
3765 return hr;
3767 *texture = &object->ID3D10Texture2D_iface;
3769 return S_OK;
3772 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device1 *iface,
3773 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
3774 ID3D10Texture3D **texture)
3776 struct d3d_device *device = impl_from_ID3D10Device(iface);
3777 D3D11_TEXTURE3D_DESC d3d11_desc;
3778 struct d3d_texture3d *object;
3779 HRESULT hr;
3781 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
3783 d3d11_desc.Width = desc->Width;
3784 d3d11_desc.Height = desc->Height;
3785 d3d11_desc.Depth = desc->Depth;
3786 d3d11_desc.MipLevels = desc->MipLevels;
3787 d3d11_desc.Format = desc->Format;
3788 d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
3789 d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
3790 d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
3791 d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
3793 if (FAILED(hr = d3d_texture3d_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
3794 return hr;
3796 *texture = &object->ID3D10Texture3D_iface;
3798 return S_OK;
3801 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView1(ID3D10Device1 *iface,
3802 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc, ID3D10ShaderResourceView1 **view)
3804 struct d3d_device *device = impl_from_ID3D10Device(iface);
3805 struct d3d_shader_resource_view *object;
3806 ID3D11Resource *d3d11_resource;
3807 HRESULT hr;
3809 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
3811 if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
3813 ERR("Resource does not implement ID3D11Resource.\n");
3814 return E_FAIL;
3817 hr = d3d_shader_resource_view_create(device, d3d11_resource, (const D3D11_SHADER_RESOURCE_VIEW_DESC *)desc,
3818 &object);
3819 ID3D11Resource_Release(d3d11_resource);
3820 if (FAILED(hr))
3821 return hr;
3823 *view = &object->ID3D10ShaderResourceView1_iface;
3825 return S_OK;
3828 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
3829 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
3831 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
3833 return d3d10_device_CreateShaderResourceView1(iface, resource,
3834 (const D3D10_SHADER_RESOURCE_VIEW_DESC1 *)desc, (ID3D10ShaderResourceView1 **)view);
3837 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device1 *iface,
3838 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
3840 struct d3d_device *device = impl_from_ID3D10Device(iface);
3841 struct d3d_rendertarget_view *object;
3842 ID3D11Resource *d3d11_resource;
3843 HRESULT hr;
3845 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
3847 if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
3849 ERR("Resource does not implement ID3D11Resource.\n");
3850 return E_FAIL;
3853 hr = d3d_rendertarget_view_create(device, d3d11_resource, (const D3D11_RENDER_TARGET_VIEW_DESC *)desc, &object);
3854 ID3D11Resource_Release(d3d11_resource);
3855 if (FAILED(hr))
3856 return hr;
3858 *view = &object->ID3D10RenderTargetView_iface;
3860 return S_OK;
3863 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device1 *iface,
3864 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
3866 struct d3d_device *device = impl_from_ID3D10Device(iface);
3867 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_desc;
3868 struct d3d_depthstencil_view *object;
3869 ID3D11Resource *d3d11_resource;
3870 HRESULT hr;
3872 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
3874 if (desc)
3876 d3d11_desc.Format = desc->Format;
3877 d3d11_desc.ViewDimension = desc->ViewDimension;
3878 d3d11_desc.Flags = 0;
3879 memcpy(&d3d11_desc.u, &desc->u, sizeof(d3d11_desc.u));
3882 if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
3884 ERR("Resource does not implement ID3D11Resource.\n");
3885 return E_FAIL;
3888 hr = d3d_depthstencil_view_create(device, d3d11_resource, desc ? &d3d11_desc : NULL, &object);
3889 ID3D11Resource_Release(d3d11_resource);
3890 if (FAILED(hr))
3891 return hr;
3893 *view = &object->ID3D10DepthStencilView_iface;
3895 return S_OK;
3898 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *iface,
3899 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
3900 const void *shader_byte_code, SIZE_T shader_byte_code_length,
3901 ID3D10InputLayout **input_layout)
3903 struct d3d_device *device = impl_from_ID3D10Device(iface);
3904 struct d3d_input_layout *object;
3905 HRESULT hr;
3907 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, "
3908 "shader_byte_code_length %lu, input_layout %p\n",
3909 iface, element_descs, element_count, shader_byte_code,
3910 shader_byte_code_length, input_layout);
3912 if (FAILED(hr = d3d_input_layout_create(device, (const D3D11_INPUT_ELEMENT_DESC *)element_descs, element_count,
3913 shader_byte_code, shader_byte_code_length, &object)))
3914 return hr;
3916 *input_layout = &object->ID3D10InputLayout_iface;
3918 return S_OK;
3921 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device1 *iface,
3922 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
3924 struct d3d_device *device = impl_from_ID3D10Device(iface);
3925 struct d3d_vertex_shader *object;
3926 HRESULT hr;
3928 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
3929 iface, byte_code, byte_code_length, shader);
3931 if (FAILED(hr = d3d_vertex_shader_create(device, byte_code, byte_code_length, &object)))
3932 return hr;
3934 *shader = &object->ID3D10VertexShader_iface;
3936 return S_OK;
3939 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device1 *iface,
3940 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
3942 struct d3d_device *device = impl_from_ID3D10Device(iface);
3943 struct d3d_geometry_shader *object;
3944 HRESULT hr;
3946 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
3947 iface, byte_code, byte_code_length, shader);
3949 if (FAILED(hr = d3d_geometry_shader_create(device, byte_code, byte_code_length, &object)))
3950 return hr;
3952 *shader = &object->ID3D10GeometryShader_iface;
3954 return S_OK;
3957 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1 *iface,
3958 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
3959 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
3961 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p, "
3962 "output_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
3963 iface, byte_code, byte_code_length, output_stream_decls,
3964 output_stream_decl_count, output_stream_stride, shader);
3966 return E_NOTIMPL;
3969 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device1 *iface,
3970 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
3972 struct d3d_device *device = impl_from_ID3D10Device(iface);
3973 struct d3d_pixel_shader *object;
3974 HRESULT hr;
3976 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
3977 iface, byte_code, byte_code_length, shader);
3979 if (FAILED(hr = d3d_pixel_shader_create(device, byte_code, byte_code_length, &object)))
3980 return hr;
3982 *shader = &object->ID3D10PixelShader_iface;
3984 return S_OK;
3987 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState1(ID3D10Device1 *iface,
3988 const D3D10_BLEND_DESC1 *desc, ID3D10BlendState1 **blend_state)
3990 struct d3d_device *device = impl_from_ID3D10Device(iface);
3991 ID3D11BlendState *d3d11_blend_state;
3992 HRESULT hr;
3994 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
3996 if (FAILED(hr = d3d11_device_CreateBlendState(&device->ID3D11Device_iface, (D3D11_BLEND_DESC *)desc,
3997 &d3d11_blend_state)))
3998 return hr;
4000 hr = ID3D11BlendState_QueryInterface(d3d11_blend_state, &IID_ID3D10BlendState1, (void **)blend_state);
4001 ID3D11BlendState_Release(d3d11_blend_state);
4002 return hr;
4005 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device1 *iface,
4006 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
4008 D3D10_BLEND_DESC1 d3d10_1_desc;
4009 unsigned int i;
4011 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
4013 if (!desc)
4014 return E_INVALIDARG;
4016 d3d10_1_desc.AlphaToCoverageEnable = desc->AlphaToCoverageEnable;
4017 d3d10_1_desc.IndependentBlendEnable = FALSE;
4018 for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT - 1; ++i)
4020 if (desc->BlendEnable[i] != desc->BlendEnable[i + 1]
4021 || desc->RenderTargetWriteMask[i] != desc->RenderTargetWriteMask[i + 1])
4022 d3d10_1_desc.IndependentBlendEnable = TRUE;
4025 for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
4027 d3d10_1_desc.RenderTarget[i].BlendEnable = desc->BlendEnable[i];
4028 d3d10_1_desc.RenderTarget[i].SrcBlend = desc->SrcBlend;
4029 d3d10_1_desc.RenderTarget[i].DestBlend = desc->DestBlend;
4030 d3d10_1_desc.RenderTarget[i].BlendOp = desc->BlendOp;
4031 d3d10_1_desc.RenderTarget[i].SrcBlendAlpha = desc->SrcBlendAlpha;
4032 d3d10_1_desc.RenderTarget[i].DestBlendAlpha = desc->DestBlendAlpha;
4033 d3d10_1_desc.RenderTarget[i].BlendOpAlpha = desc->BlendOpAlpha;
4034 d3d10_1_desc.RenderTarget[i].RenderTargetWriteMask = desc->RenderTargetWriteMask[i];
4037 return d3d10_device_CreateBlendState1(iface, &d3d10_1_desc, (ID3D10BlendState1 **)blend_state);
4040 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device1 *iface,
4041 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
4043 struct d3d_device *device = impl_from_ID3D10Device(iface);
4044 ID3D11DepthStencilState *d3d11_depth_stencil_state;
4045 HRESULT hr;
4047 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
4049 if (FAILED(hr = d3d11_device_CreateDepthStencilState(&device->ID3D11Device_iface,
4050 (const D3D11_DEPTH_STENCIL_DESC *)desc, &d3d11_depth_stencil_state)))
4051 return hr;
4053 hr = ID3D11DepthStencilState_QueryInterface(d3d11_depth_stencil_state, &IID_ID3D10DepthStencilState,
4054 (void **)depth_stencil_state);
4055 ID3D11DepthStencilState_Release(d3d11_depth_stencil_state);
4056 return hr;
4059 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device1 *iface,
4060 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
4062 struct d3d_device *device = impl_from_ID3D10Device(iface);
4063 ID3D11RasterizerState *d3d11_rasterizer_state;
4064 HRESULT hr;
4066 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
4068 if (FAILED(hr = d3d11_device_CreateRasterizerState(&device->ID3D11Device_iface,
4069 (const D3D11_RASTERIZER_DESC *)desc, &d3d11_rasterizer_state)))
4070 return hr;
4072 hr = ID3D11RasterizerState_QueryInterface(d3d11_rasterizer_state,
4073 &IID_ID3D10RasterizerState, (void **)rasterizer_state);
4074 ID3D11RasterizerState_Release(d3d11_rasterizer_state);
4075 return hr;
4078 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
4079 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
4081 struct d3d_device *device = impl_from_ID3D10Device(iface);
4082 ID3D11SamplerState *d3d11_sampler_state;
4083 HRESULT hr;
4085 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
4087 if (FAILED(hr = d3d11_device_CreateSamplerState(&device->ID3D11Device_iface,
4088 (const D3D11_SAMPLER_DESC *)desc, &d3d11_sampler_state)))
4089 return hr;
4091 hr = ID3D11SamplerState_QueryInterface(d3d11_sampler_state, &IID_ID3D10SamplerState, (void **)sampler_state);
4092 ID3D11SamplerState_Release(d3d11_sampler_state);
4093 return hr;
4096 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
4097 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
4099 struct d3d_device *device = impl_from_ID3D10Device(iface);
4100 struct d3d_query *object;
4101 HRESULT hr;
4103 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
4105 if (FAILED(hr = d3d_query_create(device, (const D3D11_QUERY_DESC *)desc, FALSE, &object)))
4106 return hr;
4108 *query = &object->ID3D10Query_iface;
4110 return S_OK;
4113 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *iface,
4114 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
4116 struct d3d_device *device = impl_from_ID3D10Device(iface);
4117 struct d3d_query *object;
4118 HRESULT hr;
4120 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
4122 if (FAILED(hr = d3d_query_create(device, (const D3D11_QUERY_DESC *)desc, TRUE, &object)))
4123 return hr;
4125 *predicate = (ID3D10Predicate *)&object->ID3D10Query_iface;
4127 return S_OK;
4130 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device1 *iface,
4131 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
4133 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
4135 return E_NOTIMPL;
4138 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 *iface,
4139 DXGI_FORMAT format, UINT *format_support)
4141 FIXME("iface %p, format %s, format_support %p stub!\n",
4142 iface, debug_dxgi_format(format), format_support);
4144 return E_NOTIMPL;
4147 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface,
4148 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
4150 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
4151 iface, debug_dxgi_format(format), sample_count, quality_level_count);
4153 return E_NOTIMPL;
4156 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device1 *iface, D3D10_COUNTER_INFO *counter_info)
4158 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
4161 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device1 *iface,
4162 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, char *name,
4163 UINT *name_length, char *units, UINT *units_length, char *description, UINT *description_length)
4165 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p, "
4166 "units %p, units_length %p, description %p, description_length %p stub!\n",
4167 iface, desc, type, active_counters, name, name_length,
4168 units, units_length, description, description_length);
4170 return E_NOTIMPL;
4173 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device1 *iface)
4175 FIXME("iface %p stub!\n", iface);
4177 return 0;
4180 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device1 *iface,
4181 HANDLE resource_handle, REFIID guid, void **resource)
4183 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
4184 iface, resource_handle, debugstr_guid(guid), resource);
4186 return E_NOTIMPL;
4189 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device1 *iface, UINT width, UINT height)
4191 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
4194 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device1 *iface, UINT *width, UINT *height)
4196 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
4199 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE d3d10_device_GetFeatureLevel(ID3D10Device1 *iface)
4201 FIXME("iface %p stub!\n", iface);
4203 return D3D10_FEATURE_LEVEL_10_1;
4206 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl =
4208 /* IUnknown methods */
4209 d3d10_device_QueryInterface,
4210 d3d10_device_AddRef,
4211 d3d10_device_Release,
4212 /* ID3D10Device methods */
4213 d3d10_device_VSSetConstantBuffers,
4214 d3d10_device_PSSetShaderResources,
4215 d3d10_device_PSSetShader,
4216 d3d10_device_PSSetSamplers,
4217 d3d10_device_VSSetShader,
4218 d3d10_device_DrawIndexed,
4219 d3d10_device_Draw,
4220 d3d10_device_PSSetConstantBuffers,
4221 d3d10_device_IASetInputLayout,
4222 d3d10_device_IASetVertexBuffers,
4223 d3d10_device_IASetIndexBuffer,
4224 d3d10_device_DrawIndexedInstanced,
4225 d3d10_device_DrawInstanced,
4226 d3d10_device_GSSetConstantBuffers,
4227 d3d10_device_GSSetShader,
4228 d3d10_device_IASetPrimitiveTopology,
4229 d3d10_device_VSSetShaderResources,
4230 d3d10_device_VSSetSamplers,
4231 d3d10_device_SetPredication,
4232 d3d10_device_GSSetShaderResources,
4233 d3d10_device_GSSetSamplers,
4234 d3d10_device_OMSetRenderTargets,
4235 d3d10_device_OMSetBlendState,
4236 d3d10_device_OMSetDepthStencilState,
4237 d3d10_device_SOSetTargets,
4238 d3d10_device_DrawAuto,
4239 d3d10_device_RSSetState,
4240 d3d10_device_RSSetViewports,
4241 d3d10_device_RSSetScissorRects,
4242 d3d10_device_CopySubresourceRegion,
4243 d3d10_device_CopyResource,
4244 d3d10_device_UpdateSubresource,
4245 d3d10_device_ClearRenderTargetView,
4246 d3d10_device_ClearDepthStencilView,
4247 d3d10_device_GenerateMips,
4248 d3d10_device_ResolveSubresource,
4249 d3d10_device_VSGetConstantBuffers,
4250 d3d10_device_PSGetShaderResources,
4251 d3d10_device_PSGetShader,
4252 d3d10_device_PSGetSamplers,
4253 d3d10_device_VSGetShader,
4254 d3d10_device_PSGetConstantBuffers,
4255 d3d10_device_IAGetInputLayout,
4256 d3d10_device_IAGetVertexBuffers,
4257 d3d10_device_IAGetIndexBuffer,
4258 d3d10_device_GSGetConstantBuffers,
4259 d3d10_device_GSGetShader,
4260 d3d10_device_IAGetPrimitiveTopology,
4261 d3d10_device_VSGetShaderResources,
4262 d3d10_device_VSGetSamplers,
4263 d3d10_device_GetPredication,
4264 d3d10_device_GSGetShaderResources,
4265 d3d10_device_GSGetSamplers,
4266 d3d10_device_OMGetRenderTargets,
4267 d3d10_device_OMGetBlendState,
4268 d3d10_device_OMGetDepthStencilState,
4269 d3d10_device_SOGetTargets,
4270 d3d10_device_RSGetState,
4271 d3d10_device_RSGetViewports,
4272 d3d10_device_RSGetScissorRects,
4273 d3d10_device_GetDeviceRemovedReason,
4274 d3d10_device_SetExceptionMode,
4275 d3d10_device_GetExceptionMode,
4276 d3d10_device_GetPrivateData,
4277 d3d10_device_SetPrivateData,
4278 d3d10_device_SetPrivateDataInterface,
4279 d3d10_device_ClearState,
4280 d3d10_device_Flush,
4281 d3d10_device_CreateBuffer,
4282 d3d10_device_CreateTexture1D,
4283 d3d10_device_CreateTexture2D,
4284 d3d10_device_CreateTexture3D,
4285 d3d10_device_CreateShaderResourceView,
4286 d3d10_device_CreateRenderTargetView,
4287 d3d10_device_CreateDepthStencilView,
4288 d3d10_device_CreateInputLayout,
4289 d3d10_device_CreateVertexShader,
4290 d3d10_device_CreateGeometryShader,
4291 d3d10_device_CreateGeometryShaderWithStreamOutput,
4292 d3d10_device_CreatePixelShader,
4293 d3d10_device_CreateBlendState,
4294 d3d10_device_CreateDepthStencilState,
4295 d3d10_device_CreateRasterizerState,
4296 d3d10_device_CreateSamplerState,
4297 d3d10_device_CreateQuery,
4298 d3d10_device_CreatePredicate,
4299 d3d10_device_CreateCounter,
4300 d3d10_device_CheckFormatSupport,
4301 d3d10_device_CheckMultisampleQualityLevels,
4302 d3d10_device_CheckCounterInfo,
4303 d3d10_device_CheckCounter,
4304 d3d10_device_GetCreationFlags,
4305 d3d10_device_OpenSharedResource,
4306 d3d10_device_SetTextFilterSize,
4307 d3d10_device_GetTextFilterSize,
4308 d3d10_device_CreateShaderResourceView1,
4309 d3d10_device_CreateBlendState1,
4310 d3d10_device_GetFeatureLevel,
4313 static const struct IUnknownVtbl d3d_device_inner_unknown_vtbl =
4315 /* IUnknown methods */
4316 d3d_device_inner_QueryInterface,
4317 d3d_device_inner_AddRef,
4318 d3d_device_inner_Release,
4321 /* ID3D10Multithread methods */
4323 static inline struct d3d_device *impl_from_ID3D10Multithread(ID3D10Multithread *iface)
4325 return CONTAINING_RECORD(iface, struct d3d_device, ID3D10Multithread_iface);
4328 static HRESULT STDMETHODCALLTYPE d3d10_multithread_QueryInterface(ID3D10Multithread *iface, REFIID iid, void **out)
4330 struct d3d_device *device = impl_from_ID3D10Multithread(iface);
4332 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
4334 return IUnknown_QueryInterface(device->outer_unk, iid, out);
4337 static ULONG STDMETHODCALLTYPE d3d10_multithread_AddRef(ID3D10Multithread *iface)
4339 struct d3d_device *device = impl_from_ID3D10Multithread(iface);
4341 TRACE("iface %p.\n", iface);
4343 return IUnknown_AddRef(device->outer_unk);
4346 static ULONG STDMETHODCALLTYPE d3d10_multithread_Release(ID3D10Multithread *iface)
4348 struct d3d_device *device = impl_from_ID3D10Multithread(iface);
4350 TRACE("iface %p.\n", iface);
4352 return IUnknown_Release(device->outer_unk);
4355 static void STDMETHODCALLTYPE d3d10_multithread_Enter(ID3D10Multithread *iface)
4357 TRACE("iface %p.\n", iface);
4359 wined3d_mutex_lock();
4362 static void STDMETHODCALLTYPE d3d10_multithread_Leave(ID3D10Multithread *iface)
4364 TRACE("iface %p.\n", iface);
4366 wined3d_mutex_unlock();
4369 static BOOL STDMETHODCALLTYPE d3d10_multithread_SetMultithreadProtected(ID3D10Multithread *iface, BOOL protect)
4371 FIXME("iface %p, protect %#x stub!\n", iface, protect);
4373 return TRUE;
4376 static BOOL STDMETHODCALLTYPE d3d10_multithread_GetMultithreadProtected(ID3D10Multithread *iface)
4378 FIXME("iface %p stub!\n", iface);
4380 return TRUE;
4383 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl =
4385 d3d10_multithread_QueryInterface,
4386 d3d10_multithread_AddRef,
4387 d3d10_multithread_Release,
4388 d3d10_multithread_Enter,
4389 d3d10_multithread_Leave,
4390 d3d10_multithread_SetMultithreadProtected,
4391 d3d10_multithread_GetMultithreadProtected,
4394 /* IWineDXGIDeviceParent IUnknown methods */
4396 static inline struct d3d_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
4398 return CONTAINING_RECORD(iface, struct d3d_device, IWineDXGIDeviceParent_iface);
4401 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
4402 REFIID riid, void **ppv)
4404 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4405 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
4408 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
4410 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4411 return IUnknown_AddRef(device->outer_unk);
4414 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
4416 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4417 return IUnknown_Release(device->outer_unk);
4420 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
4421 IWineDXGIDeviceParent *iface)
4423 struct d3d_device *device = device_from_dxgi_device_parent(iface);
4424 return &device->device_parent;
4427 static const struct IWineDXGIDeviceParentVtbl d3d_dxgi_device_parent_vtbl =
4429 /* IUnknown methods */
4430 dxgi_device_parent_QueryInterface,
4431 dxgi_device_parent_AddRef,
4432 dxgi_device_parent_Release,
4433 /* IWineDXGIDeviceParent methods */
4434 dxgi_device_parent_get_wined3d_device_parent,
4437 static inline struct d3d_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
4439 return CONTAINING_RECORD(device_parent, struct d3d_device, device_parent);
4442 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
4443 struct wined3d_device *wined3d_device)
4445 struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
4447 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
4449 wined3d_device_incref(wined3d_device);
4450 device->wined3d_device = wined3d_device;
4453 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
4455 TRACE("device_parent %p.\n", device_parent);
4458 static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate)
4460 TRACE("device_parent %p, activate %#x.\n", device_parent, activate);
4463 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
4464 struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, struct wined3d_surface *surface, void **parent,
4465 const struct wined3d_parent_ops **parent_ops)
4467 TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, surface %p, parent %p, parent_ops %p.\n",
4468 device_parent, wined3d_texture, sub_resource_idx, surface, parent, parent_ops);
4470 *parent = NULL;
4471 *parent_ops = &d3d_null_wined3d_parent_ops;
4473 return S_OK;
4476 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
4477 struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, void **parent,
4478 const struct wined3d_parent_ops **parent_ops)
4480 TRACE("device_parent %p, texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
4481 device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
4483 *parent = NULL;
4484 *parent_ops = &d3d_null_wined3d_parent_ops;
4486 return S_OK;
4489 static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_device_parent *device_parent,
4490 void *container_parent, const struct wined3d_resource_desc *wined3d_desc,
4491 struct wined3d_texture **wined3d_texture)
4493 struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
4494 struct d3d_texture2d *texture;
4495 ID3D10Texture2D *texture_iface;
4496 D3D10_TEXTURE2D_DESC desc;
4497 HRESULT hr;
4499 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, wined3d_texture %p partial stub!\n",
4500 device_parent, container_parent, wined3d_desc, wined3d_texture);
4502 FIXME("Implement DXGI<->wined3d usage conversion\n");
4504 desc.Width = wined3d_desc->width;
4505 desc.Height = wined3d_desc->height;
4506 desc.MipLevels = 1;
4507 desc.ArraySize = 1;
4508 desc.Format = dxgi_format_from_wined3dformat(wined3d_desc->format);
4509 desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1;
4510 desc.SampleDesc.Quality = wined3d_desc->multisample_quality;
4511 desc.Usage = D3D10_USAGE_DEFAULT;
4512 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
4513 desc.CPUAccessFlags = 0;
4514 desc.MiscFlags = 0;
4516 if (FAILED(hr = d3d10_device_CreateTexture2D(&device->ID3D10Device1_iface,
4517 &desc, NULL, &texture_iface)))
4519 ERR("CreateTexture2D failed, returning %#x\n", hr);
4520 return hr;
4523 texture = impl_from_ID3D10Texture2D(texture_iface);
4525 *wined3d_texture = texture->wined3d_texture;
4526 wined3d_texture_incref(*wined3d_texture);
4527 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
4529 return S_OK;
4532 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
4533 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
4535 struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
4536 IWineDXGIDevice *wine_device;
4537 HRESULT hr;
4539 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain);
4541 if (FAILED(hr = d3d10_device_QueryInterface(&device->ID3D10Device1_iface,
4542 &IID_IWineDXGIDevice, (void **)&wine_device)))
4544 ERR("Device should implement IWineDXGIDevice.\n");
4545 return E_FAIL;
4548 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
4549 IWineDXGIDevice_Release(wine_device);
4550 if (FAILED(hr))
4552 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
4553 return hr;
4556 return S_OK;
4559 static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops =
4561 device_parent_wined3d_device_created,
4562 device_parent_mode_changed,
4563 device_parent_activate,
4564 device_parent_surface_created,
4565 device_parent_volume_created,
4566 device_parent_create_swapchain_texture,
4567 device_parent_create_swapchain,
4570 static void *d3d_rb_alloc(size_t size)
4572 return HeapAlloc(GetProcessHeap(), 0, size);
4575 static void *d3d_rb_realloc(void *ptr, size_t size)
4577 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
4580 static void d3d_rb_free(void *ptr)
4582 HeapFree(GetProcessHeap(), 0, ptr);
4585 static int d3d_sampler_state_compare(const void *key, const struct wine_rb_entry *entry)
4587 const D3D11_SAMPLER_DESC *ka = key;
4588 const D3D11_SAMPLER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_sampler_state, entry)->desc;
4590 return memcmp(ka, kb, sizeof(*ka));
4593 static const struct wine_rb_functions d3d_sampler_state_rb_ops =
4595 d3d_rb_alloc,
4596 d3d_rb_realloc,
4597 d3d_rb_free,
4598 d3d_sampler_state_compare,
4601 static int d3d_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
4603 const D3D11_BLEND_DESC *ka = key;
4604 const D3D11_BLEND_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_blend_state, entry)->desc;
4606 return memcmp(ka, kb, sizeof(*ka));
4609 static const struct wine_rb_functions d3d_blend_state_rb_ops =
4611 d3d_rb_alloc,
4612 d3d_rb_realloc,
4613 d3d_rb_free,
4614 d3d_blend_state_compare,
4617 static int d3d_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
4619 const D3D11_DEPTH_STENCIL_DESC *ka = key;
4620 const D3D11_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
4621 const struct d3d_depthstencil_state, entry)->desc;
4623 return memcmp(ka, kb, sizeof(*ka));
4626 static const struct wine_rb_functions d3d_depthstencil_state_rb_ops =
4628 d3d_rb_alloc,
4629 d3d_rb_realloc,
4630 d3d_rb_free,
4631 d3d_depthstencil_state_compare,
4634 static int d3d_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
4636 const D3D11_RASTERIZER_DESC *ka = key;
4637 const D3D11_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_rasterizer_state, entry)->desc;
4639 return memcmp(ka, kb, sizeof(*ka));
4642 static const struct wine_rb_functions d3d_rasterizer_state_rb_ops =
4644 d3d_rb_alloc,
4645 d3d_rb_realloc,
4646 d3d_rb_free,
4647 d3d_rasterizer_state_compare,
4650 HRESULT d3d_device_init(struct d3d_device *device, void *outer_unknown)
4652 device->IUnknown_inner.lpVtbl = &d3d_device_inner_unknown_vtbl;
4653 device->ID3D11Device_iface.lpVtbl = &d3d11_device_vtbl;
4654 device->ID3D10Device1_iface.lpVtbl = &d3d10_device1_vtbl;
4655 device->ID3D10Multithread_iface.lpVtbl = &d3d10_multithread_vtbl;
4656 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d_dxgi_device_parent_vtbl;
4657 device->device_parent.ops = &d3d_wined3d_device_parent_ops;
4658 device->refcount = 1;
4659 /* COM aggregation always takes place */
4660 device->outer_unk = outer_unknown;
4662 if (FAILED(d3d11_immediate_context_init(&device->immediate_context, device)))
4664 WARN("Failed to initialize immediate device context.\n");
4665 return E_FAIL;
4667 ID3D11DeviceContext_Release(&device->immediate_context.ID3D11DeviceContext_iface);
4669 if (wine_rb_init(&device->blend_states, &d3d_blend_state_rb_ops) == -1)
4671 WARN("Failed to initialize blend state rbtree.\n");
4672 return E_FAIL;
4674 device->blend_factor[0] = 1.0f;
4675 device->blend_factor[1] = 1.0f;
4676 device->blend_factor[2] = 1.0f;
4677 device->blend_factor[3] = 1.0f;
4679 if (wine_rb_init(&device->depthstencil_states, &d3d_depthstencil_state_rb_ops) == -1)
4681 WARN("Failed to initialize depthstencil state rbtree.\n");
4682 wine_rb_destroy(&device->blend_states, NULL, NULL);
4683 return E_FAIL;
4686 if (wine_rb_init(&device->rasterizer_states, &d3d_rasterizer_state_rb_ops) == -1)
4688 WARN("Failed to initialize rasterizer state rbtree.\n");
4689 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
4690 wine_rb_destroy(&device->blend_states, NULL, NULL);
4691 return E_FAIL;
4694 if (wine_rb_init(&device->sampler_states, &d3d_sampler_state_rb_ops) == -1)
4696 WARN("Failed to initialize sampler state rbtree.\n");
4697 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
4698 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
4699 wine_rb_destroy(&device->blend_states, NULL, NULL);
4700 return E_FAIL;
4703 return S_OK;