push 862965e7f7bbbfb960006fcded9111ae18c06ef6
[wine/hacks.git] / dlls / d3dx9_36 / tests / mesh.c
blob0f451a2501cc19773766654c8e218f043f5ffd3f
1 /*
2 * Copyright 2008 David Adam
3 * Copyright 2008 Luis Busquets
4 * Copyright 2009 Henri Verbeet for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/test.h"
22 #include "d3dx9.h"
24 #define admitted_error 0.0001f
26 #define compare_vertex_sizes(type, exp) \
27 got=D3DXGetFVFVertexSize(type); \
28 ok(got==exp, "Expected: %d, Got: %d\n", exp, got);
30 static BOOL compare(FLOAT u, FLOAT v)
32 return (fabs(u-v) < admitted_error);
35 static BOOL compare_vec3(D3DXVECTOR3 u, D3DXVECTOR3 v)
37 return ( compare(u.x, v.x) && compare(u.y, v.y) && compare(u.z, v.z) );
40 static void D3DXBoundProbeTest(void)
42 BOOL result;
43 D3DXVECTOR3 bottom_point, center, top_point, raydirection, rayposition;
44 FLOAT radius;
46 /*____________Test the Box case___________________________*/
47 bottom_point.x = -3.0f; bottom_point.y = -2.0f; bottom_point.z = -1.0f;
48 top_point.x = 7.0f; top_point.y = 8.0f; top_point.z = 9.0f;
50 raydirection.x = -4.0f; raydirection.y = -5.0f; raydirection.z = -6.0f;
51 rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 11.0f;
52 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
53 ok(result == TRUE, "expected TRUE, received FALSE\n");
55 raydirection.x = 4.0f; raydirection.y = 5.0f; raydirection.z = 6.0f;
56 rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 11.0f;
57 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
58 ok(result == FALSE, "expected FALSE, received TRUE\n");
60 rayposition.x = -4.0f; rayposition.y = 1.0f; rayposition.z = -2.0f;
61 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
62 ok(result == TRUE, "expected TRUE, received FALSE\n");
64 bottom_point.x = 1.0f; bottom_point.y = 0.0f; bottom_point.z = 0.0f;
65 top_point.x = 1.0f; top_point.y = 0.0f; top_point.z = 0.0f;
66 rayposition.x = 0.0f; rayposition.y = 1.0f; rayposition.z = 0.0f;
67 raydirection.x = 0.0f; raydirection.y = 3.0f; raydirection.z = 0.0f;
68 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
69 ok(result == FALSE, "expected FALSE, received TRUE\n");
71 bottom_point.x = 1.0f; bottom_point.y = 2.0f; bottom_point.z = 3.0f;
72 top_point.x = 10.0f; top_point.y = 15.0f; top_point.z = 20.0f;
74 raydirection.x = 7.0f; raydirection.y = 8.0f; raydirection.z = 9.0f;
75 rayposition.x = 3.0f; rayposition.y = 7.0f; rayposition.z = -6.0f;
76 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
77 ok(result == TRUE, "expected TRUE, received FALSE\n");
79 bottom_point.x = 0.0f; bottom_point.y = 0.0f; bottom_point.z = 0.0f;
80 top_point.x = 1.0f; top_point.y = 1.0f; top_point.z = 1.0f;
82 raydirection.x = 0.0f; raydirection.y = 1.0f; raydirection.z = .0f;
83 rayposition.x = -3.0f; rayposition.y = 0.0f; rayposition.z = 0.0f;
84 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
85 ok(result == FALSE, "expected FALSE, received TRUE\n");
87 raydirection.x = 1.0f; raydirection.y = 0.0f; raydirection.z = .0f;
88 rayposition.x = -3.0f; rayposition.y = 0.0f; rayposition.z = 0.0f;
89 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
90 ok(result == TRUE, "expected TRUE, received FALSE\n");
92 /*____________Test the Sphere case________________________*/
93 radius = sqrt(77.0f);
94 center.x = 1.0f; center.y = 2.0f; center.z = 3.0f;
95 raydirection.x = 2.0f; raydirection.y = -4.0f; raydirection.z = 2.0f;
97 rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 9.0f;
98 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
99 ok(result == TRUE, "expected TRUE, received FALSE\n");
101 rayposition.x = 45.0f; rayposition.y = -75.0f; rayposition.z = 49.0f;
102 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
103 ok(result == FALSE, "expected FALSE, received TRUE\n");
105 rayposition.x = 5.0f; rayposition.y = 11.0f; rayposition.z = 9.0f;
106 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
107 ok(result == FALSE, "expected FALSE, received TRUE\n");
110 static void D3DXComputeBoundingBoxTest(void)
112 D3DXVECTOR3 exp_max, exp_min, got_max, got_min, vertex[5];
113 HRESULT hr;
115 vertex[0].x = 1.0f; vertex[0].y = 1.0f; vertex[0].z = 1.0f;
116 vertex[1].x = 1.0f; vertex[1].y = 1.0f; vertex[1].z = 1.0f;
117 vertex[2].x = 1.0f; vertex[2].y = 1.0f; vertex[2].z = 1.0f;
118 vertex[3].x = 1.0f; vertex[3].y = 1.0f; vertex[3].z = 1.0f;
119 vertex[4].x = 9.0f; vertex[4].y = 9.0f; vertex[4].z = 9.0f;
121 exp_min.x = 1.0f; exp_min.y = 1.0f; exp_min.z = 1.0f;
122 exp_max.x = 9.0f; exp_max.y = 9.0f; exp_max.z = 9.0f;
124 hr = D3DXComputeBoundingBox(&vertex[3],2,D3DXGetFVFVertexSize(D3DFVF_XYZ),&got_min,&got_max);
126 ok( hr == D3D_OK, "Expected D3D_OK, got %#x\n", hr);
127 ok( compare_vec3(exp_min,got_min), "Expected min: (%f, %f, %f), got: (%f, %f, %f)\n", exp_min.x,exp_min.y,exp_min.z,got_min.x,got_min.y,got_min.z);
128 ok( compare_vec3(exp_max,got_max), "Expected max: (%f, %f, %f), got: (%f, %f, %f)\n", exp_max.x,exp_max.y,exp_max.z,got_max.x,got_max.y,got_max.z);
130 /*________________________*/
132 vertex[0].x = 2.0f; vertex[0].y = 5.9f; vertex[0].z = -1.2f;
133 vertex[1].x = -1.87f; vertex[1].y = 7.9f; vertex[1].z = 7.4f;
134 vertex[2].x = 7.43f; vertex[2].y = -0.9f; vertex[2].z = 11.9f;
135 vertex[3].x = -6.92f; vertex[3].y = 6.3f; vertex[3].z = -3.8f;
136 vertex[4].x = 11.4f; vertex[4].y = -8.1f; vertex[4].z = 4.5f;
138 exp_min.x = -6.92f; exp_min.y = -8.1f; exp_min.z = -3.80f;
139 exp_max.x = 11.4f; exp_max.y = 7.90f; exp_max.z = 11.9f;
141 hr = D3DXComputeBoundingBox(&vertex[0],5,D3DXGetFVFVertexSize(D3DFVF_XYZ),&got_min,&got_max);
143 ok( hr == D3D_OK, "Expected D3D_OK, got %#x\n", hr);
144 ok( compare_vec3(exp_min,got_min), "Expected min: (%f, %f, %f), got: (%f, %f, %f)\n", exp_min.x,exp_min.y,exp_min.z,got_min.x,got_min.y,got_min.z);
145 ok( compare_vec3(exp_max,got_max), "Expected max: (%f, %f, %f), got: (%f, %f, %f)\n", exp_max.x,exp_max.y,exp_max.z,got_max.x,got_max.y,got_max.z);
147 /*________________________*/
149 vertex[0].x = 2.0f; vertex[0].y = 5.9f; vertex[0].z = -1.2f;
150 vertex[1].x = -1.87f; vertex[1].y = 7.9f; vertex[1].z = 7.4f;
151 vertex[2].x = 7.43f; vertex[2].y = -0.9f; vertex[2].z = 11.9f;
152 vertex[3].x = -6.92f; vertex[3].y = 6.3f; vertex[3].z = -3.8f;
153 vertex[4].x = 11.4f; vertex[4].y = -8.1f; vertex[4].z = 4.5f;
155 exp_min.x = -6.92f; exp_min.y = -0.9f; exp_min.z = -3.8f;
156 exp_max.x = 7.43f; exp_max.y = 7.90f; exp_max.z = 11.9f;
158 hr = D3DXComputeBoundingBox(&vertex[0],4,D3DXGetFVFVertexSize(D3DFVF_XYZ),&got_min,&got_max);
160 ok( hr == D3D_OK, "Expected D3D_OK, got %#x\n", hr);
161 ok( compare_vec3(exp_min,got_min), "Expected min: (%f, %f, %f), got: (%f, %f, %f)\n", exp_min.x,exp_min.y,exp_min.z,got_min.x,got_min.y,got_min.z);
162 ok( compare_vec3(exp_max,got_max), "Expected max: (%f, %f, %f), got: (%f, %f, %f)\n", exp_max.x,exp_max.y,exp_max.z,got_max.x,got_max.y,got_max.z);
164 /*________________________*/
165 hr = D3DXComputeBoundingBox(NULL,5,D3DXGetFVFVertexSize(D3DFVF_XYZ),&got_min,&got_max);
166 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
168 /*________________________*/
169 hr = D3DXComputeBoundingBox(&vertex[3],5,D3DXGetFVFVertexSize(D3DFVF_XYZ),NULL,&got_max);
170 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
172 /*________________________*/
173 hr = D3DXComputeBoundingBox(&vertex[3],5,D3DXGetFVFVertexSize(D3DFVF_XYZ),&got_min,NULL);
174 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
177 static void D3DXComputeBoundingSphereTest(void)
179 D3DXVECTOR3 exp_cen, got_cen, vertex[5];
180 FLOAT exp_rad, got_rad;
181 HRESULT hr;
183 vertex[0].x = 1.0f; vertex[0].y = 1.0f; vertex[0].z = 1.0f;
184 vertex[1].x = 1.0f; vertex[1].y = 1.0f; vertex[1].z = 1.0f;
185 vertex[2].x = 1.0f; vertex[2].y = 1.0f; vertex[2].z = 1.0f;
186 vertex[3].x = 1.0f; vertex[3].y = 1.0f; vertex[3].z = 1.0f;
187 vertex[4].x = 9.0f; vertex[4].y = 9.0f; vertex[4].z = 9.0f;
189 exp_rad = 6.928203f;
190 exp_cen.x = 5.0; exp_cen.y = 5.0; exp_cen.z = 5.0;
192 hr = D3DXComputeBoundingSphere(&vertex[3],2,D3DXGetFVFVertexSize(D3DFVF_XYZ),&got_cen,&got_rad);
194 ok( hr == D3D_OK, "Expected D3D_OK, got %#x\n", hr);
195 ok( compare(exp_rad, got_rad), "Expected radius: %f, got radius: %f\n", exp_rad, got_rad);
196 ok( compare_vec3(exp_cen,got_cen), "Expected center: (%f, %f, %f), got center: (%f, %f, %f)\n", exp_cen.x,exp_cen.y,exp_cen.z,got_cen.x,got_cen.y,got_cen.z);
198 /*________________________*/
200 vertex[0].x = 2.0f; vertex[0].y = 5.9f; vertex[0].z = -1.2f;
201 vertex[1].x = -1.87f; vertex[1].y = 7.9f; vertex[1].z = 7.4f;
202 vertex[2].x = 7.43f; vertex[2].y = -0.9f; vertex[2].z = 11.9f;
203 vertex[3].x = -6.92f; vertex[3].y = 6.3f; vertex[3].z = -3.8f;
204 vertex[4].x = 11.4f; vertex[4].y = -8.1f; vertex[4].z = 4.5f;
206 exp_rad = 13.707883f;
207 exp_cen.x = 2.408f; exp_cen.y = 2.22f; exp_cen.z = 3.76f;
209 hr = D3DXComputeBoundingSphere(&vertex[0],5,D3DXGetFVFVertexSize(D3DFVF_XYZ),&got_cen,&got_rad);
211 ok( hr == D3D_OK, "Expected D3D_OK, got %#x\n", hr);
212 ok( compare(exp_rad, got_rad), "Expected radius: %f, got radius: %f\n", exp_rad, got_rad);
213 ok( compare_vec3(exp_cen,got_cen), "Expected center: (%f, %f, %f), got center: (%f, %f, %f)\n", exp_cen.x,exp_cen.y,exp_cen.z,got_cen.x,got_cen.y,got_cen.z);
215 /*________________________*/
216 hr = D3DXComputeBoundingSphere(NULL,5,D3DXGetFVFVertexSize(D3DFVF_XYZ),&got_cen,&got_rad);
217 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
219 /*________________________*/
220 hr = D3DXComputeBoundingSphere(&vertex[3],5,D3DXGetFVFVertexSize(D3DFVF_XYZ),NULL,&got_rad);
221 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
223 /*________________________*/
224 hr = D3DXComputeBoundingSphere(&vertex[3],5,D3DXGetFVFVertexSize(D3DFVF_XYZ),&got_cen,NULL);
225 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
228 static void D3DXGetFVFVertexSizeTest(void)
230 UINT got;
232 compare_vertex_sizes (D3DFVF_XYZ, 12);
234 compare_vertex_sizes (D3DFVF_XYZB3, 24);
236 compare_vertex_sizes (D3DFVF_XYZB5, 32);
238 compare_vertex_sizes (D3DFVF_XYZ | D3DFVF_NORMAL, 24);
240 compare_vertex_sizes (D3DFVF_XYZ | D3DFVF_DIFFUSE, 16);
242 compare_vertex_sizes (
243 D3DFVF_XYZ |
244 D3DFVF_TEX1 |
245 D3DFVF_TEXCOORDSIZE1(0), 16);
246 compare_vertex_sizes (
247 D3DFVF_XYZ |
248 D3DFVF_TEX2 |
249 D3DFVF_TEXCOORDSIZE1(0) |
250 D3DFVF_TEXCOORDSIZE1(1), 20);
252 compare_vertex_sizes (
253 D3DFVF_XYZ |
254 D3DFVF_TEX1 |
255 D3DFVF_TEXCOORDSIZE2(0), 20);
257 compare_vertex_sizes (
258 D3DFVF_XYZ |
259 D3DFVF_TEX2 |
260 D3DFVF_TEXCOORDSIZE2(0) |
261 D3DFVF_TEXCOORDSIZE2(1), 28);
263 compare_vertex_sizes (
264 D3DFVF_XYZ |
265 D3DFVF_TEX6 |
266 D3DFVF_TEXCOORDSIZE2(0) |
267 D3DFVF_TEXCOORDSIZE2(1) |
268 D3DFVF_TEXCOORDSIZE2(2) |
269 D3DFVF_TEXCOORDSIZE2(3) |
270 D3DFVF_TEXCOORDSIZE2(4) |
271 D3DFVF_TEXCOORDSIZE2(5), 60);
273 compare_vertex_sizes (
274 D3DFVF_XYZ |
275 D3DFVF_TEX8 |
276 D3DFVF_TEXCOORDSIZE2(0) |
277 D3DFVF_TEXCOORDSIZE2(1) |
278 D3DFVF_TEXCOORDSIZE2(2) |
279 D3DFVF_TEXCOORDSIZE2(3) |
280 D3DFVF_TEXCOORDSIZE2(4) |
281 D3DFVF_TEXCOORDSIZE2(5) |
282 D3DFVF_TEXCOORDSIZE2(6) |
283 D3DFVF_TEXCOORDSIZE2(7), 76);
285 compare_vertex_sizes (
286 D3DFVF_XYZ |
287 D3DFVF_TEX1 |
288 D3DFVF_TEXCOORDSIZE3(0), 24);
290 compare_vertex_sizes (
291 D3DFVF_XYZ |
292 D3DFVF_TEX4 |
293 D3DFVF_TEXCOORDSIZE3(0) |
294 D3DFVF_TEXCOORDSIZE3(1) |
295 D3DFVF_TEXCOORDSIZE3(2) |
296 D3DFVF_TEXCOORDSIZE3(3), 60);
298 compare_vertex_sizes (
299 D3DFVF_XYZ |
300 D3DFVF_TEX1 |
301 D3DFVF_TEXCOORDSIZE4(0), 28);
303 compare_vertex_sizes (
304 D3DFVF_XYZ |
305 D3DFVF_TEX2 |
306 D3DFVF_TEXCOORDSIZE4(0) |
307 D3DFVF_TEXCOORDSIZE4(1), 44);
309 compare_vertex_sizes (
310 D3DFVF_XYZ |
311 D3DFVF_TEX3 |
312 D3DFVF_TEXCOORDSIZE4(0) |
313 D3DFVF_TEXCOORDSIZE4(1) |
314 D3DFVF_TEXCOORDSIZE4(2), 60);
316 compare_vertex_sizes (
317 D3DFVF_XYZB5 |
318 D3DFVF_NORMAL |
319 D3DFVF_DIFFUSE |
320 D3DFVF_SPECULAR |
321 D3DFVF_TEX8 |
322 D3DFVF_TEXCOORDSIZE4(0) |
323 D3DFVF_TEXCOORDSIZE4(1) |
324 D3DFVF_TEXCOORDSIZE4(2) |
325 D3DFVF_TEXCOORDSIZE4(3) |
326 D3DFVF_TEXCOORDSIZE4(4) |
327 D3DFVF_TEXCOORDSIZE4(5) |
328 D3DFVF_TEXCOORDSIZE4(6) |
329 D3DFVF_TEXCOORDSIZE4(7), 180);
332 static void D3DXIntersectTriTest(void)
334 BOOL exp_res, got_res;
335 D3DXVECTOR3 position, ray, vertex[3];
336 FLOAT exp_dist, got_dist, exp_u, got_u, exp_v, got_v;
338 vertex[0].x = 1.0f; vertex[0].y = 0.0f; vertex[0].z = 0.0f;
339 vertex[1].x = 2.0f; vertex[1].y = 0.0f; vertex[1].z = 0.0f;
340 vertex[2].x = 1.0f; vertex[2].y = 1.0f; vertex[2].z = 0.0f;
342 position.x = -14.5f; position.y = -23.75f; position.z = -32.0f;
344 ray.x = 2.0f; ray.y = 3.0f; ray.z = 4.0f;
346 exp_res = TRUE; exp_u = 0.5f; exp_v = 0.25f; exp_dist = 8.0f;
348 got_res = D3DXIntersectTri(&vertex[0],&vertex[1],&vertex[2],&position,&ray,&got_u,&got_v,&got_dist);
349 ok( got_res == exp_res, "Expected result = %d, got %d\n",exp_res,got_res);
350 ok( compare(exp_u,got_u), "Expected u = %f, got %f\n",exp_u,got_u);
351 ok( compare(exp_v,got_v), "Expected v = %f, got %f\n",exp_v,got_v);
352 ok( compare(exp_dist,got_dist), "Expected distance = %f, got %f\n",exp_dist,got_dist);
354 /*Only positive ray is taken in account*/
356 vertex[0].x = 1.0f; vertex[0].y = 0.0f; vertex[0].z = 0.0f;
357 vertex[1].x = 2.0f; vertex[1].y = 0.0f; vertex[1].z = 0.0f;
358 vertex[2].x = 1.0f; vertex[2].y = 1.0f; vertex[2].z = 0.0f;
360 position.x = 17.5f; position.y = 24.25f; position.z = 32.0f;
362 ray.x = 2.0f; ray.y = 3.0f; ray.z = 4.0f;
364 exp_res = FALSE;
366 got_res = D3DXIntersectTri(&vertex[0],&vertex[1],&vertex[2],&position,&ray,&got_u,&got_v,&got_dist);
367 ok( got_res == exp_res, "Expected result = %d, got %d\n",exp_res,got_res);
369 /*Intersection between ray and triangle in a same plane is considered as empty*/
371 vertex[0].x = 4.0f; vertex[0].y = 0.0f; vertex[0].z = 0.0f;
372 vertex[1].x = 6.0f; vertex[1].y = 0.0f; vertex[1].z = 0.0f;
373 vertex[2].x = 4.0f; vertex[2].y = 2.0f; vertex[2].z = 0.0f;
375 position.x = 1.0f; position.y = 1.0f; position.z = 0.0f;
377 ray.x = 1.0f; ray.y = 0.0f; ray.z = 0.0f;
379 exp_res = FALSE;
381 got_res = D3DXIntersectTri(&vertex[0],&vertex[1],&vertex[2],&position,&ray,&got_u,&got_v,&got_dist);
382 ok( got_res == exp_res, "Expected result = %d, got %d\n",exp_res,got_res);
385 static void test_get_decl_vertex_size(void)
387 static const D3DVERTEXELEMENT9 declaration1[] =
389 {0, 0, D3DDECLTYPE_FLOAT1, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
390 {1, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
391 {2, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
392 {3, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
393 {4, 0, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
394 {5, 0, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
395 {6, 0, D3DDECLTYPE_SHORT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
396 {7, 0, D3DDECLTYPE_SHORT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
397 {8, 0, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
398 {9, 0, D3DDECLTYPE_SHORT2N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
399 {10, 0, D3DDECLTYPE_SHORT4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
400 {11, 0, D3DDECLTYPE_UDEC3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
401 {12, 0, D3DDECLTYPE_DEC3N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
402 {13, 0, D3DDECLTYPE_FLOAT16_2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
403 {14, 0, D3DDECLTYPE_FLOAT16_4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
404 D3DDECL_END(),
406 static const D3DVERTEXELEMENT9 declaration2[] =
408 {0, 8, D3DDECLTYPE_FLOAT1, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
409 {1, 8, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
410 {2, 8, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
411 {3, 8, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
412 {4, 8, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
413 {5, 8, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
414 {6, 8, D3DDECLTYPE_SHORT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
415 {7, 8, D3DDECLTYPE_SHORT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
416 {0, 8, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
417 {1, 8, D3DDECLTYPE_SHORT2N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
418 {2, 8, D3DDECLTYPE_SHORT4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
419 {3, 8, D3DDECLTYPE_UDEC3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
420 {4, 8, D3DDECLTYPE_DEC3N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
421 {5, 8, D3DDECLTYPE_FLOAT16_2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
422 {6, 8, D3DDECLTYPE_FLOAT16_4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
423 {7, 8, D3DDECLTYPE_FLOAT1, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
424 D3DDECL_END(),
426 static const UINT sizes1[] =
428 4, 8, 12, 16,
429 4, 4, 4, 8,
430 4, 4, 8, 4,
431 4, 4, 8, 0,
433 static const UINT sizes2[] =
435 12, 16, 20, 24,
436 12, 12, 16, 16,
438 unsigned int i;
439 UINT size;
441 size = D3DXGetDeclVertexSize(NULL, 0);
442 ok(size == 0, "Got size %#x, expected 0.\n", size);
444 for (i = 0; i < 16; ++i)
446 size = D3DXGetDeclVertexSize(declaration1, i);
447 ok(size == sizes1[i], "Got size %u for stream %u, expected %u.\n", size, i, sizes1[i]);
450 for (i = 0; i < 8; ++i)
452 size = D3DXGetDeclVertexSize(declaration2, i);
453 ok(size == sizes2[i], "Got size %u for stream %u, expected %u.\n", size, i, sizes2[i]);
457 START_TEST(mesh)
459 D3DXBoundProbeTest();
460 D3DXComputeBoundingBoxTest();
461 D3DXComputeBoundingSphereTest();
462 D3DXGetFVFVertexSizeTest();
463 D3DXIntersectTriTest();
464 test_get_decl_vertex_size();