2 * Copyright 2021 Nikolay Sivov 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
23 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3dx
);
29 ID3DX10Mesh ID3DX10Mesh_iface
;
33 static inline struct d3dx10_mesh
*impl_from_ID3DX10Mesh(ID3DX10Mesh
*iface
)
35 return CONTAINING_RECORD(iface
, struct d3dx10_mesh
, ID3DX10Mesh_iface
);
38 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_QueryInterface(ID3DX10Mesh
*iface
, REFIID riid
, void **out
)
40 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
42 if (IsEqualGUID(riid
, &IID_ID3DX10Mesh
)
43 || IsEqualGUID(riid
, &IID_IUnknown
))
45 IUnknown_AddRef(iface
);
50 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
56 static ULONG STDMETHODCALLTYPE
d3dx10_mesh_AddRef(ID3DX10Mesh
*iface
)
58 struct d3dx10_mesh
*mesh
= impl_from_ID3DX10Mesh(iface
);
59 ULONG refcount
= InterlockedIncrement(&mesh
->refcount
);
61 TRACE("%p increasing refcount to %lu.\n", iface
, refcount
);
66 static ULONG STDMETHODCALLTYPE
d3dx10_mesh_Release(ID3DX10Mesh
*iface
)
68 struct d3dx10_mesh
*mesh
= impl_from_ID3DX10Mesh(iface
);
69 ULONG refcount
= InterlockedDecrement(&mesh
->refcount
);
71 TRACE("%p decreasing refcount to %lu.\n", iface
, refcount
);
79 static UINT STDMETHODCALLTYPE
d3dx10_mesh_GetFaceCount(ID3DX10Mesh
*iface
)
81 FIXME("iface %p stub!\n", iface
);
86 static UINT STDMETHODCALLTYPE
d3dx10_mesh_GetVertexCount(ID3DX10Mesh
*iface
)
88 FIXME("iface %p stub!\n", iface
);
93 static UINT STDMETHODCALLTYPE
d3dx10_mesh_GetVertexBufferCount(ID3DX10Mesh
*iface
)
95 FIXME("iface %p stub!\n", iface
);
100 static UINT STDMETHODCALLTYPE
d3dx10_mesh_GetFlags(ID3DX10Mesh
*iface
)
102 FIXME("iface %p stub!\n", iface
);
107 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_GetVertexDescription(ID3DX10Mesh
*iface
,
108 const D3D10_INPUT_ELEMENT_DESC
**desc
, UINT
*count
)
110 FIXME("iface %p, desc %p, count %p stub!\n", iface
, desc
, count
);
115 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_SetVertexData(ID3DX10Mesh
*iface
, UINT index
,
118 FIXME("iface %p, index %u, data %p stub!\n", iface
, index
, data
);
123 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_GetVertexBuffer(ID3DX10Mesh
*iface
, UINT index
,
124 ID3DX10MeshBuffer
**buffer
)
126 FIXME("iface %p, index %u, buffer %p stub!\n", iface
, index
, buffer
);
131 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_SetIndexData(ID3DX10Mesh
*iface
, const void *data
,
134 FIXME("iface %p, data %p, count %u stub!\n", iface
, data
, count
);
139 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_GetIndexBuffer(ID3DX10Mesh
*iface
,
140 ID3DX10MeshBuffer
**buffer
)
142 FIXME("iface %p, buffer %p stub!\n", iface
, buffer
);
147 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_SetAttributeData(ID3DX10Mesh
*iface
,
150 FIXME("iface %p, data %p stub!\n", iface
, data
);
155 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_GetAttributeBuffer(ID3DX10Mesh
*iface
,
156 ID3DX10MeshBuffer
**buffer
)
158 FIXME("iface %p, buffer %p stub!\n", iface
, buffer
);
163 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_SetAttributeTable(ID3DX10Mesh
*iface
,
164 const D3DX10_ATTRIBUTE_RANGE
*table
, UINT count
)
166 FIXME("iface %p, table %p, count %u stub!\n", iface
, table
, count
);
171 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_GetAttributeTable(ID3DX10Mesh
*iface
,
172 D3DX10_ATTRIBUTE_RANGE
*table
, UINT
*count
)
174 FIXME("iface %p, table %p, count %p stub!\n", iface
, table
, count
);
179 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_GenerateAdjacencyAndPointReps(ID3DX10Mesh
*iface
,
182 FIXME("iface %p, epsilon %.8e stub!\n", iface
, epsilon
);
187 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_GenerateGSAdjacency(ID3DX10Mesh
*iface
)
189 FIXME("iface %p stub!\n", iface
);
194 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_SetAdjacencyData(ID3DX10Mesh
*iface
,
195 const UINT
*adjacency
)
197 FIXME("iface %p, adjacency %p stub!\n", iface
, adjacency
);
202 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_GetAdjacencyBuffer(ID3DX10Mesh
*iface
,
203 ID3DX10MeshBuffer
**buffer
)
205 FIXME("iface %p, buffer %p stub!\n", iface
, buffer
);
210 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_SetPointRepData(ID3DX10Mesh
*iface
,
211 const UINT
*pointreps
)
213 FIXME("iface %p, pointreps %p stub!\n", iface
, pointreps
);
218 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_GetPointRepBuffer(ID3DX10Mesh
*iface
,
219 ID3DX10MeshBuffer
**buffer
)
221 FIXME("iface %p, buffer %p stub!\n", iface
, buffer
);
226 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_Discard(ID3DX10Mesh
*iface
,
227 D3DX10_MESH_DISCARD_FLAGS flags
)
229 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
234 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_CloneMesh(ID3DX10Mesh
*iface
, UINT flags
,
235 const char *pos_semantic
, const D3D10_INPUT_ELEMENT_DESC
*desc
, UINT decl_count
,
236 ID3DX10Mesh
**cloned_mesh
)
238 FIXME("iface %p, flags %#x, pos_semantic %s, desc %p, decl_count %u, cloned_mesh %p stub!\n",
239 iface
, flags
, debugstr_a(pos_semantic
), desc
, decl_count
, cloned_mesh
);
244 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_Optimize(ID3DX10Mesh
*iface
, UINT flags
,
245 UINT
*face_remap
, ID3D10Blob
**vertex_remap
)
247 FIXME("iface %p, flags %#x, face_remap %p, vertex_remap %p stub!\n", iface
, flags
,
248 face_remap
, vertex_remap
);
253 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_GenerateAttributeBufferFromTable(ID3DX10Mesh
*iface
)
255 FIXME("iface %p stub!\n", iface
);
260 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_Intersect(ID3DX10Mesh
*iface
, D3DXVECTOR3
*ray_pos
,
261 D3DXVECTOR3
*ray_dir
, UINT
*hit_count
, UINT
*face_index
, float *u
, float *v
, float *dist
,
262 ID3D10Blob
**all_hits
)
264 FIXME("iface %p, ray_pos %p, ray_dir %p, hit_count %p, u %p, v %p, dist %p, all_hits %p stub!\n",
265 iface
, ray_pos
, ray_dir
, hit_count
, u
, v
, dist
, all_hits
);
270 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_IntersectSubset(ID3DX10Mesh
*iface
, UINT attr_id
,
271 D3DXVECTOR3
*ray_pos
, D3DXVECTOR3
*ray_dir
, UINT
*hit_count
, float *u
, float *v
,
272 float *dist
, ID3D10Blob
**all_hits
)
274 FIXME("iface %p, attr_id %u, ray_pos %p, ray_dir %p, hit_count %p, u %p, v %p, dist %p, all_hits %p stub!\n",
275 iface
, attr_id
, ray_pos
, ray_dir
, hit_count
, u
, v
, dist
, all_hits
);
280 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_CommitToDevice(ID3DX10Mesh
*iface
)
282 FIXME("iface %p stub!\n", iface
);
287 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_DrawSubset(ID3DX10Mesh
*iface
, UINT attr_id
)
289 FIXME("iface %p, attr_id %u stub!\n", iface
, attr_id
);
294 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_DrawSubsetInstanced(ID3DX10Mesh
*iface
, UINT attr_id
,
295 UINT instance_count
, UINT start_instance
)
297 FIXME("iface %p, attr_id %u, instance_count %u, start_instance %u stub!\n", iface
, attr_id
,
298 instance_count
, start_instance
);
303 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_GetDeviceVertexBuffer(ID3DX10Mesh
*iface
, UINT index
,
304 ID3D10Buffer
**buffer
)
306 FIXME("iface %p, index %u, buffer %p stub!\n", iface
, index
, buffer
);
311 static HRESULT STDMETHODCALLTYPE
d3dx10_mesh_GetDeviceIndexBuffer(ID3DX10Mesh
*iface
,
312 ID3D10Buffer
**buffer
)
314 FIXME("iface %p, buffer %p stub!\n", iface
, buffer
);
319 static const ID3DX10MeshVtbl d3dx10_mesh_vtbl
=
321 d3dx10_mesh_QueryInterface
,
324 d3dx10_mesh_GetFaceCount
,
325 d3dx10_mesh_GetVertexCount
,
326 d3dx10_mesh_GetVertexBufferCount
,
327 d3dx10_mesh_GetFlags
,
328 d3dx10_mesh_GetVertexDescription
,
329 d3dx10_mesh_SetVertexData
,
330 d3dx10_mesh_GetVertexBuffer
,
331 d3dx10_mesh_SetIndexData
,
332 d3dx10_mesh_GetIndexBuffer
,
333 d3dx10_mesh_SetAttributeData
,
334 d3dx10_mesh_GetAttributeBuffer
,
335 d3dx10_mesh_SetAttributeTable
,
336 d3dx10_mesh_GetAttributeTable
,
337 d3dx10_mesh_GenerateAdjacencyAndPointReps
,
338 d3dx10_mesh_GenerateGSAdjacency
,
339 d3dx10_mesh_SetAdjacencyData
,
340 d3dx10_mesh_GetAdjacencyBuffer
,
341 d3dx10_mesh_SetPointRepData
,
342 d3dx10_mesh_GetPointRepBuffer
,
344 d3dx10_mesh_CloneMesh
,
345 d3dx10_mesh_Optimize
,
346 d3dx10_mesh_GenerateAttributeBufferFromTable
,
347 d3dx10_mesh_Intersect
,
348 d3dx10_mesh_IntersectSubset
,
349 d3dx10_mesh_CommitToDevice
,
350 d3dx10_mesh_DrawSubset
,
351 d3dx10_mesh_DrawSubsetInstanced
,
352 d3dx10_mesh_GetDeviceVertexBuffer
,
353 d3dx10_mesh_GetDeviceIndexBuffer
,
356 HRESULT WINAPI
D3DX10CreateMesh(ID3D10Device
*device
, const D3D10_INPUT_ELEMENT_DESC
*decl
,
357 UINT decl_count
, const char *position_semantic
, UINT vertex_count
, UINT face_count
,
358 UINT options
, ID3DX10Mesh
**mesh
)
360 struct d3dx10_mesh
*object
;
362 FIXME("device %p, decl %p, decl_count %u, position_semantic %s, vertex_count %u, face_count %u, "
363 "options %#x, mesh %p semi-stub.\n", device
, decl
, decl_count
, debugstr_a(position_semantic
), vertex_count
,
364 face_count
, options
, mesh
);
368 if (!(object
= calloc(1, sizeof(*object
))))
369 return E_OUTOFMEMORY
;
371 object
->ID3DX10Mesh_iface
.lpVtbl
= &d3dx10_mesh_vtbl
;
372 object
->refcount
= 1;
374 *mesh
= &object
->ID3DX10Mesh_iface
;