d3d10core: Implement d3d10_device_PSSetSamplers().
[wine/multimedia.git] / dlls / d3d10core / device.c
blob8944491c7a162be14da4c2139fd75178d495b728
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,
42 void **ppv)
44 struct d3d10_device *This = impl_from_IUnknown(iface);
46 TRACE("iface %p, riid %s, ppv %p\n", iface, debugstr_guid(riid), ppv);
48 if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ID3D10Device))
49 *ppv = &This->ID3D10Device_iface;
50 else if (IsEqualGUID(riid, &IID_IWineDXGIDeviceParent))
51 *ppv = &This->IWineDXGIDeviceParent_iface;
52 else
54 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
55 *ppv = NULL;
56 return E_NOINTERFACE;
59 IUnknown_AddRef((IUnknown*)*ppv);
60 return S_OK;
63 static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
65 struct d3d10_device *This = impl_from_IUnknown(iface);
66 ULONG refcount = InterlockedIncrement(&This->refcount);
68 TRACE("%p increasing refcount to %u\n", This, refcount);
70 return refcount;
73 static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
75 struct d3d10_device *This = impl_from_IUnknown(iface);
76 ULONG refcount = InterlockedDecrement(&This->refcount);
78 TRACE("%p decreasing refcount to %u\n", This, refcount);
80 if (!refcount)
82 if (This->wined3d_device)
83 wined3d_device_decref(This->wined3d_device);
86 return refcount;
89 /* IUnknown methods */
91 static inline struct d3d10_device *impl_from_ID3D10Device(ID3D10Device *iface)
93 return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Device_iface);
96 static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device *iface, REFIID riid,
97 void **ppv)
99 struct d3d10_device *This = impl_from_ID3D10Device(iface);
100 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
103 static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device *iface)
105 struct d3d10_device *This = impl_from_ID3D10Device(iface);
106 return IUnknown_AddRef(This->outer_unk);
109 static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device *iface)
111 struct d3d10_device *This = impl_from_ID3D10Device(iface);
112 return IUnknown_Release(This->outer_unk);
115 /* ID3D10Device methods */
117 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device *iface,
118 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
120 struct d3d10_device *device = impl_from_ID3D10Device(iface);
121 unsigned int i;
123 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
124 iface, start_slot, buffer_count, buffers);
126 for (i = 0; i < buffer_count; ++i)
128 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
130 wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i,
131 buffer ? buffer->wined3d_buffer : NULL);
135 static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device *iface,
136 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
138 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
139 iface, start_slot, view_count, views);
142 static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device *iface,
143 ID3D10PixelShader *shader)
145 struct d3d10_device *This = impl_from_ID3D10Device(iface);
146 struct d3d10_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader);
148 TRACE("iface %p, shader %p\n", iface, shader);
150 wined3d_device_set_pixel_shader(This->wined3d_device, ps ? ps->wined3d_shader : NULL);
153 static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device *iface,
154 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
156 struct d3d10_device *device = impl_from_ID3D10Device(iface);
157 unsigned int i;
159 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
160 iface, start_slot, sampler_count, samplers);
162 for (i = 0; i < sampler_count; ++i)
164 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
166 wined3d_device_set_ps_sampler(device->wined3d_device, start_slot + i,
167 sampler ? sampler->wined3d_sampler : NULL);
171 static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device *iface,
172 ID3D10VertexShader *shader)
174 struct d3d10_device *This = impl_from_ID3D10Device(iface);
175 struct d3d10_vertex_shader *vs = unsafe_impl_from_ID3D10VertexShader(shader);
177 TRACE("iface %p, shader %p\n", iface, shader);
179 wined3d_device_set_vertex_shader(This->wined3d_device, vs ? vs->wined3d_shader : NULL);
182 static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device *iface, UINT index_count,
183 UINT start_index_location, INT base_vertex_location)
185 struct d3d10_device *This = impl_from_ID3D10Device(iface);
187 TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n",
188 iface, index_count, start_index_location, base_vertex_location);
190 wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
191 wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
194 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device *iface, UINT vertex_count,
195 UINT start_vertex_location)
197 struct d3d10_device *This = impl_from_ID3D10Device(iface);
199 TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
200 iface, vertex_count, start_vertex_location);
202 wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
205 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device *iface,
206 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
208 struct d3d10_device *device = impl_from_ID3D10Device(iface);
209 unsigned int i;
211 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
212 iface, start_slot, buffer_count, buffers);
214 for (i = 0; i < buffer_count; ++i)
216 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
218 wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i,
219 buffer ? buffer->wined3d_buffer : NULL);
223 static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device *iface,
224 ID3D10InputLayout *input_layout)
226 struct d3d10_device *This = impl_from_ID3D10Device(iface);
227 struct d3d10_input_layout *layout = unsafe_impl_from_ID3D10InputLayout(input_layout);
229 TRACE("iface %p, input_layout %p\n", iface, input_layout);
231 wined3d_device_set_vertex_declaration(This->wined3d_device,
232 layout ? layout->wined3d_decl : NULL);
235 static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device *iface, UINT start_slot,
236 UINT buffer_count, ID3D10Buffer *const *buffers, const UINT *strides, const UINT *offsets)
238 struct d3d10_device *This = impl_from_ID3D10Device(iface);
239 unsigned int i;
241 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p\n",
242 iface, start_slot, buffer_count, buffers, strides, offsets);
244 for (i = 0; i < buffer_count; ++i)
246 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
248 wined3d_device_set_stream_source(This->wined3d_device, start_slot + i,
249 buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
253 static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device *iface,
254 ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
256 struct d3d10_device *This = impl_from_ID3D10Device(iface);
257 struct d3d10_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
259 TRACE("iface %p, buffer %p, format %s, offset %u.\n",
260 iface, buffer, debug_dxgi_format(format), offset);
262 wined3d_device_set_index_buffer(This->wined3d_device,
263 buffer_impl ? buffer_impl->wined3d_buffer : NULL,
264 wined3dformat_from_dxgi_format(format));
265 if (offset) FIXME("offset %u not supported.\n", offset);
268 static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device *iface,
269 UINT instance_index_count, UINT instance_count, UINT start_index_location,
270 INT base_vertex_location, UINT start_instance_location)
272 struct d3d10_device *device = impl_from_ID3D10Device(iface);
274 TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u,\n"
275 "\tbase_vertex_location %d, start_instance_location %u.\n",
276 iface, instance_index_count, instance_count, start_index_location,
277 base_vertex_location, start_instance_location);
279 wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_location);
280 wined3d_device_draw_indexed_primitive_instanced(device->wined3d_device, start_index_location,
281 instance_index_count, start_instance_location, instance_count);
284 static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device *iface,
285 UINT instance_vertex_count, UINT instance_count,
286 UINT start_vertex_location, UINT start_instance_location)
288 FIXME("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u,\n"
289 "\tstart_instance_location %u stub!\n", iface, instance_vertex_count, instance_count,
290 start_vertex_location, start_instance_location);
293 static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device *iface,
294 UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers)
296 struct d3d10_device *device = impl_from_ID3D10Device(iface);
297 unsigned int i;
299 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
300 iface, start_slot, buffer_count, buffers);
302 for (i = 0; i < buffer_count; ++i)
304 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
306 wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i,
307 buffer ? buffer->wined3d_buffer : NULL);
311 static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device *iface, ID3D10GeometryShader *shader)
313 struct d3d10_device *device = impl_from_ID3D10Device(iface);
314 struct d3d10_geometry_shader *gs = unsafe_impl_from_ID3D10GeometryShader(shader);
316 TRACE("iface %p, shader %p.\n", iface, shader);
318 wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL);
321 static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device *iface,
322 D3D10_PRIMITIVE_TOPOLOGY topology)
324 struct d3d10_device *This = impl_from_ID3D10Device(iface);
326 TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
328 wined3d_device_set_primitive_type(This->wined3d_device, (enum wined3d_primitive_type)topology);
331 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device *iface,
332 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
334 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
335 iface, start_slot, view_count, views);
338 static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device *iface,
339 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
341 struct d3d10_device *device = impl_from_ID3D10Device(iface);
342 unsigned int i;
344 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
345 iface, start_slot, sampler_count, samplers);
347 for (i = 0; i < sampler_count; ++i)
349 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
351 wined3d_device_set_vs_sampler(device->wined3d_device, start_slot + i,
352 sampler ? sampler->wined3d_sampler : NULL);
356 static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device *iface, ID3D10Predicate *predicate, BOOL value)
358 FIXME("iface %p, predicate %p, value %d stub!\n", iface, predicate, value);
361 static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device *iface,
362 UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
364 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
365 iface, start_slot, view_count, views);
368 static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device *iface,
369 UINT start_slot, UINT sampler_count, ID3D10SamplerState *const *samplers)
371 struct d3d10_device *device = impl_from_ID3D10Device(iface);
372 unsigned int i;
374 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
375 iface, start_slot, sampler_count, samplers);
377 for (i = 0; i < sampler_count; ++i)
379 struct d3d10_sampler_state *sampler = unsafe_impl_from_ID3D10SamplerState(samplers[i]);
381 wined3d_device_set_gs_sampler(device->wined3d_device, start_slot + i,
382 sampler ? sampler->wined3d_sampler : NULL);
386 static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device *iface,
387 UINT render_target_view_count, ID3D10RenderTargetView *const *render_target_views,
388 ID3D10DepthStencilView *depth_stencil_view)
390 FIXME("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p\n",
391 iface, render_target_view_count, render_target_views, depth_stencil_view);
394 static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device *iface,
395 ID3D10BlendState *blend_state, const FLOAT blend_factor[4], UINT sample_mask)
397 struct d3d10_device *device = impl_from_ID3D10Device(iface);
399 TRACE("iface %p, blend_state %p, blend_factor [%f %f %f %f], sample_mask 0x%08x.\n",
400 iface, blend_state, blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3], sample_mask);
402 device->blend_state = unsafe_impl_from_ID3D10BlendState(blend_state);
403 memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
404 device->sample_mask = sample_mask;
407 static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device *iface,
408 ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
410 struct d3d10_device *device = impl_from_ID3D10Device(iface);
412 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
413 iface, depth_stencil_state, stencil_ref);
415 device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
416 device->stencil_ref = stencil_ref;
419 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device *iface,
420 UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets)
422 struct d3d10_device *device = impl_from_ID3D10Device(iface);
423 unsigned int count, i;
425 TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
427 count = min(target_count, 4);
428 for (i = 0; i < count; ++i)
430 struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
432 wined3d_device_set_stream_output(device->wined3d_device, i,
433 buffer ? buffer->wined3d_buffer : NULL, offsets[i]);
436 for (i = count; i < 4; ++i)
438 wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0);
442 static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device *iface)
444 FIXME("iface %p stub!\n", iface);
447 static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device *iface, ID3D10RasterizerState *rasterizer_state)
449 struct d3d10_device *device = impl_from_ID3D10Device(iface);
451 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
453 device->rasterizer_state = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state);
456 static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device *iface,
457 UINT viewport_count, const D3D10_VIEWPORT *viewports)
459 struct d3d10_device *device = impl_from_ID3D10Device(iface);
460 struct wined3d_viewport wined3d_vp;
462 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
464 if (viewport_count > 1)
465 FIXME("Multiple viewports not implemented.\n");
467 if (!viewport_count)
468 return;
470 wined3d_vp.x = viewports[0].TopLeftX;
471 wined3d_vp.y = viewports[0].TopLeftY;
472 wined3d_vp.width = viewports[0].Width;
473 wined3d_vp.height = viewports[0].Height;
474 wined3d_vp.min_z = viewports[0].MinDepth;
475 wined3d_vp.max_z = viewports[0].MaxDepth;
477 wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp);
480 static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device *iface,
481 UINT rect_count, const D3D10_RECT *rects)
483 struct d3d10_device *device = impl_from_ID3D10Device(iface);
485 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
487 if (rect_count > 1)
488 FIXME("Multiple scissor rects not implemented.\n");
490 if (!rect_count)
491 return;
493 wined3d_device_set_scissor_rect(device->wined3d_device, rects);
496 static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device *iface,
497 ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
498 ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
500 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u,\n"
501 "\tsrc_resource %p, src_subresource_idx %u, src_box %p stub!\n",
502 iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
503 src_resource, src_subresource_idx, src_box);
506 static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device *iface,
507 ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
509 FIXME("iface %p, dst_resource %p, src_resource %p stub!\n", iface, dst_resource, src_resource);
512 static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device *iface,
513 ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
514 const void *data, UINT row_pitch, UINT depth_pitch)
516 FIXME("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
517 iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
520 static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device *iface,
521 ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4])
523 struct d3d10_device *This = impl_from_ID3D10Device(iface);
524 struct d3d10_rendertarget_view *view = unsafe_impl_from_ID3D10RenderTargetView(render_target_view);
525 const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]};
527 TRACE("iface %p, render_target_view %p, color_rgba [%f %f %f %f]\n",
528 iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
530 wined3d_device_clear_rendertarget_view(This->wined3d_device, view->wined3d_view, &color);
533 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device *iface,
534 ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
536 FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
537 iface, depth_stencil_view, flags, depth, stencil);
540 static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device *iface, ID3D10ShaderResourceView *shader_resource_view)
542 FIXME("iface %p, shader_resource_view %p stub!\n", iface, shader_resource_view);
545 static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device *iface,
546 ID3D10Resource *dst_resource, UINT dst_subresource_idx,
547 ID3D10Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format)
549 FIXME("iface %p, dst_resource %p, dst_subresource_idx %u,\n"
550 "\tsrc_resource %p, src_subresource_idx %u, format %s stub!\n",
551 iface, dst_resource, dst_subresource_idx,
552 src_resource, src_subresource_idx, debug_dxgi_format(format));
555 static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device *iface,
556 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
558 struct d3d10_device *device = impl_from_ID3D10Device(iface);
559 unsigned int i;
561 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
562 iface, start_slot, buffer_count, buffers);
564 for (i = 0; i < buffer_count; ++i)
566 struct wined3d_buffer *wined3d_buffer;
567 struct d3d10_buffer *buffer_impl;
569 if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i)))
571 buffers[i] = NULL;
572 continue;
575 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
576 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
577 ID3D10Buffer_AddRef(buffers[i]);
581 static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device *iface,
582 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
584 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
585 iface, start_slot, view_count, views);
588 static void STDMETHODCALLTYPE d3d10_device_PSGetShader(ID3D10Device *iface, ID3D10PixelShader **shader)
590 struct d3d10_device *device = impl_from_ID3D10Device(iface);
591 struct d3d10_pixel_shader *shader_impl;
592 struct wined3d_shader *wined3d_shader;
594 TRACE("iface %p, shader %p.\n", iface, shader);
596 if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device)))
598 *shader = NULL;
599 return;
602 shader_impl = wined3d_shader_get_parent(wined3d_shader);
603 *shader = &shader_impl->ID3D10PixelShader_iface;
604 ID3D10PixelShader_AddRef(*shader);
607 static void STDMETHODCALLTYPE d3d10_device_PSGetSamplers(ID3D10Device *iface,
608 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
610 FIXME("iface %p, start_slot %u, sampler_count %u, samplers %p stub!\n",
611 iface, start_slot, sampler_count, samplers);
614 static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device *iface, ID3D10VertexShader **shader)
616 struct d3d10_device *device = impl_from_ID3D10Device(iface);
617 struct d3d10_vertex_shader *shader_impl;
618 struct wined3d_shader *wined3d_shader;
620 TRACE("iface %p, shader %p.\n", iface, shader);
622 if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device)))
624 *shader = NULL;
625 return;
628 shader_impl = wined3d_shader_get_parent(wined3d_shader);
629 *shader = &shader_impl->ID3D10VertexShader_iface;
630 ID3D10VertexShader_AddRef(*shader);
633 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device *iface,
634 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
636 struct d3d10_device *device = impl_from_ID3D10Device(iface);
637 unsigned int i;
639 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
640 iface, start_slot, buffer_count, buffers);
642 for (i = 0; i < buffer_count; ++i)
644 struct wined3d_buffer *wined3d_buffer;
645 struct d3d10_buffer *buffer_impl;
647 if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i)))
649 buffers[i] = NULL;
650 continue;
653 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
654 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
655 ID3D10Buffer_AddRef(buffers[i]);
659 static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device *iface, ID3D10InputLayout **input_layout)
661 struct d3d10_device *device = impl_from_ID3D10Device(iface);
662 struct wined3d_vertex_declaration *wined3d_declaration;
663 struct d3d10_input_layout *input_layout_impl;
665 TRACE("iface %p, input_layout %p.\n", iface, input_layout);
667 if (!(wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
669 *input_layout = NULL;
670 return;
673 input_layout_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
674 *input_layout = &input_layout_impl->ID3D10InputLayout_iface;
675 ID3D10InputLayout_AddRef(*input_layout);
678 static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device *iface,
679 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers, UINT *strides, UINT *offsets)
681 struct d3d10_device *device = impl_from_ID3D10Device(iface);
682 unsigned int i;
684 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n",
685 iface, start_slot, buffer_count, buffers, strides, offsets);
687 for (i = 0; i < buffer_count; ++i)
689 struct wined3d_buffer *wined3d_buffer;
690 struct d3d10_buffer *buffer_impl;
692 if (FAILED(wined3d_device_get_stream_source(device->wined3d_device, start_slot + i,
693 &wined3d_buffer, &offsets[i], &strides[i])))
694 ERR("Failed to get vertex buffer.\n");
696 if (!wined3d_buffer)
698 buffers[i] = NULL;
699 continue;
702 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
703 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
704 ID3D10Buffer_AddRef(buffers[i]);
708 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device *iface,
709 ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
711 struct d3d10_device *device = impl_from_ID3D10Device(iface);
712 enum wined3d_format_id wined3d_format;
713 struct wined3d_buffer *wined3d_buffer;
714 struct d3d10_buffer *buffer_impl;
716 TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
718 wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
719 *format = dxgi_format_from_wined3dformat(wined3d_format);
720 *offset = 0; /* FIXME */
721 if (!wined3d_buffer)
723 *buffer = NULL;
724 return;
727 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
728 *buffer = &buffer_impl->ID3D10Buffer_iface;
729 ID3D10Buffer_AddRef(*buffer);
732 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device *iface,
733 UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers)
735 struct d3d10_device *device = impl_from_ID3D10Device(iface);
736 unsigned int i;
738 TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n",
739 iface, start_slot, buffer_count, buffers);
741 for (i = 0; i < buffer_count; ++i)
743 struct wined3d_buffer *wined3d_buffer;
744 struct d3d10_buffer *buffer_impl;
746 if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i)))
748 buffers[i] = NULL;
749 continue;
752 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
753 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
754 ID3D10Buffer_AddRef(buffers[i]);
758 static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device *iface, ID3D10GeometryShader **shader)
760 struct d3d10_device *device = impl_from_ID3D10Device(iface);
761 struct d3d10_geometry_shader *shader_impl;
762 struct wined3d_shader *wined3d_shader;
764 TRACE("iface %p, shader %p.\n", iface, shader);
766 if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device)))
768 *shader = NULL;
769 return;
772 shader_impl = wined3d_shader_get_parent(wined3d_shader);
773 *shader = &shader_impl->ID3D10GeometryShader_iface;
774 ID3D10GeometryShader_AddRef(*shader);
777 static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device *iface,
778 D3D10_PRIMITIVE_TOPOLOGY *topology)
780 struct d3d10_device *This = impl_from_ID3D10Device(iface);
782 TRACE("iface %p, topology %p\n", iface, topology);
784 wined3d_device_get_primitive_type(This->wined3d_device, (enum wined3d_primitive_type *)topology);
787 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device *iface,
788 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
790 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
791 iface, start_slot, view_count, views);
794 static void STDMETHODCALLTYPE d3d10_device_VSGetSamplers(ID3D10Device *iface,
795 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
797 struct d3d10_device *device = impl_from_ID3D10Device(iface);
798 unsigned int i;
800 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
801 iface, start_slot, sampler_count, samplers);
803 for (i = 0; i < sampler_count; ++i)
805 struct d3d10_sampler_state *sampler_impl;
806 struct wined3d_sampler *wined3d_sampler;
808 if (!(wined3d_sampler = wined3d_device_get_vs_sampler(device->wined3d_device, start_slot + i)))
810 samplers[i] = NULL;
811 continue;
814 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
815 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
816 ID3D10SamplerState_AddRef(samplers[i]);
820 static void STDMETHODCALLTYPE d3d10_device_GetPredication(ID3D10Device *iface,
821 ID3D10Predicate **predicate, BOOL *value)
823 FIXME("iface %p, predicate %p, value %p stub!\n", iface, predicate, value);
826 static void STDMETHODCALLTYPE d3d10_device_GSGetShaderResources(ID3D10Device *iface,
827 UINT start_slot, UINT view_count, ID3D10ShaderResourceView **views)
829 FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n",
830 iface, start_slot, view_count, views);
833 static void STDMETHODCALLTYPE d3d10_device_GSGetSamplers(ID3D10Device *iface,
834 UINT start_slot, UINT sampler_count, ID3D10SamplerState **samplers)
836 struct d3d10_device *device = impl_from_ID3D10Device(iface);
837 unsigned int i;
839 TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n",
840 iface, start_slot, sampler_count, samplers);
842 for (i = 0; i < sampler_count; ++i)
844 struct d3d10_sampler_state *sampler_impl;
845 struct wined3d_sampler *wined3d_sampler;
847 if (!(wined3d_sampler = wined3d_device_get_gs_sampler(device->wined3d_device, start_slot + i)))
849 samplers[i] = NULL;
850 continue;
853 sampler_impl = wined3d_sampler_get_parent(wined3d_sampler);
854 samplers[i] = &sampler_impl->ID3D10SamplerState_iface;
855 ID3D10SamplerState_AddRef(samplers[i]);
859 static void STDMETHODCALLTYPE d3d10_device_OMGetRenderTargets(ID3D10Device *iface,
860 UINT view_count, ID3D10RenderTargetView **render_target_views, ID3D10DepthStencilView **depth_stencil_view)
862 FIXME("iface %p, view_count %u, render_target_views %p, depth_stencil_view %p stub!\n",
863 iface, view_count, render_target_views, depth_stencil_view);
866 static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device *iface,
867 ID3D10BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask)
869 struct d3d10_device *device = impl_from_ID3D10Device(iface);
871 TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
872 iface, blend_state, blend_factor, sample_mask);
874 if ((*blend_state = device->blend_state ? &device->blend_state->ID3D10BlendState_iface : NULL))
875 ID3D10BlendState_AddRef(*blend_state);
876 memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor));
877 *sample_mask = device->sample_mask;
880 static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device *iface,
881 ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
883 struct d3d10_device *device = impl_from_ID3D10Device(iface);
885 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
886 iface, depth_stencil_state, stencil_ref);
888 if ((*depth_stencil_state = device->depth_stencil_state
889 ? &device->depth_stencil_state->ID3D10DepthStencilState_iface : NULL))
890 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
891 *stencil_ref = device->stencil_ref;
894 static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device *iface,
895 UINT buffer_count, ID3D10Buffer **buffers, UINT *offsets)
897 struct d3d10_device *device = impl_from_ID3D10Device(iface);
898 unsigned int i;
900 TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n",
901 iface, buffer_count, buffers, offsets);
903 for (i = 0; i < buffer_count; ++i)
905 struct wined3d_buffer *wined3d_buffer;
906 struct d3d10_buffer *buffer_impl;
908 if (!(wined3d_buffer = wined3d_device_get_stream_output(device->wined3d_device, i, &offsets[i])))
910 buffers[i] = NULL;
911 continue;
914 buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
915 buffers[i] = &buffer_impl->ID3D10Buffer_iface;
916 ID3D10Buffer_AddRef(buffers[i]);
920 static void STDMETHODCALLTYPE d3d10_device_RSGetState(ID3D10Device *iface, ID3D10RasterizerState **rasterizer_state)
922 struct d3d10_device *device = impl_from_ID3D10Device(iface);
924 TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
926 if ((*rasterizer_state = device->rasterizer_state ? &device->rasterizer_state->ID3D10RasterizerState_iface : NULL))
927 ID3D10RasterizerState_AddRef(*rasterizer_state);
930 static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device *iface,
931 UINT *viewport_count, D3D10_VIEWPORT *viewports)
933 struct d3d10_device *device = impl_from_ID3D10Device(iface);
934 struct wined3d_viewport wined3d_vp;
936 TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
938 if (!viewports)
940 *viewport_count = 1;
941 return;
944 if (!*viewport_count)
945 return;
947 wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp);
949 viewports[0].TopLeftX = wined3d_vp.x;
950 viewports[0].TopLeftY = wined3d_vp.y;
951 viewports[0].Width = wined3d_vp.width;
952 viewports[0].Height = wined3d_vp.height;
953 viewports[0].MinDepth = wined3d_vp.min_z;
954 viewports[0].MaxDepth = wined3d_vp.max_z;
956 if (*viewport_count > 1)
957 memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports));
960 static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device *iface, UINT *rect_count, D3D10_RECT *rects)
962 struct d3d10_device *device = impl_from_ID3D10Device(iface);
964 TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects);
966 if (!rects)
968 *rect_count = 1;
969 return;
972 if (!*rect_count)
973 return;
975 wined3d_device_get_scissor_rect(device->wined3d_device, rects);
976 if (*rect_count > 1)
977 memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects));
980 static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device *iface)
982 FIXME("iface %p stub!\n", iface);
984 return E_NOTIMPL;
987 static HRESULT STDMETHODCALLTYPE d3d10_device_SetExceptionMode(ID3D10Device *iface, UINT flags)
989 FIXME("iface %p, flags %#x stub!\n", iface, flags);
991 return E_NOTIMPL;
994 static UINT STDMETHODCALLTYPE d3d10_device_GetExceptionMode(ID3D10Device *iface)
996 FIXME("iface %p stub!\n", iface);
998 return 0;
1001 static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device *iface,
1002 REFGUID guid, UINT *data_size, void *data)
1004 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
1005 iface, debugstr_guid(guid), data_size, data);
1007 return E_NOTIMPL;
1010 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device *iface,
1011 REFGUID guid, UINT data_size, const void *data)
1013 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
1014 iface, debugstr_guid(guid), data_size, data);
1016 return E_NOTIMPL;
1019 static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device *iface,
1020 REFGUID guid, const IUnknown *data)
1022 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
1024 return E_NOTIMPL;
1027 static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device *iface)
1029 FIXME("iface %p stub!\n", iface);
1032 static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device *iface)
1034 FIXME("iface %p stub!\n", iface);
1037 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device *iface,
1038 const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
1040 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1041 struct d3d10_buffer *object;
1042 HRESULT hr;
1044 FIXME("iface %p, desc %p, data %p, buffer %p partial stub!\n", iface, desc, data, buffer);
1046 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1047 if (!object)
1049 ERR("Failed to allocate D3D10 buffer object memory\n");
1050 return E_OUTOFMEMORY;
1053 hr = d3d10_buffer_init(object, This, desc, data);
1054 if (FAILED(hr))
1056 WARN("Failed to initialize buffer, hr %#x.\n", hr);
1057 HeapFree(GetProcessHeap(), 0, object);
1058 return hr;
1061 *buffer = &object->ID3D10Buffer_iface;
1063 TRACE("Created ID3D10Buffer %p\n", object);
1065 return S_OK;
1068 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device *iface,
1069 const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
1071 FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
1073 return E_NOTIMPL;
1076 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *iface,
1077 const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1078 ID3D10Texture2D **texture)
1080 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1081 struct d3d10_texture2d *object;
1082 HRESULT hr;
1084 FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
1086 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1087 if (!object)
1089 ERR("Failed to allocate D3D10 texture2d object memory\n");
1090 return E_OUTOFMEMORY;
1093 hr = d3d10_texture2d_init(object, This, desc);
1094 if (FAILED(hr))
1096 WARN("Failed to initialize texture, hr %#x.\n", hr);
1097 HeapFree(GetProcessHeap(), 0, object);
1098 return hr;
1101 *texture = &object->ID3D10Texture2D_iface;
1103 TRACE("Created ID3D10Texture2D %p\n", object);
1105 return S_OK;
1108 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device *iface,
1109 const D3D10_TEXTURE3D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data,
1110 ID3D10Texture3D **texture)
1112 struct d3d10_device *device = impl_from_ID3D10Device(iface);
1113 struct d3d10_texture3d *object;
1114 HRESULT hr;
1116 TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
1118 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1119 if (!object)
1121 ERR("Failed to allocate D3D10 texture3d object memory.\n");
1122 return E_OUTOFMEMORY;
1125 hr = d3d10_texture3d_init(object, device, desc);
1126 if (FAILED(hr))
1128 WARN("Failed to initialize texture, hr %#x.\n", hr);
1129 HeapFree(GetProcessHeap(), 0, object);
1130 return hr;
1133 TRACE("Created 3D texture %p.\n", object);
1134 *texture = &object->ID3D10Texture3D_iface;
1136 return S_OK;
1139 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device *iface,
1140 ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
1142 struct d3d10_shader_resource_view *object;
1143 HRESULT hr;
1145 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1147 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1148 if (!object)
1150 ERR("Failed to allocate D3D10 shader resource view object memory.\n");
1151 return E_OUTOFMEMORY;
1154 if (FAILED(hr = d3d10_shader_resource_view_init(object, resource, desc)))
1156 WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
1157 HeapFree(GetProcessHeap(), 0, object);
1158 return hr;
1161 TRACE("Created shader resource view %p.\n", object);
1162 *view = &object->ID3D10ShaderResourceView_iface;
1164 return S_OK;
1167 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device *iface,
1168 ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
1170 struct d3d10_rendertarget_view *object;
1171 HRESULT hr;
1173 TRACE("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
1175 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1176 if (!object)
1178 ERR("Failed to allocate D3D10 rendertarget view object memory\n");
1179 return E_OUTOFMEMORY;
1182 hr = d3d10_rendertarget_view_init(object, resource, desc);
1183 if (FAILED(hr))
1185 WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
1186 HeapFree(GetProcessHeap(), 0, object);
1187 return hr;
1190 TRACE("Created rendertarget view %p.\n", object);
1191 *view = &object->ID3D10RenderTargetView_iface;
1193 return S_OK;
1196 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilView(ID3D10Device *iface,
1197 ID3D10Resource *resource, const D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10DepthStencilView **view)
1199 struct d3d10_depthstencil_view *object;
1200 HRESULT hr;
1202 TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
1204 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1205 if (!object)
1207 ERR("Failed to allocate D3D10 depthstencil view object memory.\n");
1208 return E_OUTOFMEMORY;
1211 if (FAILED(hr = d3d10_depthstencil_view_init(object, resource, desc)))
1213 WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
1214 HeapFree(GetProcessHeap(), 0, object);
1215 return hr;
1218 TRACE("Created depthstencil view %p.\n", object);
1219 *view = &object->ID3D10DepthStencilView_iface;
1221 return S_OK;
1224 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device *iface,
1225 const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count,
1226 const void *shader_byte_code, SIZE_T shader_byte_code_length,
1227 ID3D10InputLayout **input_layout)
1229 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1230 struct d3d10_input_layout *object;
1231 HRESULT hr;
1233 TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
1234 "\tshader_byte_code_length %lu, input_layout %p\n",
1235 iface, element_descs, element_count, shader_byte_code,
1236 shader_byte_code_length, input_layout);
1238 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1239 if (!object)
1241 ERR("Failed to allocate D3D10 input layout object memory\n");
1242 return E_OUTOFMEMORY;
1245 hr = d3d10_input_layout_init(object, This, element_descs, element_count,
1246 shader_byte_code, shader_byte_code_length);
1247 if (FAILED(hr))
1249 WARN("Failed to initialize input layout, hr %#x.\n", hr);
1250 HeapFree(GetProcessHeap(), 0, object);
1251 return hr;
1254 TRACE("Created input layout %p.\n", object);
1255 *input_layout = &object->ID3D10InputLayout_iface;
1257 return S_OK;
1260 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device *iface,
1261 const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader)
1263 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1264 struct d3d10_vertex_shader *object;
1265 HRESULT hr;
1267 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1268 iface, byte_code, byte_code_length, shader);
1270 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1271 if (!object)
1273 ERR("Failed to allocate D3D10 vertex shader object memory\n");
1274 return E_OUTOFMEMORY;
1277 hr = d3d10_vertex_shader_init(object, This, byte_code, byte_code_length);
1278 if (FAILED(hr))
1280 WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
1281 HeapFree(GetProcessHeap(), 0, object);
1282 return hr;
1285 TRACE("Created vertex shader %p.\n", object);
1286 *shader = &object->ID3D10VertexShader_iface;
1288 return S_OK;
1291 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShader(ID3D10Device *iface,
1292 const void *byte_code, SIZE_T byte_code_length, ID3D10GeometryShader **shader)
1294 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1295 struct d3d10_geometry_shader *object;
1296 HRESULT hr;
1298 FIXME("iface %p, byte_code %p, byte_code_length %lu, shader %p stub!\n",
1299 iface, byte_code, byte_code_length, shader);
1301 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1302 if (!object)
1304 ERR("Failed to allocate D3D10 geometry shader object memory\n");
1305 return E_OUTOFMEMORY;
1308 hr = d3d10_geometry_shader_init(object, This, byte_code, byte_code_length);
1309 if (FAILED(hr))
1311 WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
1312 HeapFree(GetProcessHeap(), 0, object);
1313 return hr;
1316 TRACE("Created geometry shader %p.\n", object);
1317 *shader = &object->ID3D10GeometryShader_iface;
1319 return S_OK;
1322 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateGeometryShaderWithStreamOutput(ID3D10Device *iface,
1323 const void *byte_code, SIZE_T byte_code_length, const D3D10_SO_DECLARATION_ENTRY *output_stream_decls,
1324 UINT output_stream_decl_count, UINT output_stream_stride, ID3D10GeometryShader **shader)
1326 FIXME("iface %p, byte_code %p, byte_code_length %lu, output_stream_decls %p,\n"
1327 "\toutput_stream_decl_count %u, output_stream_stride %u, shader %p stub!\n",
1328 iface, byte_code, byte_code_length, output_stream_decls,
1329 output_stream_decl_count, output_stream_stride, shader);
1331 return E_NOTIMPL;
1334 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device *iface,
1335 const void *byte_code, SIZE_T byte_code_length, ID3D10PixelShader **shader)
1337 struct d3d10_device *This = impl_from_ID3D10Device(iface);
1338 struct d3d10_pixel_shader *object;
1339 HRESULT hr;
1341 TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
1342 iface, byte_code, byte_code_length, shader);
1344 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1345 if (!object)
1347 ERR("Failed to allocate D3D10 pixel shader object memory\n");
1348 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(ID3D10Device *iface,
1366 const D3D10_BLEND_DESC *desc, ID3D10BlendState **blend_state)
1368 struct d3d10_blend_state *object;
1369 HRESULT hr;
1371 TRACE("iface %p, desc %p, blend_state %p.\n", iface, desc, blend_state);
1373 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1374 if (!object)
1376 ERR("Failed to allocate D3D10 blend state object memory.\n");
1377 return E_OUTOFMEMORY;
1380 hr = d3d10_blend_state_init(object);
1381 if (FAILED(hr))
1383 WARN("Failed to initialize blend state, hr %#x.\n", hr);
1384 HeapFree(GetProcessHeap(), 0, object);
1385 return hr;
1388 TRACE("Created blend state %p.\n", object);
1389 *blend_state = &object->ID3D10BlendState_iface;
1391 return S_OK;
1394 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Device *iface,
1395 const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
1397 struct d3d10_depthstencil_state *object;
1398 HRESULT hr;
1400 TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
1402 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1403 if (!object)
1405 ERR("Failed to allocate D3D10 depthstencil state object memory.\n");
1406 return E_OUTOFMEMORY;
1409 hr = d3d10_depthstencil_state_init(object);
1410 if (FAILED(hr))
1412 WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
1413 HeapFree(GetProcessHeap(), 0, object);
1414 return hr;
1417 TRACE("Created depthstencil state %p.\n", object);
1418 *depth_stencil_state = &object->ID3D10DepthStencilState_iface;
1420 return S_OK;
1423 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device *iface,
1424 const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
1426 struct d3d10_rasterizer_state *object;
1427 HRESULT hr;
1429 TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
1431 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1432 if (!object)
1434 ERR("Failed to allocate D3D10 rasterizer state object memory.\n");
1435 return E_OUTOFMEMORY;
1438 hr = d3d10_rasterizer_state_init(object);
1439 if (FAILED(hr))
1441 WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
1442 HeapFree(GetProcessHeap(), 0, object);
1443 return hr;
1446 TRACE("Created rasterizer state %p.\n", object);
1447 *rasterizer_state = &object->ID3D10RasterizerState_iface;
1449 return S_OK;
1452 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device *iface,
1453 const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
1455 struct d3d10_sampler_state *object;
1456 HRESULT hr;
1458 TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
1460 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1461 if (!object)
1463 ERR("Failed to allocate D3D10 sampler state object memory.\n");
1464 return E_OUTOFMEMORY;
1467 hr = d3d10_sampler_state_init(object);
1468 if (FAILED(hr))
1470 WARN("Failed to initialize sampler state, hr %#x.\n", hr);
1471 HeapFree(GetProcessHeap(), 0, object);
1472 return hr;
1475 TRACE("Created sampler state %p.\n", object);
1476 *sampler_state = &object->ID3D10SamplerState_iface;
1478 return S_OK;
1481 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device *iface,
1482 const D3D10_QUERY_DESC *desc, ID3D10Query **query)
1484 struct d3d10_query *object;
1485 HRESULT hr;
1487 TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
1489 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1490 if (!object)
1492 ERR("Failed to allocate D3D10 query object memory.\n");
1493 return E_OUTOFMEMORY;
1496 hr = d3d10_query_init(object);
1497 if (FAILED(hr))
1499 WARN("Failed to initialize query, hr %#x.\n", hr);
1500 HeapFree(GetProcessHeap(), 0, object);
1501 return hr;
1504 TRACE("Created query %p.\n", object);
1505 *query = &object->ID3D10Query_iface;
1507 return S_OK;
1510 static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device *iface,
1511 const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
1513 FIXME("iface %p, desc %p, predicate %p stub!\n", iface, desc, predicate);
1515 return E_NOTIMPL;
1518 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device *iface,
1519 const D3D10_COUNTER_DESC *desc, ID3D10Counter **counter)
1521 FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter);
1523 return E_NOTIMPL;
1526 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device *iface,
1527 DXGI_FORMAT format, UINT *format_support)
1529 FIXME("iface %p, format %s, format_support %p stub!\n",
1530 iface, debug_dxgi_format(format), format_support);
1532 return E_NOTIMPL;
1535 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device *iface,
1536 DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count)
1538 FIXME("iface %p, format %s, sample_count %u, quality_level_count %p stub!\n",
1539 iface, debug_dxgi_format(format), sample_count, quality_level_count);
1541 return E_NOTIMPL;
1544 static void STDMETHODCALLTYPE d3d10_device_CheckCounterInfo(ID3D10Device *iface, D3D10_COUNTER_INFO *counter_info)
1546 FIXME("iface %p, counter_info %p stub!\n", iface, counter_info);
1549 static HRESULT STDMETHODCALLTYPE d3d10_device_CheckCounter(ID3D10Device *iface,
1550 const D3D10_COUNTER_DESC *desc, D3D10_COUNTER_TYPE *type, UINT *active_counters, LPSTR name,
1551 UINT *name_length, LPSTR units, UINT *units_length, LPSTR description, UINT *description_length)
1553 FIXME("iface %p, desc %p, type %p, active_counters %p, name %p, name_length %p,\n"
1554 "\tunits %p, units_length %p, description %p, description_length %p stub!\n",
1555 iface, desc, type, active_counters, name, name_length,
1556 units, units_length, description, description_length);
1558 return E_NOTIMPL;
1561 static UINT STDMETHODCALLTYPE d3d10_device_GetCreationFlags(ID3D10Device *iface)
1563 FIXME("iface %p stub!\n", iface);
1565 return 0;
1568 static HRESULT STDMETHODCALLTYPE d3d10_device_OpenSharedResource(ID3D10Device *iface,
1569 HANDLE resource_handle, REFIID guid, void **resource)
1571 FIXME("iface %p, resource_handle %p, guid %s, resource %p stub!\n",
1572 iface, resource_handle, debugstr_guid(guid), resource);
1574 return E_NOTIMPL;
1577 static void STDMETHODCALLTYPE d3d10_device_SetTextFilterSize(ID3D10Device *iface, UINT width, UINT height)
1579 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
1582 static void STDMETHODCALLTYPE d3d10_device_GetTextFilterSize(ID3D10Device *iface, UINT *width, UINT *height)
1584 FIXME("iface %p, width %p, height %p stub!\n", iface, width, height);
1587 static const struct ID3D10DeviceVtbl d3d10_device_vtbl =
1589 /* IUnknown methods */
1590 d3d10_device_QueryInterface,
1591 d3d10_device_AddRef,
1592 d3d10_device_Release,
1593 /* ID3D10Device methods */
1594 d3d10_device_VSSetConstantBuffers,
1595 d3d10_device_PSSetShaderResources,
1596 d3d10_device_PSSetShader,
1597 d3d10_device_PSSetSamplers,
1598 d3d10_device_VSSetShader,
1599 d3d10_device_DrawIndexed,
1600 d3d10_device_Draw,
1601 d3d10_device_PSSetConstantBuffers,
1602 d3d10_device_IASetInputLayout,
1603 d3d10_device_IASetVertexBuffers,
1604 d3d10_device_IASetIndexBuffer,
1605 d3d10_device_DrawIndexedInstanced,
1606 d3d10_device_DrawInstanced,
1607 d3d10_device_GSSetConstantBuffers,
1608 d3d10_device_GSSetShader,
1609 d3d10_device_IASetPrimitiveTopology,
1610 d3d10_device_VSSetShaderResources,
1611 d3d10_device_VSSetSamplers,
1612 d3d10_device_SetPredication,
1613 d3d10_device_GSSetShaderResources,
1614 d3d10_device_GSSetSamplers,
1615 d3d10_device_OMSetRenderTargets,
1616 d3d10_device_OMSetBlendState,
1617 d3d10_device_OMSetDepthStencilState,
1618 d3d10_device_SOSetTargets,
1619 d3d10_device_DrawAuto,
1620 d3d10_device_RSSetState,
1621 d3d10_device_RSSetViewports,
1622 d3d10_device_RSSetScissorRects,
1623 d3d10_device_CopySubresourceRegion,
1624 d3d10_device_CopyResource,
1625 d3d10_device_UpdateSubresource,
1626 d3d10_device_ClearRenderTargetView,
1627 d3d10_device_ClearDepthStencilView,
1628 d3d10_device_GenerateMips,
1629 d3d10_device_ResolveSubresource,
1630 d3d10_device_VSGetConstantBuffers,
1631 d3d10_device_PSGetShaderResources,
1632 d3d10_device_PSGetShader,
1633 d3d10_device_PSGetSamplers,
1634 d3d10_device_VSGetShader,
1635 d3d10_device_PSGetConstantBuffers,
1636 d3d10_device_IAGetInputLayout,
1637 d3d10_device_IAGetVertexBuffers,
1638 d3d10_device_IAGetIndexBuffer,
1639 d3d10_device_GSGetConstantBuffers,
1640 d3d10_device_GSGetShader,
1641 d3d10_device_IAGetPrimitiveTopology,
1642 d3d10_device_VSGetShaderResources,
1643 d3d10_device_VSGetSamplers,
1644 d3d10_device_GetPredication,
1645 d3d10_device_GSGetShaderResources,
1646 d3d10_device_GSGetSamplers,
1647 d3d10_device_OMGetRenderTargets,
1648 d3d10_device_OMGetBlendState,
1649 d3d10_device_OMGetDepthStencilState,
1650 d3d10_device_SOGetTargets,
1651 d3d10_device_RSGetState,
1652 d3d10_device_RSGetViewports,
1653 d3d10_device_RSGetScissorRects,
1654 d3d10_device_GetDeviceRemovedReason,
1655 d3d10_device_SetExceptionMode,
1656 d3d10_device_GetExceptionMode,
1657 d3d10_device_GetPrivateData,
1658 d3d10_device_SetPrivateData,
1659 d3d10_device_SetPrivateDataInterface,
1660 d3d10_device_ClearState,
1661 d3d10_device_Flush,
1662 d3d10_device_CreateBuffer,
1663 d3d10_device_CreateTexture1D,
1664 d3d10_device_CreateTexture2D,
1665 d3d10_device_CreateTexture3D,
1666 d3d10_device_CreateShaderResourceView,
1667 d3d10_device_CreateRenderTargetView,
1668 d3d10_device_CreateDepthStencilView,
1669 d3d10_device_CreateInputLayout,
1670 d3d10_device_CreateVertexShader,
1671 d3d10_device_CreateGeometryShader,
1672 d3d10_device_CreateGeometryShaderWithStreamOutput,
1673 d3d10_device_CreatePixelShader,
1674 d3d10_device_CreateBlendState,
1675 d3d10_device_CreateDepthStencilState,
1676 d3d10_device_CreateRasterizerState,
1677 d3d10_device_CreateSamplerState,
1678 d3d10_device_CreateQuery,
1679 d3d10_device_CreatePredicate,
1680 d3d10_device_CreateCounter,
1681 d3d10_device_CheckFormatSupport,
1682 d3d10_device_CheckMultisampleQualityLevels,
1683 d3d10_device_CheckCounterInfo,
1684 d3d10_device_CheckCounter,
1685 d3d10_device_GetCreationFlags,
1686 d3d10_device_OpenSharedResource,
1687 d3d10_device_SetTextFilterSize,
1688 d3d10_device_GetTextFilterSize,
1691 static const struct IUnknownVtbl d3d10_device_inner_unknown_vtbl =
1693 /* IUnknown methods */
1694 d3d10_device_inner_QueryInterface,
1695 d3d10_device_inner_AddRef,
1696 d3d10_device_inner_Release,
1699 static void STDMETHODCALLTYPE d3d10_subresource_destroyed(void *parent) {}
1701 static const struct wined3d_parent_ops d3d10_subresource_parent_ops =
1703 d3d10_subresource_destroyed,
1706 /* IWineDXGIDeviceParent IUnknown methods */
1708 static inline struct d3d10_device *device_from_dxgi_device_parent(IWineDXGIDeviceParent *iface)
1710 return CONTAINING_RECORD(iface, struct d3d10_device, IWineDXGIDeviceParent_iface);
1713 static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface,
1714 REFIID riid, void **ppv)
1716 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1717 return IUnknown_QueryInterface(device->outer_unk, riid, ppv);
1720 static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface)
1722 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1723 return IUnknown_AddRef(device->outer_unk);
1726 static ULONG STDMETHODCALLTYPE dxgi_device_parent_Release(IWineDXGIDeviceParent *iface)
1728 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1729 return IUnknown_Release(device->outer_unk);
1732 static struct wined3d_device_parent * STDMETHODCALLTYPE dxgi_device_parent_get_wined3d_device_parent(
1733 IWineDXGIDeviceParent *iface)
1735 struct d3d10_device *device = device_from_dxgi_device_parent(iface);
1736 return &device->device_parent;
1739 static const struct IWineDXGIDeviceParentVtbl d3d10_dxgi_device_parent_vtbl =
1741 /* IUnknown methods */
1742 dxgi_device_parent_QueryInterface,
1743 dxgi_device_parent_AddRef,
1744 dxgi_device_parent_Release,
1745 /* IWineDXGIDeviceParent methods */
1746 dxgi_device_parent_get_wined3d_device_parent,
1749 static inline struct d3d10_device *device_from_wined3d_device_parent(struct wined3d_device_parent *device_parent)
1751 return CONTAINING_RECORD(device_parent, struct d3d10_device, device_parent);
1754 static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
1755 struct wined3d_device *wined3d_device)
1757 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1759 TRACE("device_parent %p, wined3d_device %p.\n", device_parent, wined3d_device);
1761 wined3d_device_incref(wined3d_device);
1762 device->wined3d_device = wined3d_device;
1765 static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
1767 TRACE("device_parent %p.\n", device_parent);
1770 static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
1771 void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
1772 enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface)
1774 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1776 TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
1777 "\tpool %#x, sub_resource_idx %u, surface %p.\n",
1778 device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
1780 return wined3d_surface_create(device->wined3d_device, width, height, format, usage, pool,
1781 WINED3D_MULTISAMPLE_NONE, 0, WINED3D_SURFACE_TYPE_OPENGL, 0, container_parent,
1782 &d3d10_null_wined3d_parent_ops, surface);
1785 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
1786 void *container_parent, UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage,
1787 enum wined3d_multisample_type multisample_type, DWORD multisample_quality, struct wined3d_surface **surface)
1789 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1790 struct wined3d_resource *sub_resource;
1791 struct d3d10_texture2d *texture;
1792 D3D10_TEXTURE2D_DESC desc;
1793 HRESULT hr;
1795 FIXME("device_parent %p, container_parent %p, width %u, height %u, format_id %#x, usage %#x,\n"
1796 "\tmultisample_type %#x, multisample_quality %u, surface %p partial stub!\n",
1797 device_parent, container_parent, width, height, format_id, usage,
1798 multisample_type, multisample_quality, surface);
1800 FIXME("Implement DXGI<->wined3d usage conversion\n");
1802 desc.Width = width;
1803 desc.Height = height;
1804 desc.MipLevels = 1;
1805 desc.ArraySize = 1;
1806 desc.Format = dxgi_format_from_wined3dformat(format_id);
1807 desc.SampleDesc.Count = multisample_type ? multisample_type : 1;
1808 desc.SampleDesc.Quality = multisample_quality;
1809 desc.Usage = D3D10_USAGE_DEFAULT;
1810 desc.BindFlags = D3D10_BIND_RENDER_TARGET;
1811 desc.CPUAccessFlags = 0;
1812 desc.MiscFlags = 0;
1814 hr = d3d10_device_CreateTexture2D(&device->ID3D10Device_iface, &desc, NULL,
1815 (ID3D10Texture2D **)&texture);
1816 if (FAILED(hr))
1818 ERR("CreateTexture2D failed, returning %#x\n", hr);
1819 return hr;
1822 sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
1823 *surface = wined3d_surface_from_resource(sub_resource);
1824 wined3d_surface_incref(*surface);
1825 ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
1827 return S_OK;
1830 static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
1831 void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
1832 enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume)
1834 HRESULT hr;
1836 TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
1837 "format %#x, pool %#x, usage %#x, volume %p.\n",
1838 device_parent, container_parent, width, height, depth,
1839 format, pool, usage, volume);
1841 hr = wined3d_volume_create(device_from_wined3d_device_parent(device_parent)->wined3d_device,
1842 width, height, depth, usage, format, pool, NULL, &d3d10_subresource_parent_ops, volume);
1843 if (FAILED(hr))
1845 WARN("Failed to create wined3d volume, hr %#x.\n", hr);
1846 return hr;
1849 return S_OK;
1852 static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
1853 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
1855 struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
1856 IWineDXGIDevice *wine_device;
1857 HRESULT hr;
1859 TRACE("device_parent %p, desc %p, swapchain %p\n", device_parent, desc, swapchain);
1861 hr = d3d10_device_QueryInterface(&device->ID3D10Device_iface, &IID_IWineDXGIDevice,
1862 (void **)&wine_device);
1863 if (FAILED(hr))
1865 ERR("Device should implement IWineDXGIDevice\n");
1866 return E_FAIL;
1869 hr = IWineDXGIDevice_create_swapchain(wine_device, desc, swapchain);
1870 IWineDXGIDevice_Release(wine_device);
1871 if (FAILED(hr))
1873 ERR("Failed to create DXGI swapchain, returning %#x\n", hr);
1874 return hr;
1877 return S_OK;
1880 static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
1882 device_parent_wined3d_device_created,
1883 device_parent_mode_changed,
1884 device_parent_create_swapchain_surface,
1885 device_parent_create_texture_surface,
1886 device_parent_create_volume,
1887 device_parent_create_swapchain,
1890 void d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
1892 device->ID3D10Device_iface.lpVtbl = &d3d10_device_vtbl;
1893 device->IUnknown_inner.lpVtbl = &d3d10_device_inner_unknown_vtbl;
1894 device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d10_dxgi_device_parent_vtbl;
1895 device->device_parent.ops = &d3d10_wined3d_device_parent_ops;
1896 device->refcount = 1;
1897 /* COM aggregation always takes place */
1898 device->outer_unk = outer_unknown;