2 * Copyright (C) 2005 Henri Verbeet
3 * Copyright (C) 2006 Ivan Gyurdiev
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
24 static HMODULE d3d9_handle
= 0;
26 #define VDECL_CHECK(fcall) \
28 trace(" Test failed on line #%d\n", __LINE__);
30 static HWND
create_window(void)
33 wc
.lpfnWndProc
= DefWindowProc
;
34 wc
.lpszClassName
= "d3d9_test_wc";
37 return CreateWindow("d3d9_test_wc", "d3d9_test",
38 0, 0, 0, 0, 0, 0, 0, 0, 0);
41 static IDirect3DDevice9
*init_d3d9(void)
43 IDirect3D9
* (__stdcall
* d3d9_create
)(UINT SDKVersion
) = 0;
44 IDirect3D9
*d3d9_ptr
= 0;
45 IDirect3DDevice9
*device_ptr
= 0;
46 D3DPRESENT_PARAMETERS present_parameters
;
49 d3d9_create
= (void *)GetProcAddress(d3d9_handle
, "Direct3DCreate9");
50 ok(d3d9_create
!= NULL
, "Failed to get address of Direct3DCreate9\n");
51 if (!d3d9_create
) return NULL
;
53 d3d9_ptr
= d3d9_create(D3D_SDK_VERSION
);
56 skip("could not create D3D9\n");
60 ZeroMemory(&present_parameters
, sizeof(present_parameters
));
61 present_parameters
.Windowed
= TRUE
;
62 present_parameters
.hDeviceWindow
= create_window();
63 present_parameters
.SwapEffect
= D3DSWAPEFFECT_DISCARD
;
65 hres
= IDirect3D9_CreateDevice(d3d9_ptr
, D3DADAPTER_DEFAULT
, D3DDEVTYPE_HAL
, NULL
, D3DCREATE_SOFTWARE_VERTEXPROCESSING
, &present_parameters
, &device_ptr
);
69 hres
= IDirect3D9_CreateDevice(d3d9_ptr
, D3DADAPTER_DEFAULT
, D3DDEVTYPE_REF
, NULL
, D3DCREATE_SOFTWARE_VERTEXPROCESSING
, &present_parameters
, &device_ptr
);
72 trace("could not create device, IDirect3D9_CreateDevice returned %#x\n", hres
);
80 static int get_refcount(IUnknown
*object
)
82 IUnknown_AddRef(object
);
83 return IUnknown_Release(object
);
86 static inline void print_elements(
87 D3DVERTEXELEMENT9
*elements
) {
89 D3DVERTEXELEMENT9 last
= D3DDECL_END();
90 D3DVERTEXELEMENT9
*ptr
= elements
;
93 while (memcmp(ptr
, &last
, sizeof(D3DVERTEXELEMENT9
))) {
96 "[Element %d] Stream = %d, Offset = %d, Type = %d, Method = %d, Usage = %d, UsageIndex = %d\n",
97 count
, ptr
->Stream
, ptr
->Offset
, ptr
->Type
, ptr
->Method
, ptr
->Usage
, ptr
->UsageIndex
);
104 static int compare_elements(
105 IDirect3DVertexDeclaration9
*decl
,
106 const D3DVERTEXELEMENT9
*expected_elements
) {
109 unsigned int i
, size
;
110 D3DVERTEXELEMENT9 last
= D3DDECL_END();
111 D3DVERTEXELEMENT9
*elements
= NULL
;
113 /* How many elements are there? */
114 hr
= IDirect3DVertexDeclaration9_GetDeclaration( decl
, NULL
, &size
);
115 ok(SUCCEEDED(hr
), "GetDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
116 if (FAILED(hr
)) goto fail
;
118 /* Allocate buffer */
119 elements
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(D3DVERTEXELEMENT9
) * size
);
120 ok (elements
!= NULL
, "Out of memory, aborting test\n");
121 if (elements
== NULL
) goto fail
;
123 /* Get the elements */
124 hr
= IDirect3DVertexDeclaration9_GetDeclaration( decl
, elements
, &size
);
125 ok(SUCCEEDED(hr
), "GetDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
126 if (FAILED(hr
)) goto fail
;
128 /* Compare one by one */
129 for (i
= 0; i
< size
; i
++) {
133 int end1
= memcmp(&elements
[i
], &last
, sizeof(D3DVERTEXELEMENT9
));
134 int end2
= memcmp(&expected_elements
[i
], &last
, sizeof(D3DVERTEXELEMENT9
));
135 status
= ((end1
&& !end2
) || (!end1
&& end2
));
136 ok (!status
, "Mismatch in size, test declaration is %s than expected\n",
137 (end1
&& !end2
) ? "shorter" : "longer");
138 if (status
) { print_elements(elements
); goto fail
; }
140 status
= memcmp(&elements
[i
], &expected_elements
[i
], sizeof(D3DVERTEXELEMENT9
));
141 ok (!status
, "Mismatch in element %d\n", i
);
142 if (status
) { print_elements(elements
); goto fail
; }
145 HeapFree(GetProcessHeap(), 0, elements
);
149 HeapFree(GetProcessHeap(), 0, elements
);
153 static IDirect3DVertexDeclaration9
*test_create_vertex_declaration(IDirect3DDevice9
*device_ptr
, D3DVERTEXELEMENT9
*vertex_decl
)
155 IDirect3DVertexDeclaration9
*decl_ptr
= 0;
158 hret
= IDirect3DDevice9_CreateVertexDeclaration(device_ptr
, vertex_decl
, &decl_ptr
);
159 ok(hret
== D3D_OK
&& decl_ptr
!= NULL
, "CreateVertexDeclaration returned: hret 0x%x, decl_ptr %p. "
160 "Expected hret 0x%x, decl_ptr != %p. Aborting.\n", hret
, decl_ptr
, D3D_OK
, NULL
);
165 static void test_get_set_vertex_declaration(IDirect3DDevice9
*device_ptr
, IDirect3DVertexDeclaration9
*decl_ptr
)
167 IDirect3DVertexDeclaration9
*current_decl_ptr
= 0;
169 int decl_refcount
= 0;
172 /* SetVertexDeclaration should not touch the declaration's refcount. */
173 i
= get_refcount((IUnknown
*)decl_ptr
);
174 hret
= IDirect3DDevice9_SetVertexDeclaration(device_ptr
, decl_ptr
);
175 decl_refcount
= get_refcount((IUnknown
*)decl_ptr
);
176 ok(hret
== D3D_OK
&& decl_refcount
== i
, "SetVertexDeclaration returned: hret 0x%x, refcount %d. "
177 "Expected hret 0x%x, refcount %d.\n", hret
, decl_refcount
, D3D_OK
, i
);
179 /* GetVertexDeclaration should increase the declaration's refcount by one. */
181 hret
= IDirect3DDevice9_GetVertexDeclaration(device_ptr
, ¤t_decl_ptr
);
182 decl_refcount
= get_refcount((IUnknown
*)decl_ptr
);
183 ok(hret
== D3D_OK
&& decl_refcount
== i
&& current_decl_ptr
== decl_ptr
,
184 "GetVertexDeclaration returned: hret 0x%x, current_decl_ptr %p refcount %d. "
185 "Expected hret 0x%x, current_decl_ptr %p, refcount %d.\n", hret
, current_decl_ptr
, decl_refcount
, D3D_OK
, decl_ptr
, i
);
186 IDirect3DVertexDeclaration9_Release(current_decl_ptr
);
189 static void test_get_declaration(IDirect3DVertexDeclaration9
*decl_ptr
, D3DVERTEXELEMENT9
*vertex_decl
, UINT expected_num_elements
)
192 UINT num_elements
= 0;
193 D3DVERTEXELEMENT9
*decl
= 0;
196 /* First test only getting the number of elements */
197 num_elements
= 0x1337c0de;
198 hret
= IDirect3DVertexDeclaration9_GetDeclaration(decl_ptr
, NULL
, &num_elements
);
199 ok(hret
== D3D_OK
&& num_elements
== expected_num_elements
,
200 "GetDeclaration returned: hret 0x%x, num_elements %d. "
201 "Expected hret 0x%x, num_elements %d.\n", hret
, num_elements
, D3D_OK
, expected_num_elements
);
204 hret
= IDirect3DVertexDeclaration9_GetDeclaration(decl_ptr
, NULL
, &num_elements
);
205 ok(hret
== D3D_OK
&& num_elements
== expected_num_elements
,
206 "GetDeclaration returned: hret 0x%x, num_elements %d. "
207 "Expected hret 0x%x, num_elements %d.\n", hret
, num_elements
, D3D_OK
, expected_num_elements
);
209 /* Also test the returned data */
210 decl
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(D3DVERTEXELEMENT9
) * expected_num_elements
);
212 num_elements
= 0x1337c0de;
213 hret
= IDirect3DVertexDeclaration9_GetDeclaration(decl_ptr
, decl
, &num_elements
);
214 ok(hret
== D3D_OK
&& num_elements
== expected_num_elements
,
215 "GetDeclaration returned: hret 0x%x, num_elements %d. "
216 "Expected hret 0x%x, num_elements %d.\n", hret
, num_elements
, D3D_OK
, expected_num_elements
);
217 i
= memcmp(decl
, vertex_decl
, sizeof(vertex_decl
));
218 ok (!i
, "Original and returned vertexdeclarations are not the same\n");
219 ZeroMemory(decl
, sizeof(D3DVERTEXELEMENT9
) * expected_num_elements
);
222 hret
= IDirect3DVertexDeclaration9_GetDeclaration(decl_ptr
, decl
, &num_elements
);
223 ok(hret
== D3D_OK
&& num_elements
== expected_num_elements
,
224 "GetDeclaration returned: hret 0x%x, num_elements %d. "
225 "Expected hret 0x%x, num_elements %d.\n", hret
, num_elements
, D3D_OK
, expected_num_elements
);
226 i
= memcmp(decl
, vertex_decl
, sizeof(vertex_decl
));
227 ok (!i
, "Original and returned vertexdeclarations are not the same\n");
229 HeapFree(GetProcessHeap(), 0, decl
);
232 /* FIXME: also write a test, which shows that attempting to set
233 * an invalid vertex declaration returns E_FAIL */
235 static HRESULT
test_fvf_to_decl(
236 IDirect3DDevice9
* device
,
237 IDirect3DVertexDeclaration9
* default_decl
,
239 const D3DVERTEXELEMENT9 expected_elements
[],
240 char object_should_change
)
244 IDirect3DVertexDeclaration9
*result_decl
= NULL
;
246 /* Set a default declaration to make sure it is changed */
247 hr
= IDirect3DDevice9_SetVertexDeclaration ( device
, default_decl
);
248 ok (SUCCEEDED(hr
), "SetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
249 if (FAILED(hr
)) goto fail
;
252 hr
= IDirect3DDevice9_SetFVF( device
, test_fvf
);
253 ok(SUCCEEDED(hr
), "SetFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
254 if (FAILED(hr
)) goto fail
;
256 /* Check if the declaration object changed underneath */
257 hr
= IDirect3DDevice9_GetVertexDeclaration ( device
, &result_decl
);
258 ok(SUCCEEDED(hr
), "GetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
259 if (FAILED(hr
)) goto fail
;
260 if (object_should_change
) {
261 ok(result_decl
!= default_decl
, "result declaration matches original\n");
262 if (result_decl
== default_decl
) goto fail
;
264 ok(result_decl
== default_decl
, "result declaration does not match original\n");
265 if (result_decl
!= default_decl
) goto fail
;
268 /* Declaration content/size test */
269 ok(result_decl
!= NULL
, "result declaration was null\n");
270 if (result_decl
== NULL
)
272 else if (compare_elements(result_decl
, expected_elements
) != S_OK
)
275 if (result_decl
) IUnknown_Release( result_decl
);
279 if (result_decl
) IUnknown_Release( result_decl
);
283 static HRESULT
test_decl_to_fvf(IDirect3DDevice9
* device
, DWORD default_fvf
,
284 const D3DVERTEXELEMENT9 test_decl
[], DWORD test_fvf
, BOOL todo
)
288 IDirect3DVertexDeclaration9
*vdecl
= NULL
;
290 DWORD result_fvf
= 0xdeadbeef;
292 /* Set a default FVF of SPECULAR and DIFFUSE to make sure it is changed back to 0 */
293 hr
= IDirect3DDevice9_SetFVF( device
, default_fvf
);
294 ok(SUCCEEDED(hr
), "SetFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
295 if (FAILED(hr
)) goto fail
;
297 /* Create a testing declaration */
298 hr
= IDirect3DDevice9_CreateVertexDeclaration( device
, test_decl
, &vdecl
);
299 ok(SUCCEEDED(hr
), "CreateVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
300 if (FAILED(hr
)) goto fail
;
302 /* Set the declaration */
303 hr
= IDirect3DDevice9_SetVertexDeclaration ( device
, vdecl
);
304 ok (SUCCEEDED(hr
), "SetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
305 if (FAILED(hr
)) goto fail
;
308 hr
= IDirect3DDevice9_GetFVF( device
, &result_fvf
);
309 ok(SUCCEEDED(hr
), "GetFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
310 if (FAILED(hr
)) goto fail
;
311 if (todo
) todo_wine
ok(test_fvf
== result_fvf
, "result FVF was: %#x, expected: %#x\n", result_fvf
, test_fvf
);
312 else ok(test_fvf
== result_fvf
, "result FVF was: %#x, expected: %#x\n", result_fvf
, test_fvf
);
313 if (test_fvf
!= result_fvf
) goto fail
;
315 IDirect3DDevice9_SetVertexDeclaration ( device
, NULL
);
316 if (vdecl
) IUnknown_Release( vdecl
);
320 IDirect3DDevice9_SetVertexDeclaration ( device
, NULL
);
321 if (vdecl
) IUnknown_Release( vdecl
);
325 static void test_fvf_decl_conversion(IDirect3DDevice9
*pDevice
)
331 IDirect3DVertexDeclaration9
* default_decl
= NULL
;
332 DWORD default_fvf
= D3DFVF_SPECULAR
| D3DFVF_DIFFUSE
;
333 D3DVERTEXELEMENT9 default_elements
[] =
334 { { 0, 0, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
335 { 0, 4, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 1 }, D3DDECL_END() };
337 /* Create a default declaration and FVF that does not match any of the tests */
338 hr
= IDirect3DDevice9_CreateVertexDeclaration( pDevice
, default_elements
, &default_decl
);
339 ok(SUCCEEDED(hr
), "CreateVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
340 if (FAILED(hr
)) goto cleanup
;
342 /* Test conversions from vertex declaration to an FVF.
343 * For some reason those seem to occur only for POSITION/POSITIONT,
344 * Otherwise the FVF is forced to 0 - maybe this is configuration specific */
346 CONST D3DVERTEXELEMENT9 test_buffer
[] =
347 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 }, D3DDECL_END() };
348 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, D3DFVF_XYZ
, TRUE
));
351 CONST D3DVERTEXELEMENT9 test_buffer
[] =
352 { { 0, 0, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_POSITIONT
, 0 }, D3DDECL_END() };
353 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, D3DFVF_XYZRHW
, TRUE
));
355 for (i
= 0; i
< 4; i
++) {
356 CONST D3DVERTEXELEMENT9 test_buffer
[] =
357 { { 0, 0, D3DDECLTYPE_FLOAT1
+i
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0}, D3DDECL_END() };
358 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
361 CONST D3DVERTEXELEMENT9 test_buffer
[] =
362 { { 0, 0, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0}, D3DDECL_END() };
363 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
366 CONST D3DVERTEXELEMENT9 test_buffer
[] =
367 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_NORMAL
, 0 }, D3DDECL_END() };
368 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
371 CONST D3DVERTEXELEMENT9 test_buffer
[] =
372 { { 0, 0, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_PSIZE
, 0 }, D3DDECL_END() };
373 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
376 CONST D3DVERTEXELEMENT9 test_buffer
[] =
377 { { 0, 0, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 }, D3DDECL_END() };
378 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
381 CONST D3DVERTEXELEMENT9 test_buffer
[] =
382 { { 0, 0, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 1 }, D3DDECL_END() };
383 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
386 /* Make sure textures of different sizes work */
388 CONST D3DVERTEXELEMENT9 test_buffer
[] =
389 { { 0, 0, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
390 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
393 CONST D3DVERTEXELEMENT9 test_buffer
[] =
394 { { 0, 0, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
395 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
398 CONST D3DVERTEXELEMENT9 test_buffer
[] =
399 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
400 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
403 CONST D3DVERTEXELEMENT9 test_buffer
[] =
404 { { 0, 0, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
405 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
408 /* Make sure the TEXCOORD index works correctly - try several textures */
410 CONST D3DVERTEXELEMENT9 test_buffer
[] =
411 { { 0, 0, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_TEXCOORD
, 0 },
412 { 0, 4, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_TEXCOORD
, 1 },
413 { 0, 16, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_TEXCOORD
, 2 },
414 { 0, 24, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_TEXCOORD
, 3 }, D3DDECL_END() };
415 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
418 /* No FVF mapping available */
420 CONST D3DVERTEXELEMENT9 test_buffer
[] =
421 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 1 }, D3DDECL_END() };
422 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
425 CONST D3DVERTEXELEMENT9 test_buffer
[] =
426 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_NORMAL
, 1 }, D3DDECL_END() };
427 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
430 /* Try empty declaration */
432 CONST D3DVERTEXELEMENT9 test_buffer
[] = { D3DDECL_END() };
433 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
436 /* Now try a combination test */
438 CONST D3DVERTEXELEMENT9 test_buffer
[] =
439 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITIONT
, 0 },
440 { 0, 12, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_NORMAL
, 0 },
441 { 0, 24, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_PSIZE
, 0 },
442 { 0, 28, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 1 },
443 { 0, 32, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_TEXCOORD
, 0 },
444 { 0, 44, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_TEXCOORD
, 1 }, D3DDECL_END() };
445 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0, FALSE
));
448 /* Test conversions from FVF to a vertex declaration
449 * These seem to always occur internally. A new declaration object is created if necessary */
452 CONST D3DVERTEXELEMENT9 test_buffer
[] =
453 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 }, D3DDECL_END() };
454 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZ
, test_buffer
, 1));
457 CONST D3DVERTEXELEMENT9 test_buffer
[] =
458 { { 0, 0, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_POSITION
, 0 }, D3DDECL_END() };
459 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZW
, test_buffer
, 1));
462 CONST D3DVERTEXELEMENT9 test_buffer
[] =
463 { { 0, 0, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_POSITIONT
, 0 }, D3DDECL_END() };
464 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZRHW
, test_buffer
, 1));
467 CONST D3DVERTEXELEMENT9 test_buffer
[] =
468 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
469 { 0, 12, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
470 { 0, 28, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
471 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
472 D3DFVF_XYZB5
| D3DFVF_LASTBETA_UBYTE4
, test_buffer
, 1));
475 CONST D3DVERTEXELEMENT9 test_buffer
[] =
476 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
477 { 0, 12, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
478 { 0, 28, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
479 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
480 D3DFVF_XYZB5
| D3DFVF_LASTBETA_D3DCOLOR
, test_buffer
, 1));
483 CONST D3DVERTEXELEMENT9 test_buffer
[] =
484 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
485 { 0, 12, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
486 { 0, 28, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
487 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZB5
, test_buffer
, 1));
490 CONST D3DVERTEXELEMENT9 test_buffer
[] =
491 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
492 { 0, 12, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 }, D3DDECL_END() };
493 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZB1
, test_buffer
, 1));
496 CONST D3DVERTEXELEMENT9 test_buffer
[] =
497 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
498 { 0, 12, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
499 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
500 D3DFVF_XYZB1
| D3DFVF_LASTBETA_UBYTE4
, test_buffer
, 1));
503 CONST D3DVERTEXELEMENT9 test_buffer
[] =
504 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
505 { 0, 12, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
506 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
507 D3DFVF_XYZB1
| D3DFVF_LASTBETA_D3DCOLOR
, test_buffer
, 1));
510 CONST D3DVERTEXELEMENT9 test_buffer
[] =
511 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
512 { 0, 12, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 }, D3DDECL_END() };
513 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZB2
, test_buffer
, 1));
516 CONST D3DVERTEXELEMENT9 test_buffer
[] =
517 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
518 { 0, 12, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
519 { 0, 16, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
520 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
521 D3DFVF_XYZB2
| D3DFVF_LASTBETA_UBYTE4
, test_buffer
, 1));
524 CONST D3DVERTEXELEMENT9 test_buffer
[] =
525 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
526 { 0, 12, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
527 { 0, 16, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
528 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
529 D3DFVF_XYZB2
| D3DFVF_LASTBETA_D3DCOLOR
, test_buffer
, 1));
532 CONST D3DVERTEXELEMENT9 test_buffer
[] =
533 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
534 { 0, 12, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 }, D3DDECL_END() };
535 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZB3
, test_buffer
, 1));
538 CONST D3DVERTEXELEMENT9 test_buffer
[] =
539 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
540 { 0, 12, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
541 { 0, 20, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
542 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
543 D3DFVF_XYZB3
| D3DFVF_LASTBETA_UBYTE4
, test_buffer
, 1));
546 CONST D3DVERTEXELEMENT9 test_buffer
[] =
547 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
548 { 0, 12, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
549 { 0, 20, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
550 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
551 D3DFVF_XYZB3
| D3DFVF_LASTBETA_D3DCOLOR
, test_buffer
, 1));
554 CONST D3DVERTEXELEMENT9 test_buffer
[] =
555 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
556 { 0, 12, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 }, D3DDECL_END() };
557 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZB4
, test_buffer
, 1));
560 CONST D3DVERTEXELEMENT9 test_buffer
[] =
561 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
562 { 0, 12, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
563 { 0, 24, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
564 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
565 D3DFVF_XYZB4
| D3DFVF_LASTBETA_UBYTE4
, test_buffer
, 1));
568 CONST D3DVERTEXELEMENT9 test_buffer
[] =
569 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
570 { 0, 12, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
571 { 0, 24, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
572 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
573 D3DFVF_XYZB4
| D3DFVF_LASTBETA_D3DCOLOR
, test_buffer
, 1));
576 CONST D3DVERTEXELEMENT9 test_buffer
[] =
577 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_NORMAL
, 0 }, D3DDECL_END() };
578 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_NORMAL
, test_buffer
, 1));
581 CONST D3DVERTEXELEMENT9 test_buffer
[] =
582 { { 0, 0, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_PSIZE
, 0 }, D3DDECL_END() };
583 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_PSIZE
, test_buffer
, 1));
586 CONST D3DVERTEXELEMENT9 test_buffer
[] =
587 { { 0, 0, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 }, D3DDECL_END() };
588 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_DIFFUSE
, test_buffer
, 1));
591 CONST D3DVERTEXELEMENT9 test_buffer
[] =
592 { { 0, 0, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 1 }, D3DDECL_END() };
593 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_SPECULAR
, test_buffer
, 1));
596 /* Make sure textures of different sizes work */
598 CONST D3DVERTEXELEMENT9 test_buffer
[] =
599 { { 0, 0, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
600 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
601 D3DFVF_TEXCOORDSIZE1(0) | D3DFVF_TEX1
, test_buffer
, 1));
604 CONST D3DVERTEXELEMENT9 test_buffer
[] =
605 { { 0, 0, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
606 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
607 D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEX1
, test_buffer
, 1));
610 CONST D3DVERTEXELEMENT9 test_buffer
[] =
611 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
612 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
613 D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEX1
, test_buffer
, 1));
616 CONST D3DVERTEXELEMENT9 test_buffer
[] =
617 { { 0, 0, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
618 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
619 D3DFVF_TEXCOORDSIZE4(0) | D3DFVF_TEX1
, test_buffer
, 1));
622 /* Make sure the TEXCOORD index works correctly - try several textures */
624 CONST D3DVERTEXELEMENT9 test_buffer
[] =
625 { { 0, 0, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_TEXCOORD
, 0 },
626 { 0, 4, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_TEXCOORD
, 1 },
627 { 0, 16, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_TEXCOORD
, 2 },
628 { 0, 24, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_TEXCOORD
, 3 }, D3DDECL_END() };
629 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
630 D3DFVF_TEXCOORDSIZE1(0) | D3DFVF_TEXCOORDSIZE3(1) | D3DFVF_TEXCOORDSIZE2(2) |
631 D3DFVF_TEXCOORDSIZE4(3) | D3DFVF_TEX4
, test_buffer
, 1));
634 /* Now try a combination test */
636 CONST D3DVERTEXELEMENT9 test_buffer
[] =
637 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
638 { 0, 12, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
639 { 0, 28, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
640 { 0, 32, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 1 },
641 { 0, 36, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_TEXCOORD
, 0 },
642 { 0, 44, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_TEXCOORD
, 1 }, D3DDECL_END() };
643 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZB4
| D3DFVF_SPECULAR
| D3DFVF_DIFFUSE
|
644 D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEXCOORDSIZE3(1) | D3DFVF_TEX2
, test_buffer
, 1));
647 /* Setting the FVF to 0 should result in no change to the default decl */
648 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, 0, default_elements
, 0));
651 IDirect3DDevice9_SetVertexDeclaration ( pDevice
, NULL
);
652 if ( default_decl
) IUnknown_Release (default_decl
);
655 /* Check whether a declaration converted from FVF is shared.
656 * Check whether refcounts behave as expected */
657 static void test_fvf_decl_management(
658 IDirect3DDevice9
* device
) {
661 IDirect3DVertexDeclaration9
* result_decl1
= NULL
;
662 IDirect3DVertexDeclaration9
* result_decl2
= NULL
;
663 IDirect3DVertexDeclaration9
* result_decl3
= NULL
;
664 IDirect3DVertexDeclaration9
* result_decl4
= NULL
;
665 int ref1
, ref2
, ref3
, ref4
;
667 DWORD test_fvf1
= D3DFVF_XYZRHW
;
668 DWORD test_fvf2
= D3DFVF_NORMAL
;
669 CONST D3DVERTEXELEMENT9 test_elements1
[] =
670 { { 0, 0, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_POSITIONT
, 0 }, D3DDECL_END() };
671 CONST D3DVERTEXELEMENT9 test_elements2
[] =
672 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_NORMAL
, 0 }, D3DDECL_END() };
674 /* Clear down any current vertex declaration */
675 hr
= IDirect3DDevice9_SetVertexDeclaration ( device
, NULL
);
676 ok (SUCCEEDED(hr
), "SetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
677 if (FAILED(hr
)) return;
680 hr
= IDirect3DDevice9_SetFVF( device
, test_fvf1
);
681 ok(SUCCEEDED(hr
), "SetFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
682 if (FAILED(hr
)) return;
684 /* Get converted decl (#1) */
685 hr
= IDirect3DDevice9_GetVertexDeclaration ( device
, &result_decl1
);
686 ok(SUCCEEDED(hr
), "GetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
687 if (FAILED(hr
)) return;
689 /* Get converted decl again (#2) */
690 hr
= IDirect3DDevice9_GetVertexDeclaration ( device
, &result_decl2
);
691 ok(SUCCEEDED(hr
), "GetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
692 if (FAILED(hr
)) return;
695 hr
= IDirect3DDevice9_SetFVF( device
, test_fvf2
);
696 ok(SUCCEEDED(hr
), "SetFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
697 if (FAILED(hr
)) return;
699 /* The contents should correspond to the first conversion */
700 VDECL_CHECK(compare_elements(result_decl1
, test_elements1
));
702 /* Get converted decl (#3) */
703 hr
= IDirect3DDevice9_GetVertexDeclaration ( device
, &result_decl3
);
704 ok(SUCCEEDED(hr
), "GetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
705 if (FAILED(hr
)) return;
707 /* The object should be the same */
708 ok (result_decl1
== result_decl2
, "Declaration object changes on the second Get() call\n");
709 ok (result_decl2
!= result_decl3
, "Declaration object did not change during conversion\n");
711 /* The contents should correspond to the second conversion */
712 VDECL_CHECK(compare_elements(result_decl3
, test_elements2
));
713 /* Re-Check if the first decl was overwritten by the new Get() */
714 VDECL_CHECK(compare_elements(result_decl1
, test_elements1
));
716 hr
= IDirect3DDevice9_SetFVF( device
, test_fvf1
);
717 ok(SUCCEEDED(hr
), "SetFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
718 if (FAILED(hr
)) return;
720 hr
= IDirect3DDevice9_GetVertexDeclaration ( device
, &result_decl4
);
721 ok(SUCCEEDED(hr
), "GetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
722 if (FAILED(hr
)) return;
724 ok(result_decl4
== result_decl1
, "Setting an already used FVF over results in a different vertexdeclaration\n");
726 ref1
= get_refcount((IUnknown
*) result_decl1
);
727 ref2
= get_refcount((IUnknown
*) result_decl2
);
728 ref3
= get_refcount((IUnknown
*) result_decl3
);
729 ref4
= get_refcount((IUnknown
*) result_decl4
);
730 ok (ref1
== 3, "Refcount #1 is %d, expected 3\n", ref1
);
731 ok (ref2
== 3, "Refcount #2 is %d, expected 3\n", ref2
);
732 ok (ref3
== 1, "Refcount #3 is %d, expected 1\n", ref3
);
733 ok (ref4
== 3, "Refcount #4 is %d, expected 3\n", ref4
);
735 /* Clear down any current vertex declaration */
736 hr
= IDirect3DDevice9_SetVertexDeclaration ( device
, NULL
);
737 ok (SUCCEEDED(hr
), "SetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
738 if (FAILED(hr
)) return;
740 IDirect3DVertexDeclaration9_Release(result_decl1
);
741 IDirect3DVertexDeclaration9_Release(result_decl2
);
742 IDirect3DVertexDeclaration9_Release(result_decl3
);
743 IDirect3DVertexDeclaration9_Release(result_decl4
);
748 static void test_vertex_declaration_alignment(
749 IDirect3DDevice9
* device
) {
752 IDirect3DVertexDeclaration9
* result_decl
= NULL
;
755 CONST D3DVERTEXELEMENT9 test_elements
[5][3] =
758 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
759 { 0, 16, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
763 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
764 { 0, 17, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
768 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
769 { 0, 18, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
773 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
774 { 0, 19, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
778 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
779 { 0, 20, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
783 HRESULT results
[5] = {D3D_OK
, E_FAIL
, E_FAIL
, E_FAIL
, D3D_OK
};
785 for(i
= 0; i
< sizeof(test_elements
) / sizeof(test_elements
[0]); i
++) {
787 hr
= IDirect3DDevice9_CreateVertexDeclaration(device
, test_elements
[i
], &result_decl
);
788 ok(hr
== results
[i
], "CreateVertexDeclaration for declaration %d returned %#x, expected %#x\n",
790 if(result_decl
) IDirect3DVertexDeclaration9_Release(result_decl
);
794 static void test_unused_type(
795 IDirect3DDevice9
* device
) {
798 IDirect3DVertexDeclaration9
* result_decl
= NULL
;
801 static const D3DVERTEXELEMENT9 test_elements
[][3] =
804 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
805 { 0, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_COLOR
, 0 },
809 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
810 { 0, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_TEXCOORD
, 0 },
814 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
815 { 0, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_TEXCOORD
, 1 },
819 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
820 { 0, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_TEXCOORD
, 12},
824 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
825 { 1, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_TEXCOORD
, 12},
829 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
830 { 0, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_NORMAL
, 0 },
834 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
835 { 1, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_NORMAL
, 0 },
840 for(i
= 0; i
< sizeof(test_elements
) / sizeof(test_elements
[0]); i
++) {
842 hr
= IDirect3DDevice9_CreateVertexDeclaration(device
, test_elements
[i
], &result_decl
);
843 ok(hr
== E_FAIL
, "CreateVertexDeclaration for declaration %d returned %#x, expected E_FAIL(%#x)\n",
845 if(result_decl
) IDirect3DVertexDeclaration9_Release(result_decl
);
848 START_TEST(vertexdeclaration
)
850 static D3DVERTEXELEMENT9 simple_decl
[] = {
851 { 0, 0, D3DDECLTYPE_FLOAT3
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0 },
853 UINT simple_decl_num_elements
= sizeof(simple_decl
) / sizeof(*simple_decl
);
854 IDirect3DDevice9
*device_ptr
= 0;
855 IDirect3DVertexDeclaration9
*decl_ptr
= 0;
858 d3d9_handle
= LoadLibraryA("d3d9.dll");
861 skip("Could not load d3d9.dll\n");
865 device_ptr
= init_d3d9();
868 skip("Failed to initialise d3d9\n");
872 decl_ptr
= test_create_vertex_declaration(device_ptr
, simple_decl
);
875 skip("Failed to create a vertex declaration\n");
879 test_get_set_vertex_declaration(device_ptr
, decl_ptr
);
880 test_get_declaration(decl_ptr
, simple_decl
, simple_decl_num_elements
);
881 test_fvf_decl_conversion(device_ptr
);
882 test_fvf_decl_management(device_ptr
);
883 test_vertex_declaration_alignment(device_ptr
);
884 test_unused_type(device_ptr
);
886 IDirect3DVertexDeclaration9_Release(decl_ptr
);
888 refcount
= IDirect3DDevice9_Release(device_ptr
);
889 ok(!refcount
, "Device has %u references left\n", refcount
);