d3d10core: Implement d3d10_device_VSSetShaderResources().
[wine.git] / dlls / d3d10core / device.c
blob89c0bba1be4d44ca5a03f99d18e463e67956cd52
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 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
384 iface, start_slot, view_count, views);
387 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device1 *iface,
388 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
390 struct d3d10_device *device = impl_from_ID3D10Device(iface);
391 unsigned int i;
393 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
394 iface, start_slot, sampler_count, samplers);
396 for (i = 0; i < sampler_count; ++i)
398 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
400 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
401 sampler ? sampler->wined3d_sampler : NULL);
405 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device1 *iface,
406 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
407 ID3D10DepthStencilView *depth_stencil_view)
409 struct d3d10_device *device = impl_from_ID3D10Device(iface);
410 struct d3d10_depthstencil_view *dsv;
411 unsigned int i;
413 TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n",
414 iface, render_target_view_count, render_target_views, depth_stencil_view);
416 for (i = 0; i < render_target_view_count; ++i)
418 struct d3d10_rendertarget_view *rtv = unsafe_impl_from_ID3D10RenderTargetView(render_target_views[i]);
420 wined3d_device_set_rendertarget_view(device->wined3d_device, i,
421 rtv ? rtv->wined3d_view : NULL, FALSE);
423 for (; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
425 wined3d_device_set_rendertarget_view(device->wined3d_device, i, NULL, FALSE);
428 dsv = unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view);
429 wined3d_device_set_depth_stencil_view(device->wined3d_device,
430 dsv ? dsv->wined3d_view : NULL);
433 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface,
434 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
436 struct d3d10_device *device = impl_from_ID3D10Device(iface);
438 TRACE("iface %p, blend_state %p, blend_factor [%f %f %f %f], sample_mask 0x%08x.\n",
439 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
441 device->blend_state = unsafe_impl_from_ID3D10BlendState(blend_state);
442 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
443 device->sample_mask = sample_mask;
446 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1 *iface,
447 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
449 struct d3d10_device *device = impl_from_ID3D10Device(iface);
451 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
452 iface, depth_stencil_state, stencil_ref);
454 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
455 device->stencil_ref = stencil_ref;
458 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface,
459 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
461 struct d3d10_device *device = impl_from_ID3D10Device(iface);
462 unsigned int count, i;
464 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
466 count = min(target_count, 4);
467 for (i = 0; i < count; ++i)
469 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
471 wined3d_device_set_stream_output(device->wined3d_device, i,
472 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
475 for (i = count; i < 4; ++i)
477 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
481 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device1 *iface)
483 FIXME("iface %p stub!\n", iface);
486 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device1 *iface, ID3D10RasterizerState *rasterizer_state)
488 struct d3d10_device *device = impl_from_ID3D10Device(iface);
489 const D3D10_RASTERIZER_DESC *desc;
491 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
493 if (!(device->rasterizer_state = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state)))
495 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, WINED3D_FILL_SOLID);
496 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, WINED3D_CULL_CCW);
497 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE);
498 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE);
499 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ANTIALIASEDLINEENABLE, FALSE);
500 return;
503 desc = &device->rasterizer_state->desc;
504 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, desc->FillMode);
505 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, desc->CullMode);
506 /* glFrontFace() */
507 if (desc->FrontCounterClockwise)
508 FIXME("Ignoring FrontCounterClockwise %#x.\n", desc->FrontCounterClockwise);
509 /* OpenGL style depth bias. */
510 if (desc->DepthBias || desc->SlopeScaledDepthBias)
511 FIXME("Ignoring depth bias.\n");
512 /* GL_DEPTH_CLAMP */
513 if (!desc->DepthClipEnable)
514 FIXME("Ignoring DepthClipEnable %#x.\n", desc->DepthClipEnable);
515 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable);
516 wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable);
517 wined3d_device_set_render_state(device->wined3d_device,
518 WINED3D_RS_ANTIALIASEDLINEENABLE, desc->AntialiasedLineEnable);
521 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface,
522 UINT viewport_count, const D3D10_VIEWPORT *viewports)
524 struct d3d10_device *device = impl_from_ID3D10Device(iface);
525 struct wined3d_viewport wined3d_vp;
527 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
529 if (viewport_count > 1)
530 FIXME("Multiple viewports not implemented.\n");
532 if (!viewport_count)
533 return;
535 wined3d_vp.x = viewports[0].TopLeftX;
536 wined3d_vp.y = viewports[0].TopLeftY;
537 wined3d_vp.width = viewports[0].Width;
538 wined3d_vp.height = viewports[0].Height;
539 wined3d_vp.min_z = viewports[0].MinDepth;
540 wined3d_vp.max_z = viewports[0].MaxDepth;
542 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
545 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *iface,
546 UINT rect_count, const D3D10_RECT *rects)
548 struct d3d10_device *device = impl_from_ID3D10Device(iface);
550 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
552 if (rect_count > 1)
553 FIXME("Multiple scissor rects not implemented.\n");
555 if (!rect_count)
556 return;
558 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
561 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *iface,
562 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
563 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
565 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u,\n"
566 "\tsrc_resource %p, src_subresource_idx %u, src_box %p stub!\n",
567 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
568 src_resource, src_subresource_idx, src_box);
571 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,
572 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
574 struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
575 struct d3d10_device *device = impl_from_ID3D10Device(iface);
577 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
579 wined3d_dst_resource = wined3d_resource_from_resource(dst_resource);
580 wined3d_src_resource = wined3d_resource_from_resource(src_resource);
581 wined3d_device_copy_resource(device->wined3d_device, wined3d_dst_resource, wined3d_src_resource);
584 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface,
585 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
586 const void *data, UINT row_pitch, UINT depth_pitch)
588 FIXME("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
589 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
592 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 *iface,
593 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
595 struct d3d10_device *device = impl_from_ID3D10Device(iface);
596 struct d3d10_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
597 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
598 HRESULT hr;
600 TRACE("iface %p, render_target_view %p, color_rgba {%.8e, %.8e, %.8e, %.8e}.\n",
601 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
603 if (FAILED(hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, view->wined3d_view, NULL, &color)))
604 ERR("Failed to clear view, hr %#x.\n", hr);
607 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *iface,
608 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
610 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
611 iface, depth_stencil_view, flags, depth, stencil);
614 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
615 ID3D10ShaderResourceView *shader_resource_view)
617 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
620 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *iface,
621 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
622 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
624 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u,\n"
625 "\tsrc_resource %p, src_subresource_idx %u, format %s stub!\n",
626 iface, dst_resource, dst_subresource_idx,
627 src_resource, src_subresource_idx, debug_dxgi_format(format));
630 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device1 *iface,
631 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
633 struct d3d10_device *device = impl_from_ID3D10Device(iface);
634 unsigned int i;
636 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
637 iface, start_slot, buffer_count, buffers);
639 for (i = 0; i < buffer_count; ++i)
641 struct wined3d_buffer *wined3d_buffer;
642 struct d3d10_buffer *buffer_impl;
644 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
646 buffers[i] = NULL;
647 continue;
650 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
651 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
652 ID3D10Buffer_AddRef(buffers[i]);
656 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device1 *iface,
657 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
659 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
660 iface, start_slot, view_count, views);
663 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device1 *iface, ID3D10PixelShader **shader)
665 struct d3d10_device *device = impl_from_ID3D10Device(iface);
666 struct d3d10_pixel_shader *shader_impl;
667 struct wined3d_shader *wined3d_shader;
669 TRACE("iface %p, shader %p.\n", iface, shader);
671 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
673 *shader = NULL;
674 return;
677 shader_impl = wined3d_shader_get_parent(wined3d_shader);
678 *shader = &shader_impl->ID3D10PixelShader_iface;
679 ID3D10PixelShader_AddRef(*shader);
682 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device1 *iface,
683 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
685 struct d3d10_device *device = impl_from_ID3D10Device(iface);
686 unsigned int i;
688 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
689 iface, start_slot, sampler_count, samplers);
691 for (i = 0; i < sampler_count; ++i)
693 struct d3d10_sampler_state *sampler_impl;
694 struct wined3d_sampler *wined3d_sampler;
696 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
698 samplers[i] = NULL;
699 continue;
702 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
703 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
704 ID3D10SamplerState_AddRef(samplers[i]);
708 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device1 *iface, ID3D10VertexShader **shader)
710 struct d3d10_device *device = impl_from_ID3D10Device(iface);
711 struct d3d10_vertex_shader *shader_impl;
712 struct wined3d_shader *wined3d_shader;
714 TRACE("iface %p, shader %p.\n", iface, shader);
716 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
718 *shader = NULL;
719 return;
722 shader_impl = wined3d_shader_get_parent(wined3d_shader);
723 *shader = &shader_impl->ID3D10VertexShader_iface;
724 ID3D10VertexShader_AddRef(*shader);
727 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device1 *iface,
728 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
730 struct d3d10_device *device = impl_from_ID3D10Device(iface);
731 unsigned int i;
733 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
734 iface, start_slot, buffer_count, buffers);
736 for (i = 0; i < buffer_count; ++i)
738 struct wined3d_buffer *wined3d_buffer;
739 struct d3d10_buffer *buffer_impl;
741 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
743 buffers[i] = NULL;
744 continue;
747 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
748 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
749 ID3D10Buffer_AddRef(buffers[i]);
753 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device1 *iface, ID3D10InputLayout **input_layout)
755 struct d3d10_device *device = impl_from_ID3D10Device(iface);
756 struct wined3d_vertex_declaration *wined3d_declaration;
757 struct d3d10_input_layout *input_layout_impl;
759 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
761 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
763 *input_layout = NULL;
764 return;
767 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
768 *input_layout = &input_layout_impl->ID3D10InputLayout_iface;
769 ID3D10InputLayout_AddRef(*input_layout);
772 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device1 *iface,
773 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
775 struct d3d10_device *device = impl_from_ID3D10Device(iface);
776 unsigned int i;
778 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
779 iface, start_slot, buffer_count, buffers, strides, offsets);
781 for (i = 0; i < buffer_count; ++i)
783 struct wined3d_buffer *wined3d_buffer;
784 struct d3d10_buffer *buffer_impl;
786 if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
787 &wined3d_buffer, &offsets[i], &strides[i])))
788 ERR("Failed to get vertex buffer.\n");
790 if (!wined3d_buffer)
792 buffers[i] = NULL;
793 continue;
796 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
797 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
798 ID3D10Buffer_AddRef(buffers[i]);
802 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device1 *iface,
803 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
805 struct d3d10_device *device = impl_from_ID3D10Device(iface);
806 enum wined3d_format_id wined3d_format;
807 struct wined3d_buffer *wined3d_buffer;
808 struct d3d10_buffer *buffer_impl;
810 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
812 wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
813 *format = dxgi_format_from_wined3dformat(wined3d_format);
814 *offset = 0; /* FIXME */
815 if (!wined3d_buffer)
817 *buffer = NULL;
818 return;
821 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
822 *buffer = &buffer_impl->ID3D10Buffer_iface;
823 ID3D10Buffer_AddRef(*buffer);
826 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device1 *iface,
827 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
829 struct d3d10_device *device = impl_from_ID3D10Device(iface);
830 unsigned int i;
832 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
833 iface, start_slot, buffer_count, buffers);
835 for (i = 0; i < buffer_count; ++i)
837 struct wined3d_buffer *wined3d_buffer;
838 struct d3d10_buffer *buffer_impl;
840 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
842 buffers[i] = NULL;
843 continue;
846 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
847 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
848 ID3D10Buffer_AddRef(buffers[i]);
852 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device1 *iface, ID3D10GeometryShader **shader)
854 struct d3d10_device *device = impl_from_ID3D10Device(iface);
855 struct d3d10_geometry_shader *shader_impl;
856 struct wined3d_shader *wined3d_shader;
858 TRACE("iface %p, shader %p.\n", iface, shader);
860 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
862 *shader = NULL;
863 return;
866 shader_impl = wined3d_shader_get_parent(wined3d_shader);
867 *shader = &shader_impl->ID3D10GeometryShader_iface;
868 ID3D10GeometryShader_AddRef(*shader);
871 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device1 *iface,
872 D3D10_PRIMITIVE_TOPOLOGY *topology)
874 struct d3d10_device *This = impl_from_ID3D10Device(iface);
876 TRACE("iface %p, topology %p\n", iface, topology);
878 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
881 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device1 *iface,
882 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
884 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
885 iface, start_slot, view_count, views);
888 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device1 *iface,
889 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
891 struct d3d10_device *device = impl_from_ID3D10Device(iface);
892 unsigned int i;
894 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
895 iface, start_slot, sampler_count, samplers);
897 for (i = 0; i < sampler_count; ++i)
899 struct d3d10_sampler_state *sampler_impl;
900 struct wined3d_sampler *wined3d_sampler;
902 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
904 samplers[i] = NULL;
905 continue;
908 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
909 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
910 ID3D10SamplerState_AddRef(samplers[i]);
914 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device1 *iface,
915 ID3D10Predicate **predicate, BOOL *value)
917 FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
920 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device1 *iface,
921 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
923 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
924 iface, start_slot, view_count, views);
927 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device1 *iface,
928 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
930 struct d3d10_device *device = impl_from_ID3D10Device(iface);
931 unsigned int i;
933 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
934 iface, start_slot, sampler_count, samplers);
936 for (i = 0; i < sampler_count; ++i)
938 struct d3d10_sampler_state *sampler_impl;
939 struct wined3d_sampler *wined3d_sampler;
941 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
943 samplers[i] = NULL;
944 continue;
947 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
948 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
949 ID3D10SamplerState_AddRef(samplers[i]);
953 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device1 *iface,
954 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
956 struct d3d10_device *device = impl_from_ID3D10Device(iface);
957 struct wined3d_rendertarget_view *wined3d_view;
959 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
960 iface, view_count, render_target_views, depth_stencil_view);
962 if (render_target_views)
964 struct d3d10_rendertarget_view *view_impl;
965 unsigned int i;
967 for (i = 0; i < view_count; ++i)
969 if (!(wined3d_view = wined3d_device_get_rendertarget_view(device->wined3d_device, i))
970 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
972 render_target_views[i] = NULL;
973 continue;
976 render_target_views[i] = &view_impl->ID3D10RenderTargetView_iface;
977 ID3D10RenderTargetView_AddRef(render_target_views[i]);
981 if (depth_stencil_view)
983 struct d3d10_depthstencil_view *view_impl;
985 if (!(wined3d_view = wined3d_device_get_depth_stencil_view(device->wined3d_device))
986 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
988 *depth_stencil_view = NULL;
990 else
992 *depth_stencil_view = &view_impl->ID3D10DepthStencilView_iface;
993 ID3D10DepthStencilView_AddRef(*depth_stencil_view);
998 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface,
999 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
1001 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1003 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
1004 iface, blend_state, blend_factor, sample_mask);
1006 if ((*blend_state = device->blend_state ? &device->blend_state->ID3D10BlendState_iface : NULL))
1007 ID3D10BlendState_AddRef(*blend_state);
1008 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
1009 *sample_mask = device->sample_mask;
1012 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
1013 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
1015 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1017 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
1018 iface, depth_stencil_state, stencil_ref);
1020 if ((*depth_stencil_state = device->depth_stencil_state
1021 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
1022 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1023 *stencil_ref = device->stencil_ref;
1026 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device1 *iface,
1027 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
1029 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1030 unsigned int i;
1032 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
1033 iface, buffer_count, buffers, offsets);
1035 for (i = 0; i < buffer_count; ++i)
1037 struct wined3d_buffer *wined3d_buffer;
1038 struct d3d10_buffer *buffer_impl;
1040 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
1042 buffers[i] = NULL;
1043 continue;
1046 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1047 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
1048 ID3D10Buffer_AddRef(buffers[i]);
1052 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device1 *iface, ID3D10RasterizerState **rasterizer_state)
1054 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1056 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
1058 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
1059 ID3D10RasterizerState_AddRef(*rasterizer_state);
1062 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface,
1063 UINT *viewport_count, D3D10_VIEWPORT *viewports)
1065 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1066 struct wined3d_viewport wined3d_vp;
1068 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
1070 if (!viewports)
1072 *viewport_count = 1;
1073 return;
1076 if (!*viewport_count)
1077 return;
1079 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
1081 viewports[0].TopLeftX = wined3d_vp.x;
1082 viewports[0].TopLeftY = wined3d_vp.y;
1083 viewports[0].Width = wined3d_vp.width;
1084 viewports[0].Height = wined3d_vp.height;
1085 viewports[0].MinDepth = wined3d_vp.min_z;
1086 viewports[0].MaxDepth = wined3d_vp.max_z;
1088 if (*viewport_count > 1)
1089 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
1092 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects)
1094 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1096 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
1098 if (!rects)
1100 *rect_count = 1;
1101 return;
1104 if (!*rect_count)
1105 return;
1107 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
1108 if (*rect_count > 1)
1109 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
1112 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device1 *iface)
1114 TRACE("iface %p.\n", iface);
1116 /* In the current implementation the device is never removed, so we can
1117 * just return S_OK here. */
1119 return S_OK;
1122 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device1 *iface, UINT flags)
1124 FIXME("iface %p, flags %#x stub!\n", iface, flags);
1126 return E_NOTIMPL;
1129 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device1 *iface)
1131 FIXME("iface %p stub!\n", iface);
1133 return 0;
1136 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *iface,
1137 REFGUID guid, UINT *data_size, void *data)
1139 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
1140 iface, debugstr_guid(guid), data_size, data);
1142 return E_NOTIMPL;
1145 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface,
1146 REFGUID guid, UINT data_size, const void *data)
1148 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
1149 iface, debugstr_guid(guid), data_size, data);
1151 return E_NOTIMPL;
1154 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface,
1155 REFGUID guid, const IUnknown *data)
1157 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
1159 return E_NOTIMPL;
1162 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface)
1164 FIXME("iface %p stub!\n", iface);
1167 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
1169 FIXME("iface %p stub!\n", iface);
1172 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
1173 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
1175 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1176 struct d3d10_buffer *object;
1177 HRESULT hr;
1179 FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
1181 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1182 if (!object)
1183 return E_OUTOFMEMORY;
1185 hr = d3d10_buffer_init(object, This, desc, data);
1186 if (FAILED(hr))
1188 WARN("Failed to initialize buffer, hr %#x.\n", hr);
1189 HeapFree(GetProcessHeap(), 0, object);
1190 return hr;
1193 *buffer = &object->ID3D10Buffer_iface;
1195 TRACE("Created ID3D10Buffer %p\n", object);
1197 return S_OK;
1200 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface,
1201 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
1203 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1205 return E_NOTIMPL;
1208 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface,
1209 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1210 ID3D10Texture2D **texture)
1212 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1213 struct d3d10_texture2d *object;
1214 HRESULT hr;
1216 FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
1218 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1219 if (!object)
1220 return E_OUTOFMEMORY;
1222 hr = d3d10_texture2d_init(object, This, desc);
1223 if (FAILED(hr))
1225 WARN("Failed to initialize texture, hr %#x.\n", hr);
1226 HeapFree(GetProcessHeap(), 0, object);
1227 return hr;
1230 *texture = &object->ID3D10Texture2D_iface;
1232 TRACE("Created ID3D10Texture2D %p\n", object);
1234 return S_OK;
1237 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device1 *iface,
1238 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1239 ID3D10Texture3D **texture)
1241 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1242 struct d3d10_texture3d *object;
1243 HRESULT hr;
1245 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1247 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1248 if (!object)
1249 return E_OUTOFMEMORY;
1251 hr = d3d10_texture3d_init(object, device, desc);
1252 if (FAILED(hr))
1254 WARN("Failed to initialize texture, hr %#x.\n", hr);
1255 HeapFree(GetProcessHeap(), 0, object);
1256 return hr;
1259 TRACE("Created 3D texture %p.\n", object);
1260 *texture = &object->ID3D10Texture3D_iface;
1262 return S_OK;
1265 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
1266 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
1268 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1269 struct d3d10_shader_resource_view *object;
1270 HRESULT hr;
1272 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1274 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1275 return E_OUTOFMEMORY;
1277 if (FAILED(hr = d3d10_shader_resource_view_init(object, device, resource, desc)))
1279 WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
1280 HeapFree(GetProcessHeap(), 0, object);
1281 return hr;
1284 TRACE("Created shader resource view %p.\n", object);
1285 *view = &object->ID3D10ShaderResourceView_iface;
1287 return S_OK;
1290 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device1 *iface,
1291 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
1293 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1294 struct d3d10_rendertarget_view *object;
1295 HRESULT hr;
1297 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1299 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1300 return E_OUTOFMEMORY;
1302 if (FAILED(hr = d3d10_rendertarget_view_init(object, device, resource, desc)))
1304 WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
1305 HeapFree(GetProcessHeap(), 0, object);
1306 return hr;
1309 TRACE("Created rendertarget view %p.\n", object);
1310 *view = &object->ID3D10RenderTargetView_iface;
1312 return S_OK;
1315 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device1 *iface,
1316 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
1318 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1319 struct d3d10_depthstencil_view *object;
1320 HRESULT hr;
1322 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1324 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1325 return E_OUTOFMEMORY;
1327 if (FAILED(hr = d3d10_depthstencil_view_init(object, device, resource, desc)))
1329 WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
1330 HeapFree(GetProcessHeap(), 0, object);
1331 return hr;
1334 TRACE("Created depthstencil view %p.\n", object);
1335 *view = &object->ID3D10DepthStencilView_iface;
1337 return S_OK;
1340 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *iface,
1341 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
1342 const void *shader_byte_code, SIZE_T shader_byte_code_length,
1343 ID3D10InputLayout **input_layout)
1345 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1346 struct d3d10_input_layout *object;
1347 HRESULT hr;
1349 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
1350 "\tshader_byte_code_length %lu, input_layout %p\n",
1351 iface, element_descs, element_count, shader_byte_code,
1352 shader_byte_code_length, input_layout);
1354 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1355 if (!object)
1356 return E_OUTOFMEMORY;
1358 hr = d3d10_input_layout_init(object, This, element_descs, element_count,
1359 shader_byte_code, shader_byte_code_length);
1360 if (FAILED(hr))
1362 WARN("Failed to initialize input layout, hr %#x.\n", hr);
1363 HeapFree(GetProcessHeap(), 0, object);
1364 return hr;
1367 TRACE("Created input layout %p.\n", object);
1368 *input_layout = &object->ID3D10InputLayout_iface;
1370 return S_OK;
1373 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device1 *iface,
1374 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
1376 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1377 struct d3d10_vertex_shader *object;
1378 HRESULT hr;
1380 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1381 iface, byte_code, byte_code_length, shader);
1383 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1384 if (!object)
1385 return E_OUTOFMEMORY;
1387 hr = d3d10_vertex_shader_init(object, This, byte_code, byte_code_length);
1388 if (FAILED(hr))
1390 WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
1391 HeapFree(GetProcessHeap(), 0, object);
1392 return hr;
1395 TRACE("Created vertex shader %p.\n", object);
1396 *shader = &object->ID3D10VertexShader_iface;
1398 return S_OK;
1401 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device1 *iface,
1402 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
1404 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1405 struct d3d10_geometry_shader *object;
1406 HRESULT hr;
1408 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
1409 iface, byte_code, byte_code_length, shader);
1411 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1412 if (!object)
1413 return E_OUTOFMEMORY;
1415 hr = d3d10_geometry_shader_init(object, This, byte_code, byte_code_length);
1416 if (FAILED(hr))
1418 WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
1419 HeapFree(GetProcessHeap(), 0, object);
1420 return hr;
1423 TRACE("Created geometry shader %p.\n", object);
1424 *shader = &object->ID3D10GeometryShader_iface;
1426 return S_OK;
1429 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1 *iface,
1430 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
1431 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
1433 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p,\n"
1434 "\toutput_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
1435 iface, byte_code, byte_code_length, output_stream_decls,
1436 output_stream_decl_count, output_stream_stride, shader);
1438 return E_NOTIMPL;
1441 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device1 *iface,
1442 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
1444 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1445 struct d3d10_pixel_shader *object;
1446 HRESULT hr;
1448 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1449 iface, byte_code, byte_code_length, shader);
1451 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1452 if (!object)
1453 return E_OUTOFMEMORY;
1455 hr = d3d10_pixel_shader_init(object, This, byte_code, byte_code_length);
1456 if (FAILED(hr))
1458 WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
1459 HeapFree(GetProcessHeap(), 0, object);
1460 return hr;
1463 TRACE("Created pixel shader %p.\n", object);
1464 *shader = &object->ID3D10PixelShader_iface;
1466 return S_OK;
1469 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device1 *iface,
1470 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1472 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1473 struct d3d10_blend_state *object;
1474 struct wine_rb_entry *entry;
1475 HRESULT hr;
1477 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
1479 if (!desc)
1480 return E_INVALIDARG;
1482 if ((entry = wine_rb_get(&device->blend_states, desc)))
1484 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_blend_state, entry);
1486 TRACE("Returning existing blend state %p.\n", object);
1487 *blend_state = &object->ID3D10BlendState_iface;
1488 ID3D10BlendState_AddRef(*blend_state);
1490 return S_OK;
1493 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1494 if (!object)
1495 return E_OUTOFMEMORY;
1497 if (FAILED(hr = d3d10_blend_state_init(object, device, desc)))
1499 WARN("Failed to initialize blend state, hr %#x.\n", hr);
1500 HeapFree(GetProcessHeap(), 0, object);
1501 return hr;
1504 TRACE("Created blend state %p.\n", object);
1505 *blend_state = &object->ID3D10BlendState_iface;
1507 return S_OK;
1510 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device1 *iface,
1511 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1513 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1514 struct d3d10_depthstencil_state *object;
1515 struct wine_rb_entry *entry;
1516 HRESULT hr;
1518 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
1520 if (!desc)
1521 return E_INVALIDARG;
1523 if ((entry = wine_rb_get(&device->depthstencil_states, desc)))
1525 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_depthstencil_state, entry);
1527 TRACE("Returning existing depthstencil state %p.\n", object);
1528 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1529 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1531 return S_OK;
1534 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1535 if (!object)
1536 return E_OUTOFMEMORY;
1538 if (FAILED(hr = d3d10_depthstencil_state_init(object, device, desc)))
1540 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1541 HeapFree(GetProcessHeap(), 0, object);
1542 return hr;
1545 TRACE("Created depthstencil state %p.\n", object);
1546 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1548 return S_OK;
1551 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device1 *iface,
1552 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1554 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1555 struct d3d10_rasterizer_state *object;
1556 struct wine_rb_entry *entry;
1557 HRESULT hr;
1559 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1561 if (!desc)
1562 return E_INVALIDARG;
1564 if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
1566 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_rasterizer_state, entry);
1568 TRACE("Returning existing rasterizer state %p.\n", object);
1569 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1570 ID3D10RasterizerState_AddRef(*rasterizer_state);
1572 return S_OK;
1576 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1577 if (!object)
1578 return E_OUTOFMEMORY;
1580 if (FAILED(hr = d3d10_rasterizer_state_init(object, device, desc)))
1582 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1583 HeapFree(GetProcessHeap(), 0, object);
1584 return hr;
1587 TRACE("Created rasterizer state %p.\n", object);
1588 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1590 return S_OK;
1593 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
1594 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1596 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1597 struct d3d10_sampler_state *object;
1598 struct wine_rb_entry *entry;
1599 HRESULT hr;
1601 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
1603 if (!desc)
1604 return E_INVALIDARG;
1606 if ((entry = wine_rb_get(&device->sampler_states, desc)))
1608 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_sampler_state, entry);
1610 TRACE("Returning existing sampler state %p.\n", object);
1611 *sampler_state = &object->ID3D10SamplerState_iface;
1612 ID3D10SamplerState_AddRef(*sampler_state);
1614 return S_OK;
1617 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1618 if (!object)
1619 return E_OUTOFMEMORY;
1621 if (FAILED(hr = d3d10_sampler_state_init(object, device, desc)))
1623 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
1624 HeapFree(GetProcessHeap(), 0, object);
1625 return hr;
1628 TRACE("Created sampler state %p.\n", object);
1629 *sampler_state = &object->ID3D10SamplerState_iface;
1631 return S_OK;
1634 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
1635 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1637 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1638 struct d3d10_query *object;
1639 HRESULT hr;
1641 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
1643 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1644 return E_OUTOFMEMORY;
1646 if (FAILED(hr = d3d10_query_init(object, device, FALSE)))
1648 WARN("Failed to initialize query, hr %#x.\n", hr);
1649 HeapFree(GetProcessHeap(), 0, object);
1650 return hr;
1653 TRACE("Created query %p.\n", object);
1654 *query = &object->ID3D10Query_iface;
1656 return S_OK;
1659 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *iface,
1660 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1662 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1663 struct d3d10_query *object;
1664 HRESULT hr;
1666 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
1668 if (!desc)
1669 return E_INVALIDARG;
1671 if (desc->Query != D3D10_QUERY_OCCLUSION_PREDICATE && desc->Query != D3D10_QUERY_SO_OVERFLOW_PREDICATE)
1673 WARN("Query type %#x is not a predicate.\n", desc->Query);
1674 return E_INVALIDARG;
1677 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1678 return E_OUTOFMEMORY;
1680 if (FAILED(hr = d3d10_query_init(object, device, TRUE)))
1682 WARN("Failed to initialize predicate, hr %#x.\n", hr);
1683 HeapFree(GetProcessHeap(), 0, object);
1684 return hr;
1687 TRACE("Created predicate %p.\n", object);
1688 *predicate = (ID3D10Predicate *)&object->ID3D10Query_iface;
1690 return S_OK;
1693 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device1 *iface,
1694 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1696 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1698 return E_NOTIMPL;
1701 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 *iface,
1702 DXGI_FORMAT format, UINT *format_support)
1704 FIXME("iface %p, format %s, format_support %p stub!\n",
1705 iface, debug_dxgi_format(format), format_support);
1707 return E_NOTIMPL;
1710 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface,
1711 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1713 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1714 iface, debug_dxgi_format(format), sample_count, quality_level_count);
1716 return E_NOTIMPL;
1719 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device1 *iface, D3D10_COUNTER_INFO *counter_info)
1721 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1724 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device1 *iface,
1725 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, char *name,
1726 UINT *name_length, char *units, UINT *units_length, char *description, UINT *description_length)
1728 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1729 "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1730 iface, desc, type, active_counters, name, name_length,
1731 units, units_length, description, description_length);
1733 return E_NOTIMPL;
1736 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device1 *iface)
1738 FIXME("iface %p stub!\n", iface);
1740 return 0;
1743 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device1 *iface,
1744 HANDLE resource_handle, REFIID guid, void **resource)
1746 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1747 iface, resource_handle, debugstr_guid(guid), resource);
1749 return E_NOTIMPL;
1752 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device1 *iface, UINT width, UINT height)
1754 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1757 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device1 *iface, UINT *width, UINT *height)
1759 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1762 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView1(ID3D10Device1 *iface,
1763 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc, ID3D10ShaderResourceView1 **view)
1765 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1767 return E_NOTIMPL;
1770 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState1(ID3D10Device1 *iface,
1771 const D3D10_BLEND_DESC1 *desc, ID3D10BlendState1 **blend_state)
1773 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface, desc, blend_state);
1775 return E_NOTIMPL;
1778 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE d3d10_device_GetFeatureLevel(ID3D10Device1 *iface)
1780 FIXME("iface %p stub!\n", iface);
1782 return D3D10_FEATURE_LEVEL_10_1;
1785 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl =
1787 /* IUnknown methods */
1788 d3d10_device_QueryInterface,
1789 d3d10_device_AddRef,
1790 d3d10_device_Release,
1791 /* ID3D10Device methods */
1792 d3d10_device_VSSetConstantBuffers,
1793 d3d10_device_PSSetShaderResources,
1794 d3d10_device_PSSetShader,
1795 d3d10_device_PSSetSamplers,
1796 d3d10_device_VSSetShader,
1797 d3d10_device_DrawIndexed,
1798 d3d10_device_Draw,
1799 d3d10_device_PSSetConstantBuffers,
1800 d3d10_device_IASetInputLayout,
1801 d3d10_device_IASetVertexBuffers,
1802 d3d10_device_IASetIndexBuffer,
1803 d3d10_device_DrawIndexedInstanced,
1804 d3d10_device_DrawInstanced,
1805 d3d10_device_GSSetConstantBuffers,
1806 d3d10_device_GSSetShader,
1807 d3d10_device_IASetPrimitiveTopology,
1808 d3d10_device_VSSetShaderResources,
1809 d3d10_device_VSSetSamplers,
1810 d3d10_device_SetPredication,
1811 d3d10_device_GSSetShaderResources,
1812 d3d10_device_GSSetSamplers,
1813 d3d10_device_OMSetRenderTargets,
1814 d3d10_device_OMSetBlendState,
1815 d3d10_device_OMSetDepthStencilState,
1816 d3d10_device_SOSetTargets,
1817 d3d10_device_DrawAuto,
1818 d3d10_device_RSSetState,
1819 d3d10_device_RSSetViewports,
1820 d3d10_device_RSSetScissorRects,
1821 d3d10_device_CopySubresourceRegion,
1822 d3d10_device_CopyResource,
1823 d3d10_device_UpdateSubresource,
1824 d3d10_device_ClearRenderTargetView,
1825 d3d10_device_ClearDepthStencilView,
1826 d3d10_device_GenerateMips,
1827 d3d10_device_ResolveSubresource,
1828 d3d10_device_VSGetConstantBuffers,
1829 d3d10_device_PSGetShaderResources,
1830 d3d10_device_PSGetShader,
1831 d3d10_device_PSGetSamplers,
1832 d3d10_device_VSGetShader,
1833 d3d10_device_PSGetConstantBuffers,
1834 d3d10_device_IAGetInputLayout,
1835 d3d10_device_IAGetVertexBuffers,
1836 d3d10_device_IAGetIndexBuffer,
1837 d3d10_device_GSGetConstantBuffers,
1838 d3d10_device_GSGetShader,
1839 d3d10_device_IAGetPrimitiveTopology,
1840 d3d10_device_VSGetShaderResources,
1841 d3d10_device_VSGetSamplers,
1842 d3d10_device_GetPredication,
1843 d3d10_device_GSGetShaderResources,
1844 d3d10_device_GSGetSamplers,
1845 d3d10_device_OMGetRenderTargets,
1846 d3d10_device_OMGetBlendState,
1847 d3d10_device_OMGetDepthStencilState,
1848 d3d10_device_SOGetTargets,
1849 d3d10_device_RSGetState,
1850 d3d10_device_RSGetViewports,
1851 d3d10_device_RSGetScissorRects,
1852 d3d10_device_GetDeviceRemovedReason,
1853 d3d10_device_SetExceptionMode,
1854 d3d10_device_GetExceptionMode,
1855 d3d10_device_GetPrivateData,
1856 d3d10_device_SetPrivateData,
1857 d3d10_device_SetPrivateDataInterface,
1858 d3d10_device_ClearState,
1859 d3d10_device_Flush,
1860 d3d10_device_CreateBuffer,
1861 d3d10_device_CreateTexture1D,
1862 d3d10_device_CreateTexture2D,
1863 d3d10_device_CreateTexture3D,
1864 d3d10_device_CreateShaderResourceView,
1865 d3d10_device_CreateRenderTargetView,
1866 d3d10_device_CreateDepthStencilView,
1867 d3d10_device_CreateInputLayout,
1868 d3d10_device_CreateVertexShader,
1869 d3d10_device_CreateGeometryShader,
1870 d3d10_device_CreateGeometryShaderWithStreamOutput,
1871 d3d10_device_CreatePixelShader,
1872 d3d10_device_CreateBlendState,
1873 d3d10_device_CreateDepthStencilState,
1874 d3d10_device_CreateRasterizerState,
1875 d3d10_device_CreateSamplerState,
1876 d3d10_device_CreateQuery,
1877 d3d10_device_CreatePredicate,
1878 d3d10_device_CreateCounter,
1879 d3d10_device_CheckFormatSupport,
1880 d3d10_device_CheckMultisampleQualityLevels,
1881 d3d10_device_CheckCounterInfo,
1882 d3d10_device_CheckCounter,
1883 d3d10_device_GetCreationFlags,
1884 d3d10_device_OpenSharedResource,
1885 d3d10_device_SetTextFilterSize,
1886 d3d10_device_GetTextFilterSize,
1887 d3d10_device_CreateShaderResourceView1,
1888 d3d10_device_CreateBlendState1,
1889 d3d10_device_GetFeatureLevel,
1892 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1894 /* IUnknown methods */
1895 d3d10_device_inner_QueryInterface,
1896 d3d10_device_inner_AddRef,
1897 d3d10_device_inner_Release,
1900 static inline struct d3d10_device *impl_from_ID3D10Multithread(ID3D10Multithread *iface)
1902 return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Multithread_iface);
1905 static HRESULT STDMETHODCALLTYPE d3d10_multithread_QueryInterface(ID3D10Multithread *iface, REFIID iid, void **out)
1907 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1909 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
1911 return IUnknown_QueryInterface(device->outer_unk, iid, out);
1914 static ULONG STDMETHODCALLTYPE d3d10_multithread_AddRef(ID3D10Multithread *iface)
1916 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1918 TRACE("iface %p.\n", iface);
1920 return IUnknown_AddRef(device->outer_unk);
1923 static ULONG STDMETHODCALLTYPE d3d10_multithread_Release(ID3D10Multithread *iface)
1925 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1927 TRACE("iface %p.\n", iface);
1929 return IUnknown_Release(device->outer_unk);
1932 static void STDMETHODCALLTYPE d3d10_multithread_Enter(ID3D10Multithread *iface)
1934 TRACE("iface %p.\n", iface);
1936 wined3d_mutex_lock();
1939 static void STDMETHODCALLTYPE d3d10_multithread_Leave(ID3D10Multithread *iface)
1941 TRACE("iface %p.\n", iface);
1943 wined3d_mutex_unlock();
1946 static BOOL STDMETHODCALLTYPE d3d10_multithread_SetMultithreadProtected(ID3D10Multithread *iface, BOOL protect)
1948 FIXME("iface %p, protect %#x stub!\n", iface, protect);
1950 return TRUE;
1953 static BOOL STDMETHODCALLTYPE d3d10_multithread_GetMultithreadProtected(ID3D10Multithread *iface)
1955 FIXME("iface %p stub!\n", iface);
1957 return TRUE;
1960 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl =
1962 d3d10_multithread_QueryInterface,
1963 d3d10_multithread_AddRef,
1964 d3d10_multithread_Release,
1965 d3d10_multithread_Enter,
1966 d3d10_multithread_Leave,
1967 d3d10_multithread_SetMultithreadProtected,
1968 d3d10_multithread_GetMultithreadProtected,
1971 static void STDMETHODCALLTYPE d3d10_subresource_destroyed(void *parent) {}
1973 static const struct wined3d_parent_ops d3d10_subresource_parent_ops =
1975 d3d10_subresource_destroyed,
1978 /* IWineDXGIDeviceParent IUnknown methods */
1980 static inline struct d3d10_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
1982 return CONTAINING_RECORD(iface, struct d3d10_device, IWineDXGIDeviceParent_iface);
1985 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
1986 REFIID riid, void **ppv)
1988 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1989 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
1992 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
1994 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1995 return IUnknown_AddRef(device->outer_unk);
1998 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
2000 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2001 return IUnknown_Release(device->outer_unk);
2004 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
2005 IWineDXGIDeviceParent *iface)
2007 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2008 return &device->device_parent;
2011 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl =
2013 /* IUnknown methods */
2014 dxgi_device_parent_QueryInterface,
2015 dxgi_device_parent_AddRef,
2016 dxgi_device_parent_Release,
2017 /* IWineDXGIDeviceParent methods */
2018 dxgi_device_parent_get_wined3d_device_parent,
2021 static inline struct d3d10_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
2023 return CONTAINING_RECORD(device_parent, struct d3d10_device, device_parent);
2026 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
2027 struct wined3d_device *wined3d_device)
2029 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2031 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
2033 wined3d_device_incref(wined3d_device);
2034 device->wined3d_device = wined3d_device;
2037 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
2039 TRACE("device_parent %p.\n", device_parent);
2042 static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate)
2044 TRACE("device_parent %p, activate %#x.\n", device_parent, activate);
2047 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
2048 void *container_parent, struct wined3d_surface *surface, void **parent,
2049 const struct wined3d_parent_ops **parent_ops)
2051 TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
2052 device_parent, container_parent, surface, parent, parent_ops);
2054 *parent = container_parent;
2055 *parent_ops = &d3d10_null_wined3d_parent_ops;
2057 return S_OK;
2060 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
2061 void *container_parent, struct wined3d_volume *volume, void **parent,
2062 const struct wined3d_parent_ops **parent_ops)
2064 TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
2065 device_parent, container_parent, volume, parent, parent_ops);
2067 *parent = container_parent;
2068 *parent_ops = &d3d10_null_wined3d_parent_ops;
2070 return S_OK;
2073 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
2074 void *container_parent, const struct wined3d_resource_desc *wined3d_desc, struct wined3d_surface **surface)
2076 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2077 struct wined3d_resource *sub_resource;
2078 struct d3d10_texture2d *texture;
2079 D3D10_TEXTURE2D_DESC desc;
2080 HRESULT hr;
2082 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, surface %p partial stub!\n",
2083 device_parent, container_parent, wined3d_desc, surface);
2085 FIXME("Implement DXGI<->wined3d usage conversion\n");
2087 desc.Width = wined3d_desc->width;
2088 desc.Height = wined3d_desc->height;
2089 desc.MipLevels = 1;
2090 desc.ArraySize = 1;
2091 desc.Format = dxgi_format_from_wined3dformat(wined3d_desc->format);
2092 desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1;
2093 desc.SampleDesc.Quality = wined3d_desc->multisample_quality;
2094 desc.Usage = D3D10_USAGE_DEFAULT;
2095 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
2096 desc.CPUAccessFlags = 0;
2097 desc.MiscFlags = 0;
2099 if (FAILED(hr = d3d10_device_CreateTexture2D(&device->ID3D10Device1_iface,
2100 &desc, NULL, (ID3D10Texture2D **)&texture)))
2102 ERR("CreateTexture2D failed, returning %#x\n", hr);
2103 return hr;
2106 sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
2107 *surface = wined3d_surface_from_resource(sub_resource);
2108 wined3d_surface_incref(*surface);
2109 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
2111 return S_OK;
2114 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
2115 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
2117 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2118 IWineDXGIDevice *wine_device;
2119 HRESULT hr;
2121 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain);
2123 if (FAILED(hr = d3d10_device_QueryInterface(&device->ID3D10Device1_iface,
2124 &IID_IWineDXGIDevice, (void **)&wine_device)))
2126 ERR("Device should implement IWineDXGIDevice.\n");
2127 return E_FAIL;
2130 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
2131 IWineDXGIDevice_Release(wine_device);
2132 if (FAILED(hr))
2134 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
2135 return hr;
2138 return S_OK;
2141 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
2143 device_parent_wined3d_device_created,
2144 device_parent_mode_changed,
2145 device_parent_activate,
2146 device_parent_surface_created,
2147 device_parent_volume_created,
2148 device_parent_create_swapchain_surface,
2149 device_parent_create_swapchain,
2152 static void *d3d10_rb_alloc(size_t size)
2154 return HeapAlloc(GetProcessHeap(), 0, size);
2157 static void *d3d10_rb_realloc(void *ptr, size_t size)
2159 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
2162 static void d3d10_rb_free(void *ptr)
2164 HeapFree(GetProcessHeap(), 0, ptr);
2167 static int d3d10_sampler_state_compare(const void *key, const struct wine_rb_entry *entry)
2169 const D3D10_SAMPLER_DESC *ka = key;
2170 const D3D10_SAMPLER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_sampler_state, entry)->desc;
2172 return memcmp(ka, kb, sizeof(*ka));
2175 static const struct wine_rb_functions d3d10_sampler_state_rb_ops =
2177 d3d10_rb_alloc,
2178 d3d10_rb_realloc,
2179 d3d10_rb_free,
2180 d3d10_sampler_state_compare,
2183 static int d3d10_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
2185 const D3D10_BLEND_DESC *ka = key;
2186 const D3D10_BLEND_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_blend_state, entry)->desc;
2188 return memcmp(ka, kb, sizeof(*ka));
2191 static const struct wine_rb_functions d3d10_blend_state_rb_ops =
2193 d3d10_rb_alloc,
2194 d3d10_rb_realloc,
2195 d3d10_rb_free,
2196 d3d10_blend_state_compare,
2199 static int d3d10_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
2201 const D3D10_DEPTH_STENCIL_DESC *ka = key;
2202 const D3D10_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
2203 const struct d3d10_depthstencil_state, entry)->desc;
2205 return memcmp(ka, kb, sizeof(*ka));
2208 static const struct wine_rb_functions d3d10_depthstencil_state_rb_ops =
2210 d3d10_rb_alloc,
2211 d3d10_rb_realloc,
2212 d3d10_rb_free,
2213 d3d10_depthstencil_state_compare,
2216 static int d3d10_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
2218 const D3D10_RASTERIZER_DESC *ka = key;
2219 const D3D10_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_rasterizer_state, entry)->desc;
2221 return memcmp(ka, kb, sizeof(*ka));
2224 static const struct wine_rb_functions d3d10_rasterizer_state_rb_ops =
2226 d3d10_rb_alloc,
2227 d3d10_rb_realloc,
2228 d3d10_rb_free,
2229 d3d10_rasterizer_state_compare,
2232 HRESULT d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
2234 device->IUnknown_inner.lpVtbl = &d3d10_device_inner_unknown_vtbl;
2235 device->ID3D10Device1_iface.lpVtbl = &d3d10_device1_vtbl;
2236 device->ID3D10Multithread_iface.lpVtbl = &d3d10_multithread_vtbl;
2237 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d10_dxgi_device_parent_vtbl;
2238 device->device_parent.ops = &d3d10_wined3d_device_parent_ops;
2239 device->refcount = 1;
2240 /* COM aggregation always takes place */
2241 device->outer_unk = outer_unknown;
2243 if (wine_rb_init(&device->blend_states, &d3d10_blend_state_rb_ops) == -1)
2245 WARN("Failed to initialize blend state rbtree.\n");
2246 return E_FAIL;
2249 if (wine_rb_init(&device->depthstencil_states, &d3d10_depthstencil_state_rb_ops) == -1)
2251 WARN("Failed to initialize depthstencil state rbtree.\n");
2252 wine_rb_destroy(&device->blend_states, NULL, NULL);
2253 return E_FAIL;
2256 if (wine_rb_init(&device->rasterizer_states, &d3d10_rasterizer_state_rb_ops) == -1)
2258 WARN("Failed to initialize rasterizer state rbtree.\n");
2259 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2260 wine_rb_destroy(&device->blend_states, NULL, NULL);
2261 return E_FAIL;
2264 if (wine_rb_init(&device->sampler_states, &d3d10_sampler_state_rb_ops) == -1)
2266 WARN("Failed to initialize sampler state rbtree.\n");
2267 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
2268 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2269 wine_rb_destroy(&device->blend_states, NULL, NULL);
2270 return E_FAIL;
2273 return S_OK;