msvcrt: Add small blocks heap tests.
[wine.git] / dlls / d3d10core / device.c
blob722b5aa9d26f8a876fa74761f6547925366b9eba
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 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
343 iface, start_slot, view_count, views);
346 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device1 *iface,
347 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
349 struct d3d10_device *device = impl_from_ID3D10Device(iface);
350 unsigned int i;
352 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
353 iface, start_slot, sampler_count, samplers);
355 for (i = 0; i < sampler_count; ++i)
357 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
359 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
360 sampler ? sampler->wined3d_sampler : NULL);
364 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device1 *iface, ID3D10Predicate *predicate, BOOL value)
366 FIXME("iface %p, predicate %p, value %d stub!\n", iface, predicate, value);
369 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device1 *iface,
370 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
372 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
373 iface, start_slot, view_count, views);
376 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device1 *iface,
377 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
379 struct d3d10_device *device = impl_from_ID3D10Device(iface);
380 unsigned int i;
382 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
383 iface, start_slot, sampler_count, samplers);
385 for (i = 0; i < sampler_count; ++i)
387 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
389 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
390 sampler ? sampler->wined3d_sampler : NULL);
394 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device1 *iface,
395 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
396 ID3D10DepthStencilView *depth_stencil_view)
398 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p\n",
399 iface, render_target_view_count, render_target_views, depth_stencil_view);
402 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface,
403 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
405 struct d3d10_device *device = impl_from_ID3D10Device(iface);
407 TRACE("iface %p, blend_state %p, blend_factor [%f %f %f %f], sample_mask 0x%08x.\n",
408 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
410 device->blend_state = unsafe_impl_from_ID3D10BlendState(blend_state);
411 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
412 device->sample_mask = sample_mask;
415 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1 *iface,
416 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
418 struct d3d10_device *device = impl_from_ID3D10Device(iface);
420 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
421 iface, depth_stencil_state, stencil_ref);
423 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
424 device->stencil_ref = stencil_ref;
427 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface,
428 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
430 struct d3d10_device *device = impl_from_ID3D10Device(iface);
431 unsigned int count, i;
433 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
435 count = min(target_count, 4);
436 for (i = 0; i < count; ++i)
438 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
440 wined3d_device_set_stream_output(device->wined3d_device, i,
441 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
444 for (i = count; i < 4; ++i)
446 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
450 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device1 *iface)
452 FIXME("iface %p stub!\n", iface);
455 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device1 *iface, ID3D10RasterizerState *rasterizer_state)
457 struct d3d10_device *device = impl_from_ID3D10Device(iface);
459 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
461 device->rasterizer_state = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state);
464 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface,
465 UINT viewport_count, const D3D10_VIEWPORT *viewports)
467 struct d3d10_device *device = impl_from_ID3D10Device(iface);
468 struct wined3d_viewport wined3d_vp;
470 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
472 if (viewport_count > 1)
473 FIXME("Multiple viewports not implemented.\n");
475 if (!viewport_count)
476 return;
478 wined3d_vp.x = viewports[0].TopLeftX;
479 wined3d_vp.y = viewports[0].TopLeftY;
480 wined3d_vp.width = viewports[0].Width;
481 wined3d_vp.height = viewports[0].Height;
482 wined3d_vp.min_z = viewports[0].MinDepth;
483 wined3d_vp.max_z = viewports[0].MaxDepth;
485 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
488 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *iface,
489 UINT rect_count, const D3D10_RECT *rects)
491 struct d3d10_device *device = impl_from_ID3D10Device(iface);
493 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
495 if (rect_count > 1)
496 FIXME("Multiple scissor rects not implemented.\n");
498 if (!rect_count)
499 return;
501 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
504 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *iface,
505 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
506 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
508 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u,\n"
509 "\tsrc_resource %p, src_subresource_idx %u, src_box %p stub!\n",
510 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
511 src_resource, src_subresource_idx, src_box);
514 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,
515 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
517 FIXME("iface %p, dst_resource %p, src_resource %p stub!\n", iface, dst_resource, src_resource);
520 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface,
521 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
522 const void *data, UINT row_pitch, UINT depth_pitch)
524 FIXME("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
525 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
528 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 *iface,
529 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
531 struct d3d10_device *This = impl_from_ID3D10Device(iface);
532 struct d3d10_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
533 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
535 TRACE("iface %p, render_target_view %p, color_rgba [%f %f %f %f]\n",
536 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
538 wined3d_device_clear_rendertarget_view(This->wined3d_device, view->wined3d_view, &color);
541 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *iface,
542 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
544 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
545 iface, depth_stencil_view, flags, depth, stencil);
548 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
549 ID3D10ShaderResourceView *shader_resource_view)
551 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
554 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *iface,
555 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
556 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
558 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u,\n"
559 "\tsrc_resource %p, src_subresource_idx %u, format %s stub!\n",
560 iface, dst_resource, dst_subresource_idx,
561 src_resource, src_subresource_idx, debug_dxgi_format(format));
564 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device1 *iface,
565 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
567 struct d3d10_device *device = impl_from_ID3D10Device(iface);
568 unsigned int i;
570 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
571 iface, start_slot, buffer_count, buffers);
573 for (i = 0; i < buffer_count; ++i)
575 struct wined3d_buffer *wined3d_buffer;
576 struct d3d10_buffer *buffer_impl;
578 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
580 buffers[i] = NULL;
581 continue;
584 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
585 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
586 ID3D10Buffer_AddRef(buffers[i]);
590 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device1 *iface,
591 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
593 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
594 iface, start_slot, view_count, views);
597 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device1 *iface, ID3D10PixelShader **shader)
599 struct d3d10_device *device = impl_from_ID3D10Device(iface);
600 struct d3d10_pixel_shader *shader_impl;
601 struct wined3d_shader *wined3d_shader;
603 TRACE("iface %p, shader %p.\n", iface, shader);
605 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
607 *shader = NULL;
608 return;
611 shader_impl = wined3d_shader_get_parent(wined3d_shader);
612 *shader = &shader_impl->ID3D10PixelShader_iface;
613 ID3D10PixelShader_AddRef(*shader);
616 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device1 *iface,
617 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
619 struct d3d10_device *device = impl_from_ID3D10Device(iface);
620 unsigned int i;
622 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
623 iface, start_slot, sampler_count, samplers);
625 for (i = 0; i < sampler_count; ++i)
627 struct d3d10_sampler_state *sampler_impl;
628 struct wined3d_sampler *wined3d_sampler;
630 if (!(wined3d_sampler = wined3d_device_get_ps_sampler(device->wined3d_device, start_slot + i)))
632 samplers[i] = NULL;
633 continue;
636 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
637 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
638 ID3D10SamplerState_AddRef(samplers[i]);
642 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device1 *iface, ID3D10VertexShader **shader)
644 struct d3d10_device *device = impl_from_ID3D10Device(iface);
645 struct d3d10_vertex_shader *shader_impl;
646 struct wined3d_shader *wined3d_shader;
648 TRACE("iface %p, shader %p.\n", iface, shader);
650 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
652 *shader = NULL;
653 return;
656 shader_impl = wined3d_shader_get_parent(wined3d_shader);
657 *shader = &shader_impl->ID3D10VertexShader_iface;
658 ID3D10VertexShader_AddRef(*shader);
661 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device1 *iface,
662 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
664 struct d3d10_device *device = impl_from_ID3D10Device(iface);
665 unsigned int i;
667 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
668 iface, start_slot, buffer_count, buffers);
670 for (i = 0; i < buffer_count; ++i)
672 struct wined3d_buffer *wined3d_buffer;
673 struct d3d10_buffer *buffer_impl;
675 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
677 buffers[i] = NULL;
678 continue;
681 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
682 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
683 ID3D10Buffer_AddRef(buffers[i]);
687 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device1 *iface, ID3D10InputLayout **input_layout)
689 struct d3d10_device *device = impl_from_ID3D10Device(iface);
690 struct wined3d_vertex_declaration *wined3d_declaration;
691 struct d3d10_input_layout *input_layout_impl;
693 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
695 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
697 *input_layout = NULL;
698 return;
701 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
702 *input_layout = &input_layout_impl->ID3D10InputLayout_iface;
703 ID3D10InputLayout_AddRef(*input_layout);
706 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device1 *iface,
707 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
709 struct d3d10_device *device = impl_from_ID3D10Device(iface);
710 unsigned int i;
712 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
713 iface, start_slot, buffer_count, buffers, strides, offsets);
715 for (i = 0; i < buffer_count; ++i)
717 struct wined3d_buffer *wined3d_buffer;
718 struct d3d10_buffer *buffer_impl;
720 if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
721 &wined3d_buffer, &offsets[i], &strides[i])))
722 ERR("Failed to get vertex buffer.\n");
724 if (!wined3d_buffer)
726 buffers[i] = NULL;
727 continue;
730 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
731 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
732 ID3D10Buffer_AddRef(buffers[i]);
736 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device1 *iface,
737 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
739 struct d3d10_device *device = impl_from_ID3D10Device(iface);
740 enum wined3d_format_id wined3d_format;
741 struct wined3d_buffer *wined3d_buffer;
742 struct d3d10_buffer *buffer_impl;
744 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
746 wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
747 *format = dxgi_format_from_wined3dformat(wined3d_format);
748 *offset = 0; /* FIXME */
749 if (!wined3d_buffer)
751 *buffer = NULL;
752 return;
755 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
756 *buffer = &buffer_impl->ID3D10Buffer_iface;
757 ID3D10Buffer_AddRef(*buffer);
760 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device1 *iface,
761 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
763 struct d3d10_device *device = impl_from_ID3D10Device(iface);
764 unsigned int i;
766 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
767 iface, start_slot, buffer_count, buffers);
769 for (i = 0; i < buffer_count; ++i)
771 struct wined3d_buffer *wined3d_buffer;
772 struct d3d10_buffer *buffer_impl;
774 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
776 buffers[i] = NULL;
777 continue;
780 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
781 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
782 ID3D10Buffer_AddRef(buffers[i]);
786 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device1 *iface, ID3D10GeometryShader **shader)
788 struct d3d10_device *device = impl_from_ID3D10Device(iface);
789 struct d3d10_geometry_shader *shader_impl;
790 struct wined3d_shader *wined3d_shader;
792 TRACE("iface %p, shader %p.\n", iface, shader);
794 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
796 *shader = NULL;
797 return;
800 shader_impl = wined3d_shader_get_parent(wined3d_shader);
801 *shader = &shader_impl->ID3D10GeometryShader_iface;
802 ID3D10GeometryShader_AddRef(*shader);
805 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device1 *iface,
806 D3D10_PRIMITIVE_TOPOLOGY *topology)
808 struct d3d10_device *This = impl_from_ID3D10Device(iface);
810 TRACE("iface %p, topology %p\n", iface, topology);
812 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
815 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device1 *iface,
816 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
818 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
819 iface, start_slot, view_count, views);
822 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device1 *iface,
823 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
825 struct d3d10_device *device = impl_from_ID3D10Device(iface);
826 unsigned int i;
828 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
829 iface, start_slot, sampler_count, samplers);
831 for (i = 0; i < sampler_count; ++i)
833 struct d3d10_sampler_state *sampler_impl;
834 struct wined3d_sampler *wined3d_sampler;
836 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
838 samplers[i] = NULL;
839 continue;
842 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
843 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
844 ID3D10SamplerState_AddRef(samplers[i]);
848 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device1 *iface,
849 ID3D10Predicate **predicate, BOOL *value)
851 FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
854 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device1 *iface,
855 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
857 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
858 iface, start_slot, view_count, views);
861 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device1 *iface,
862 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
864 struct d3d10_device *device = impl_from_ID3D10Device(iface);
865 unsigned int i;
867 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
868 iface, start_slot, sampler_count, samplers);
870 for (i = 0; i < sampler_count; ++i)
872 struct d3d10_sampler_state *sampler_impl;
873 struct wined3d_sampler *wined3d_sampler;
875 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
877 samplers[i] = NULL;
878 continue;
881 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
882 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
883 ID3D10SamplerState_AddRef(samplers[i]);
887 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device1 *iface,
888 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
890 FIXME("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p stub!\n",
891 iface, view_count, render_target_views, depth_stencil_view);
894 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface,
895 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
897 struct d3d10_device *device = impl_from_ID3D10Device(iface);
899 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
900 iface, blend_state, blend_factor, sample_mask);
902 if ((*blend_state = device->blend_state ? &device->blend_state->ID3D10BlendState_iface : NULL))
903 ID3D10BlendState_AddRef(*blend_state);
904 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
905 *sample_mask = device->sample_mask;
908 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
909 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
911 struct d3d10_device *device = impl_from_ID3D10Device(iface);
913 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
914 iface, depth_stencil_state, stencil_ref);
916 if ((*depth_stencil_state = device->depth_stencil_state
917 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
918 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
919 *stencil_ref = device->stencil_ref;
922 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device1 *iface,
923 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
925 struct d3d10_device *device = impl_from_ID3D10Device(iface);
926 unsigned int i;
928 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
929 iface, buffer_count, buffers, offsets);
931 for (i = 0; i < buffer_count; ++i)
933 struct wined3d_buffer *wined3d_buffer;
934 struct d3d10_buffer *buffer_impl;
936 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
938 buffers[i] = NULL;
939 continue;
942 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
943 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
944 ID3D10Buffer_AddRef(buffers[i]);
948 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device1 *iface, ID3D10RasterizerState **rasterizer_state)
950 struct d3d10_device *device = impl_from_ID3D10Device(iface);
952 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
954 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
955 ID3D10RasterizerState_AddRef(*rasterizer_state);
958 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface,
959 UINT *viewport_count, D3D10_VIEWPORT *viewports)
961 struct d3d10_device *device = impl_from_ID3D10Device(iface);
962 struct wined3d_viewport wined3d_vp;
964 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
966 if (!viewports)
968 *viewport_count = 1;
969 return;
972 if (!*viewport_count)
973 return;
975 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
977 viewports[0].TopLeftX = wined3d_vp.x;
978 viewports[0].TopLeftY = wined3d_vp.y;
979 viewports[0].Width = wined3d_vp.width;
980 viewports[0].Height = wined3d_vp.height;
981 viewports[0].MinDepth = wined3d_vp.min_z;
982 viewports[0].MaxDepth = wined3d_vp.max_z;
984 if (*viewport_count > 1)
985 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
988 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects)
990 struct d3d10_device *device = impl_from_ID3D10Device(iface);
992 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
994 if (!rects)
996 *rect_count = 1;
997 return;
1000 if (!*rect_count)
1001 return;
1003 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
1004 if (*rect_count > 1)
1005 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
1008 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device1 *iface)
1010 TRACE("iface %p.\n", iface);
1012 /* In the current implementation the device is never removed, so we can
1013 * just return S_OK here. */
1015 return S_OK;
1018 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device1 *iface, UINT flags)
1020 FIXME("iface %p, flags %#x stub!\n", iface, flags);
1022 return E_NOTIMPL;
1025 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device1 *iface)
1027 FIXME("iface %p stub!\n", iface);
1029 return 0;
1032 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *iface,
1033 REFGUID guid, UINT *data_size, void *data)
1035 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
1036 iface, debugstr_guid(guid), data_size, data);
1038 return E_NOTIMPL;
1041 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface,
1042 REFGUID guid, UINT data_size, const void *data)
1044 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
1045 iface, debugstr_guid(guid), data_size, data);
1047 return E_NOTIMPL;
1050 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface,
1051 REFGUID guid, const IUnknown *data)
1053 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
1055 return E_NOTIMPL;
1058 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface)
1060 FIXME("iface %p stub!\n", iface);
1063 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
1065 FIXME("iface %p stub!\n", iface);
1068 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
1069 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
1071 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1072 struct d3d10_buffer *object;
1073 HRESULT hr;
1075 FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
1077 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1078 if (!object)
1079 return E_OUTOFMEMORY;
1081 hr = d3d10_buffer_init(object, This, desc, data);
1082 if (FAILED(hr))
1084 WARN("Failed to initialize buffer, hr %#x.\n", hr);
1085 HeapFree(GetProcessHeap(), 0, object);
1086 return hr;
1089 *buffer = &object->ID3D10Buffer_iface;
1091 TRACE("Created ID3D10Buffer %p\n", object);
1093 return S_OK;
1096 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface,
1097 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
1099 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1101 return E_NOTIMPL;
1104 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface,
1105 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1106 ID3D10Texture2D **texture)
1108 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1109 struct d3d10_texture2d *object;
1110 HRESULT hr;
1112 FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
1114 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1115 if (!object)
1116 return E_OUTOFMEMORY;
1118 hr = d3d10_texture2d_init(object, This, desc);
1119 if (FAILED(hr))
1121 WARN("Failed to initialize texture, hr %#x.\n", hr);
1122 HeapFree(GetProcessHeap(), 0, object);
1123 return hr;
1126 *texture = &object->ID3D10Texture2D_iface;
1128 TRACE("Created ID3D10Texture2D %p\n", object);
1130 return S_OK;
1133 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device1 *iface,
1134 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1135 ID3D10Texture3D **texture)
1137 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1138 struct d3d10_texture3d *object;
1139 HRESULT hr;
1141 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1143 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1144 if (!object)
1145 return E_OUTOFMEMORY;
1147 hr = d3d10_texture3d_init(object, device, desc);
1148 if (FAILED(hr))
1150 WARN("Failed to initialize texture, hr %#x.\n", hr);
1151 HeapFree(GetProcessHeap(), 0, object);
1152 return hr;
1155 TRACE("Created 3D texture %p.\n", object);
1156 *texture = &object->ID3D10Texture3D_iface;
1158 return S_OK;
1161 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
1162 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
1164 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1165 struct d3d10_shader_resource_view *object;
1166 HRESULT hr;
1168 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1170 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1171 return E_OUTOFMEMORY;
1173 if (FAILED(hr = d3d10_shader_resource_view_init(object, device, resource, desc)))
1175 WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
1176 HeapFree(GetProcessHeap(), 0, object);
1177 return hr;
1180 TRACE("Created shader resource view %p.\n", object);
1181 *view = &object->ID3D10ShaderResourceView_iface;
1183 return S_OK;
1186 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device1 *iface,
1187 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
1189 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1190 struct d3d10_rendertarget_view *object;
1191 HRESULT hr;
1193 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1195 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1196 return E_OUTOFMEMORY;
1198 if (FAILED(hr = d3d10_rendertarget_view_init(object, device, resource, desc)))
1200 WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
1201 HeapFree(GetProcessHeap(), 0, object);
1202 return hr;
1205 TRACE("Created rendertarget view %p.\n", object);
1206 *view = &object->ID3D10RenderTargetView_iface;
1208 return S_OK;
1211 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device1 *iface,
1212 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
1214 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1215 struct d3d10_depthstencil_view *object;
1216 HRESULT hr;
1218 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1220 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1221 return E_OUTOFMEMORY;
1223 if (FAILED(hr = d3d10_depthstencil_view_init(object, device, resource, desc)))
1225 WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
1226 HeapFree(GetProcessHeap(), 0, object);
1227 return hr;
1230 TRACE("Created depthstencil view %p.\n", object);
1231 *view = &object->ID3D10DepthStencilView_iface;
1233 return S_OK;
1236 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *iface,
1237 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
1238 const void *shader_byte_code, SIZE_T shader_byte_code_length,
1239 ID3D10InputLayout **input_layout)
1241 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1242 struct d3d10_input_layout *object;
1243 HRESULT hr;
1245 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
1246 "\tshader_byte_code_length %lu, input_layout %p\n",
1247 iface, element_descs, element_count, shader_byte_code,
1248 shader_byte_code_length, input_layout);
1250 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1251 if (!object)
1252 return E_OUTOFMEMORY;
1254 hr = d3d10_input_layout_init(object, This, element_descs, element_count,
1255 shader_byte_code, shader_byte_code_length);
1256 if (FAILED(hr))
1258 WARN("Failed to initialize input layout, hr %#x.\n", hr);
1259 HeapFree(GetProcessHeap(), 0, object);
1260 return hr;
1263 TRACE("Created input layout %p.\n", object);
1264 *input_layout = &object->ID3D10InputLayout_iface;
1266 return S_OK;
1269 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device1 *iface,
1270 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
1272 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1273 struct d3d10_vertex_shader *object;
1274 HRESULT hr;
1276 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1277 iface, byte_code, byte_code_length, shader);
1279 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1280 if (!object)
1281 return E_OUTOFMEMORY;
1283 hr = d3d10_vertex_shader_init(object, This, byte_code, byte_code_length);
1284 if (FAILED(hr))
1286 WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
1287 HeapFree(GetProcessHeap(), 0, object);
1288 return hr;
1291 TRACE("Created vertex shader %p.\n", object);
1292 *shader = &object->ID3D10VertexShader_iface;
1294 return S_OK;
1297 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device1 *iface,
1298 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
1300 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1301 struct d3d10_geometry_shader *object;
1302 HRESULT hr;
1304 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p.\n",
1305 iface, byte_code, byte_code_length, shader);
1307 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1308 if (!object)
1309 return E_OUTOFMEMORY;
1311 hr = d3d10_geometry_shader_init(object, This, byte_code, byte_code_length);
1312 if (FAILED(hr))
1314 WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
1315 HeapFree(GetProcessHeap(), 0, object);
1316 return hr;
1319 TRACE("Created geometry shader %p.\n", object);
1320 *shader = &object->ID3D10GeometryShader_iface;
1322 return S_OK;
1325 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device1 *iface,
1326 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
1327 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
1329 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p,\n"
1330 "\toutput_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
1331 iface, byte_code, byte_code_length, output_stream_decls,
1332 output_stream_decl_count, output_stream_stride, shader);
1334 return E_NOTIMPL;
1337 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device1 *iface,
1338 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
1340 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1341 struct d3d10_pixel_shader *object;
1342 HRESULT hr;
1344 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1345 iface, byte_code, byte_code_length, shader);
1347 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1348 if (!object)
1349 return E_OUTOFMEMORY;
1351 hr = d3d10_pixel_shader_init(object, This, byte_code, byte_code_length);
1352 if (FAILED(hr))
1354 WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
1355 HeapFree(GetProcessHeap(), 0, object);
1356 return hr;
1359 TRACE("Created pixel shader %p.\n", object);
1360 *shader = &object->ID3D10PixelShader_iface;
1362 return S_OK;
1365 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState(ID3D10Device1 *iface,
1366 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1368 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1369 struct d3d10_blend_state *object;
1370 struct wine_rb_entry *entry;
1371 HRESULT hr;
1373 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
1375 if (!desc)
1376 return E_INVALIDARG;
1378 if ((entry = wine_rb_get(&device->blend_states, desc)))
1380 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_blend_state, entry);
1382 TRACE("Returning existing blend state %p.\n", object);
1383 *blend_state = &object->ID3D10BlendState_iface;
1384 ID3D10BlendState_AddRef(*blend_state);
1386 return S_OK;
1389 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1390 if (!object)
1391 return E_OUTOFMEMORY;
1393 if (FAILED(hr = d3d10_blend_state_init(object, device, desc)))
1395 WARN("Failed to initialize blend state, hr %#x.\n", hr);
1396 HeapFree(GetProcessHeap(), 0, object);
1397 return hr;
1400 TRACE("Created blend state %p.\n", object);
1401 *blend_state = &object->ID3D10BlendState_iface;
1403 return S_OK;
1406 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device1 *iface,
1407 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1409 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1410 struct d3d10_depthstencil_state *object;
1411 struct wine_rb_entry *entry;
1412 HRESULT hr;
1414 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
1416 if (!desc)
1417 return E_INVALIDARG;
1419 if ((entry = wine_rb_get(&device->depthstencil_states, desc)))
1421 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_depthstencil_state, entry);
1423 TRACE("Returning existing depthstencil state %p.\n", object);
1424 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1425 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
1427 return S_OK;
1430 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1431 if (!object)
1432 return E_OUTOFMEMORY;
1434 if (FAILED(hr = d3d10_depthstencil_state_init(object, device, desc)))
1436 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1437 HeapFree(GetProcessHeap(), 0, object);
1438 return hr;
1441 TRACE("Created depthstencil state %p.\n", object);
1442 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1444 return S_OK;
1447 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device1 *iface,
1448 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1450 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1451 struct d3d10_rasterizer_state *object;
1452 struct wine_rb_entry *entry;
1453 HRESULT hr;
1455 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1457 if (!desc)
1458 return E_INVALIDARG;
1460 if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
1462 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_rasterizer_state, entry);
1464 TRACE("Returning existing rasterizer state %p.\n", object);
1465 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1466 ID3D10RasterizerState_AddRef(*rasterizer_state);
1468 return S_OK;
1472 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1473 if (!object)
1474 return E_OUTOFMEMORY;
1476 if (FAILED(hr = d3d10_rasterizer_state_init(object, device, desc)))
1478 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1479 HeapFree(GetProcessHeap(), 0, object);
1480 return hr;
1483 TRACE("Created rasterizer state %p.\n", object);
1484 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1486 return S_OK;
1489 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
1490 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1492 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1493 struct d3d10_sampler_state *object;
1494 struct wine_rb_entry *entry;
1495 HRESULT hr;
1497 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
1499 if (!desc)
1500 return E_INVALIDARG;
1502 if ((entry = wine_rb_get(&device->sampler_states, desc)))
1504 object = WINE_RB_ENTRY_VALUE(entry, struct d3d10_sampler_state, entry);
1506 TRACE("Returning existing sampler state %p.\n", object);
1507 *sampler_state = &object->ID3D10SamplerState_iface;
1508 ID3D10SamplerState_AddRef(*sampler_state);
1510 return S_OK;
1513 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1514 if (!object)
1515 return E_OUTOFMEMORY;
1517 if (FAILED(hr = d3d10_sampler_state_init(object, device, desc)))
1519 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
1520 HeapFree(GetProcessHeap(), 0, object);
1521 return hr;
1524 TRACE("Created sampler state %p.\n", object);
1525 *sampler_state = &object->ID3D10SamplerState_iface;
1527 return S_OK;
1530 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
1531 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1533 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1534 struct d3d10_query *object;
1535 HRESULT hr;
1537 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
1539 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1540 return E_OUTOFMEMORY;
1542 if (FAILED(hr = d3d10_query_init(object, device, FALSE)))
1544 WARN("Failed to initialize query, hr %#x.\n", hr);
1545 HeapFree(GetProcessHeap(), 0, object);
1546 return hr;
1549 TRACE("Created query %p.\n", object);
1550 *query = &object->ID3D10Query_iface;
1552 return S_OK;
1555 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *iface,
1556 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1558 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1559 struct d3d10_query *object;
1560 HRESULT hr;
1562 TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
1564 if (!desc)
1565 return E_INVALIDARG;
1567 if (desc->Query != D3D10_QUERY_OCCLUSION_PREDICATE && desc->Query != D3D10_QUERY_SO_OVERFLOW_PREDICATE)
1569 WARN("Query type %#x is not a predicate.\n", desc->Query);
1570 return E_INVALIDARG;
1573 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1574 return E_OUTOFMEMORY;
1576 if (FAILED(hr = d3d10_query_init(object, device, TRUE)))
1578 WARN("Failed to initialize predicate, hr %#x.\n", hr);
1579 HeapFree(GetProcessHeap(), 0, object);
1580 return hr;
1583 TRACE("Created predicate %p.\n", object);
1584 *predicate = (ID3D10Predicate *)&object->ID3D10Query_iface;
1586 return S_OK;
1589 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device1 *iface,
1590 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1592 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1594 return E_NOTIMPL;
1597 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 *iface,
1598 DXGI_FORMAT format, UINT *format_support)
1600 FIXME("iface %p, format %s, format_support %p stub!\n",
1601 iface, debug_dxgi_format(format), format_support);
1603 return E_NOTIMPL;
1606 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface,
1607 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1609 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1610 iface, debug_dxgi_format(format), sample_count, quality_level_count);
1612 return E_NOTIMPL;
1615 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device1 *iface, D3D10_COUNTER_INFO *counter_info)
1617 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1620 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device1 *iface,
1621 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, char *name,
1622 UINT *name_length, char *units, UINT *units_length, char *description, UINT *description_length)
1624 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1625 "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1626 iface, desc, type, active_counters, name, name_length,
1627 units, units_length, description, description_length);
1629 return E_NOTIMPL;
1632 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device1 *iface)
1634 FIXME("iface %p stub!\n", iface);
1636 return 0;
1639 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device1 *iface,
1640 HANDLE resource_handle, REFIID guid, void **resource)
1642 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1643 iface, resource_handle, debugstr_guid(guid), resource);
1645 return E_NOTIMPL;
1648 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device1 *iface, UINT width, UINT height)
1650 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1653 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device1 *iface, UINT *width, UINT *height)
1655 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1658 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView1(ID3D10Device1 *iface,
1659 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc, ID3D10ShaderResourceView1 **view)
1661 FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1663 return E_NOTIMPL;
1666 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBlendState1(ID3D10Device1 *iface,
1667 const D3D10_BLEND_DESC1 *desc, ID3D10BlendState1 **blend_state)
1669 FIXME("iface %p, desc %p, blend_state %p stub!\n", iface, desc, blend_state);
1671 return E_NOTIMPL;
1674 static D3D10_FEATURE_LEVEL1 STDMETHODCALLTYPE d3d10_device_GetFeatureLevel(ID3D10Device1 *iface)
1676 FIXME("iface %p stub!\n", iface);
1678 return D3D10_FEATURE_LEVEL_10_1;
1681 static const struct ID3D10Device1Vtbl d3d10_device1_vtbl =
1683 /* IUnknown methods */
1684 d3d10_device_QueryInterface,
1685 d3d10_device_AddRef,
1686 d3d10_device_Release,
1687 /* ID3D10Device methods */
1688 d3d10_device_VSSetConstantBuffers,
1689 d3d10_device_PSSetShaderResources,
1690 d3d10_device_PSSetShader,
1691 d3d10_device_PSSetSamplers,
1692 d3d10_device_VSSetShader,
1693 d3d10_device_DrawIndexed,
1694 d3d10_device_Draw,
1695 d3d10_device_PSSetConstantBuffers,
1696 d3d10_device_IASetInputLayout,
1697 d3d10_device_IASetVertexBuffers,
1698 d3d10_device_IASetIndexBuffer,
1699 d3d10_device_DrawIndexedInstanced,
1700 d3d10_device_DrawInstanced,
1701 d3d10_device_GSSetConstantBuffers,
1702 d3d10_device_GSSetShader,
1703 d3d10_device_IASetPrimitiveTopology,
1704 d3d10_device_VSSetShaderResources,
1705 d3d10_device_VSSetSamplers,
1706 d3d10_device_SetPredication,
1707 d3d10_device_GSSetShaderResources,
1708 d3d10_device_GSSetSamplers,
1709 d3d10_device_OMSetRenderTargets,
1710 d3d10_device_OMSetBlendState,
1711 d3d10_device_OMSetDepthStencilState,
1712 d3d10_device_SOSetTargets,
1713 d3d10_device_DrawAuto,
1714 d3d10_device_RSSetState,
1715 d3d10_device_RSSetViewports,
1716 d3d10_device_RSSetScissorRects,
1717 d3d10_device_CopySubresourceRegion,
1718 d3d10_device_CopyResource,
1719 d3d10_device_UpdateSubresource,
1720 d3d10_device_ClearRenderTargetView,
1721 d3d10_device_ClearDepthStencilView,
1722 d3d10_device_GenerateMips,
1723 d3d10_device_ResolveSubresource,
1724 d3d10_device_VSGetConstantBuffers,
1725 d3d10_device_PSGetShaderResources,
1726 d3d10_device_PSGetShader,
1727 d3d10_device_PSGetSamplers,
1728 d3d10_device_VSGetShader,
1729 d3d10_device_PSGetConstantBuffers,
1730 d3d10_device_IAGetInputLayout,
1731 d3d10_device_IAGetVertexBuffers,
1732 d3d10_device_IAGetIndexBuffer,
1733 d3d10_device_GSGetConstantBuffers,
1734 d3d10_device_GSGetShader,
1735 d3d10_device_IAGetPrimitiveTopology,
1736 d3d10_device_VSGetShaderResources,
1737 d3d10_device_VSGetSamplers,
1738 d3d10_device_GetPredication,
1739 d3d10_device_GSGetShaderResources,
1740 d3d10_device_GSGetSamplers,
1741 d3d10_device_OMGetRenderTargets,
1742 d3d10_device_OMGetBlendState,
1743 d3d10_device_OMGetDepthStencilState,
1744 d3d10_device_SOGetTargets,
1745 d3d10_device_RSGetState,
1746 d3d10_device_RSGetViewports,
1747 d3d10_device_RSGetScissorRects,
1748 d3d10_device_GetDeviceRemovedReason,
1749 d3d10_device_SetExceptionMode,
1750 d3d10_device_GetExceptionMode,
1751 d3d10_device_GetPrivateData,
1752 d3d10_device_SetPrivateData,
1753 d3d10_device_SetPrivateDataInterface,
1754 d3d10_device_ClearState,
1755 d3d10_device_Flush,
1756 d3d10_device_CreateBuffer,
1757 d3d10_device_CreateTexture1D,
1758 d3d10_device_CreateTexture2D,
1759 d3d10_device_CreateTexture3D,
1760 d3d10_device_CreateShaderResourceView,
1761 d3d10_device_CreateRenderTargetView,
1762 d3d10_device_CreateDepthStencilView,
1763 d3d10_device_CreateInputLayout,
1764 d3d10_device_CreateVertexShader,
1765 d3d10_device_CreateGeometryShader,
1766 d3d10_device_CreateGeometryShaderWithStreamOutput,
1767 d3d10_device_CreatePixelShader,
1768 d3d10_device_CreateBlendState,
1769 d3d10_device_CreateDepthStencilState,
1770 d3d10_device_CreateRasterizerState,
1771 d3d10_device_CreateSamplerState,
1772 d3d10_device_CreateQuery,
1773 d3d10_device_CreatePredicate,
1774 d3d10_device_CreateCounter,
1775 d3d10_device_CheckFormatSupport,
1776 d3d10_device_CheckMultisampleQualityLevels,
1777 d3d10_device_CheckCounterInfo,
1778 d3d10_device_CheckCounter,
1779 d3d10_device_GetCreationFlags,
1780 d3d10_device_OpenSharedResource,
1781 d3d10_device_SetTextFilterSize,
1782 d3d10_device_GetTextFilterSize,
1783 d3d10_device_CreateShaderResourceView1,
1784 d3d10_device_CreateBlendState1,
1785 d3d10_device_GetFeatureLevel,
1788 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1790 /* IUnknown methods */
1791 d3d10_device_inner_QueryInterface,
1792 d3d10_device_inner_AddRef,
1793 d3d10_device_inner_Release,
1796 static inline struct d3d10_device *impl_from_ID3D10Multithread(ID3D10Multithread *iface)
1798 return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Multithread_iface);
1801 static HRESULT STDMETHODCALLTYPE d3d10_multithread_QueryInterface(ID3D10Multithread *iface, REFIID iid, void **out)
1803 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1805 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
1807 return IUnknown_QueryInterface(device->outer_unk, iid, out);
1810 static ULONG STDMETHODCALLTYPE d3d10_multithread_AddRef(ID3D10Multithread *iface)
1812 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1814 TRACE("iface %p.\n", iface);
1816 return IUnknown_AddRef(device->outer_unk);
1819 static ULONG STDMETHODCALLTYPE d3d10_multithread_Release(ID3D10Multithread *iface)
1821 struct d3d10_device *device = impl_from_ID3D10Multithread(iface);
1823 TRACE("iface %p.\n", iface);
1825 return IUnknown_Release(device->outer_unk);
1828 static void STDMETHODCALLTYPE d3d10_multithread_Enter(ID3D10Multithread *iface)
1830 TRACE("iface %p.\n", iface);
1832 wined3d_mutex_lock();
1835 static void STDMETHODCALLTYPE d3d10_multithread_Leave(ID3D10Multithread *iface)
1837 TRACE("iface %p.\n", iface);
1839 wined3d_mutex_unlock();
1842 static BOOL STDMETHODCALLTYPE d3d10_multithread_SetMultithreadProtected(ID3D10Multithread *iface, BOOL protect)
1844 FIXME("iface %p, protect %#x stub!\n", iface, protect);
1846 return TRUE;
1849 static BOOL STDMETHODCALLTYPE d3d10_multithread_GetMultithreadProtected(ID3D10Multithread *iface)
1851 FIXME("iface %p stub!\n", iface);
1853 return TRUE;
1856 static const struct ID3D10MultithreadVtbl d3d10_multithread_vtbl =
1858 d3d10_multithread_QueryInterface,
1859 d3d10_multithread_AddRef,
1860 d3d10_multithread_Release,
1861 d3d10_multithread_Enter,
1862 d3d10_multithread_Leave,
1863 d3d10_multithread_SetMultithreadProtected,
1864 d3d10_multithread_GetMultithreadProtected,
1867 static void STDMETHODCALLTYPE d3d10_subresource_destroyed(void *parent) {}
1869 static const struct wined3d_parent_ops d3d10_subresource_parent_ops =
1871 d3d10_subresource_destroyed,
1874 /* IWineDXGIDeviceParent IUnknown methods */
1876 static inline struct d3d10_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
1878 return CONTAINING_RECORD(iface, struct d3d10_device, IWineDXGIDeviceParent_iface);
1881 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
1882 REFIID riid, void **ppv)
1884 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1885 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
1888 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
1890 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1891 return IUnknown_AddRef(device->outer_unk);
1894 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
1896 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1897 return IUnknown_Release(device->outer_unk);
1900 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
1901 IWineDXGIDeviceParent *iface)
1903 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1904 return &device->device_parent;
1907 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl =
1909 /* IUnknown methods */
1910 dxgi_device_parent_QueryInterface,
1911 dxgi_device_parent_AddRef,
1912 dxgi_device_parent_Release,
1913 /* IWineDXGIDeviceParent methods */
1914 dxgi_device_parent_get_wined3d_device_parent,
1917 static inline struct d3d10_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
1919 return CONTAINING_RECORD(device_parent, struct d3d10_device, device_parent);
1922 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
1923 struct wined3d_device *wined3d_device)
1925 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1927 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
1929 wined3d_device_incref(wined3d_device);
1930 device->wined3d_device = wined3d_device;
1933 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
1935 TRACE("device_parent %p.\n", device_parent);
1938 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
1939 void *container_parent, struct wined3d_surface *surface, void **parent,
1940 const struct wined3d_parent_ops **parent_ops)
1942 TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
1943 device_parent, container_parent, surface, parent, parent_ops);
1945 *parent = container_parent;
1946 *parent_ops = &d3d10_null_wined3d_parent_ops;
1948 return S_OK;
1951 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
1952 void *container_parent, struct wined3d_volume *volume, void **parent,
1953 const struct wined3d_parent_ops **parent_ops)
1955 TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
1956 device_parent, container_parent, volume, parent, parent_ops);
1958 *parent = container_parent;
1959 *parent_ops = &d3d10_null_wined3d_parent_ops;
1961 return S_OK;
1964 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
1965 void *container_parent, const struct wined3d_resource_desc *wined3d_desc, struct wined3d_surface **surface)
1967 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1968 struct wined3d_resource *sub_resource;
1969 struct d3d10_texture2d *texture;
1970 D3D10_TEXTURE2D_DESC desc;
1971 HRESULT hr;
1973 FIXME("device_parent %p, container_parent %p, wined3d_desc %p, surface %p partial stub!\n",
1974 device_parent, container_parent, wined3d_desc, surface);
1976 FIXME("Implement DXGI<->wined3d usage conversion\n");
1978 desc.Width = wined3d_desc->width;
1979 desc.Height = wined3d_desc->height;
1980 desc.MipLevels = 1;
1981 desc.ArraySize = 1;
1982 desc.Format = dxgi_format_from_wined3dformat(wined3d_desc->format);
1983 desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1;
1984 desc.SampleDesc.Quality = wined3d_desc->multisample_quality;
1985 desc.Usage = D3D10_USAGE_DEFAULT;
1986 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
1987 desc.CPUAccessFlags = 0;
1988 desc.MiscFlags = 0;
1990 if (FAILED(hr = d3d10_device_CreateTexture2D(&device->ID3D10Device1_iface,
1991 &desc, NULL, (ID3D10Texture2D **)&texture)))
1993 ERR("CreateTexture2D failed, returning %#x\n", hr);
1994 return hr;
1997 sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
1998 *surface = wined3d_surface_from_resource(sub_resource);
1999 wined3d_surface_incref(*surface);
2000 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
2002 return S_OK;
2005 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
2006 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
2008 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
2009 IWineDXGIDevice *wine_device;
2010 HRESULT hr;
2012 TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain);
2014 if (FAILED(hr = d3d10_device_QueryInterface(&device->ID3D10Device1_iface,
2015 &IID_IWineDXGIDevice, (void **)&wine_device)))
2017 ERR("Device should implement IWineDXGIDevice.\n");
2018 return E_FAIL;
2021 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
2022 IWineDXGIDevice_Release(wine_device);
2023 if (FAILED(hr))
2025 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
2026 return hr;
2029 return S_OK;
2032 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
2034 device_parent_wined3d_device_created,
2035 device_parent_mode_changed,
2036 device_parent_surface_created,
2037 device_parent_volume_created,
2038 device_parent_create_swapchain_surface,
2039 device_parent_create_swapchain,
2042 static void *d3d10_rb_alloc(size_t size)
2044 return HeapAlloc(GetProcessHeap(), 0, size);
2047 static void *d3d10_rb_realloc(void *ptr, size_t size)
2049 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
2052 static void d3d10_rb_free(void *ptr)
2054 HeapFree(GetProcessHeap(), 0, ptr);
2057 static int d3d10_sampler_state_compare(const void *key, const struct wine_rb_entry *entry)
2059 const D3D10_SAMPLER_DESC *ka = key;
2060 const D3D10_SAMPLER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_sampler_state, entry)->desc;
2062 return memcmp(ka, kb, sizeof(*ka));
2065 static const struct wine_rb_functions d3d10_sampler_state_rb_ops =
2067 d3d10_rb_alloc,
2068 d3d10_rb_realloc,
2069 d3d10_rb_free,
2070 d3d10_sampler_state_compare,
2073 static int d3d10_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
2075 const D3D10_BLEND_DESC *ka = key;
2076 const D3D10_BLEND_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_blend_state, entry)->desc;
2078 return memcmp(ka, kb, sizeof(*ka));
2081 static const struct wine_rb_functions d3d10_blend_state_rb_ops =
2083 d3d10_rb_alloc,
2084 d3d10_rb_realloc,
2085 d3d10_rb_free,
2086 d3d10_blend_state_compare,
2089 static int d3d10_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
2091 const D3D10_DEPTH_STENCIL_DESC *ka = key;
2092 const D3D10_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
2093 const struct d3d10_depthstencil_state, entry)->desc;
2095 return memcmp(ka, kb, sizeof(*ka));
2098 static const struct wine_rb_functions d3d10_depthstencil_state_rb_ops =
2100 d3d10_rb_alloc,
2101 d3d10_rb_realloc,
2102 d3d10_rb_free,
2103 d3d10_depthstencil_state_compare,
2106 static int d3d10_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
2108 const D3D10_RASTERIZER_DESC *ka = key;
2109 const D3D10_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d10_rasterizer_state, entry)->desc;
2111 return memcmp(ka, kb, sizeof(*ka));
2114 static const struct wine_rb_functions d3d10_rasterizer_state_rb_ops =
2116 d3d10_rb_alloc,
2117 d3d10_rb_realloc,
2118 d3d10_rb_free,
2119 d3d10_rasterizer_state_compare,
2122 HRESULT d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
2124 device->IUnknown_inner.lpVtbl = &d3d10_device_inner_unknown_vtbl;
2125 device->ID3D10Device1_iface.lpVtbl = &d3d10_device1_vtbl;
2126 device->ID3D10Multithread_iface.lpVtbl = &d3d10_multithread_vtbl;
2127 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d10_dxgi_device_parent_vtbl;
2128 device->device_parent.ops = &d3d10_wined3d_device_parent_ops;
2129 device->refcount = 1;
2130 /* COM aggregation always takes place */
2131 device->outer_unk = outer_unknown;
2133 if (wine_rb_init(&device->blend_states, &d3d10_blend_state_rb_ops) == -1)
2135 WARN("Failed to initialize blend state rbtree.\n");
2136 return E_FAIL;
2139 if (wine_rb_init(&device->depthstencil_states, &d3d10_depthstencil_state_rb_ops) == -1)
2141 WARN("Failed to initialize depthstencil state rbtree.\n");
2142 wine_rb_destroy(&device->blend_states, NULL, NULL);
2143 return E_FAIL;
2146 if (wine_rb_init(&device->rasterizer_states, &d3d10_rasterizer_state_rb_ops) == -1)
2148 WARN("Failed to initialize rasterizer state rbtree.\n");
2149 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2150 wine_rb_destroy(&device->blend_states, NULL, NULL);
2151 return E_FAIL;
2154 if (wine_rb_init(&device->sampler_states, &d3d10_sampler_state_rb_ops) == -1)
2156 WARN("Failed to initialize sampler state rbtree.\n");
2157 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
2158 wine_rb_destroy(&device->depthstencil_states, NULL, NULL);
2159 wine_rb_destroy(&device->blend_states, NULL, NULL);
2160 return E_FAIL;
2163 return S_OK;