d3d10core: Implement d3d10_device_VSGetShaderResources().
[wine.git] / dlls / d3d10core / device.c
blob201dca338ebee73a5dde4e68ab5de4cc42aff2ec
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 struct d3d10_device *device = impl_from_ID3D10Device(iface);
885 unsigned int i;
887 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
888 iface, start_slot, view_count, views);
890 for (i = 0; i < view_count; ++i)
892 struct wined3d_shader_resource_view *wined3d_view;
893 struct d3d10_shader_resource_view *view_impl;
895 if (!(wined3d_view = wined3d_device_get_vs_resource_view(device->wined3d_device, start_slot + i)))
897 views[i] = NULL;
898 continue;
901 view_impl = wined3d_shader_resource_view_get_parent(wined3d_view);
902 views[i] = &view_impl->ID3D10ShaderResourceView_iface;
903 ID3D10ShaderResourceView_AddRef(views[i]);
907 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device1 *iface,
908 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
910 struct d3d10_device *device = impl_from_ID3D10Device(iface);
911 unsigned int i;
913 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
914 iface, start_slot, sampler_count, samplers);
916 for (i = 0; i < sampler_count; ++i)
918 struct d3d10_sampler_state *sampler_impl;
919 struct wined3d_sampler *wined3d_sampler;
921 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
923 samplers[i] = NULL;
924 continue;
927 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
928 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
929 ID3D10SamplerState_AddRef(samplers[i]);
933 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device1 *iface,
934 ID3D10Predicate **predicate, BOOL *value)
936 FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
939 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device1 *iface,
940 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
942 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
943 iface, start_slot, view_count, views);
946 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device1 *iface,
947 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
949 struct d3d10_device *device = impl_from_ID3D10Device(iface);
950 unsigned int i;
952 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
953 iface, start_slot, sampler_count, samplers);
955 for (i = 0; i < sampler_count; ++i)
957 struct d3d10_sampler_state *sampler_impl;
958 struct wined3d_sampler *wined3d_sampler;
960 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
962 samplers[i] = NULL;
963 continue;
966 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
967 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
968 ID3D10SamplerState_AddRef(samplers[i]);
972 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device1 *iface,
973 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
975 struct d3d10_device *device = impl_from_ID3D10Device(iface);
976 struct wined3d_rendertarget_view *wined3d_view;
978 TRACE("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p.\n",
979 iface, view_count, render_target_views, depth_stencil_view);
981 if (render_target_views)
983 struct d3d10_rendertarget_view *view_impl;
984 unsigned int i;
986 for (i = 0; i < view_count; ++i)
988 if (!(wined3d_view = wined3d_device_get_rendertarget_view(device->wined3d_device, i))
989 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
991 render_target_views[i] = NULL;
992 continue;
995 render_target_views[i] = &view_impl->ID3D10RenderTargetView_iface;
996 ID3D10RenderTargetView_AddRef(render_target_views[i]);
1000 if (depth_stencil_view)
1002 struct d3d10_depthstencil_view *view_impl;
1004 if (!(wined3d_view = wined3d_device_get_depth_stencil_view(device->wined3d_device))
1005 || !(view_impl = wined3d_rendertarget_view_get_parent(wined3d_view)))
1007 *depth_stencil_view = NULL;
1009 else
1011 *depth_stencil_view = &view_impl->ID3D10DepthStencilView_iface;
1012 ID3D10DepthStencilView_AddRef(*depth_stencil_view);
1017 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface,
1018 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
1020 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1022 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
1023 iface, blend_state, blend_factor, sample_mask);
1025 if ((*blend_state = device->blend_state ? &device->blend_state->ID3D10BlendState_iface : NULL))
1026 ID3D10BlendState_AddRef(*blend_state);
1027 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
1028 *sample_mask = device->sample_mask;
1031 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
1032 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
1034 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1036 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
1037 iface, depth_stencil_state, stencil_ref);
1039 if ((*depth_stencil_state = device->depth_stencil_state
1040 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
1041 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1042 *stencil_ref = device->stencil_ref;
1045 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device1 *iface,
1046 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
1048 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1049 unsigned int i;
1051 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
1052 iface, buffer_count, buffers, offsets);
1054 for (i = 0; i < buffer_count; ++i)
1056 struct wined3d_buffer *wined3d_buffer;
1057 struct d3d10_buffer *buffer_impl;
1059 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
1061 buffers[i] = NULL;
1062 continue;
1065 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
1066 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
1067 ID3D10Buffer_AddRef(buffers[i]);
1071 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device1 *iface, ID3D10RasterizerState **rasterizer_state)
1073 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1075 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
1077 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
1078 ID3D10RasterizerState_AddRef(*rasterizer_state);
1081 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface,
1082 UINT *viewport_count, D3D10_VIEWPORT *viewports)
1084 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1085 struct wined3d_viewport wined3d_vp;
1087 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
1089 if (!viewports)
1091 *viewport_count = 1;
1092 return;
1095 if (!*viewport_count)
1096 return;
1098 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
1100 viewports[0].TopLeftX = wined3d_vp.x;
1101 viewports[0].TopLeftY = wined3d_vp.y;
1102 viewports[0].Width = wined3d_vp.width;
1103 viewports[0].Height = wined3d_vp.height;
1104 viewports[0].MinDepth = wined3d_vp.min_z;
1105 viewports[0].MaxDepth = wined3d_vp.max_z;
1107 if (*viewport_count > 1)
1108 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
1111 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects)
1113 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1115 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
1117 if (!rects)
1119 *rect_count = 1;
1120 return;
1123 if (!*rect_count)
1124 return;
1126 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
1127 if (*rect_count > 1)
1128 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
1131 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device1 *iface)
1133 TRACE("iface %p.\n", iface);
1135 /* In the current implementation the device is never removed, so we can
1136 * just return S_OK here. */
1138 return S_OK;
1141 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device1 *iface, UINT flags)
1143 FIXME("iface %p, flags %#x stub!\n", iface, flags);
1145 return E_NOTIMPL;
1148 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device1 *iface)
1150 FIXME("iface %p stub!\n", iface);
1152 return 0;
1155 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *iface,
1156 REFGUID guid, UINT *data_size, void *data)
1158 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
1159 iface, debugstr_guid(guid), data_size, data);
1161 return E_NOTIMPL;
1164 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface,
1165 REFGUID guid, UINT data_size, const void *data)
1167 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
1168 iface, debugstr_guid(guid), data_size, data);
1170 return E_NOTIMPL;
1173 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface,
1174 REFGUID guid, const IUnknown *data)
1176 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
1178 return E_NOTIMPL;
1181 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface)
1183 FIXME("iface %p stub!\n", iface);
1186 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
1188 FIXME("iface %p stub!\n", iface);
1191 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
1192 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
1194 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1195 struct d3d10_buffer *object;
1196 HRESULT hr;
1198 FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
1200 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1201 if (!object)
1202 return E_OUTOFMEMORY;
1204 hr = d3d10_buffer_init(object, This, desc, data);
1205 if (FAILED(hr))
1207 WARN("Failed to initialize buffer, hr %#x.\n", hr);
1208 HeapFree(GetProcessHeap(), 0, object);
1209 return hr;
1212 *buffer = &object->ID3D10Buffer_iface;
1214 TRACE("Created ID3D10Buffer %p\n", object);
1216 return S_OK;
1219 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface,
1220 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
1222 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1224 return E_NOTIMPL;
1227 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface,
1228 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1229 ID3D10Texture2D **texture)
1231 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1232 struct d3d10_texture2d *object;
1233 HRESULT hr;
1235 FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
1237 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1238 if (!object)
1239 return E_OUTOFMEMORY;
1241 hr = d3d10_texture2d_init(object, This, desc);
1242 if (FAILED(hr))
1244 WARN("Failed to initialize texture, hr %#x.\n", hr);
1245 HeapFree(GetProcessHeap(), 0, object);
1246 return hr;
1249 *texture = &object->ID3D10Texture2D_iface;
1251 TRACE("Created ID3D10Texture2D %p\n", object);
1253 return S_OK;
1256 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device1 *iface,
1257 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1258 ID3D10Texture3D **texture)
1260 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1261 struct d3d10_texture3d *object;
1262 HRESULT hr;
1264 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1266 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1267 if (!object)
1268 return E_OUTOFMEMORY;
1270 hr = d3d10_texture3d_init(object, device, desc);
1271 if (FAILED(hr))
1273 WARN("Failed to initialize texture, hr %#x.\n", hr);
1274 HeapFree(GetProcessHeap(), 0, object);
1275 return hr;
1278 TRACE("Created 3D texture %p.\n", object);
1279 *texture = &object->ID3D10Texture3D_iface;
1281 return S_OK;
1284 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
1285 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
1287 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1288 struct d3d10_shader_resource_view *object;
1289 HRESULT hr;
1291 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1293 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1294 return E_OUTOFMEMORY;
1296 if (FAILED(hr = d3d10_shader_resource_view_init(object, device, resource, desc)))
1298 WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
1299 HeapFree(GetProcessHeap(), 0, object);
1300 return hr;
1303 TRACE("Created shader resource view %p.\n", object);
1304 *view = &object->ID3D10ShaderResourceView_iface;
1306 return S_OK;
1309 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device1 *iface,
1310 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
1312 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1313 struct d3d10_rendertarget_view *object;
1314 HRESULT hr;
1316 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1318 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1319 return E_OUTOFMEMORY;
1321 if (FAILED(hr = d3d10_rendertarget_view_init(object, device, resource, desc)))
1323 WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
1324 HeapFree(GetProcessHeap(), 0, object);
1325 return hr;
1328 TRACE("Created rendertarget view %p.\n", object);
1329 *view = &object->ID3D10RenderTargetView_iface;
1331 return S_OK;
1334 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device1 *iface,
1335 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
1337 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1338 struct d3d10_depthstencil_view *object;
1339 HRESULT hr;
1341 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1343 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1344 return E_OUTOFMEMORY;
1346 if (FAILED(hr = d3d10_depthstencil_view_init(object, device, resource, desc)))
1348 WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
1349 HeapFree(GetProcessHeap(), 0, object);
1350 return hr;
1353 TRACE("Created depthstencil view %p.\n", object);
1354 *view = &object->ID3D10DepthStencilView_iface;
1356 return S_OK;
1359 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *iface,
1360 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
1361 const void *shader_byte_code, SIZE_T shader_byte_code_length,
1362 ID3D10InputLayout **input_layout)
1364 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1365 struct d3d10_input_layout *object;
1366 HRESULT hr;
1368 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
1369 "\tshader_byte_code_length %lu, input_layout %p\n",
1370 iface, element_descs, element_count, shader_byte_code,
1371 shader_byte_code_length, input_layout);
1373 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1374 if (!object)
1375 return E_OUTOFMEMORY;
1377 hr = d3d10_input_layout_init(object, This, element_descs, element_count,
1378 shader_byte_code, shader_byte_code_length);
1379 if (FAILED(hr))
1381 WARN("Failed to initialize input layout, hr %#x.\n", hr);
1382 HeapFree(GetProcessHeap(), 0, object);
1383 return hr;
1386 TRACE("Created input layout %p.\n", object);
1387 *input_layout = &object->ID3D10InputLayout_iface;
1389 return S_OK;
1392 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device1 *iface,
1393 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
1395 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1396 struct d3d10_vertex_shader *object;
1397 HRESULT hr;
1399 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1400 iface, byte_code, byte_code_length, shader);
1402 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1403 if (!object)
1404 return E_OUTOFMEMORY;
1406 hr = d3d10_vertex_shader_init(object, This, byte_code, byte_code_length);
1407 if (FAILED(hr))
1409 WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
1410 HeapFree(GetProcessHeap(), 0, object);
1411 return hr;
1414 TRACE("Created vertex shader %p.\n", object);
1415 *shader = &object->ID3D10VertexShader_iface;
1417 return S_OK;
1420 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device1 *iface,
1421 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
1423 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1424 struct d3d10_geometry_shader *object;
1425 HRESULT hr;
1427 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
1428 iface, byte_code, byte_code_length, shader);
1430 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1431 if (!object)
1432 return E_OUTOFMEMORY;
1434 hr = d3d10_geometry_shader_init(object, This, byte_code, byte_code_length);
1435 if (FAILED(hr))
1437 WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
1438 HeapFree(GetProcessHeap(), 0, object);
1439 return hr;
1442 TRACE("Created geometry shader %p.\n", object);
1443 *shader = &object->ID3D10GeometryShader_iface;
1445 return S_OK;
1448 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1 *iface,
1449 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
1450 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
1452 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p,\n"
1453 "\toutput_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
1454 iface, byte_code, byte_code_length, output_stream_decls,
1455 output_stream_decl_count, output_stream_stride, shader);
1457 return E_NOTIMPL;
1460 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device1 *iface,
1461 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
1463 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1464 struct d3d10_pixel_shader *object;
1465 HRESULT hr;
1467 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1468 iface, byte_code, byte_code_length, shader);
1470 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1471 if (!object)
1472 return E_OUTOFMEMORY;
1474 hr = d3d10_pixel_shader_init(object, This, byte_code, byte_code_length);
1475 if (FAILED(hr))
1477 WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
1478 HeapFree(GetProcessHeap(), 0, object);
1479 return hr;
1482 TRACE("Created pixel shader %p.\n", object);
1483 *shader = &object->ID3D10PixelShader_iface;
1485 return S_OK;
1488 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device1 *iface,
1489 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1491 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1492 struct d3d10_blend_state *object;
1493 struct wine_rb_entry *entry;
1494 HRESULT hr;
1496 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
1498 if (!desc)
1499 return E_INVALIDARG;
1501 if ((entry = wine_rb_get(&device->blend_states, desc)))
1503 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_blend_state, entry);
1505 TRACE("Returning existing blend state %p.\n", object);
1506 *blend_state = &object->ID3D10BlendState_iface;
1507 ID3D10BlendState_AddRef(*blend_state);
1509 return S_OK;
1512 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1513 if (!object)
1514 return E_OUTOFMEMORY;
1516 if (FAILED(hr = d3d10_blend_state_init(object, device, desc)))
1518 WARN("Failed to initialize blend state, hr %#x.\n", hr);
1519 HeapFree(GetProcessHeap(), 0, object);
1520 return hr;
1523 TRACE("Created blend state %p.\n", object);
1524 *blend_state = &object->ID3D10BlendState_iface;
1526 return S_OK;
1529 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device1 *iface,
1530 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1532 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1533 struct d3d10_depthstencil_state *object;
1534 struct wine_rb_entry *entry;
1535 HRESULT hr;
1537 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
1539 if (!desc)
1540 return E_INVALIDARG;
1542 if ((entry = wine_rb_get(&device->depthstencil_states, desc)))
1544 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_depthstencil_state, entry);
1546 TRACE("Returning existing depthstencil state %p.\n", object);
1547 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1548 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1550 return S_OK;
1553 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1554 if (!object)
1555 return E_OUTOFMEMORY;
1557 if (FAILED(hr = d3d10_depthstencil_state_init(object, device, desc)))
1559 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1560 HeapFree(GetProcessHeap(), 0, object);
1561 return hr;
1564 TRACE("Created depthstencil state %p.\n", object);
1565 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1567 return S_OK;
1570 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device1 *iface,
1571 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1573 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1574 struct d3d10_rasterizer_state *object;
1575 struct wine_rb_entry *entry;
1576 HRESULT hr;
1578 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1580 if (!desc)
1581 return E_INVALIDARG;
1583 if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
1585 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_rasterizer_state, entry);
1587 TRACE("Returning existing rasterizer state %p.\n", object);
1588 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1589 ID3D10RasterizerState_AddRef(*rasterizer_state);
1591 return S_OK;
1595 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1596 if (!object)
1597 return E_OUTOFMEMORY;
1599 if (FAILED(hr = d3d10_rasterizer_state_init(object, device, desc)))
1601 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1602 HeapFree(GetProcessHeap(), 0, object);
1603 return hr;
1606 TRACE("Created rasterizer state %p.\n", object);
1607 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1609 return S_OK;
1612 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
1613 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1615 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1616 struct d3d10_sampler_state *object;
1617 struct wine_rb_entry *entry;
1618 HRESULT hr;
1620 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
1622 if (!desc)
1623 return E_INVALIDARG;
1625 if ((entry = wine_rb_get(&device->sampler_states, desc)))
1627 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_sampler_state, entry);
1629 TRACE("Returning existing sampler state %p.\n", object);
1630 *sampler_state = &object->ID3D10SamplerState_iface;
1631 ID3D10SamplerState_AddRef(*sampler_state);
1633 return S_OK;
1636 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1637 if (!object)
1638 return E_OUTOFMEMORY;
1640 if (FAILED(hr = d3d10_sampler_state_init(object, device, desc)))
1642 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
1643 HeapFree(GetProcessHeap(), 0, object);
1644 return hr;
1647 TRACE("Created sampler state %p.\n", object);
1648 *sampler_state = &object->ID3D10SamplerState_iface;
1650 return S_OK;
1653 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
1654 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1656 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1657 struct d3d10_query *object;
1658 HRESULT hr;
1660 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
1662 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1663 return E_OUTOFMEMORY;
1665 if (FAILED(hr = d3d10_query_init(object, device, FALSE)))
1667 WARN("Failed to initialize query, hr %#x.\n", hr);
1668 HeapFree(GetProcessHeap(), 0, object);
1669 return hr;
1672 TRACE("Created query %p.\n", object);
1673 *query = &object->ID3D10Query_iface;
1675 return S_OK;
1678 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *iface,
1679 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1681 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1682 struct d3d10_query *object;
1683 HRESULT hr;
1685 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
1687 if (!desc)
1688 return E_INVALIDARG;
1690 if (desc->Query != D3D10_QUERY_OCCLUSION_PREDICATE && desc->Query != D3D10_QUERY_SO_OVERFLOW_PREDICATE)
1692 WARN("Query type %#x is not a predicate.\n", desc->Query);
1693 return E_INVALIDARG;
1696 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1697 return E_OUTOFMEMORY;
1699 if (FAILED(hr = d3d10_query_init(object, device, TRUE)))
1701 WARN("Failed to initialize predicate, hr %#x.\n", hr);
1702 HeapFree(GetProcessHeap(), 0, object);
1703 return hr;
1706 TRACE("Created predicate %p.\n", object);
1707 *predicate = (ID3D10Predicate *)&object->ID3D10Query_iface;
1709 return S_OK;
1712 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device1 *iface,
1713 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1715 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1717 return E_NOTIMPL;
1720 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 *iface,
1721 DXGI_FORMAT format, UINT *format_support)
1723 FIXME("iface %p, format %s, format_support %p stub!\n",
1724 iface, debug_dxgi_format(format), format_support);
1726 return E_NOTIMPL;
1729 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface,
1730 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1732 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1733 iface, debug_dxgi_format(format), sample_count, quality_level_count);
1735 return E_NOTIMPL;
1738 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device1 *iface, D3D10_COUNTER_INFO *counter_info)
1740 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1743 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device1 *iface,
1744 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, char *name,
1745 UINT *name_length, char *units, UINT *units_length, char *description, UINT *description_length)
1747 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1748 "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1749 iface, desc, type, active_counters, name, name_length,
1750 units, units_length, description, description_length);
1752 return E_NOTIMPL;
1755 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device1 *iface)
1757 FIXME("iface %p stub!\n", iface);
1759 return 0;
1762 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device1 *iface,
1763 HANDLE resource_handle, REFIID guid, void **resource)
1765 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1766 iface, resource_handle, debugstr_guid(guid), resource);
1768 return E_NOTIMPL;
1771 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device1 *iface, UINT width, UINT height)
1773 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1776 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device1 *iface, UINT *width, UINT *height)
1778 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1781 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView1(ID3D10Device1 *iface,
1782 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc, ID3D10ShaderResourceView1 **view)
1784 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1786 return E_NOTIMPL;
1789 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState1(ID3D10Device1 *iface,
1790 const D3D10_BLEND_DESC1 *desc, ID3D10BlendState1 **blend_state)
1792 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface, desc, blend_state);
1794 return E_NOTIMPL;
1797 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE d3d10_device_GetFeatureLevel(ID3D10Device1 *iface)
1799 FIXME("iface %p stub!\n", iface);
1801 return D3D10_FEATURE_LEVEL_10_1;
1804 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl =
1806 /* IUnknown methods */
1807 d3d10_device_QueryInterface,
1808 d3d10_device_AddRef,
1809 d3d10_device_Release,
1810 /* ID3D10Device methods */
1811 d3d10_device_VSSetConstantBuffers,
1812 d3d10_device_PSSetShaderResources,
1813 d3d10_device_PSSetShader,
1814 d3d10_device_PSSetSamplers,
1815 d3d10_device_VSSetShader,
1816 d3d10_device_DrawIndexed,
1817 d3d10_device_Draw,
1818 d3d10_device_PSSetConstantBuffers,
1819 d3d10_device_IASetInputLayout,
1820 d3d10_device_IASetVertexBuffers,
1821 d3d10_device_IASetIndexBuffer,
1822 d3d10_device_DrawIndexedInstanced,
1823 d3d10_device_DrawInstanced,
1824 d3d10_device_GSSetConstantBuffers,
1825 d3d10_device_GSSetShader,
1826 d3d10_device_IASetPrimitiveTopology,
1827 d3d10_device_VSSetShaderResources,
1828 d3d10_device_VSSetSamplers,
1829 d3d10_device_SetPredication,
1830 d3d10_device_GSSetShaderResources,
1831 d3d10_device_GSSetSamplers,
1832 d3d10_device_OMSetRenderTargets,
1833 d3d10_device_OMSetBlendState,
1834 d3d10_device_OMSetDepthStencilState,
1835 d3d10_device_SOSetTargets,
1836 d3d10_device_DrawAuto,
1837 d3d10_device_RSSetState,
1838 d3d10_device_RSSetViewports,
1839 d3d10_device_RSSetScissorRects,
1840 d3d10_device_CopySubresourceRegion,
1841 d3d10_device_CopyResource,
1842 d3d10_device_UpdateSubresource,
1843 d3d10_device_ClearRenderTargetView,
1844 d3d10_device_ClearDepthStencilView,
1845 d3d10_device_GenerateMips,
1846 d3d10_device_ResolveSubresource,
1847 d3d10_device_VSGetConstantBuffers,
1848 d3d10_device_PSGetShaderResources,
1849 d3d10_device_PSGetShader,
1850 d3d10_device_PSGetSamplers,
1851 d3d10_device_VSGetShader,
1852 d3d10_device_PSGetConstantBuffers,
1853 d3d10_device_IAGetInputLayout,
1854 d3d10_device_IAGetVertexBuffers,
1855 d3d10_device_IAGetIndexBuffer,
1856 d3d10_device_GSGetConstantBuffers,
1857 d3d10_device_GSGetShader,
1858 d3d10_device_IAGetPrimitiveTopology,
1859 d3d10_device_VSGetShaderResources,
1860 d3d10_device_VSGetSamplers,
1861 d3d10_device_GetPredication,
1862 d3d10_device_GSGetShaderResources,
1863 d3d10_device_GSGetSamplers,
1864 d3d10_device_OMGetRenderTargets,
1865 d3d10_device_OMGetBlendState,
1866 d3d10_device_OMGetDepthStencilState,
1867 d3d10_device_SOGetTargets,
1868 d3d10_device_RSGetState,
1869 d3d10_device_RSGetViewports,
1870 d3d10_device_RSGetScissorRects,
1871 d3d10_device_GetDeviceRemovedReason,
1872 d3d10_device_SetExceptionMode,
1873 d3d10_device_GetExceptionMode,
1874 d3d10_device_GetPrivateData,
1875 d3d10_device_SetPrivateData,
1876 d3d10_device_SetPrivateDataInterface,
1877 d3d10_device_ClearState,
1878 d3d10_device_Flush,
1879 d3d10_device_CreateBuffer,
1880 d3d10_device_CreateTexture1D,
1881 d3d10_device_CreateTexture2D,
1882 d3d10_device_CreateTexture3D,
1883 d3d10_device_CreateShaderResourceView,
1884 d3d10_device_CreateRenderTargetView,
1885 d3d10_device_CreateDepthStencilView,
1886 d3d10_device_CreateInputLayout,
1887 d3d10_device_CreateVertexShader,
1888 d3d10_device_CreateGeometryShader,
1889 d3d10_device_CreateGeometryShaderWithStreamOutput,
1890 d3d10_device_CreatePixelShader,
1891 d3d10_device_CreateBlendState,
1892 d3d10_device_CreateDepthStencilState,
1893 d3d10_device_CreateRasterizerState,
1894 d3d10_device_CreateSamplerState,
1895 d3d10_device_CreateQuery,
1896 d3d10_device_CreatePredicate,
1897 d3d10_device_CreateCounter,
1898 d3d10_device_CheckFormatSupport,
1899 d3d10_device_CheckMultisampleQualityLevels,
1900 d3d10_device_CheckCounterInfo,
1901 d3d10_device_CheckCounter,
1902 d3d10_device_GetCreationFlags,
1903 d3d10_device_OpenSharedResource,
1904 d3d10_device_SetTextFilterSize,
1905 d3d10_device_GetTextFilterSize,
1906 d3d10_device_CreateShaderResourceView1,
1907 d3d10_device_CreateBlendState1,
1908 d3d10_device_GetFeatureLevel,
1911 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1913 /* IUnknown methods */
1914 d3d10_device_inner_QueryInterface,
1915 d3d10_device_inner_AddRef,
1916 d3d10_device_inner_Release,
1919 static inline struct d3d10_device *impl_from_ID3D10Multithread(ID3D10Multithread *iface)
1921 return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Multithread_iface);
1924 static HRESULT STDMETHODCALLTYPE d3d10_multithread_QueryInterface(ID3D10Multithread *iface, REFIID iid, void **out)
1926 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1928 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
1930 return IUnknown_QueryInterface(device->outer_unk, iid, out);
1933 static ULONG STDMETHODCALLTYPE d3d10_multithread_AddRef(ID3D10Multithread *iface)
1935 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1937 TRACE("iface %p.\n", iface);
1939 return IUnknown_AddRef(device->outer_unk);
1942 static ULONG STDMETHODCALLTYPE d3d10_multithread_Release(ID3D10Multithread *iface)
1944 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1946 TRACE("iface %p.\n", iface);
1948 return IUnknown_Release(device->outer_unk);
1951 static void STDMETHODCALLTYPE d3d10_multithread_Enter(ID3D10Multithread *iface)
1953 TRACE("iface %p.\n", iface);
1955 wined3d_mutex_lock();
1958 static void STDMETHODCALLTYPE d3d10_multithread_Leave(ID3D10Multithread *iface)
1960 TRACE("iface %p.\n", iface);
1962 wined3d_mutex_unlock();
1965 static BOOL STDMETHODCALLTYPE d3d10_multithread_SetMultithreadProtected(ID3D10Multithread *iface, BOOL protect)
1967 FIXME("iface %p, protect %#x stub!\n", iface, protect);
1969 return TRUE;
1972 static BOOL STDMETHODCALLTYPE d3d10_multithread_GetMultithreadProtected(ID3D10Multithread *iface)
1974 FIXME("iface %p stub!\n", iface);
1976 return TRUE;
1979 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl =
1981 d3d10_multithread_QueryInterface,
1982 d3d10_multithread_AddRef,
1983 d3d10_multithread_Release,
1984 d3d10_multithread_Enter,
1985 d3d10_multithread_Leave,
1986 d3d10_multithread_SetMultithreadProtected,
1987 d3d10_multithread_GetMultithreadProtected,
1990 static void STDMETHODCALLTYPE d3d10_subresource_destroyed(void *parent) {}
1992 static const struct wined3d_parent_ops d3d10_subresource_parent_ops =
1994 d3d10_subresource_destroyed,
1997 /* IWineDXGIDeviceParent IUnknown methods */
1999 static inline struct d3d10_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
2001 return CONTAINING_RECORD(iface, struct d3d10_device, IWineDXGIDeviceParent_iface);
2004 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
2005 REFIID riid, void **ppv)
2007 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2008 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
2011 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
2013 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2014 return IUnknown_AddRef(device->outer_unk);
2017 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
2019 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2020 return IUnknown_Release(device->outer_unk);
2023 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
2024 IWineDXGIDeviceParent *iface)
2026 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
2027 return &device->device_parent;
2030 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl =
2032 /* IUnknown methods */
2033 dxgi_device_parent_QueryInterface,
2034 dxgi_device_parent_AddRef,
2035 dxgi_device_parent_Release,
2036 /* IWineDXGIDeviceParent methods */
2037 dxgi_device_parent_get_wined3d_device_parent,
2040 static inline struct d3d10_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
2042 return CONTAINING_RECORD(device_parent, struct d3d10_device, device_parent);
2045 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
2046 struct wined3d_device *wined3d_device)
2048 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2050 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
2052 wined3d_device_incref(wined3d_device);
2053 device->wined3d_device = wined3d_device;
2056 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
2058 TRACE("device_parent %p.\n", device_parent);
2061 static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate)
2063 TRACE("device_parent %p, activate %#x.\n", device_parent, activate);
2066 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
2067 void *container_parent, struct wined3d_surface *surface, void **parent,
2068 const struct wined3d_parent_ops **parent_ops)
2070 TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
2071 device_parent, container_parent, surface, parent, parent_ops);
2073 *parent = container_parent;
2074 *parent_ops = &d3d10_null_wined3d_parent_ops;
2076 return S_OK;
2079 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
2080 void *container_parent, struct wined3d_volume *volume, void **parent,
2081 const struct wined3d_parent_ops **parent_ops)
2083 TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
2084 device_parent, container_parent, volume, parent, parent_ops);
2086 *parent = container_parent;
2087 *parent_ops = &d3d10_null_wined3d_parent_ops;
2089 return S_OK;
2092 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
2093 void *container_parent, const struct wined3d_resource_desc *wined3d_desc, struct wined3d_surface **surface)
2095 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2096 struct wined3d_resource *sub_resource;
2097 struct d3d10_texture2d *texture;
2098 D3D10_TEXTURE2D_DESC desc;
2099 HRESULT hr;
2101 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, surface %p partial stub!\n",
2102 device_parent, container_parent, wined3d_desc, surface);
2104 FIXME("Implement DXGI<->wined3d usage conversion\n");
2106 desc.Width = wined3d_desc->width;
2107 desc.Height = wined3d_desc->height;
2108 desc.MipLevels = 1;
2109 desc.ArraySize = 1;
2110 desc.Format = dxgi_format_from_wined3dformat(wined3d_desc->format);
2111 desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1;
2112 desc.SampleDesc.Quality = wined3d_desc->multisample_quality;
2113 desc.Usage = D3D10_USAGE_DEFAULT;
2114 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
2115 desc.CPUAccessFlags = 0;
2116 desc.MiscFlags = 0;
2118 if (FAILED(hr = d3d10_device_CreateTexture2D(&device->ID3D10Device1_iface,
2119 &desc, NULL, (ID3D10Texture2D **)&texture)))
2121 ERR("CreateTexture2D failed, returning %#x\n", hr);
2122 return hr;
2125 sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
2126 *surface = wined3d_surface_from_resource(sub_resource);
2127 wined3d_surface_incref(*surface);
2128 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
2130 return S_OK;
2133 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
2134 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
2136 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2137 IWineDXGIDevice *wine_device;
2138 HRESULT hr;
2140 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain);
2142 if (FAILED(hr = d3d10_device_QueryInterface(&device->ID3D10Device1_iface,
2143 &IID_IWineDXGIDevice, (void **)&wine_device)))
2145 ERR("Device should implement IWineDXGIDevice.\n");
2146 return E_FAIL;
2149 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
2150 IWineDXGIDevice_Release(wine_device);
2151 if (FAILED(hr))
2153 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
2154 return hr;
2157 return S_OK;
2160 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
2162 device_parent_wined3d_device_created,
2163 device_parent_mode_changed,
2164 device_parent_activate,
2165 device_parent_surface_created,
2166 device_parent_volume_created,
2167 device_parent_create_swapchain_surface,
2168 device_parent_create_swapchain,
2171 static void *d3d10_rb_alloc(size_t size)
2173 return HeapAlloc(GetProcessHeap(), 0, size);
2176 static void *d3d10_rb_realloc(void *ptr, size_t size)
2178 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
2181 static void d3d10_rb_free(void *ptr)
2183 HeapFree(GetProcessHeap(), 0, ptr);
2186 static int d3d10_sampler_state_compare(const void *key, const struct wine_rb_entry *entry)
2188 const D3D10_SAMPLER_DESC *ka = key;
2189 const D3D10_SAMPLER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_sampler_state, entry)->desc;
2191 return memcmp(ka, kb, sizeof(*ka));
2194 static const struct wine_rb_functions d3d10_sampler_state_rb_ops =
2196 d3d10_rb_alloc,
2197 d3d10_rb_realloc,
2198 d3d10_rb_free,
2199 d3d10_sampler_state_compare,
2202 static int d3d10_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
2204 const D3D10_BLEND_DESC *ka = key;
2205 const D3D10_BLEND_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_blend_state, entry)->desc;
2207 return memcmp(ka, kb, sizeof(*ka));
2210 static const struct wine_rb_functions d3d10_blend_state_rb_ops =
2212 d3d10_rb_alloc,
2213 d3d10_rb_realloc,
2214 d3d10_rb_free,
2215 d3d10_blend_state_compare,
2218 static int d3d10_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
2220 const D3D10_DEPTH_STENCIL_DESC *ka = key;
2221 const D3D10_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
2222 const struct d3d10_depthstencil_state, entry)->desc;
2224 return memcmp(ka, kb, sizeof(*ka));
2227 static const struct wine_rb_functions d3d10_depthstencil_state_rb_ops =
2229 d3d10_rb_alloc,
2230 d3d10_rb_realloc,
2231 d3d10_rb_free,
2232 d3d10_depthstencil_state_compare,
2235 static int d3d10_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
2237 const D3D10_RASTERIZER_DESC *ka = key;
2238 const D3D10_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_rasterizer_state, entry)->desc;
2240 return memcmp(ka, kb, sizeof(*ka));
2243 static const struct wine_rb_functions d3d10_rasterizer_state_rb_ops =
2245 d3d10_rb_alloc,
2246 d3d10_rb_realloc,
2247 d3d10_rb_free,
2248 d3d10_rasterizer_state_compare,
2251 HRESULT d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
2253 device->IUnknown_inner.lpVtbl = &d3d10_device_inner_unknown_vtbl;
2254 device->ID3D10Device1_iface.lpVtbl = &d3d10_device1_vtbl;
2255 device->ID3D10Multithread_iface.lpVtbl = &d3d10_multithread_vtbl;
2256 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d10_dxgi_device_parent_vtbl;
2257 device->device_parent.ops = &d3d10_wined3d_device_parent_ops;
2258 device->refcount = 1;
2259 /* COM aggregation always takes place */
2260 device->outer_unk = outer_unknown;
2262 if (wine_rb_init(&device->blend_states, &d3d10_blend_state_rb_ops) == -1)
2264 WARN("Failed to initialize blend state rbtree.\n");
2265 return E_FAIL;
2268 if (wine_rb_init(&device->depthstencil_states, &d3d10_depthstencil_state_rb_ops) == -1)
2270 WARN("Failed to initialize depthstencil state rbtree.\n");
2271 wine_rb_destroy(&device->blend_states, NULL, NULL);
2272 return E_FAIL;
2275 if (wine_rb_init(&device->rasterizer_states, &d3d10_rasterizer_state_rb_ops) == -1)
2277 WARN("Failed to initialize rasterizer state rbtree.\n");
2278 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2279 wine_rb_destroy(&device->blend_states, NULL, NULL);
2280 return E_FAIL;
2283 if (wine_rb_init(&device->sampler_states, &d3d10_sampler_state_rb_ops) == -1)
2285 WARN("Failed to initialize sampler state rbtree.\n");
2286 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
2287 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2288 wine_rb_destroy(&device->blend_states, NULL, NULL);
2289 return E_FAIL;
2292 return S_OK;