d3d10core: Implement d3d10_device_GSGetShaderResources().
[wine/multimedia.git] / dlls / d3d10core / device.c
blob639e22039db6798bdecc2ce01d79d8de7e5efe3e
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 #include "d3d10core_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
27 static void STDMETHODCALLTYPE d3d10_null_wined3d_object_destroyed(void *parent) {}
29 const struct wined3d_parent_ops d3d10_null_wined3d_parent_ops =
31 d3d10_null_wined3d_object_destroyed,
34 /* Inner IUnknown methods */
36 static inline struct d3d10_device *impl_from_IUnknown(IUnknown *iface)
38 return CONTAINING_RECORD(iface, struct d3d10_device, IUnknown_inner);
41 static HRESULT STDMETHODCALLTYPE d3d10_device_inner_QueryInterface(IUnknown *iface, REFIID riid, void **out)
43 struct d3d10_device *device = impl_from_IUnknown(iface);
45 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
47 if (IsEqualGUID(riid, &IID_ID3D10Device1)
48 || IsEqualGUID(riid, &IID_ID3D10Device)
49 || IsEqualGUID(riid, &IID_IUnknown))
51 *out = &device->ID3D10Device1_iface;
53 else if (IsEqualGUID(riid, &IID_ID3D10Multithread))
55 *out = &device->ID3D10Multithread_iface;
57 else if (IsEqualGUID(riid, &IID_IWineDXGIDeviceParent))
59 *out = &device->IWineDXGIDeviceParent_iface;
61 else
63 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
64 *out = NULL;
65 return E_NOINTERFACE;
68 IUnknown_AddRef((IUnknown *)*out);
69 return S_OK;
72 static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
74 struct d3d10_device *This = impl_from_IUnknown(iface);
75 ULONG refcount = InterlockedIncrement(&This->refcount);
77 TRACE("%p increasing refcount to %u\n", This, refcount);
79 return refcount;
82 static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
84 struct d3d10_device *device = impl_from_IUnknown(iface);
85 ULONG refcount = InterlockedDecrement(&device->refcount);
87 TRACE("%p decreasing refcount to %u.\n", device, refcount);
89 if (!refcount)
91 if (device->wined3d_device)
92 wined3d_device_decref(device->wined3d_device);
93 wine_rb_destroy(&device->sampler_states, NULL, NULL);
94 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
95 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
96 wine_rb_destroy(&device->blend_states, NULL, NULL);
99 return refcount;
102 /* IUnknown methods */
104 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device1 *iface, REFIID riid,
105 void **ppv)
107 struct d3d10_device *This = impl_from_ID3D10Device(iface);
108 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
111 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device1 *iface)
113 struct d3d10_device *This = impl_from_ID3D10Device(iface);
114 return IUnknown_AddRef(This->outer_unk);
117 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device1 *iface)
119 struct d3d10_device *This = impl_from_ID3D10Device(iface);
120 return IUnknown_Release(This->outer_unk);
123 /* ID3D10Device methods */
125 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *iface,
126 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
128 struct d3d10_device *device = impl_from_ID3D10Device(iface);
129 unsigned int i;
131 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
132 iface, start_slot, buffer_count, buffers);
134 for (i = 0; i < buffer_count; ++i)
136 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
138 wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i,
139 buffer ? buffer->wined3d_buffer : NULL);
143 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device1 *iface,
144 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
146 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
147 iface, start_slot, view_count, views);
150 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device1 *iface,
151 ID3D10PixelShader *shader)
153 struct d3d10_device *This = impl_from_ID3D10Device(iface);
154 struct d3d10_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader);
156 TRACE("iface %p, shader %p\n", iface, shader);
158 wined3d_device_set_pixel_shader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
161 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device1 *iface,
162 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
164 struct d3d10_device *device = impl_from_ID3D10Device(iface);
165 unsigned int i;
167 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
168 iface, start_slot, sampler_count, samplers);
170 for (i = 0; i < sampler_count; ++i)
172 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
174 wined3d_device_set_ps_sampler(device->wined3d_device, start_slot + i,
175 sampler ? sampler->wined3d_sampler : NULL);
179 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device1 *iface,
180 ID3D10VertexShader *shader)
182 struct d3d10_device *This = impl_from_ID3D10Device(iface);
183 struct d3d10_vertex_shader *vs = unsafe_impl_from_ID3D10VertexShader(shader);
185 TRACE("iface %p, shader %p\n", iface, shader);
187 wined3d_device_set_vertex_shader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
190 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device1 *iface, UINT index_count,
191 UINT start_index_location, INT base_vertex_location)
193 struct d3d10_device *This = impl_from_ID3D10Device(iface);
195 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
196 iface, index_count, start_index_location, base_vertex_location);
198 wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
199 wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
202 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device1 *iface, UINT vertex_count,
203 UINT start_vertex_location)
205 struct d3d10_device *This = impl_from_ID3D10Device(iface);
207 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
208 iface, vertex_count, start_vertex_location);
210 wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
213 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device1 *iface,
214 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
216 struct d3d10_device *device = impl_from_ID3D10Device(iface);
217 unsigned int i;
219 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
220 iface, start_slot, buffer_count, buffers);
222 for (i = 0; i < buffer_count; ++i)
224 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
226 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
227 buffer ? buffer->wined3d_buffer : NULL);
231 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device1 *iface,
232 ID3D10InputLayout *input_layout)
234 struct d3d10_device *This = impl_from_ID3D10Device(iface);
235 struct d3d10_input_layout *layout = unsafe_impl_from_ID3D10InputLayout(input_layout);
237 TRACE("iface %p, input_layout %p\n", iface, input_layout);
239 wined3d_device_set_vertex_declaration(This->wined3d_device,
240 layout ? layout->wined3d_decl : NULL);
243 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device1 *iface, UINT start_slot,
244 UINT buffer_count, ID3D10Buffer *const *buffers, const UINT *strides, const UINT *offsets)
246 struct d3d10_device *This = impl_from_ID3D10Device(iface);
247 unsigned int i;
249 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
250 iface, start_slot, buffer_count, buffers, strides, offsets);
252 for (i = 0; i < buffer_count; ++i)
254 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
256 wined3d_device_set_stream_source(This->wined3d_device, start_slot + i,
257 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
261 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device1 *iface,
262 ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
264 struct d3d10_device *This = impl_from_ID3D10Device(iface);
265 struct d3d10_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
267 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
268 iface, buffer, debug_dxgi_format(format), offset);
270 wined3d_device_set_index_buffer(This->wined3d_device,
271 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
272 wined3dformat_from_dxgi_format(format));
273 if (offset) FIXME("offset %u not supported.\n", offset);
276 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device1 *iface,
277 UINT instance_index_count, UINT instance_count, UINT start_index_location,
278 INT base_vertex_location, UINT start_instance_location)
280 struct d3d10_device *device = impl_from_ID3D10Device(iface);
282 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u,\n"
283 "\tbase_vertex_location %d, start_instance_location %u.\n",
284 iface, instance_index_count, instance_count, start_index_location,
285 base_vertex_location, start_instance_location);
287 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
288 wined3d_device_draw_indexed_primitive_instanced(device->wined3d_device, start_index_location,
289 instance_index_count, start_instance_location, instance_count);
292 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device1 *iface,
293 UINT instance_vertex_count, UINT instance_count,
294 UINT start_vertex_location, UINT start_instance_location)
296 FIXME("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u,\n"
297 "\tstart_instance_location %u stub!\n", iface, instance_vertex_count, instance_count,
298 start_vertex_location, start_instance_location);
301 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device1 *iface,
302 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
304 struct d3d10_device *device = impl_from_ID3D10Device(iface);
305 unsigned int i;
307 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
308 iface, start_slot, buffer_count, buffers);
310 for (i = 0; i < buffer_count; ++i)
312 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
314 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
315 buffer ? buffer->wined3d_buffer : NULL);
319 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device1 *iface, ID3D10GeometryShader *shader)
321 struct d3d10_device *device = impl_from_ID3D10Device(iface);
322 struct d3d10_geometry_shader *gs = unsafe_impl_from_ID3D10GeometryShader(shader);
324 TRACE("iface %p, shader %p.\n", iface, shader);
326 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
329 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device1 *iface,
330 D3D10_PRIMITIVE_TOPOLOGY topology)
332 struct d3d10_device *This = impl_from_ID3D10Device(iface);
334 TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
336 wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
339 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device1 *iface,
340 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
342 struct d3d10_device *device = impl_from_ID3D10Device(iface);
343 unsigned int i;
345 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
346 iface, start_slot, view_count, views);
348 for (i = 0; i < view_count; ++i)
350 struct d3d10_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
352 wined3d_device_set_vs_resource_view(device->wined3d_device, start_slot + i,
353 view ? view->wined3d_view : NULL);
357 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device1 *iface,
358 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
360 struct d3d10_device *device = impl_from_ID3D10Device(iface);
361 unsigned int i;
363 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
364 iface, start_slot, sampler_count, samplers);
366 for (i = 0; i < sampler_count; ++i)
368 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
370 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
371 sampler ? sampler->wined3d_sampler : NULL);
375 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device1 *iface, ID3D10Predicate *predicate, BOOL value)
377 FIXME("iface %p, predicate %p, value %d stub!\n", iface, predicate, value);
380 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device1 *iface,
381 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
383 struct d3d10_device *device = impl_from_ID3D10Device(iface);
384 unsigned int i;
386 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
387 iface, start_slot, view_count, views);
389 for (i = 0; i < view_count; ++i)
391 struct d3d10_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
393 wined3d_device_set_gs_resource_view(device->wined3d_device, start_slot + i,
394 view ? view->wined3d_view : NULL);
398 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device1 *iface,
399 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
401 struct d3d10_device *device = impl_from_ID3D10Device(iface);
402 unsigned int i;
404 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
405 iface, start_slot, sampler_count, samplers);
407 for (i = 0; i < sampler_count; ++i)
409 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
411 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
412 sampler ? sampler->wined3d_sampler : NULL);
416 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device1 *iface,
417 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
418 ID3D10DepthStencilView *depth_stencil_view)
420 struct d3d10_device *device = impl_from_ID3D10Device(iface);
421 struct d3d10_depthstencil_view *dsv;
422 unsigned int i;
424 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
425 iface, render_target_view_count, render_target_views, depth_stencil_view);
427 for (i = 0; i < render_target_view_count; ++i)
429 struct d3d10_rendertarget_view *rtv = unsafe_impl_from_ID3D10RenderTargetView(render_target_views[i]);
431 wined3d_device_set_rendertarget_view(device->wined3d_device, i,
432 rtv ? rtv->wined3d_view : NULL, FALSE);
434 for (; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
436 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
439 dsv = unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view);
440 wined3d_device_set_depth_stencil_view(device->wined3d_device,
441 dsv ? dsv->wined3d_view : NULL);
444 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface,
445 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
447 struct d3d10_device *device = impl_from_ID3D10Device(iface);
449 TRACE("iface %p, blend_state %p, blend_factor [%f %f %f %f], sample_mask 0x%08x.\n",
450 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
452 device->blend_state = unsafe_impl_from_ID3D10BlendState(blend_state);
453 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
454 device->sample_mask = sample_mask;
457 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1 *iface,
458 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
460 struct d3d10_device *device = impl_from_ID3D10Device(iface);
462 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
463 iface, depth_stencil_state, stencil_ref);
465 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
466 device->stencil_ref = stencil_ref;
469 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface,
470 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
472 struct d3d10_device *device = impl_from_ID3D10Device(iface);
473 unsigned int count, i;
475 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
477 count = min(target_count, 4);
478 for (i = 0; i < count; ++i)
480 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
482 wined3d_device_set_stream_output(device->wined3d_device, i,
483 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
486 for (i = count; i < 4; ++i)
488 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
492 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device1 *iface)
494 FIXME("iface %p stub!\n", iface);
497 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device1 *iface, ID3D10RasterizerState *rasterizer_state)
499 struct d3d10_device *device = impl_from_ID3D10Device(iface);
500 const D3D10_RASTERIZER_DESC *desc;
502 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
504 if (!(device->rasterizer_state = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state)))
506 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, WINED3D_FILL_SOLID);
507 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, WINED3D_CULL_CCW);
508 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE);
509 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE);
510 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ANTIALIASEDLINEENABLE, FALSE);
511 return;
514 desc = &device->rasterizer_state->desc;
515 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, desc->FillMode);
516 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, desc->CullMode);
517 /* glFrontFace() */
518 if (desc->FrontCounterClockwise)
519 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc->FrontCounterClockwise);
520 /* OpenGL style depth bias. */
521 if (desc->DepthBias || desc->SlopeScaledDepthBias)
522 FIXME("Ignoring depth bias.\n");
523 /* GL_DEPTH_CLAMP */
524 if (!desc->DepthClipEnable)
525 FIXME("Ignoring DepthClipEnable %#x.\n", desc->DepthClipEnable);
526 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable);
527 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable);
528 wined3d_device_set_render_state(device->wined3d_device,
529 WINED3D_RS_ANTIALIASEDLINEENABLE, desc->AntialiasedLineEnable);
532 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface,
533 UINT viewport_count, const D3D10_VIEWPORT *viewports)
535 struct d3d10_device *device = impl_from_ID3D10Device(iface);
536 struct wined3d_viewport wined3d_vp;
538 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
540 if (viewport_count > 1)
541 FIXME("Multiple viewports not implemented.\n");
543 if (!viewport_count)
544 return;
546 wined3d_vp.x = viewports[0].TopLeftX;
547 wined3d_vp.y = viewports[0].TopLeftY;
548 wined3d_vp.width = viewports[0].Width;
549 wined3d_vp.height = viewports[0].Height;
550 wined3d_vp.min_z = viewports[0].MinDepth;
551 wined3d_vp.max_z = viewports[0].MaxDepth;
553 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
556 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *iface,
557 UINT rect_count, const D3D10_RECT *rects)
559 struct d3d10_device *device = impl_from_ID3D10Device(iface);
561 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
563 if (rect_count > 1)
564 FIXME("Multiple scissor rects not implemented.\n");
566 if (!rect_count)
567 return;
569 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
572 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *iface,
573 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
574 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
576 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u,\n"
577 "\tsrc_resource %p, src_subresource_idx %u, src_box %p stub!\n",
578 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
579 src_resource, src_subresource_idx, src_box);
582 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,
583 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
585 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
586 struct d3d10_device *device = impl_from_ID3D10Device(iface);
588 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
590 wined3d_dst_resource = wined3d_resource_from_resource(dst_resource);
591 wined3d_src_resource = wined3d_resource_from_resource(src_resource);
592 wined3d_device_copy_resource(device->wined3d_device, wined3d_dst_resource, wined3d_src_resource);
595 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface,
596 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
597 const void *data, UINT row_pitch, UINT depth_pitch)
599 FIXME("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
600 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
603 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 *iface,
604 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
606 struct d3d10_device *device = impl_from_ID3D10Device(iface);
607 struct d3d10_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
608 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
609 HRESULT hr;
611 TRACE("iface %p, render_target_view %p, color_rgba {%.8e, %.8e, %.8e, %.8e}.\n",
612 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
614 if (FAILED(hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, view->wined3d_view, NULL, &color)))
615 ERR("Failed to clear view, hr %#x.\n", hr);
618 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *iface,
619 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
621 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
622 iface, depth_stencil_view, flags, depth, stencil);
625 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
626 ID3D10ShaderResourceView *shader_resource_view)
628 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
631 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *iface,
632 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
633 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
635 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u,\n"
636 "\tsrc_resource %p, src_subresource_idx %u, format %s stub!\n",
637 iface, dst_resource, dst_subresource_idx,
638 src_resource, src_subresource_idx, debug_dxgi_format(format));
641 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device1 *iface,
642 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
644 struct d3d10_device *device = impl_from_ID3D10Device(iface);
645 unsigned int i;
647 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
648 iface, start_slot, buffer_count, buffers);
650 for (i = 0; i < buffer_count; ++i)
652 struct wined3d_buffer *wined3d_buffer;
653 struct d3d10_buffer *buffer_impl;
655 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
657 buffers[i] = NULL;
658 continue;
661 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
662 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
663 ID3D10Buffer_AddRef(buffers[i]);
667 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device1 *iface,
668 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
670 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
671 iface, start_slot, view_count, views);
674 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device1 *iface, ID3D10PixelShader **shader)
676 struct d3d10_device *device = impl_from_ID3D10Device(iface);
677 struct d3d10_pixel_shader *shader_impl;
678 struct wined3d_shader *wined3d_shader;
680 TRACE("iface %p, shader %p.\n", iface, shader);
682 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
684 *shader = NULL;
685 return;
688 shader_impl = wined3d_shader_get_parent(wined3d_shader);
689 *shader = &shader_impl->ID3D10PixelShader_iface;
690 ID3D10PixelShader_AddRef(*shader);
693 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device1 *iface,
694 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
696 struct d3d10_device *device = impl_from_ID3D10Device(iface);
697 unsigned int i;
699 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
700 iface, start_slot, sampler_count, samplers);
702 for (i = 0; i < sampler_count; ++i)
704 struct d3d10_sampler_state *sampler_impl;
705 struct wined3d_sampler *wined3d_sampler;
707 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
709 samplers[i] = NULL;
710 continue;
713 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
714 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
715 ID3D10SamplerState_AddRef(samplers[i]);
719 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device1 *iface, ID3D10VertexShader **shader)
721 struct d3d10_device *device = impl_from_ID3D10Device(iface);
722 struct d3d10_vertex_shader *shader_impl;
723 struct wined3d_shader *wined3d_shader;
725 TRACE("iface %p, shader %p.\n", iface, shader);
727 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
729 *shader = NULL;
730 return;
733 shader_impl = wined3d_shader_get_parent(wined3d_shader);
734 *shader = &shader_impl->ID3D10VertexShader_iface;
735 ID3D10VertexShader_AddRef(*shader);
738 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device1 *iface,
739 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
741 struct d3d10_device *device = impl_from_ID3D10Device(iface);
742 unsigned int i;
744 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
745 iface, start_slot, buffer_count, buffers);
747 for (i = 0; i < buffer_count; ++i)
749 struct wined3d_buffer *wined3d_buffer;
750 struct d3d10_buffer *buffer_impl;
752 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
754 buffers[i] = NULL;
755 continue;
758 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
759 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
760 ID3D10Buffer_AddRef(buffers[i]);
764 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device1 *iface, ID3D10InputLayout **input_layout)
766 struct d3d10_device *device = impl_from_ID3D10Device(iface);
767 struct wined3d_vertex_declaration *wined3d_declaration;
768 struct d3d10_input_layout *input_layout_impl;
770 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
772 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
774 *input_layout = NULL;
775 return;
778 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
779 *input_layout = &input_layout_impl->ID3D10InputLayout_iface;
780 ID3D10InputLayout_AddRef(*input_layout);
783 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device1 *iface,
784 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
786 struct d3d10_device *device = impl_from_ID3D10Device(iface);
787 unsigned int i;
789 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
790 iface, start_slot, buffer_count, buffers, strides, offsets);
792 for (i = 0; i < buffer_count; ++i)
794 struct wined3d_buffer *wined3d_buffer;
795 struct d3d10_buffer *buffer_impl;
797 if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
798 &wined3d_buffer, &offsets[i], &strides[i])))
799 ERR("Failed to get vertex buffer.\n");
801 if (!wined3d_buffer)
803 buffers[i] = NULL;
804 continue;
807 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
808 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
809 ID3D10Buffer_AddRef(buffers[i]);
813 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device1 *iface,
814 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
816 struct d3d10_device *device = impl_from_ID3D10Device(iface);
817 enum wined3d_format_id wined3d_format;
818 struct wined3d_buffer *wined3d_buffer;
819 struct d3d10_buffer *buffer_impl;
821 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
823 wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
824 *format = dxgi_format_from_wined3dformat(wined3d_format);
825 *offset = 0; /* FIXME */
826 if (!wined3d_buffer)
828 *buffer = NULL;
829 return;
832 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
833 *buffer = &buffer_impl->ID3D10Buffer_iface;
834 ID3D10Buffer_AddRef(*buffer);
837 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device1 *iface,
838 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
840 struct d3d10_device *device = impl_from_ID3D10Device(iface);
841 unsigned int i;
843 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
844 iface, start_slot, buffer_count, buffers);
846 for (i = 0; i < buffer_count; ++i)
848 struct wined3d_buffer *wined3d_buffer;
849 struct d3d10_buffer *buffer_impl;
851 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
853 buffers[i] = NULL;
854 continue;
857 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
858 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
859 ID3D10Buffer_AddRef(buffers[i]);
863 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device1 *iface, ID3D10GeometryShader **shader)
865 struct d3d10_device *device = impl_from_ID3D10Device(iface);
866 struct d3d10_geometry_shader *shader_impl;
867 struct wined3d_shader *wined3d_shader;
869 TRACE("iface %p, shader %p.\n", iface, shader);
871 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
873 *shader = NULL;
874 return;
877 shader_impl = wined3d_shader_get_parent(wined3d_shader);
878 *shader = &shader_impl->ID3D10GeometryShader_iface;
879 ID3D10GeometryShader_AddRef(*shader);
882 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device1 *iface,
883 D3D10_PRIMITIVE_TOPOLOGY *topology)
885 struct d3d10_device *This = impl_from_ID3D10Device(iface);
887 TRACE("iface %p, topology %p\n", iface, topology);
889 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
892 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device1 *iface,
893 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
895 struct d3d10_device *device = impl_from_ID3D10Device(iface);
896 unsigned int i;
898 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
899 iface, start_slot, view_count, views);
901 for (i = 0; i < view_count; ++i)
903 struct wined3d_shader_resource_view *wined3d_view;
904 struct d3d10_shader_resource_view *view_impl;
906 if (!(wined3d_view = wined3d_device_get_vs_resource_view(device->wined3d_device, start_slot + i)))
908 views[i] = NULL;
909 continue;
912 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
913 views[i] = &view_impl->ID3D10ShaderResourceView_iface;
914 ID3D10ShaderResourceView_AddRef(views[i]);
918 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device1 *iface,
919 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
921 struct d3d10_device *device = impl_from_ID3D10Device(iface);
922 unsigned int i;
924 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
925 iface, start_slot, sampler_count, samplers);
927 for (i = 0; i < sampler_count; ++i)
929 struct d3d10_sampler_state *sampler_impl;
930 struct wined3d_sampler *wined3d_sampler;
932 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
934 samplers[i] = NULL;
935 continue;
938 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
939 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
940 ID3D10SamplerState_AddRef(samplers[i]);
944 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device1 *iface,
945 ID3D10Predicate **predicate, BOOL *value)
947 FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
950 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device1 *iface,
951 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
953 struct d3d10_device *device = impl_from_ID3D10Device(iface);
954 unsigned int i;
956 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
957 iface, start_slot, view_count, views);
959 for (i = 0; i < view_count; ++i)
961 struct wined3d_shader_resource_view *wined3d_view;
962 struct d3d10_shader_resource_view *view_impl;
964 if (!(wined3d_view = wined3d_device_get_gs_resource_view(device->wined3d_device, start_slot + i)))
966 views[i] = NULL;
967 continue;
970 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
971 views[i] = &view_impl->ID3D10ShaderResourceView_iface;
972 ID3D10ShaderResourceView_AddRef(views[i]);
976 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device1 *iface,
977 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
979 struct d3d10_device *device = impl_from_ID3D10Device(iface);
980 unsigned int i;
982 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
983 iface, start_slot, sampler_count, samplers);
985 for (i = 0; i < sampler_count; ++i)
987 struct d3d10_sampler_state *sampler_impl;
988 struct wined3d_sampler *wined3d_sampler;
990 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
992 samplers[i] = NULL;
993 continue;
996 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
997 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
998 ID3D10SamplerState_AddRef(samplers[i]);
1002 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device1 *iface,
1003 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
1005 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1006 struct wined3d_rendertarget_view *wined3d_view;
1008 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
1009 iface, view_count, render_target_views, depth_stencil_view);
1011 if (render_target_views)
1013 struct d3d10_rendertarget_view *view_impl;
1014 unsigned int i;
1016 for (i = 0; i < view_count; ++i)
1018 if (!(wined3d_view = wined3d_device_get_rendertarget_view(device->wined3d_device, i))
1019 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
1021 render_target_views[i] = NULL;
1022 continue;
1025 render_target_views[i] = &view_impl->ID3D10RenderTargetView_iface;
1026 ID3D10RenderTargetView_AddRef(render_target_views[i]);
1030 if (depth_stencil_view)
1032 struct d3d10_depthstencil_view *view_impl;
1034 if (!(wined3d_view = wined3d_device_get_depth_stencil_view(device->wined3d_device))
1035 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
1037 *depth_stencil_view = NULL;
1039 else
1041 *depth_stencil_view = &view_impl->ID3D10DepthStencilView_iface;
1042 ID3D10DepthStencilView_AddRef(*depth_stencil_view);
1047 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface,
1048 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
1050 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1052 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
1053 iface, blend_state, blend_factor, sample_mask);
1055 if ((*blend_state = device->blend_state ? &device->blend_state->ID3D10BlendState_iface : NULL))
1056 ID3D10BlendState_AddRef(*blend_state);
1057 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
1058 *sample_mask = device->sample_mask;
1061 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
1062 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
1064 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1066 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
1067 iface, depth_stencil_state, stencil_ref);
1069 if ((*depth_stencil_state = device->depth_stencil_state
1070 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
1071 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1072 *stencil_ref = device->stencil_ref;
1075 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device1 *iface,
1076 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
1078 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1079 unsigned int i;
1081 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
1082 iface, buffer_count, buffers, offsets);
1084 for (i = 0; i < buffer_count; ++i)
1086 struct wined3d_buffer *wined3d_buffer;
1087 struct d3d10_buffer *buffer_impl;
1089 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
1091 buffers[i] = NULL;
1092 continue;
1095 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1096 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
1097 ID3D10Buffer_AddRef(buffers[i]);
1101 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device1 *iface, ID3D10RasterizerState **rasterizer_state)
1103 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1105 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
1107 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
1108 ID3D10RasterizerState_AddRef(*rasterizer_state);
1111 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface,
1112 UINT *viewport_count, D3D10_VIEWPORT *viewports)
1114 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1115 struct wined3d_viewport wined3d_vp;
1117 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
1119 if (!viewports)
1121 *viewport_count = 1;
1122 return;
1125 if (!*viewport_count)
1126 return;
1128 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
1130 viewports[0].TopLeftX = wined3d_vp.x;
1131 viewports[0].TopLeftY = wined3d_vp.y;
1132 viewports[0].Width = wined3d_vp.width;
1133 viewports[0].Height = wined3d_vp.height;
1134 viewports[0].MinDepth = wined3d_vp.min_z;
1135 viewports[0].MaxDepth = wined3d_vp.max_z;
1137 if (*viewport_count > 1)
1138 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
1141 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects)
1143 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1145 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
1147 if (!rects)
1149 *rect_count = 1;
1150 return;
1153 if (!*rect_count)
1154 return;
1156 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
1157 if (*rect_count > 1)
1158 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
1161 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device1 *iface)
1163 TRACE("iface %p.\n", iface);
1165 /* In the current implementation the device is never removed, so we can
1166 * just return S_OK here. */
1168 return S_OK;
1171 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device1 *iface, UINT flags)
1173 FIXME("iface %p, flags %#x stub!\n", iface, flags);
1175 return E_NOTIMPL;
1178 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device1 *iface)
1180 FIXME("iface %p stub!\n", iface);
1182 return 0;
1185 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *iface,
1186 REFGUID guid, UINT *data_size, void *data)
1188 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
1189 iface, debugstr_guid(guid), data_size, data);
1191 return E_NOTIMPL;
1194 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface,
1195 REFGUID guid, UINT data_size, const void *data)
1197 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
1198 iface, debugstr_guid(guid), data_size, data);
1200 return E_NOTIMPL;
1203 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface,
1204 REFGUID guid, const IUnknown *data)
1206 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
1208 return E_NOTIMPL;
1211 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface)
1213 FIXME("iface %p stub!\n", iface);
1216 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
1218 FIXME("iface %p stub!\n", iface);
1221 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
1222 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
1224 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1225 struct d3d10_buffer *object;
1226 HRESULT hr;
1228 FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
1230 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1231 if (!object)
1232 return E_OUTOFMEMORY;
1234 hr = d3d10_buffer_init(object, This, desc, data);
1235 if (FAILED(hr))
1237 WARN("Failed to initialize buffer, hr %#x.\n", hr);
1238 HeapFree(GetProcessHeap(), 0, object);
1239 return hr;
1242 *buffer = &object->ID3D10Buffer_iface;
1244 TRACE("Created ID3D10Buffer %p\n", object);
1246 return S_OK;
1249 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface,
1250 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
1252 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1254 return E_NOTIMPL;
1257 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface,
1258 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1259 ID3D10Texture2D **texture)
1261 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1262 struct d3d10_texture2d *object;
1263 HRESULT hr;
1265 FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
1267 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1268 if (!object)
1269 return E_OUTOFMEMORY;
1271 hr = d3d10_texture2d_init(object, This, desc);
1272 if (FAILED(hr))
1274 WARN("Failed to initialize texture, hr %#x.\n", hr);
1275 HeapFree(GetProcessHeap(), 0, object);
1276 return hr;
1279 *texture = &object->ID3D10Texture2D_iface;
1281 TRACE("Created ID3D10Texture2D %p\n", object);
1283 return S_OK;
1286 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device1 *iface,
1287 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1288 ID3D10Texture3D **texture)
1290 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1291 struct d3d10_texture3d *object;
1292 HRESULT hr;
1294 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1296 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1297 if (!object)
1298 return E_OUTOFMEMORY;
1300 hr = d3d10_texture3d_init(object, device, desc);
1301 if (FAILED(hr))
1303 WARN("Failed to initialize texture, hr %#x.\n", hr);
1304 HeapFree(GetProcessHeap(), 0, object);
1305 return hr;
1308 TRACE("Created 3D texture %p.\n", object);
1309 *texture = &object->ID3D10Texture3D_iface;
1311 return S_OK;
1314 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
1315 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
1317 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1318 struct d3d10_shader_resource_view *object;
1319 HRESULT hr;
1321 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1323 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1324 return E_OUTOFMEMORY;
1326 if (FAILED(hr = d3d10_shader_resource_view_init(object, device, resource, desc)))
1328 WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
1329 HeapFree(GetProcessHeap(), 0, object);
1330 return hr;
1333 TRACE("Created shader resource view %p.\n", object);
1334 *view = &object->ID3D10ShaderResourceView_iface;
1336 return S_OK;
1339 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device1 *iface,
1340 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
1342 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1343 struct d3d10_rendertarget_view *object;
1344 HRESULT hr;
1346 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1348 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1349 return E_OUTOFMEMORY;
1351 if (FAILED(hr = d3d10_rendertarget_view_init(object, device, resource, desc)))
1353 WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
1354 HeapFree(GetProcessHeap(), 0, object);
1355 return hr;
1358 TRACE("Created rendertarget view %p.\n", object);
1359 *view = &object->ID3D10RenderTargetView_iface;
1361 return S_OK;
1364 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device1 *iface,
1365 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
1367 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1368 struct d3d10_depthstencil_view *object;
1369 HRESULT hr;
1371 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1373 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1374 return E_OUTOFMEMORY;
1376 if (FAILED(hr = d3d10_depthstencil_view_init(object, device, resource, desc)))
1378 WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
1379 HeapFree(GetProcessHeap(), 0, object);
1380 return hr;
1383 TRACE("Created depthstencil view %p.\n", object);
1384 *view = &object->ID3D10DepthStencilView_iface;
1386 return S_OK;
1389 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *iface,
1390 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
1391 const void *shader_byte_code, SIZE_T shader_byte_code_length,
1392 ID3D10InputLayout **input_layout)
1394 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1395 struct d3d10_input_layout *object;
1396 HRESULT hr;
1398 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
1399 "\tshader_byte_code_length %lu, input_layout %p\n",
1400 iface, element_descs, element_count, shader_byte_code,
1401 shader_byte_code_length, input_layout);
1403 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1404 if (!object)
1405 return E_OUTOFMEMORY;
1407 hr = d3d10_input_layout_init(object, This, element_descs, element_count,
1408 shader_byte_code, shader_byte_code_length);
1409 if (FAILED(hr))
1411 WARN("Failed to initialize input layout, hr %#x.\n", hr);
1412 HeapFree(GetProcessHeap(), 0, object);
1413 return hr;
1416 TRACE("Created input layout %p.\n", object);
1417 *input_layout = &object->ID3D10InputLayout_iface;
1419 return S_OK;
1422 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device1 *iface,
1423 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
1425 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1426 struct d3d10_vertex_shader *object;
1427 HRESULT hr;
1429 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1430 iface, byte_code, byte_code_length, shader);
1432 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1433 if (!object)
1434 return E_OUTOFMEMORY;
1436 hr = d3d10_vertex_shader_init(object, This, byte_code, byte_code_length);
1437 if (FAILED(hr))
1439 WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
1440 HeapFree(GetProcessHeap(), 0, object);
1441 return hr;
1444 TRACE("Created vertex shader %p.\n", object);
1445 *shader = &object->ID3D10VertexShader_iface;
1447 return S_OK;
1450 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device1 *iface,
1451 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
1453 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1454 struct d3d10_geometry_shader *object;
1455 HRESULT hr;
1457 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
1458 iface, byte_code, byte_code_length, shader);
1460 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1461 if (!object)
1462 return E_OUTOFMEMORY;
1464 hr = d3d10_geometry_shader_init(object, This, byte_code, byte_code_length);
1465 if (FAILED(hr))
1467 WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
1468 HeapFree(GetProcessHeap(), 0, object);
1469 return hr;
1472 TRACE("Created geometry shader %p.\n", object);
1473 *shader = &object->ID3D10GeometryShader_iface;
1475 return S_OK;
1478 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1 *iface,
1479 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
1480 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
1482 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p,\n"
1483 "\toutput_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
1484 iface, byte_code, byte_code_length, output_stream_decls,
1485 output_stream_decl_count, output_stream_stride, shader);
1487 return E_NOTIMPL;
1490 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device1 *iface,
1491 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
1493 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1494 struct d3d10_pixel_shader *object;
1495 HRESULT hr;
1497 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1498 iface, byte_code, byte_code_length, shader);
1500 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1501 if (!object)
1502 return E_OUTOFMEMORY;
1504 hr = d3d10_pixel_shader_init(object, This, byte_code, byte_code_length);
1505 if (FAILED(hr))
1507 WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
1508 HeapFree(GetProcessHeap(), 0, object);
1509 return hr;
1512 TRACE("Created pixel shader %p.\n", object);
1513 *shader = &object->ID3D10PixelShader_iface;
1515 return S_OK;
1518 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device1 *iface,
1519 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1521 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1522 struct d3d10_blend_state *object;
1523 struct wine_rb_entry *entry;
1524 HRESULT hr;
1526 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
1528 if (!desc)
1529 return E_INVALIDARG;
1531 if ((entry = wine_rb_get(&device->blend_states, desc)))
1533 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_blend_state, entry);
1535 TRACE("Returning existing blend state %p.\n", object);
1536 *blend_state = &object->ID3D10BlendState_iface;
1537 ID3D10BlendState_AddRef(*blend_state);
1539 return S_OK;
1542 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1543 if (!object)
1544 return E_OUTOFMEMORY;
1546 if (FAILED(hr = d3d10_blend_state_init(object, device, desc)))
1548 WARN("Failed to initialize blend state, hr %#x.\n", hr);
1549 HeapFree(GetProcessHeap(), 0, object);
1550 return hr;
1553 TRACE("Created blend state %p.\n", object);
1554 *blend_state = &object->ID3D10BlendState_iface;
1556 return S_OK;
1559 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device1 *iface,
1560 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1562 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1563 struct d3d10_depthstencil_state *object;
1564 struct wine_rb_entry *entry;
1565 HRESULT hr;
1567 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
1569 if (!desc)
1570 return E_INVALIDARG;
1572 if ((entry = wine_rb_get(&device->depthstencil_states, desc)))
1574 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_depthstencil_state, entry);
1576 TRACE("Returning existing depthstencil state %p.\n", object);
1577 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1578 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1580 return S_OK;
1583 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1584 if (!object)
1585 return E_OUTOFMEMORY;
1587 if (FAILED(hr = d3d10_depthstencil_state_init(object, device, desc)))
1589 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1590 HeapFree(GetProcessHeap(), 0, object);
1591 return hr;
1594 TRACE("Created depthstencil state %p.\n", object);
1595 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1597 return S_OK;
1600 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device1 *iface,
1601 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1603 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1604 struct d3d10_rasterizer_state *object;
1605 struct wine_rb_entry *entry;
1606 HRESULT hr;
1608 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1610 if (!desc)
1611 return E_INVALIDARG;
1613 if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
1615 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_rasterizer_state, entry);
1617 TRACE("Returning existing rasterizer state %p.\n", object);
1618 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1619 ID3D10RasterizerState_AddRef(*rasterizer_state);
1621 return S_OK;
1625 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1626 if (!object)
1627 return E_OUTOFMEMORY;
1629 if (FAILED(hr = d3d10_rasterizer_state_init(object, device, desc)))
1631 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1632 HeapFree(GetProcessHeap(), 0, object);
1633 return hr;
1636 TRACE("Created rasterizer state %p.\n", object);
1637 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1639 return S_OK;
1642 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
1643 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1645 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1646 struct d3d10_sampler_state *object;
1647 struct wine_rb_entry *entry;
1648 HRESULT hr;
1650 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
1652 if (!desc)
1653 return E_INVALIDARG;
1655 if ((entry = wine_rb_get(&device->sampler_states, desc)))
1657 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_sampler_state, entry);
1659 TRACE("Returning existing sampler state %p.\n", object);
1660 *sampler_state = &object->ID3D10SamplerState_iface;
1661 ID3D10SamplerState_AddRef(*sampler_state);
1663 return S_OK;
1666 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1667 if (!object)
1668 return E_OUTOFMEMORY;
1670 if (FAILED(hr = d3d10_sampler_state_init(object, device, desc)))
1672 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
1673 HeapFree(GetProcessHeap(), 0, object);
1674 return hr;
1677 TRACE("Created sampler state %p.\n", object);
1678 *sampler_state = &object->ID3D10SamplerState_iface;
1680 return S_OK;
1683 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
1684 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1686 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1687 struct d3d10_query *object;
1688 HRESULT hr;
1690 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
1692 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1693 return E_OUTOFMEMORY;
1695 if (FAILED(hr = d3d10_query_init(object, device, FALSE)))
1697 WARN("Failed to initialize query, hr %#x.\n", hr);
1698 HeapFree(GetProcessHeap(), 0, object);
1699 return hr;
1702 TRACE("Created query %p.\n", object);
1703 *query = &object->ID3D10Query_iface;
1705 return S_OK;
1708 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *iface,
1709 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1711 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1712 struct d3d10_query *object;
1713 HRESULT hr;
1715 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
1717 if (!desc)
1718 return E_INVALIDARG;
1720 if (desc->Query != D3D10_QUERY_OCCLUSION_PREDICATE && desc->Query != D3D10_QUERY_SO_OVERFLOW_PREDICATE)
1722 WARN("Query type %#x is not a predicate.\n", desc->Query);
1723 return E_INVALIDARG;
1726 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1727 return E_OUTOFMEMORY;
1729 if (FAILED(hr = d3d10_query_init(object, device, TRUE)))
1731 WARN("Failed to initialize predicate, hr %#x.\n", hr);
1732 HeapFree(GetProcessHeap(), 0, object);
1733 return hr;
1736 TRACE("Created predicate %p.\n", object);
1737 *predicate = (ID3D10Predicate *)&object->ID3D10Query_iface;
1739 return S_OK;
1742 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device1 *iface,
1743 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1745 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1747 return E_NOTIMPL;
1750 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 *iface,
1751 DXGI_FORMAT format, UINT *format_support)
1753 FIXME("iface %p, format %s, format_support %p stub!\n",
1754 iface, debug_dxgi_format(format), format_support);
1756 return E_NOTIMPL;
1759 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface,
1760 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1762 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1763 iface, debug_dxgi_format(format), sample_count, quality_level_count);
1765 return E_NOTIMPL;
1768 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device1 *iface, D3D10_COUNTER_INFO *counter_info)
1770 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1773 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device1 *iface,
1774 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, char *name,
1775 UINT *name_length, char *units, UINT *units_length, char *description, UINT *description_length)
1777 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1778 "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1779 iface, desc, type, active_counters, name, name_length,
1780 units, units_length, description, description_length);
1782 return E_NOTIMPL;
1785 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device1 *iface)
1787 FIXME("iface %p stub!\n", iface);
1789 return 0;
1792 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device1 *iface,
1793 HANDLE resource_handle, REFIID guid, void **resource)
1795 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1796 iface, resource_handle, debugstr_guid(guid), resource);
1798 return E_NOTIMPL;
1801 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device1 *iface, UINT width, UINT height)
1803 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1806 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device1 *iface, UINT *width, UINT *height)
1808 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1811 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView1(ID3D10Device1 *iface,
1812 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc, ID3D10ShaderResourceView1 **view)
1814 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1816 return E_NOTIMPL;
1819 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState1(ID3D10Device1 *iface,
1820 const D3D10_BLEND_DESC1 *desc, ID3D10BlendState1 **blend_state)
1822 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface, desc, blend_state);
1824 return E_NOTIMPL;
1827 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE d3d10_device_GetFeatureLevel(ID3D10Device1 *iface)
1829 FIXME("iface %p stub!\n", iface);
1831 return D3D10_FEATURE_LEVEL_10_1;
1834 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl =
1836 /* IUnknown methods */
1837 d3d10_device_QueryInterface,
1838 d3d10_device_AddRef,
1839 d3d10_device_Release,
1840 /* ID3D10Device methods */
1841 d3d10_device_VSSetConstantBuffers,
1842 d3d10_device_PSSetShaderResources,
1843 d3d10_device_PSSetShader,
1844 d3d10_device_PSSetSamplers,
1845 d3d10_device_VSSetShader,
1846 d3d10_device_DrawIndexed,
1847 d3d10_device_Draw,
1848 d3d10_device_PSSetConstantBuffers,
1849 d3d10_device_IASetInputLayout,
1850 d3d10_device_IASetVertexBuffers,
1851 d3d10_device_IASetIndexBuffer,
1852 d3d10_device_DrawIndexedInstanced,
1853 d3d10_device_DrawInstanced,
1854 d3d10_device_GSSetConstantBuffers,
1855 d3d10_device_GSSetShader,
1856 d3d10_device_IASetPrimitiveTopology,
1857 d3d10_device_VSSetShaderResources,
1858 d3d10_device_VSSetSamplers,
1859 d3d10_device_SetPredication,
1860 d3d10_device_GSSetShaderResources,
1861 d3d10_device_GSSetSamplers,
1862 d3d10_device_OMSetRenderTargets,
1863 d3d10_device_OMSetBlendState,
1864 d3d10_device_OMSetDepthStencilState,
1865 d3d10_device_SOSetTargets,
1866 d3d10_device_DrawAuto,
1867 d3d10_device_RSSetState,
1868 d3d10_device_RSSetViewports,
1869 d3d10_device_RSSetScissorRects,
1870 d3d10_device_CopySubresourceRegion,
1871 d3d10_device_CopyResource,
1872 d3d10_device_UpdateSubresource,
1873 d3d10_device_ClearRenderTargetView,
1874 d3d10_device_ClearDepthStencilView,
1875 d3d10_device_GenerateMips,
1876 d3d10_device_ResolveSubresource,
1877 d3d10_device_VSGetConstantBuffers,
1878 d3d10_device_PSGetShaderResources,
1879 d3d10_device_PSGetShader,
1880 d3d10_device_PSGetSamplers,
1881 d3d10_device_VSGetShader,
1882 d3d10_device_PSGetConstantBuffers,
1883 d3d10_device_IAGetInputLayout,
1884 d3d10_device_IAGetVertexBuffers,
1885 d3d10_device_IAGetIndexBuffer,
1886 d3d10_device_GSGetConstantBuffers,
1887 d3d10_device_GSGetShader,
1888 d3d10_device_IAGetPrimitiveTopology,
1889 d3d10_device_VSGetShaderResources,
1890 d3d10_device_VSGetSamplers,
1891 d3d10_device_GetPredication,
1892 d3d10_device_GSGetShaderResources,
1893 d3d10_device_GSGetSamplers,
1894 d3d10_device_OMGetRenderTargets,
1895 d3d10_device_OMGetBlendState,
1896 d3d10_device_OMGetDepthStencilState,
1897 d3d10_device_SOGetTargets,
1898 d3d10_device_RSGetState,
1899 d3d10_device_RSGetViewports,
1900 d3d10_device_RSGetScissorRects,
1901 d3d10_device_GetDeviceRemovedReason,
1902 d3d10_device_SetExceptionMode,
1903 d3d10_device_GetExceptionMode,
1904 d3d10_device_GetPrivateData,
1905 d3d10_device_SetPrivateData,
1906 d3d10_device_SetPrivateDataInterface,
1907 d3d10_device_ClearState,
1908 d3d10_device_Flush,
1909 d3d10_device_CreateBuffer,
1910 d3d10_device_CreateTexture1D,
1911 d3d10_device_CreateTexture2D,
1912 d3d10_device_CreateTexture3D,
1913 d3d10_device_CreateShaderResourceView,
1914 d3d10_device_CreateRenderTargetView,
1915 d3d10_device_CreateDepthStencilView,
1916 d3d10_device_CreateInputLayout,
1917 d3d10_device_CreateVertexShader,
1918 d3d10_device_CreateGeometryShader,
1919 d3d10_device_CreateGeometryShaderWithStreamOutput,
1920 d3d10_device_CreatePixelShader,
1921 d3d10_device_CreateBlendState,
1922 d3d10_device_CreateDepthStencilState,
1923 d3d10_device_CreateRasterizerState,
1924 d3d10_device_CreateSamplerState,
1925 d3d10_device_CreateQuery,
1926 d3d10_device_CreatePredicate,
1927 d3d10_device_CreateCounter,
1928 d3d10_device_CheckFormatSupport,
1929 d3d10_device_CheckMultisampleQualityLevels,
1930 d3d10_device_CheckCounterInfo,
1931 d3d10_device_CheckCounter,
1932 d3d10_device_GetCreationFlags,
1933 d3d10_device_OpenSharedResource,
1934 d3d10_device_SetTextFilterSize,
1935 d3d10_device_GetTextFilterSize,
1936 d3d10_device_CreateShaderResourceView1,
1937 d3d10_device_CreateBlendState1,
1938 d3d10_device_GetFeatureLevel,
1941 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1943 /* IUnknown methods */
1944 d3d10_device_inner_QueryInterface,
1945 d3d10_device_inner_AddRef,
1946 d3d10_device_inner_Release,
1949 static inline struct d3d10_device *impl_from_ID3D10Multithread(ID3D10Multithread *iface)
1951 return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Multithread_iface);
1954 static HRESULT STDMETHODCALLTYPE d3d10_multithread_QueryInterface(ID3D10Multithread *iface, REFIID iid, void **out)
1956 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1958 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
1960 return IUnknown_QueryInterface(device->outer_unk, iid, out);
1963 static ULONG STDMETHODCALLTYPE d3d10_multithread_AddRef(ID3D10Multithread *iface)
1965 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1967 TRACE("iface %p.\n", iface);
1969 return IUnknown_AddRef(device->outer_unk);
1972 static ULONG STDMETHODCALLTYPE d3d10_multithread_Release(ID3D10Multithread *iface)
1974 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1976 TRACE("iface %p.\n", iface);
1978 return IUnknown_Release(device->outer_unk);
1981 static void STDMETHODCALLTYPE d3d10_multithread_Enter(ID3D10Multithread *iface)
1983 TRACE("iface %p.\n", iface);
1985 wined3d_mutex_lock();
1988 static void STDMETHODCALLTYPE d3d10_multithread_Leave(ID3D10Multithread *iface)
1990 TRACE("iface %p.\n", iface);
1992 wined3d_mutex_unlock();
1995 static BOOL STDMETHODCALLTYPE d3d10_multithread_SetMultithreadProtected(ID3D10Multithread *iface, BOOL protect)
1997 FIXME("iface %p, protect %#x stub!\n", iface, protect);
1999 return TRUE;
2002 static BOOL STDMETHODCALLTYPE d3d10_multithread_GetMultithreadProtected(ID3D10Multithread *iface)
2004 FIXME("iface %p stub!\n", iface);
2006 return TRUE;
2009 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl =
2011 d3d10_multithread_QueryInterface,
2012 d3d10_multithread_AddRef,
2013 d3d10_multithread_Release,
2014 d3d10_multithread_Enter,
2015 d3d10_multithread_Leave,
2016 d3d10_multithread_SetMultithreadProtected,
2017 d3d10_multithread_GetMultithreadProtected,
2020 static void STDMETHODCALLTYPE d3d10_subresource_destroyed(void *parent) {}
2022 static const struct wined3d_parent_ops d3d10_subresource_parent_ops =
2024 d3d10_subresource_destroyed,
2027 /* IWineDXGIDeviceParent IUnknown methods */
2029 static inline struct d3d10_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
2031 return CONTAINING_RECORD(iface, struct d3d10_device, IWineDXGIDeviceParent_iface);
2034 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
2035 REFIID riid, void **ppv)
2037 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2038 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
2041 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
2043 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2044 return IUnknown_AddRef(device->outer_unk);
2047 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
2049 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2050 return IUnknown_Release(device->outer_unk);
2053 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
2054 IWineDXGIDeviceParent *iface)
2056 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2057 return &device->device_parent;
2060 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl =
2062 /* IUnknown methods */
2063 dxgi_device_parent_QueryInterface,
2064 dxgi_device_parent_AddRef,
2065 dxgi_device_parent_Release,
2066 /* IWineDXGIDeviceParent methods */
2067 dxgi_device_parent_get_wined3d_device_parent,
2070 static inline struct d3d10_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
2072 return CONTAINING_RECORD(device_parent, struct d3d10_device, device_parent);
2075 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
2076 struct wined3d_device *wined3d_device)
2078 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2080 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
2082 wined3d_device_incref(wined3d_device);
2083 device->wined3d_device = wined3d_device;
2086 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
2088 TRACE("device_parent %p.\n", device_parent);
2091 static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate)
2093 TRACE("device_parent %p, activate %#x.\n", device_parent, activate);
2096 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
2097 void *container_parent, struct wined3d_surface *surface, void **parent,
2098 const struct wined3d_parent_ops **parent_ops)
2100 TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
2101 device_parent, container_parent, surface, parent, parent_ops);
2103 *parent = container_parent;
2104 *parent_ops = &d3d10_null_wined3d_parent_ops;
2106 return S_OK;
2109 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
2110 void *container_parent, struct wined3d_volume *volume, void **parent,
2111 const struct wined3d_parent_ops **parent_ops)
2113 TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
2114 device_parent, container_parent, volume, parent, parent_ops);
2116 *parent = container_parent;
2117 *parent_ops = &d3d10_null_wined3d_parent_ops;
2119 return S_OK;
2122 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
2123 void *container_parent, const struct wined3d_resource_desc *wined3d_desc, struct wined3d_surface **surface)
2125 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2126 struct wined3d_resource *sub_resource;
2127 struct d3d10_texture2d *texture;
2128 D3D10_TEXTURE2D_DESC desc;
2129 HRESULT hr;
2131 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, surface %p partial stub!\n",
2132 device_parent, container_parent, wined3d_desc, surface);
2134 FIXME("Implement DXGI<->wined3d usage conversion\n");
2136 desc.Width = wined3d_desc->width;
2137 desc.Height = wined3d_desc->height;
2138 desc.MipLevels = 1;
2139 desc.ArraySize = 1;
2140 desc.Format = dxgi_format_from_wined3dformat(wined3d_desc->format);
2141 desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1;
2142 desc.SampleDesc.Quality = wined3d_desc->multisample_quality;
2143 desc.Usage = D3D10_USAGE_DEFAULT;
2144 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
2145 desc.CPUAccessFlags = 0;
2146 desc.MiscFlags = 0;
2148 if (FAILED(hr = d3d10_device_CreateTexture2D(&device->ID3D10Device1_iface,
2149 &desc, NULL, (ID3D10Texture2D **)&texture)))
2151 ERR("CreateTexture2D failed, returning %#x\n", hr);
2152 return hr;
2155 sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
2156 *surface = wined3d_surface_from_resource(sub_resource);
2157 wined3d_surface_incref(*surface);
2158 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
2160 return S_OK;
2163 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
2164 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
2166 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2167 IWineDXGIDevice *wine_device;
2168 HRESULT hr;
2170 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain);
2172 if (FAILED(hr = d3d10_device_QueryInterface(&device->ID3D10Device1_iface,
2173 &IID_IWineDXGIDevice, (void **)&wine_device)))
2175 ERR("Device should implement IWineDXGIDevice.\n");
2176 return E_FAIL;
2179 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
2180 IWineDXGIDevice_Release(wine_device);
2181 if (FAILED(hr))
2183 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
2184 return hr;
2187 return S_OK;
2190 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
2192 device_parent_wined3d_device_created,
2193 device_parent_mode_changed,
2194 device_parent_activate,
2195 device_parent_surface_created,
2196 device_parent_volume_created,
2197 device_parent_create_swapchain_surface,
2198 device_parent_create_swapchain,
2201 static void *d3d10_rb_alloc(size_t size)
2203 return HeapAlloc(GetProcessHeap(), 0, size);
2206 static void *d3d10_rb_realloc(void *ptr, size_t size)
2208 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
2211 static void d3d10_rb_free(void *ptr)
2213 HeapFree(GetProcessHeap(), 0, ptr);
2216 static int d3d10_sampler_state_compare(const void *key, const struct wine_rb_entry *entry)
2218 const D3D10_SAMPLER_DESC *ka = key;
2219 const D3D10_SAMPLER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_sampler_state, entry)->desc;
2221 return memcmp(ka, kb, sizeof(*ka));
2224 static const struct wine_rb_functions d3d10_sampler_state_rb_ops =
2226 d3d10_rb_alloc,
2227 d3d10_rb_realloc,
2228 d3d10_rb_free,
2229 d3d10_sampler_state_compare,
2232 static int d3d10_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
2234 const D3D10_BLEND_DESC *ka = key;
2235 const D3D10_BLEND_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_blend_state, entry)->desc;
2237 return memcmp(ka, kb, sizeof(*ka));
2240 static const struct wine_rb_functions d3d10_blend_state_rb_ops =
2242 d3d10_rb_alloc,
2243 d3d10_rb_realloc,
2244 d3d10_rb_free,
2245 d3d10_blend_state_compare,
2248 static int d3d10_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
2250 const D3D10_DEPTH_STENCIL_DESC *ka = key;
2251 const D3D10_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
2252 const struct d3d10_depthstencil_state, entry)->desc;
2254 return memcmp(ka, kb, sizeof(*ka));
2257 static const struct wine_rb_functions d3d10_depthstencil_state_rb_ops =
2259 d3d10_rb_alloc,
2260 d3d10_rb_realloc,
2261 d3d10_rb_free,
2262 d3d10_depthstencil_state_compare,
2265 static int d3d10_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
2267 const D3D10_RASTERIZER_DESC *ka = key;
2268 const D3D10_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_rasterizer_state, entry)->desc;
2270 return memcmp(ka, kb, sizeof(*ka));
2273 static const struct wine_rb_functions d3d10_rasterizer_state_rb_ops =
2275 d3d10_rb_alloc,
2276 d3d10_rb_realloc,
2277 d3d10_rb_free,
2278 d3d10_rasterizer_state_compare,
2281 HRESULT d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
2283 device->IUnknown_inner.lpVtbl = &d3d10_device_inner_unknown_vtbl;
2284 device->ID3D10Device1_iface.lpVtbl = &d3d10_device1_vtbl;
2285 device->ID3D10Multithread_iface.lpVtbl = &d3d10_multithread_vtbl;
2286 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d10_dxgi_device_parent_vtbl;
2287 device->device_parent.ops = &d3d10_wined3d_device_parent_ops;
2288 device->refcount = 1;
2289 /* COM aggregation always takes place */
2290 device->outer_unk = outer_unknown;
2292 if (wine_rb_init(&device->blend_states, &d3d10_blend_state_rb_ops) == -1)
2294 WARN("Failed to initialize blend state rbtree.\n");
2295 return E_FAIL;
2298 if (wine_rb_init(&device->depthstencil_states, &d3d10_depthstencil_state_rb_ops) == -1)
2300 WARN("Failed to initialize depthstencil state rbtree.\n");
2301 wine_rb_destroy(&device->blend_states, NULL, NULL);
2302 return E_FAIL;
2305 if (wine_rb_init(&device->rasterizer_states, &d3d10_rasterizer_state_rb_ops) == -1)
2307 WARN("Failed to initialize rasterizer state rbtree.\n");
2308 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2309 wine_rb_destroy(&device->blend_states, NULL, NULL);
2310 return E_FAIL;
2313 if (wine_rb_init(&device->sampler_states, &d3d10_sampler_state_rb_ops) == -1)
2315 WARN("Failed to initialize sampler state rbtree.\n");
2316 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
2317 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2318 wine_rb_destroy(&device->blend_states, NULL, NULL);
2319 return E_FAIL;
2322 return S_OK;