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
);
188 static void test_get_declaration(IDirect3DVertexDeclaration9
*decl_ptr
, D3DVERTEXELEMENT9
*vertex_decl
, UINT expected_num_elements
)
191 UINT num_elements
= 0;
192 D3DVERTEXELEMENT9
*decl
= 0;
195 /* First test only getting the number of elements */
196 num_elements
= 0x1337c0de;
197 hret
= IDirect3DVertexDeclaration9_GetDeclaration(decl_ptr
, NULL
, &num_elements
);
198 ok(hret
== D3D_OK
&& num_elements
== expected_num_elements
,
199 "GetDeclaration returned: hret 0x%x, num_elements %d. "
200 "Expected hret 0x%x, num_elements %d.\n", hret
, num_elements
, D3D_OK
, expected_num_elements
);
203 hret
= IDirect3DVertexDeclaration9_GetDeclaration(decl_ptr
, NULL
, &num_elements
);
204 ok(hret
== D3D_OK
&& num_elements
== expected_num_elements
,
205 "GetDeclaration returned: hret 0x%x, num_elements %d. "
206 "Expected hret 0x%x, num_elements %d.\n", hret
, num_elements
, D3D_OK
, expected_num_elements
);
208 /* Also test the returned data */
209 decl
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(D3DVERTEXELEMENT9
) * expected_num_elements
);
211 num_elements
= 0x1337c0de;
212 hret
= IDirect3DVertexDeclaration9_GetDeclaration(decl_ptr
, decl
, &num_elements
);
213 ok(hret
== D3D_OK
&& num_elements
== expected_num_elements
,
214 "GetDeclaration returned: hret 0x%x, num_elements %d. "
215 "Expected hret 0x%x, num_elements %d.\n", hret
, num_elements
, D3D_OK
, expected_num_elements
);
216 i
= memcmp(decl
, vertex_decl
, sizeof(vertex_decl
));
217 ok (!i
, "Original and returned vertexdeclarations are not the same\n");
218 ZeroMemory(decl
, sizeof(D3DVERTEXELEMENT9
) * expected_num_elements
);
221 hret
= IDirect3DVertexDeclaration9_GetDeclaration(decl_ptr
, decl
, &num_elements
);
222 ok(hret
== D3D_OK
&& num_elements
== expected_num_elements
,
223 "GetDeclaration returned: hret 0x%x, num_elements %d. "
224 "Expected hret 0x%x, num_elements %d.\n", hret
, num_elements
, D3D_OK
, expected_num_elements
);
225 i
= memcmp(decl
, vertex_decl
, sizeof(vertex_decl
));
226 ok (!i
, "Original and returned vertexdeclarations are not the same\n");
228 HeapFree(GetProcessHeap(), 0, decl
);
231 /* FIXME: also write a test, which shows that attempting to set
232 * an invalid vertex declaration returns E_FAIL */
234 static HRESULT
test_fvf_to_decl(
235 IDirect3DDevice9
* device
,
236 IDirect3DVertexDeclaration9
* default_decl
,
238 const D3DVERTEXELEMENT9 expected_elements
[],
239 char object_should_change
)
243 IDirect3DVertexDeclaration9
*result_decl
= NULL
;
245 /* Set a default declaration to make sure it is changed */
246 hr
= IDirect3DDevice9_SetVertexDeclaration ( device
, default_decl
);
247 ok (SUCCEEDED(hr
), "SetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
248 if (FAILED(hr
)) goto fail
;
251 hr
= IDirect3DDevice9_SetFVF( device
, test_fvf
);
252 ok(SUCCEEDED(hr
), "SetFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
253 if (FAILED(hr
)) goto fail
;
255 /* Check if the declaration object changed underneath */
256 hr
= IDirect3DDevice9_GetVertexDeclaration ( device
, &result_decl
);
257 ok(SUCCEEDED(hr
), "GetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
258 if (FAILED(hr
)) goto fail
;
259 if (object_should_change
) {
260 ok(result_decl
!= default_decl
, "result declaration matches original\n");
261 if (result_decl
== default_decl
) goto fail
;
263 ok(result_decl
== default_decl
, "result declaration does not match original\n");
264 if (result_decl
!= default_decl
) goto fail
;
267 /* Declaration content/size test */
268 ok(result_decl
!= NULL
, "result declaration was null\n");
269 if (result_decl
== NULL
)
271 else if (compare_elements(result_decl
, expected_elements
) != S_OK
)
274 if (result_decl
) IUnknown_Release( result_decl
);
278 if (result_decl
) IUnknown_Release( result_decl
);
282 static HRESULT
test_decl_to_fvf(
283 IDirect3DDevice9
* device
,
285 CONST D3DVERTEXELEMENT9 test_decl
[],
290 IDirect3DVertexDeclaration9
*vdecl
= NULL
;
292 DWORD result_fvf
= 0xdeadbeef;
294 /* Set a default FVF of SPECULAR and DIFFUSE to make sure it is changed back to 0 */
295 hr
= IDirect3DDevice9_SetFVF( device
, default_fvf
);
296 ok(SUCCEEDED(hr
), "SetFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
297 if (FAILED(hr
)) goto fail
;
299 /* Create a testing declaration */
300 hr
= IDirect3DDevice9_CreateVertexDeclaration( device
, test_decl
, &vdecl
);
301 ok(SUCCEEDED(hr
), "CreateVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
302 if (FAILED(hr
)) goto fail
;
304 /* Set the declaration */
305 hr
= IDirect3DDevice9_SetVertexDeclaration ( device
, vdecl
);
306 ok (SUCCEEDED(hr
), "SetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
307 if (FAILED(hr
)) goto fail
;
310 hr
= IDirect3DDevice9_GetFVF( device
, &result_fvf
);
311 ok(SUCCEEDED(hr
), "GetFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
312 if (FAILED(hr
)) goto fail
;
314 ok(test_fvf
== result_fvf
, "result FVF was: %#x, expected: %#x\n", result_fvf
, test_fvf
);
316 if (test_fvf
!= result_fvf
) goto fail
;
318 IDirect3DDevice9_SetVertexDeclaration ( device
, NULL
);
319 if (vdecl
) IUnknown_Release( vdecl
);
323 IDirect3DDevice9_SetVertexDeclaration ( device
, NULL
);
324 if (vdecl
) IUnknown_Release( vdecl
);
328 static void test_fvf_decl_conversion(IDirect3DDevice9
*pDevice
)
334 IDirect3DVertexDeclaration9
* default_decl
= NULL
;
335 DWORD default_fvf
= D3DFVF_SPECULAR
| D3DFVF_DIFFUSE
;
336 D3DVERTEXELEMENT9 default_elements
[] =
337 { { 0, 0, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
338 { 0, 4, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 1 }, D3DDECL_END() };
340 /* Create a default declaration and FVF that does not match any of the tests */
341 hr
= IDirect3DDevice9_CreateVertexDeclaration( pDevice
, default_elements
, &default_decl
);
342 ok(SUCCEEDED(hr
), "CreateVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
343 if (FAILED(hr
)) goto cleanup
;
345 /* Test conversions from vertex declaration to an FVF.
346 * For some reason those seem to occur only for POSITION/POSITIONT,
347 * Otherwise the FVF is forced to 0 - maybe this is configuration specific */
349 CONST D3DVERTEXELEMENT9 test_buffer
[] =
350 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 }, D3DDECL_END() };
351 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, D3DFVF_XYZ
));
354 CONST D3DVERTEXELEMENT9 test_buffer
[] =
355 { { 0, 0, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_POSITIONT
, 0 }, D3DDECL_END() };
356 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, D3DFVF_XYZRHW
));
358 for (i
= 0; i
< 4; i
++) {
359 CONST D3DVERTEXELEMENT9 test_buffer
[] =
360 { { 0, 0, D3DDECLTYPE_FLOAT1
+i
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0}, D3DDECL_END() };
361 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
364 CONST D3DVERTEXELEMENT9 test_buffer
[] =
365 { { 0, 0, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0}, D3DDECL_END() };
366 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
369 CONST D3DVERTEXELEMENT9 test_buffer
[] =
370 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_NORMAL
, 0 }, D3DDECL_END() };
371 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
374 CONST D3DVERTEXELEMENT9 test_buffer
[] =
375 { { 0, 0, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_PSIZE
, 0 }, D3DDECL_END() };
376 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
379 CONST D3DVERTEXELEMENT9 test_buffer
[] =
380 { { 0, 0, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 }, D3DDECL_END() };
381 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
384 CONST D3DVERTEXELEMENT9 test_buffer
[] =
385 { { 0, 0, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 1 }, D3DDECL_END() };
386 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
389 /* Make sure textures of different sizes work */
391 CONST D3DVERTEXELEMENT9 test_buffer
[] =
392 { { 0, 0, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
393 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
396 CONST D3DVERTEXELEMENT9 test_buffer
[] =
397 { { 0, 0, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
398 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
401 CONST D3DVERTEXELEMENT9 test_buffer
[] =
402 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
403 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
406 CONST D3DVERTEXELEMENT9 test_buffer
[] =
407 { { 0, 0, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
408 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
411 /* Make sure the TEXCOORD index works correctly - try several textures */
413 CONST D3DVERTEXELEMENT9 test_buffer
[] =
414 { { 0, 0, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_TEXCOORD
, 0 },
415 { 0, 4, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_TEXCOORD
, 1 },
416 { 0, 16, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_TEXCOORD
, 2 },
417 { 0, 24, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_TEXCOORD
, 3 }, D3DDECL_END() };
418 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
421 /* No FVF mapping available */
423 CONST D3DVERTEXELEMENT9 test_buffer
[] =
424 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 1 }, D3DDECL_END() };
425 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
428 CONST D3DVERTEXELEMENT9 test_buffer
[] =
429 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_NORMAL
, 1 }, D3DDECL_END() };
430 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
433 /* Try empty declaration */
435 CONST D3DVERTEXELEMENT9 test_buffer
[] = { D3DDECL_END() };
436 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
439 /* Now try a combination test */
441 CONST D3DVERTEXELEMENT9 test_buffer
[] =
442 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITIONT
, 0 },
443 { 0, 12, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_NORMAL
, 0 },
444 { 0, 24, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_PSIZE
, 0 },
445 { 0, 28, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 1 },
446 { 0, 32, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_TEXCOORD
, 0 },
447 { 0, 44, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_TEXCOORD
, 1 }, D3DDECL_END() };
448 VDECL_CHECK(test_decl_to_fvf(pDevice
, default_fvf
, test_buffer
, 0));
451 /* Test conversions from FVF to a vertex declaration
452 * These seem to always occur internally. A new declaration object is created if necessary */
455 CONST D3DVERTEXELEMENT9 test_buffer
[] =
456 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 }, D3DDECL_END() };
457 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZ
, test_buffer
, 1));
460 CONST D3DVERTEXELEMENT9 test_buffer
[] =
461 { { 0, 0, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_POSITIONT
, 0 }, D3DDECL_END() };
462 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZRHW
, test_buffer
, 1));
465 CONST D3DVERTEXELEMENT9 test_buffer
[] =
466 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
467 { 0, 12, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
468 { 0, 28, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
469 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
470 D3DFVF_XYZB5
| D3DFVF_LASTBETA_UBYTE4
, test_buffer
, 1));
473 CONST D3DVERTEXELEMENT9 test_buffer
[] =
474 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
475 { 0, 12, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
476 { 0, 28, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
477 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
478 D3DFVF_XYZB5
| D3DFVF_LASTBETA_D3DCOLOR
, test_buffer
, 1));
481 CONST D3DVERTEXELEMENT9 test_buffer
[] =
482 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
483 { 0, 12, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
484 { 0, 28, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
485 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZB5
, test_buffer
, 1));
488 CONST D3DVERTEXELEMENT9 test_buffer
[] =
489 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
490 { 0, 12, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 }, D3DDECL_END() };
491 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZB1
, test_buffer
, 1));
494 CONST D3DVERTEXELEMENT9 test_buffer
[] =
495 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
496 { 0, 12, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
497 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
498 D3DFVF_XYZB1
| D3DFVF_LASTBETA_UBYTE4
, test_buffer
, 1));
501 CONST D3DVERTEXELEMENT9 test_buffer
[] =
502 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
503 { 0, 12, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
504 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
505 D3DFVF_XYZB1
| D3DFVF_LASTBETA_D3DCOLOR
, test_buffer
, 1));
508 CONST D3DVERTEXELEMENT9 test_buffer
[] =
509 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
510 { 0, 12, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 }, D3DDECL_END() };
511 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZB2
, test_buffer
, 1));
514 CONST D3DVERTEXELEMENT9 test_buffer
[] =
515 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
516 { 0, 12, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
517 { 0, 16, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
518 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
519 D3DFVF_XYZB2
| D3DFVF_LASTBETA_UBYTE4
, test_buffer
, 1));
522 CONST D3DVERTEXELEMENT9 test_buffer
[] =
523 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
524 { 0, 12, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
525 { 0, 16, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
526 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
527 D3DFVF_XYZB2
| D3DFVF_LASTBETA_D3DCOLOR
, test_buffer
, 1));
530 CONST D3DVERTEXELEMENT9 test_buffer
[] =
531 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
532 { 0, 12, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 }, D3DDECL_END() };
533 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZB3
, test_buffer
, 1));
536 CONST D3DVERTEXELEMENT9 test_buffer
[] =
537 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
538 { 0, 12, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
539 { 0, 20, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
540 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
541 D3DFVF_XYZB3
| D3DFVF_LASTBETA_UBYTE4
, test_buffer
, 1));
544 CONST D3DVERTEXELEMENT9 test_buffer
[] =
545 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
546 { 0, 12, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
547 { 0, 20, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
548 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
549 D3DFVF_XYZB3
| D3DFVF_LASTBETA_D3DCOLOR
, test_buffer
, 1));
552 CONST D3DVERTEXELEMENT9 test_buffer
[] =
553 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
554 { 0, 12, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 }, D3DDECL_END() };
555 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZB4
, test_buffer
, 1));
558 CONST D3DVERTEXELEMENT9 test_buffer
[] =
559 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
560 { 0, 12, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
561 { 0, 24, D3DDECLTYPE_UBYTE4
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
562 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
563 D3DFVF_XYZB4
| D3DFVF_LASTBETA_UBYTE4
, test_buffer
, 1));
566 CONST D3DVERTEXELEMENT9 test_buffer
[] =
567 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
568 { 0, 12, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
569 { 0, 24, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_BLENDINDICES
, 0 }, D3DDECL_END() };
570 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
571 D3DFVF_XYZB4
| D3DFVF_LASTBETA_D3DCOLOR
, test_buffer
, 1));
574 CONST D3DVERTEXELEMENT9 test_buffer
[] =
575 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_NORMAL
, 0 }, D3DDECL_END() };
576 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_NORMAL
, test_buffer
, 1));
579 CONST D3DVERTEXELEMENT9 test_buffer
[] =
580 { { 0, 0, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_PSIZE
, 0 }, D3DDECL_END() };
581 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_PSIZE
, test_buffer
, 1));
584 CONST D3DVERTEXELEMENT9 test_buffer
[] =
585 { { 0, 0, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 }, D3DDECL_END() };
586 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_DIFFUSE
, test_buffer
, 1));
589 CONST D3DVERTEXELEMENT9 test_buffer
[] =
590 { { 0, 0, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 1 }, D3DDECL_END() };
591 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_SPECULAR
, test_buffer
, 1));
594 /* Make sure textures of different sizes work */
596 CONST D3DVERTEXELEMENT9 test_buffer
[] =
597 { { 0, 0, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
598 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
599 D3DFVF_TEXCOORDSIZE1(0) | D3DFVF_TEX1
, test_buffer
, 1));
602 CONST D3DVERTEXELEMENT9 test_buffer
[] =
603 { { 0, 0, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
604 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
605 D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEX1
, test_buffer
, 1));
608 CONST D3DVERTEXELEMENT9 test_buffer
[] =
609 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
610 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
611 D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEX1
, test_buffer
, 1));
614 CONST D3DVERTEXELEMENT9 test_buffer
[] =
615 { { 0, 0, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_TEXCOORD
, 0 }, D3DDECL_END() };
616 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
617 D3DFVF_TEXCOORDSIZE4(0) | D3DFVF_TEX1
, test_buffer
, 1));
620 /* Make sure the TEXCOORD index works correctly - try several textures */
622 CONST D3DVERTEXELEMENT9 test_buffer
[] =
623 { { 0, 0, D3DDECLTYPE_FLOAT1
, 0, D3DDECLUSAGE_TEXCOORD
, 0 },
624 { 0, 4, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_TEXCOORD
, 1 },
625 { 0, 16, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_TEXCOORD
, 2 },
626 { 0, 24, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_TEXCOORD
, 3 }, D3DDECL_END() };
627 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
,
628 D3DFVF_TEXCOORDSIZE1(0) | D3DFVF_TEXCOORDSIZE3(1) | D3DFVF_TEXCOORDSIZE2(2) |
629 D3DFVF_TEXCOORDSIZE4(3) | D3DFVF_TEX4
, test_buffer
, 1));
632 /* Now try a combination test */
634 CONST D3DVERTEXELEMENT9 test_buffer
[] =
635 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
636 { 0, 12, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_BLENDWEIGHT
, 0 },
637 { 0, 28, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
638 { 0, 32, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 1 },
639 { 0, 36, D3DDECLTYPE_FLOAT2
, 0, D3DDECLUSAGE_TEXCOORD
, 0 },
640 { 0, 44, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_TEXCOORD
, 1 }, D3DDECL_END() };
641 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, D3DFVF_XYZB4
| D3DFVF_SPECULAR
| D3DFVF_DIFFUSE
|
642 D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEXCOORDSIZE3(1) | D3DFVF_TEX2
, test_buffer
, 1));
645 /* Setting the FVF to 0 should result in no change to the default decl */
646 VDECL_CHECK(test_fvf_to_decl(pDevice
, default_decl
, 0, default_elements
, 0));
649 IDirect3DDevice9_SetVertexDeclaration ( pDevice
, NULL
);
650 if ( default_decl
) IUnknown_Release (default_decl
);
653 /* Check whether a declaration converted from FVF is shared.
654 * Check whether refcounts behave as expected */
655 static void test_fvf_decl_management(
656 IDirect3DDevice9
* device
) {
659 IDirect3DVertexDeclaration9
* result_decl1
= NULL
;
660 IDirect3DVertexDeclaration9
* result_decl2
= NULL
;
661 IDirect3DVertexDeclaration9
* result_decl3
= NULL
;
662 IDirect3DVertexDeclaration9
* result_decl4
= NULL
;
663 int ref1
, ref2
, ref3
, ref4
;
665 DWORD test_fvf1
= D3DFVF_XYZRHW
;
666 DWORD test_fvf2
= D3DFVF_NORMAL
;
667 CONST D3DVERTEXELEMENT9 test_elements1
[] =
668 { { 0, 0, D3DDECLTYPE_FLOAT4
, 0, D3DDECLUSAGE_POSITIONT
, 0 }, D3DDECL_END() };
669 CONST D3DVERTEXELEMENT9 test_elements2
[] =
670 { { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_NORMAL
, 0 }, D3DDECL_END() };
672 /* Clear down any current vertex declaration */
673 hr
= IDirect3DDevice9_SetVertexDeclaration ( device
, NULL
);
674 ok (SUCCEEDED(hr
), "SetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
675 if (FAILED(hr
)) return;
678 hr
= IDirect3DDevice9_SetFVF( device
, test_fvf1
);
679 ok(SUCCEEDED(hr
), "SetFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
680 if (FAILED(hr
)) return;
682 /* Get converted decl (#1) */
683 hr
= IDirect3DDevice9_GetVertexDeclaration ( device
, &result_decl1
);
684 ok(SUCCEEDED(hr
), "GetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
685 if (FAILED(hr
)) return;
687 /* Get converted decl again (#2) */
688 hr
= IDirect3DDevice9_GetVertexDeclaration ( device
, &result_decl2
);
689 ok(SUCCEEDED(hr
), "GetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
690 if (FAILED(hr
)) return;
693 hr
= IDirect3DDevice9_SetFVF( device
, test_fvf2
);
694 ok(SUCCEEDED(hr
), "SetFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
695 if (FAILED(hr
)) return;
697 /* The contents should correspond to the first conversion */
698 VDECL_CHECK(compare_elements(result_decl1
, test_elements1
));
700 /* Get converted decl (#3) */
701 hr
= IDirect3DDevice9_GetVertexDeclaration ( device
, &result_decl3
);
702 ok(SUCCEEDED(hr
), "GetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
703 if (FAILED(hr
)) return;
705 /* The object should be the same */
706 ok (result_decl1
== result_decl2
, "Declaration object changes on the second Get() call\n");
707 ok (result_decl2
!= result_decl3
, "Declaration object did not change during conversion\n");
709 /* The contents should correspond to the second conversion */
710 VDECL_CHECK(compare_elements(result_decl3
, test_elements2
));
711 /* Re-Check if the first decl was overwritten by the new Get() */
712 VDECL_CHECK(compare_elements(result_decl1
, test_elements1
));
714 hr
= IDirect3DDevice9_SetFVF( device
, test_fvf1
);
715 ok(SUCCEEDED(hr
), "SetFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
716 if (FAILED(hr
)) return;
718 hr
= IDirect3DDevice9_GetVertexDeclaration ( device
, &result_decl4
);
719 ok(SUCCEEDED(hr
), "GetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
720 if (FAILED(hr
)) return;
722 ok(result_decl4
== result_decl1
, "Setting an already used FVF over results in a different vertexdeclaration\n");
724 ref1
= get_refcount((IUnknown
*) result_decl1
);
725 ref2
= get_refcount((IUnknown
*) result_decl2
);
726 ref3
= get_refcount((IUnknown
*) result_decl3
);
727 ref4
= get_refcount((IUnknown
*) result_decl4
);
728 ok (ref1
== 3, "Refcount #1 is %d, expected 3\n", ref1
);
729 ok (ref2
== 3, "Refcount #2 is %d, expected 3\n", ref2
);
730 ok (ref3
== 1, "Refcount #3 is %d, expected 1\n", ref3
);
731 ok (ref4
== 3, "Refcount #4 is %d, expected 3\n", ref4
);
733 /* Clear down any current vertex declaration */
734 hr
= IDirect3DDevice9_SetVertexDeclaration ( device
, NULL
);
735 ok (SUCCEEDED(hr
), "SetVertexDeclaration returned %#x, expected %#x\n", hr
, D3D_OK
);
736 if (FAILED(hr
)) return;
738 IDirect3DVertexDeclaration9_Release(result_decl1
);
739 IDirect3DVertexDeclaration9_Release(result_decl2
);
740 IDirect3DVertexDeclaration9_Release(result_decl3
);
741 IDirect3DVertexDeclaration9_Release(result_decl4
);
746 static void test_vertex_declaration_alignment(
747 IDirect3DDevice9
* device
) {
750 IDirect3DVertexDeclaration9
* result_decl
= NULL
;
753 CONST D3DVERTEXELEMENT9 test_elements
[5][3] =
756 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
757 { 0, 16, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
761 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
762 { 0, 17, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
766 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
767 { 0, 18, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
771 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
772 { 0, 19, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
776 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
777 { 0, 20, D3DDECLTYPE_D3DCOLOR
, 0, D3DDECLUSAGE_COLOR
, 0 },
781 HRESULT results
[5] = {D3D_OK
, E_FAIL
, E_FAIL
, E_FAIL
, D3D_OK
};
783 for(i
= 0; i
< sizeof(test_elements
) / sizeof(test_elements
[0]); i
++) {
785 hr
= IDirect3DDevice9_CreateVertexDeclaration(device
, test_elements
[i
], &result_decl
);
786 ok(hr
== results
[i
], "CreateVertexDeclaration for declaration %d returned %#x, expected %#x\n",
788 if(result_decl
) IDirect3DVertexDeclaration9_Release(result_decl
);
792 static void test_unused_type(
793 IDirect3DDevice9
* device
) {
796 IDirect3DVertexDeclaration9
* result_decl
= NULL
;
799 static const D3DVERTEXELEMENT9 test_elements
[][3] =
802 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
803 { 0, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_COLOR
, 0 },
807 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
808 { 0, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_TEXCOORD
, 0 },
812 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
813 { 0, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_TEXCOORD
, 1 },
817 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
818 { 0, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_TEXCOORD
, 12},
822 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
823 { 1, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_TEXCOORD
, 12},
827 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
828 { 0, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_NORMAL
, 0 },
832 { 0, 0, D3DDECLTYPE_FLOAT3
, 0, D3DDECLUSAGE_POSITION
, 0 },
833 { 1, 16, D3DDECLTYPE_UNUSED
, 0, D3DDECLUSAGE_NORMAL
, 0 },
838 for(i
= 0; i
< sizeof(test_elements
) / sizeof(test_elements
[0]); i
++) {
840 hr
= IDirect3DDevice9_CreateVertexDeclaration(device
, test_elements
[i
], &result_decl
);
841 ok(hr
== E_FAIL
, "CreateVertexDeclaration for declaration %d returned %#x, expected E_FAIL(%#x)\n",
843 if(result_decl
) IDirect3DVertexDeclaration9_Release(result_decl
);
846 START_TEST(vertexdeclaration
)
848 static D3DVERTEXELEMENT9 simple_decl
[] = {
849 { 0, 0, D3DDECLTYPE_FLOAT3
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0 },
851 UINT simple_decl_num_elements
= sizeof(simple_decl
) / sizeof(*simple_decl
);
852 IDirect3DDevice9
*device_ptr
= 0;
853 IDirect3DVertexDeclaration9
*decl_ptr
= 0;
855 d3d9_handle
= LoadLibraryA("d3d9.dll");
858 skip("Could not load d3d9.dll\n");
862 device_ptr
= init_d3d9();
865 skip("Failed to initialise d3d9\n");
869 decl_ptr
= test_create_vertex_declaration(device_ptr
, simple_decl
);
872 skip("Failed to create a vertex declaration\n");
876 test_get_set_vertex_declaration(device_ptr
, decl_ptr
);
877 test_get_declaration(decl_ptr
, simple_decl
, simple_decl_num_elements
);
878 test_fvf_decl_conversion(device_ptr
);
879 test_fvf_decl_management(device_ptr
);
880 test_vertex_declaration_alignment(device_ptr
);
881 test_unused_type(device_ptr
);