ReactOS 0.4.17-dev-966-gf06eace
mesh.c File Reference
#include <stdio.h>
#include <float.h>
#include <limits.h>
#include <assert.h>
#include "wine/test.h"
#include "d3dx9.h"
#include "initguid.h"
#include "rmxftmpl.h"
#include "rmxfguid.h"
Include dependency graph for mesh.c:

Go to the source code of this file.

Classes

struct  vertex
 
struct  test_context
 
struct  mesh
 
struct  test_user_data
 
struct  test_load_user_data
 
struct  sincos_table
 
struct  dynamic_array
 
struct  point2d
 
struct  outline
 
struct  outline_array
 
struct  glyphinfo
 
struct  udec3
 
struct  dec3n
 

Macros

#define COBJMACROS
 
#define TRACECALLBACK   if(winetest_debug > 1) trace
 
#define admitted_error   0.0001f
 
#define compare_vertex_sizes(type, exp)
 
#define compare_float(got, exp)
 
#define check_floats(got, exp, dim)   check_floats_(__LINE__, "", got, exp, dim)
 
#define check_vertex_buffer(mesh, vertices, num_vertices, fvf)    check_vertex_buffer_(__LINE__, mesh, vertices, num_vertices, fvf)
 
#define check_index_buffer(mesh, indices, num_indices, index_size)    check_index_buffer_(__LINE__, mesh, indices, num_indices, index_size)
 
#define check_matrix(got, expected)   check_matrix_(__LINE__, got, expected)
 
#define check_materials(got, got_count, expected, expected_count)    check_materials_(__LINE__, got, got_count, expected, expected_count)
 
#define check_generated_adjacency(mesh, got, epsilon)   check_generated_adjacency_(__LINE__, mesh, got, epsilon)
 
#define check_generated_effects(materials, num_materials, effects)    check_generated_effects_(__LINE__, materials, num_materials, effects)
 
#define EFFECT_TABLE_ENTRY(str, field)    {str, sizeof(str), sizeof(materials->MatD3D.field), offsetof(D3DXMATERIAL, MatD3D.field)}
 
#define test_LoadMeshFromX(device, xfile_str, vertex_array, fvf, index_array, materials_array, check_adjacency)
 
#define MAX_USER_DATA_COUNT   32
 

Typedefs

typedef WORD face[3]
 

Enumerations

enum  user_data_type { USER_DATA_TYPE_TOP , USER_DATA_TYPE_FRAME_CHILD , USER_DATA_TYPE_MESH_CHILD }
 
enum  pointtype {
  POINTTYPE_CURVE = 0 , POINTTYPE_CORNER , POINTTYPE_CURVE_START , POINTTYPE_CURVE_END ,
  POINTTYPE_CURVE_MIDDLE , POINTTYPE_CURVE = 0 , POINTTYPE_CORNER , POINTTYPE_CURVE_START ,
  POINTTYPE_CURVE_END , POINTTYPE_CURVE_MIDDLE
}
 

Functions

static BOOL compare (FLOAT u, FLOAT v)
 
static BOOL compare_vec3 (D3DXVECTOR3 u, D3DXVECTOR3 v)
 
static BOOL compare_vec4 (D3DXVECTOR4 u, D3DXVECTOR4 v)
 
static void check_floats_ (int line, const char *prefix, const float *got, const float *exp, int dim)
 
static BOOL compare_face (face a, face b)
 
static struct test_context * new_test_context (void)
 
static void free_test_context (struct test_context *test_context)
 
static void free_mesh (struct mesh *mesh)
 
static BOOL new_mesh (struct mesh *mesh, DWORD number_of_vertices, DWORD number_of_faces)
 
static void compare_mesh (const char *name, ID3DXMesh *d3dxmesh, struct mesh *mesh)
 
static void D3DXBoundProbeTest (void)
 
static void D3DXComputeBoundingBoxTest (void)
 
static void D3DXComputeBoundingSphereTest (void)
 
static void print_elements (const D3DVERTEXELEMENT9 *elements)
 
static void compare_elements (const D3DVERTEXELEMENT9 *elements, const D3DVERTEXELEMENT9 *expected_elements, unsigned int line, unsigned int test_id)
 
static void test_fvf_to_decl (DWORD test_fvf, const D3DVERTEXELEMENT9 expected_elements[], HRESULT expected_hr, unsigned int line, unsigned int test_id)
 
static void test_decl_to_fvf (const D3DVERTEXELEMENT9 *decl, DWORD expected_fvf, HRESULT expected_hr, unsigned int line, unsigned int test_id)
 
static void test_fvf_decl_conversion (void)
 
static void D3DXGetFVFVertexSizeTest (void)
 
static void D3DXIntersectTriTest (void)
 
static void D3DXCreateMeshTest (void)
 
static void D3DXCreateMeshFVFTest (void)
 
static void check_vertex_buffer_ (int line, ID3DXMesh *mesh, const void *vertices, DWORD num_vertices, DWORD fvf)
 
static void check_index_buffer_ (int line, ID3DXMesh *mesh, const void *indices, DWORD num_indices, DWORD index_size)
 
static void check_matrix_ (int line, const D3DXMATRIX *got, const D3DXMATRIX *expected)
 
static void check_colorvalue_ (int line, const char *prefix, const D3DCOLORVALUE got, const D3DCOLORVALUE expected)
 
static void check_materials_ (int line, const D3DXMATERIAL *got, DWORD got_count, const D3DXMATERIAL *expected, DWORD expected_count)
 
static void check_generated_adjacency_ (int line, ID3DXMesh *mesh, const DWORD *got, FLOAT epsilon)
 
static void check_generated_effects_ (int line, const D3DXMATERIAL *materials, DWORD num_materials, const D3DXEFFECTINSTANCE *effects)
 
static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_DestroyFrame (ID3DXAllocateHierarchy *iface, LPD3DXFRAME frame)
 
static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_CreateFrame (ID3DXAllocateHierarchy *iface, const char *name, D3DXFRAME **new_frame)
 
static HRESULT destroy_mesh_container (LPD3DXMESHCONTAINER mesh_container)
 
static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_DestroyMeshContainer (ID3DXAllocateHierarchy *iface, LPD3DXMESHCONTAINER mesh_container)
 
static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_CreateMeshContainer (ID3DXAllocateHierarchy *iface, const char *name, const D3DXMESHDATA *mesh_data, const D3DXMATERIAL *materials, const D3DXEFFECTINSTANCE *effects, DWORD num_materials, const DWORD *adjacency, ID3DXSkinInfo *skin_info, D3DXMESHCONTAINER **new_mesh_container)
 
static void test_LoadMeshFromX_ (int line, IDirect3DDevice9 *device, const char *xfile_str, size_t xfile_strlen, const void *vertices, DWORD num_vertices, DWORD fvf, const void *indices, DWORD num_indices, size_t index_size, const D3DXMATERIAL *expected_materials, DWORD expected_num_materials, BOOL check_adjacency)
 
static void record_common_user_data (struct test_load_user_data *data, ID3DXFileData *filedata, enum user_data_type data_type)
 
static struct test_load_user_data * impl_from_ID3DXLoadUserData (ID3DXLoadUserData *iface)
 
static HRESULT STDMETHODCALLTYPE load_top_level_data (ID3DXLoadUserData *iface, ID3DXFileData *filedata)
 
static HRESULT STDMETHODCALLTYPE load_frame_child_data (ID3DXLoadUserData *iface, D3DXFRAME *frame, ID3DXFileData *filedata)
 
static HRESULT STDMETHODCALLTYPE load_mesh_child_data (ID3DXLoadUserData *iface, D3DXMESHCONTAINER *mesh_container, ID3DXFileData *filedata)
 
static void init_load_user_data (struct test_load_user_data *data)
 
static void check_user_data (struct test_load_user_data *user_data, unsigned int expected_count, const struct test_user_data *expected)
 
 DEFINE_GUID (TID_TestDataGuid, 0x12345678, 0x1234, 0x1234, 0x12, 0x34, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11)
 
static void D3DXLoadMeshTest (void)
 
static BOOL compute_box (struct mesh *mesh, float width, float height, float depth)
 
static void test_box (IDirect3DDevice9 *device, float width, float height, float depth)
 
static void D3DXCreateBoxTest (void)
 
static BOOL compute_polygon (struct mesh *mesh, float length, unsigned int sides)
 
static void test_polygon (IDirect3DDevice9 *device, float length, unsigned int sides)
 
static void D3DXCreatePolygonTest (void)
 
static void free_sincos_table (struct sincos_table *sincos_table)
 
static BOOL compute_sincos_table (struct sincos_table *sincos_table, float angle_start, float angle_step, int n)
 
static WORD vertex_index (UINT slices, int slice, int stack)
 
static BOOL compute_sphere (struct mesh *mesh, FLOAT radius, UINT slices, UINT stacks)
 
static void test_sphere (IDirect3DDevice9 *device, FLOAT radius, UINT slices, UINT stacks)
 
static void D3DXCreateSphereTest (void)
 
static BOOL compute_cylinder (struct mesh *mesh, FLOAT radius1, FLOAT radius2, FLOAT length, UINT slices, UINT stacks)
 
static void test_cylinder (IDirect3DDevice9 *device, FLOAT radius1, FLOAT radius2, FLOAT length, UINT slices, UINT stacks)
 
static void D3DXCreateCylinderTest (void)
 
static BOOL compute_torus (struct mesh *mesh, float innerradius, float outerradius, UINT sides, UINT rings)
 
static void test_torus (IDirect3DDevice9 *device, float innerradius, float outerradius, UINT sides, UINT rings)
 
static void D3DXCreateTorusTest (void)
 
static BOOL reserve (struct dynamic_array *array, int count, int itemsize)
 
static struct point2d * add_point (struct outline *array)
 
static struct outline * add_outline (struct outline_array *array)
 
static D3DXVECTOR2 * convert_fixed_to_float (POINTFX *pt, int count, float emsquare)
 
static HRESULT add_bezier_points (struct outline *outline, const D3DXVECTOR2 *p1, const D3DXVECTOR2 *p2, const D3DXVECTOR2 *p3, float max_deviation)
 
static BOOL is_direction_similar (D3DXVECTOR2 *dir1, D3DXVECTOR2 *dir2, float cos_theta)
 
static D3DXVECTOR2 * unit_vec2 (D3DXVECTOR2 *dir, const D3DXVECTOR2 *pt1, const D3DXVECTOR2 *pt2)
 
static BOOL attempt_line_merge (struct outline *outline, int pt_index, const D3DXVECTOR2 *nextpt, BOOL to_curve)
 
static HRESULT create_outline (struct glyphinfo *glyph, void *raw_outline, int datasize, float max_deviation, float emsquare)
 
static void free_outline (struct outline *outline)
 
static void free_glyphinfo (struct glyphinfo *glyph)
 
static void compute_text_mesh (struct mesh *mesh, const char *text, float deviation, float extrusion, float otmEMSquare, const struct glyphinfo *glyphs)
 
static void compare_text_outline_mesh (const char *name, ID3DXMesh *d3dxmesh, struct mesh *mesh, size_t textlen, float extrusion, const struct glyphinfo *glyphs)
 
static void test_createtext (IDirect3DDevice9 *device, HDC hdc, const char *text, float deviation, float extrusion)
 
static void D3DXCreateTextTest (void)
 
static void test_get_decl_length (void)
 
static void test_get_decl_vertex_size (void)
 
static void D3DXGenerateAdjacencyTest (void)
 
static void test_update_semantics (void)
 
static void test_create_skin_info (void)
 
static void test_convert_adjacency_to_point_reps (void)
 
static void test_convert_point_reps_to_adjacency (void)
 
static HRESULT init_test_mesh (const DWORD num_faces, const DWORD num_vertices, const DWORD options, const D3DVERTEXELEMENT9 *declaration, IDirect3DDevice9 *device, ID3DXMesh **mesh_ptr, const void *vertices, const DWORD vertex_size, const DWORD *indices, const DWORD *attributes)
 
static DWORD init_udec3_dword (UINT x, UINT y, UINT z, UINT w)
 
static DWORD init_dec3n_dword (INT x, INT y, INT z, INT w)
 
static struct udec3 dword_to_udec3 (DWORD d)
 
static struct dec3n dword_to_dec3n (DWORD d)
 
static void check_vertex_components (int line, int mesh_number, int vertex_number, BYTE *got_ptr, const BYTE *exp_ptr, D3DVERTEXELEMENT9 *declaration)
 
static void test_weld_vertices (void)
 
static void test_clone_mesh (void)
 
static void test_valid_mesh (void)
 
static void test_optimize_faces (void)
 
static void test_optimize_vertices (void)
 
static HRESULT clear_normals (ID3DXMesh *mesh)
 
static void compare_normals (unsigned int line, const char *test_name, ID3DXMesh *mesh, const D3DXVECTOR3 *normals, unsigned int num_normals)
 
static HRESULT compute_normals_D3DXComputeNormals (ID3DXMesh *mesh, const DWORD *adjacency)
 
static HRESULT compute_normals_D3DXComputeTangentFrameEx (ID3DXMesh *mesh, const DWORD *adjacency)
 
static void test_compute_normals (void)
 
static void D3DXCreateAnimationControllerTest (void)
 
static void D3DXCreateKeyframedAnimationSetTest (void)
 
static void test_D3DXFrameFind (void)
 
static ID3DXFileData * get_mesh_data (const void *memory, SIZE_T length)
 
static void test_load_skin_mesh_from_xof (void)
 
static void test_mesh_optimize (void)
 
 START_TEST (mesh)
 

Variables

static ID3DXAllocateHierarchyVtbl ID3DXAllocateHierarchyImpl_Vtbl
 
static ID3DXAllocateHierarchy alloc_hier = { &ID3DXAllocateHierarchyImpl_Vtbl }
 
static const struct ID3DXLoadUserDataVtbl load_user_data_vtbl
 

Macro Definition Documentation

◆ admitted_error

#define admitted_error   0.0001f

Definition at line 37 of file mesh.c.

◆ check_floats

#define check_floats (   got,
  exp,
  dim 
)    check_floats_(__LINE__, "", got, exp, dim)

Definition at line 65 of file mesh.c.

◆ check_generated_adjacency

#define check_generated_adjacency (   mesh,
  got,
  epsilon 
)    check_generated_adjacency_(__LINE__, mesh, got, epsilon)

Definition at line 1703 of file mesh.c.

◆ check_generated_effects

#define check_generated_effects (   materials,
  num_materials,
  effects 
)     check_generated_effects_(__LINE__, materials, num_materials, effects)

Definition at line 1733 of file mesh.c.

◆ check_index_buffer

#define check_index_buffer (   mesh,
  indices,
  num_indices,
  index_size 
)     check_index_buffer_(__LINE__, mesh, indices, num_indices, index_size)

Definition at line 1620 of file mesh.c.

◆ check_materials

#define check_materials (   got,
  got_count,
  expected,
  expected_count 
)     check_materials_(__LINE__, got, got_count, expected, expected_count)

Definition at line 1676 of file mesh.c.

◆ check_matrix

#define check_matrix (   got,
  expected 
)    check_matrix_(__LINE__, got, expected)

Definition at line 1656 of file mesh.c.

◆ check_vertex_buffer

#define check_vertex_buffer (   mesh,
  vertices,
  num_vertices,
  fvf 
)     check_vertex_buffer_(__LINE__, mesh, vertices, num_vertices, fvf)

Definition at line 1518 of file mesh.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file mesh.c.

◆ compare_float

#define compare_float (   got,
  exp 
)
Value:
do { \
float _got = (got); \
float _exp = (exp); \
ok(_got == _exp, "Expected: %g, Got: %g\n", _exp, _got); \
} while (0)
DWORD exp
Definition: msg.c:18625

Definition at line 43 of file mesh.c.

◆ compare_vertex_sizes

#define compare_vertex_sizes (   type,
  exp 
)
Value:
ok(got==exp, "Expected: %d, Got: %d\n", exp, got);
UINT WINAPI D3DXGetFVFVertexSize(DWORD FVF)
Definition: mesh.c:2287
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Definition at line 39 of file mesh.c.

◆ EFFECT_TABLE_ENTRY

#define EFFECT_TABLE_ENTRY (   str,
  field 
)     {str, sizeof(str), sizeof(materials->MatD3D.field), offsetof(D3DXMATERIAL, MatD3D.field)}

◆ MAX_USER_DATA_COUNT

#define MAX_USER_DATA_COUNT   32

Definition at line 2034 of file mesh.c.

◆ test_LoadMeshFromX

#define test_LoadMeshFromX (   device,
  xfile_str,
  vertex_array,
  fvf,
  index_array,
  materials_array,
  check_adjacency 
)
Value:
test_LoadMeshFromX_(__LINE__, device, xfile_str, sizeof(xfile_str) - 1, vertex_array, ARRAY_SIZE(vertex_array), fvf, \
index_array, ARRAY_SIZE(index_array), sizeof(*index_array), materials_array, ARRAY_SIZE(materials_array), \
check_adjacency);
#define ARRAY_SIZE(A)
Definition: main.h:20
static void test_LoadMeshFromX_(int line, IDirect3DDevice9 *device, const char *xfile_str, size_t xfile_strlen, const void *vertices, DWORD num_vertices, DWORD fvf, const void *indices, DWORD num_indices, size_t index_size, const D3DXMATERIAL *expected_materials, DWORD expected_num_materials, BOOL check_adjacency)
Definition: mesh.c:1997
Definition: devices.h:37

Definition at line 1993 of file mesh.c.

◆ TRACECALLBACK

#define TRACECALLBACK   if(winetest_debug > 1) trace

Definition at line 35 of file mesh.c.

Typedef Documentation

◆ face

typedef WORD face[3]

Definition at line 94 of file mesh.c.

Enumeration Type Documentation

◆ pointtype

Enumerator
POINTTYPE_CURVE 
POINTTYPE_CORNER 
POINTTYPE_CURVE_START 
POINTTYPE_CURVE_END 
POINTTYPE_CURVE_MIDDLE 
POINTTYPE_CURVE 
POINTTYPE_CORNER 
POINTTYPE_CURVE_START 
POINTTYPE_CURVE_END 
POINTTYPE_CURVE_MIDDLE 

Definition at line 3694 of file mesh.c.

3694 {
3695 POINTTYPE_CURVE = 0,
3700};
@ POINTTYPE_CURVE_MIDDLE
Definition: mesh.c:5420
@ POINTTYPE_CORNER
Definition: mesh.c:5417
@ POINTTYPE_CURVE_END
Definition: mesh.c:5419
@ POINTTYPE_CURVE_START
Definition: mesh.c:5418
@ POINTTYPE_CURVE
Definition: mesh.c:5416

◆ user_data_type

Enumerator
USER_DATA_TYPE_TOP 
USER_DATA_TYPE_FRAME_CHILD 
USER_DATA_TYPE_MESH_CHILD 

Definition at line 2035 of file mesh.c.

2036{
2040};
@ USER_DATA_TYPE_TOP
Definition: mesh.c:2037
@ USER_DATA_TYPE_MESH_CHILD
Definition: mesh.c:2039
@ USER_DATA_TYPE_FRAME_CHILD
Definition: mesh.c:2038

Function Documentation

◆ add_bezier_points()

static HRESULT add_bezier_points ( struct outline *  outline,
const D3DXVECTOR2 *  p1,
const D3DXVECTOR2 *  p2,
const D3DXVECTOR2 *  p3,
float  max_deviation 
)
static

Definition at line 3784 of file mesh.c.

3787{
3788 D3DXVECTOR2 split1 = {0, 0}, split2 = {0, 0}, middle, vec;
3789 float deviation;
3790
3791 D3DXVec2Scale(&split1, D3DXVec2Add(&split1, p1, p2), 0.5f);
3792 D3DXVec2Scale(&split2, D3DXVec2Add(&split2, p2, p3), 0.5f);
3793 D3DXVec2Scale(&middle, D3DXVec2Add(&middle, &split1, &split2), 0.5f);
3794
3795 deviation = D3DXVec2Length(D3DXVec2Subtract(&vec, &middle, p2));
3796 if (deviation < max_deviation) {
3797 struct point2d *pt = add_point(outline);
3798 if (!pt) return E_OUTOFMEMORY;
3799 pt->pos = *p2;
3800 pt->corner = POINTTYPE_CURVE;
3801 /* the end point is omitted because the end line merges into the next segment of
3802 * the split bezier curve, and the end of the split bezier curve is added outside
3803 * this recursive function. */
3804 } else {
3805 HRESULT hr = add_bezier_points(outline, p1, &split1, &middle, max_deviation);
3806 if (hr != S_OK) return hr;
3807 hr = add_bezier_points(outline, &middle, &split2, p3, max_deviation);
3808 if (hr != S_OK) return hr;
3809 }
3810
3811 return S_OK;
3812}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT hr
Definition: delayimp.cpp:582
static HRESULT add_bezier_points(struct outline *outline, const D3DXVECTOR2 *p1, const D3DXVECTOR2 *p2, const D3DXVECTOR2 *p3, float max_deviation_sq)
Definition: mesh.c:5579
#define pt(x, y)
Definition: drawing.c:79
FT_Vector * vec
Definition: ftbbox.c:469
#define S_OK
Definition: intsafe.h:52
static struct point2d * add_point(struct outline *array)
Definition: mesh.c:3748
Definition: mesh.c:5437
Definition: mesh.c:5424

◆ add_outline()

static struct outline * add_outline ( struct outline_array *  array)
static

Definition at line 3760 of file mesh.c.

3761{
3762 struct outline *item;
3763
3764 if (!reserve((struct dynamic_array *)array, array->count + 1, sizeof(array->items[0])))
3765 return NULL;
3766
3767 item = &array->items[array->count++];
3768 ZeroMemory(item, sizeof(*item));
3769 return item;
3770}
#define NULL
Definition: types.h:112
static BOOL reserve(struct dynamic_array *array, int count, int itemsize)
Definition: mesh.c:5499
#define ZeroMemory
Definition: minwinbase.h:31
Definition: undname.c:54

◆ add_point()

static struct point2d * add_point ( struct outline *  array)
static

Definition at line 3748 of file mesh.c.

3749{
3750 struct point2d *item;
3751
3752 if (!reserve((struct dynamic_array *)array, array->count + 1, sizeof(array->items[0])))
3753 return NULL;
3754
3755 item = &array->items[array->count++];
3756 ZeroMemory(item, sizeof(*item));
3757 return item;
3758}

Referenced by add_bezier_points(), and create_outline().

◆ attempt_line_merge()

static BOOL attempt_line_merge ( struct outline *  outline,
int  pt_index,
const D3DXVECTOR2 *  nextpt,
BOOL  to_curve 
)
static

Definition at line 3825 of file mesh.c.

3829{
3830 D3DXVECTOR2 curdir, lastdir;
3831 struct point2d *prevpt, *pt;
3832 BOOL ret = FALSE;
3833 const float cos_half = cos(D3DXToRadian(0.5f));
3834
3835 pt = &outline->items[pt_index];
3836 pt_index = (pt_index - 1 + outline->count) % outline->count;
3837 prevpt = &outline->items[pt_index];
3838
3839 if (to_curve)
3841
3842 if (outline->count < 2)
3843 return FALSE;
3844
3845 /* remove last point if the next line continues the last line */
3846 unit_vec2(&lastdir, &prevpt->pos, &pt->pos);
3847 unit_vec2(&curdir, &pt->pos, nextpt);
3848 if (is_direction_similar(&lastdir, &curdir, cos_half))
3849 {
3850 outline->count--;
3851 if (pt->corner == POINTTYPE_CURVE_END)
3852 prevpt->corner = pt->corner;
3853 if (prevpt->corner == POINTTYPE_CURVE_END && to_curve)
3855 pt = prevpt;
3856
3857 ret = TRUE;
3858 if (outline->count < 2)
3859 return ret;
3860
3861 pt_index = (pt_index - 1 + outline->count) % outline->count;
3862 prevpt = &outline->items[pt_index];
3863 unit_vec2(&lastdir, &prevpt->pos, &pt->pos);
3864 unit_vec2(&curdir, &pt->pos, nextpt);
3865 }
3866 return ret;
3867}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static BOOL is_direction_similar(D3DXVECTOR2 *dir1, D3DXVECTOR2 *dir2, float cos_theta)
Definition: mesh.c:5609
static D3DXVECTOR2 * unit_vec2(D3DXVECTOR2 *dir, const D3DXVECTOR2 *pt1, const D3DXVECTOR2 *pt2)
Definition: mesh.c:5615
_ACRTIMP double __cdecl cos(double)
Definition: cos.c:21
return ret
Definition: mutex.c:147
#define D3DXToRadian(degree)
Definition: d3dx9math.h:33
unsigned int BOOL
Definition: ntddk_ex.h:94
if(dx< 0)
Definition: linetemp.h:194
struct point2d * items
Definition: mesh.c:5439
int count
Definition: mesh.c:5438
D3DXVECTOR2 pos
Definition: mesh.c:5425
enum pointtype corner
Definition: mesh.c:5426

◆ check_colorvalue_()

static void check_colorvalue_ ( int  line,
const char *  prefix,
const D3DCOLORVALUE  got,
const D3DCOLORVALUE  expected 
)
static

Definition at line 1669 of file mesh.c.

1670{
1671 ok_(__FILE__,line)(expected.r == got.r && expected.g == got.g && expected.b == got.b && expected.a == got.a,
1672 "%sExpected (%g, %g, %g, %g), got (%g, %g, %g, %g)\n", prefix,
1673 expected.r, expected.g, expected.b, expected.a, got.r, got.g, got.b, got.a);
1674}
#define ok_(x1, x2)
Definition: atltest.h:61
BOOL expected
Definition: store.c:2000
Definition: parser.c:49
Character const *const prefix
Definition: tempnam.cpp:195

Referenced by check_materials_().

◆ check_floats_()

static void check_floats_ ( int  line,
const char *  prefix,
const float *  got,
const float *  exp,
int  dim 
)
static

Definition at line 66 of file mesh.c.

67{
68 int i;
69 char exp_buffer[256] = "";
70 char got_buffer[256] = "";
71 char *exp_buffer_ptr = exp_buffer;
72 char *got_buffer_ptr = got_buffer;
73 BOOL equal = TRUE;
74
75 for (i = 0; i < dim; i++) {
76 if (i) {
77 exp_buffer_ptr += sprintf(exp_buffer_ptr, ", ");
78 got_buffer_ptr += sprintf(got_buffer_ptr, ", ");
79 }
80 equal = equal && compare(*exp, *got);
81 exp_buffer_ptr += sprintf(exp_buffer_ptr, "%g", *exp);
82 got_buffer_ptr += sprintf(got_buffer_ptr, "%g", *got);
83 exp++; got++;
84 }
85 ok_(__FILE__,line)(equal, "%sExpected (%s), got (%s)", prefix, exp_buffer, got_buffer);
86}
#define compare
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define sprintf
Definition: sprintf.c:45
#define equal(x, y)
Definition: reader.cc:56

Referenced by check_vertex_buffer_().

◆ check_generated_adjacency_()

static void check_generated_adjacency_ ( int  line,
ID3DXMesh *  mesh,
const DWORD *  got,
FLOAT  epsilon 
)
static

Definition at line 1704 of file mesh.c.

1705{
1706 DWORD *expected;
1707 DWORD num_faces = mesh->lpVtbl->GetNumFaces(mesh);
1708 HRESULT hr;
1709
1710 expected = malloc(num_faces * sizeof(DWORD) * 3);
1711 if (!expected) {
1712 skip_(__FILE__, line)("Out of memory\n");
1713 return;
1714 }
1715 hr = mesh->lpVtbl->GenerateAdjacency(mesh, epsilon, expected);
1716 ok_(__FILE__, line)(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
1717 if (SUCCEEDED(hr))
1718 {
1719 int i;
1720 for (i = 0; i < num_faces; i++)
1721 {
1722 ok_(__FILE__, line)(expected[i * 3] == got[i * 3] &&
1723 expected[i * 3 + 1] == got[i * 3 + 1] &&
1724 expected[i * 3 + 2] == got[i * 3 + 2],
1725 "Face %u adjacencies: Expected (%lu, %lu, %lu), got (%lu, %lu, %lu)\n", i,
1726 expected[i * 3], expected[i * 3 + 1], expected[i * 3 + 2],
1727 got[i * 3], got[i * 3 + 1], got[i * 3 + 2]);
1728 }
1729 }
1730 free(expected);
1731}
#define D3D_OK
Definition: d3d.h:106
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define skip_(test, file, line,...)
Definition: kmt_test.h:231
Definition: mesh.c:189

Referenced by test_LoadMeshFromX_().

◆ check_generated_effects_()

static void check_generated_effects_ ( int  line,
const D3DXMATERIAL *  materials,
DWORD  num_materials,
const D3DXEFFECTINSTANCE *  effects 
)
static

Definition at line 1735 of file mesh.c.

1736{
1737 int i;
1738 static const struct {
1739 const char *name;
1740 DWORD name_size;
1741 DWORD num_bytes;
1742 DWORD value_offset;
1743 } params[] = {
1744#define EFFECT_TABLE_ENTRY(str, field) \
1745 {str, sizeof(str), sizeof(materials->MatD3D.field), offsetof(D3DXMATERIAL, MatD3D.field)}
1746 EFFECT_TABLE_ENTRY("Diffuse", Diffuse),
1747 EFFECT_TABLE_ENTRY("Power", Power),
1748 EFFECT_TABLE_ENTRY("Specular", Specular),
1749 EFFECT_TABLE_ENTRY("Emissive", Emissive),
1750 EFFECT_TABLE_ENTRY("Ambient", Ambient),
1751#undef EFFECT_TABLE_ENTRY
1752 };
1753
1754 if (!num_materials) {
1755 ok_(__FILE__, line)(effects == NULL, "Expected NULL effects, got %p\n", effects);
1756 return;
1757 }
1758 for (i = 0; i < num_materials; i++)
1759 {
1760 int j;
1761 DWORD expected_num_defaults = ARRAY_SIZE(params) + (materials[i].pTextureFilename ? 1 : 0);
1762
1763 ok_(__FILE__,line)(expected_num_defaults == effects[i].NumDefaults,
1764 "effect[%u] NumDefaults: Expected %lu, got %lu\n", i,
1765 expected_num_defaults, effects[i].NumDefaults);
1766 for (j = 0; j < min(ARRAY_SIZE(params), effects[i].NumDefaults); j++)
1767 {
1768 int k;
1769 D3DXEFFECTDEFAULT *got_param = &effects[i].pDefaults[j];
1770 ok_(__FILE__,line)(!strcmp(params[j].name, got_param->pParamName),
1771 "effect[%u].pDefaults[%u].pParamName: Expected '%s', got '%s'\n", i, j,
1772 params[j].name, got_param->pParamName);
1773 ok_(__FILE__,line)(D3DXEDT_FLOATS == got_param->Type,
1774 "effect[%u].pDefaults[%u].Type: Expected %u, got %u\n", i, j,
1775 D3DXEDT_FLOATS, got_param->Type);
1776 ok_(__FILE__,line)(params[j].num_bytes == got_param->NumBytes,
1777 "effect[%u].pDefaults[%u].NumBytes: Expected %lu, got %lu\n", i, j,
1778 params[j].num_bytes, got_param->NumBytes);
1779 for (k = 0; k < min(params[j].num_bytes, got_param->NumBytes) / 4; k++)
1780 {
1781 FLOAT expected = ((FLOAT*)((BYTE*)&materials[i] + params[j].value_offset))[k];
1782 FLOAT got = ((FLOAT*)got_param->pValue)[k];
1783 ok_(__FILE__,line)(compare(expected, got),
1784 "effect[%u].pDefaults[%u] float value %u: Expected %g, got %g\n", i, j, k, expected, got);
1785 }
1786 }
1787 if (effects[i].NumDefaults > ARRAY_SIZE(params)) {
1788 D3DXEFFECTDEFAULT *got_param = &effects[i].pDefaults[j];
1789 static const char *expected_name = "Texture0@Name";
1790
1791 ok_(__FILE__,line)(!strcmp(expected_name, got_param->pParamName),
1792 "effect[%u].pDefaults[%u].pParamName: Expected '%s', got '%s'\n", i, j,
1793 expected_name, got_param->pParamName);
1794 ok_(__FILE__,line)(D3DXEDT_STRING == got_param->Type,
1795 "effect[%u].pDefaults[%u].Type: Expected %u, got %u\n", i, j,
1796 D3DXEDT_STRING, got_param->Type);
1797 if (materials[i].pTextureFilename) {
1798 ok_(__FILE__,line)(strlen(materials[i].pTextureFilename) + 1 == got_param->NumBytes,
1799 "effect[%u] texture filename length: Expected %lu, got %lu\n", i,
1800 (DWORD)strlen(materials[i].pTextureFilename) + 1, got_param->NumBytes);
1801 ok_(__FILE__,line)(!strcmp(materials[i].pTextureFilename, got_param->pValue),
1802 "effect[%u] texture filename: Expected '%s', got '%s'\n", i,
1803 materials[i].pTextureFilename, (char*)got_param->pValue);
1804 }
1805 }
1806 }
1807}
#define EFFECT_TABLE_ENTRY(str, field)
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
@ D3DXEDT_FLOATS
Definition: d3dx9mesh.h:142
@ D3DXEDT_STRING
Definition: d3dx9mesh.h:141
GLenum const GLfloat * params
Definition: glext.h:5645
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define min(a, b)
Definition: monoChain.cc:55
int k
Definition: mpi.c:3369
#define DWORD
Definition: nt_native.h:44
D3DXEFFECTDEFAULTTYPE Type
Definition: d3dx9mesh.h:202
LPD3DXEFFECTDEFAULT pDefaults
Definition: d3dx9mesh.h:211
Definition: name.c:39
float FLOAT
Definition: typedefs.h:69
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_LoadMeshFromX_().

◆ check_index_buffer_()

static void check_index_buffer_ ( int  line,
ID3DXMesh *  mesh,
const void *  indices,
DWORD  num_indices,
DWORD  index_size 
)
static

Definition at line 1622 of file mesh.c.

1623{
1624 DWORD mesh_index_size = (mesh->lpVtbl->GetOptions(mesh) & D3DXMESH_32BIT) ? 4 : 2;
1625 DWORD mesh_num_indices = mesh->lpVtbl->GetNumFaces(mesh) * 3;
1626 const void *mesh_indices;
1627 HRESULT hr;
1628 DWORD i;
1629
1630 ok_(__FILE__,line)(index_size == mesh_index_size,
1631 "Expected index size %lu, got %lu\n", index_size, mesh_index_size);
1632 ok_(__FILE__,line)(num_indices == mesh_num_indices,
1633 "Expected %lu indices, got %lu\n", num_indices, mesh_num_indices);
1634
1635 hr = mesh->lpVtbl->LockIndexBuffer(mesh, D3DLOCK_READONLY, (void**)&mesh_indices);
1636 ok_(__FILE__,line)(hr == D3D_OK, "LockIndexBuffer returned %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
1637 if (FAILED(hr))
1638 return;
1639
1640 if (mesh_index_size == index_size) {
1641 for (i = 0; i < min(num_indices, mesh_num_indices); i++)
1642 {
1643 if (index_size == 4)
1644 ok_(__FILE__,line)(*(DWORD*)indices == *(DWORD*)mesh_indices,
1645 "Index[%lu]: expected %lu, got %lu\n", i, *(DWORD*)indices, *(DWORD*)mesh_indices);
1646 else
1647 ok_(__FILE__,line)(*(WORD*)indices == *(WORD*)mesh_indices,
1648 "Index[%lu]: expected %u, got %u\n", i, *(WORD*)indices, *(WORD*)mesh_indices);
1649 indices = (BYTE*)indices + index_size;
1650 mesh_indices = (BYTE*)mesh_indices + index_size;
1651 }
1652 }
1653 mesh->lpVtbl->UnlockIndexBuffer(mesh);
1654}
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
@ D3DXMESH_32BIT
Definition: d3dx9mesh.h:46
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by test_LoadMeshFromX_().

◆ check_materials_()

static void check_materials_ ( int  line,
const D3DXMATERIAL *  got,
DWORD  got_count,
const D3DXMATERIAL *  expected,
DWORD  expected_count 
)
static

Definition at line 1678 of file mesh.c.

1679{
1680 int i;
1681 ok_(__FILE__,line)(expected_count == got_count, "Expected %lu materials, got %lu\n", expected_count, got_count);
1682 if (!expected) {
1683 ok_(__FILE__,line)(got == NULL, "Expected NULL material ptr, got %p\n", got);
1684 return;
1685 }
1686 for (i = 0; i < min(expected_count, got_count); i++)
1687 {
1688 if (!expected[i].pTextureFilename)
1689 ok_(__FILE__,line)(got[i].pTextureFilename == NULL,
1690 "Expected NULL pTextureFilename, got %p\n", got[i].pTextureFilename);
1691 else
1692 ok_(__FILE__,line)(!strcmp(expected[i].pTextureFilename, got[i].pTextureFilename),
1693 "Expected '%s' for pTextureFilename, got '%s'\n", expected[i].pTextureFilename, got[i].pTextureFilename);
1694 check_colorvalue_(line, "Diffuse: ", got[i].MatD3D.Diffuse, expected[i].MatD3D.Diffuse);
1695 check_colorvalue_(line, "Ambient: ", got[i].MatD3D.Ambient, expected[i].MatD3D.Ambient);
1696 check_colorvalue_(line, "Specular: ", got[i].MatD3D.Specular, expected[i].MatD3D.Specular);
1697 check_colorvalue_(line, "Emissive: ", got[i].MatD3D.Emissive, expected[i].MatD3D.Emissive);
1698 ok_(__FILE__,line)(expected[i].MatD3D.Power == got[i].MatD3D.Power,
1699 "Power: Expected %g, got %g\n", expected[i].MatD3D.Power, got[i].MatD3D.Power);
1700 }
1701}
static int expected_count(int *sink)
static void check_colorvalue_(int line, const char *prefix, const D3DCOLORVALUE got, const D3DCOLORVALUE expected)
Definition: mesh.c:1669
D3DMATERIAL8 MatD3D
Definition: dx8vb.idl:77

Referenced by test_LoadMeshFromX_().

◆ check_matrix_()

static void check_matrix_ ( int  line,
const D3DXMATRIX *  got,
const D3DXMATRIX *  expected 
)
static

Definition at line 1657 of file mesh.c.

1658{
1659 int i, j;
1660 for (i = 0; i < 4; i++) {
1661 for (j = 0; j < 4; j++) {
1662 ok_(__FILE__,line)(compare(expected->m[i][j], got->m[i][j]),
1663 "matrix[%u][%u]: expected %g, got %g\n",
1664 i, j, expected->m[i][j], got->m[i][j]);
1665 }
1666 }
1667}
float m[4][4]
Definition: d3d8types.h:1116

◆ check_user_data()

static void check_user_data ( struct test_load_user_data *  user_data,
unsigned int  expected_count,
const struct test_user_data *  expected 
)
static

Definition at line 2134 of file mesh.c.

2136{
2137 unsigned int i;
2138
2139 ok(user_data->data_count == expected_count, "got %u, expected %u.\n", user_data->data_count, expected_count);
2140 for (i = 0; i < expected_count; ++i)
2141 {
2142 winetest_push_context("i %u", i);
2143 ok(user_data->data[i].data_type == expected[i].data_type, "got %u, expected %u.\n",
2144 user_data->data[i].data_type, expected[i].data_type);
2145 ok(IsEqualGUID(&user_data->guids[i], expected[i].type), "got %s, expected %s.\n",
2147 ok(user_data->data[i].size == expected[i].size, "got %Iu, expected %Iu.\n",
2148 user_data->data[i].size, expected[i].size);
2149 ok(user_data->data[i].value == expected[i].value, "got %u, expected %u.\n",
2150 user_data->data[i].value, expected[i].value);
2151 ok(user_data->data[i].mesh_container == expected[i].mesh_container, "got %u, expected %u.\n",
2152 user_data->data[i].mesh_container, expected[i].mesh_container);
2153 ok(user_data->data[i].num_materials == expected[i].num_materials, "got %u, expected %u.\n",
2154 user_data->data[i].num_materials, expected[i].num_materials);
2156 }
2157}
#define ok(value,...)
Definition: atltest.h:57
static void * user_data
Definition: metahost.c:106
#define debugstr_guid
Definition: kernel32.h:35
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:539
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147

Referenced by D3DXLoadMeshTest().

◆ check_vertex_buffer_()

static void check_vertex_buffer_ ( int  line,
ID3DXMesh *  mesh,
const void *  vertices,
DWORD  num_vertices,
DWORD  fvf 
)
static

Definition at line 1520 of file mesh.c.

1521{
1522 DWORD mesh_num_vertices = mesh->lpVtbl->GetNumVertices(mesh);
1523 DWORD mesh_fvf = mesh->lpVtbl->GetFVF(mesh);
1524 const void *mesh_vertices;
1525 HRESULT hr;
1526
1527 ok_(__FILE__,line)(fvf == mesh_fvf, "expected FVF %lx, got %lx\n", fvf, mesh_fvf);
1528 ok_(__FILE__,line)(num_vertices == mesh_num_vertices,
1529 "Expected %lu vertices, got %lu\n", num_vertices, mesh_num_vertices);
1530
1531 hr = mesh->lpVtbl->LockVertexBuffer(mesh, D3DLOCK_READONLY, (void**)&mesh_vertices);
1532 ok_(__FILE__,line)(hr == D3D_OK, "LockVertexBuffer returned %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
1533 if (FAILED(hr))
1534 return;
1535
1536 if (mesh_fvf == fvf) {
1537 DWORD vertex_size = D3DXGetFVFVertexSize(fvf), i;
1538
1539 for (i = 0; i < min(num_vertices, mesh_num_vertices); i++)
1540 {
1541 const FLOAT *exp_float = vertices;
1542 const FLOAT *got_float = mesh_vertices;
1543 DWORD texcount;
1544 DWORD pos_dim = 0;
1545 int j;
1546 BOOL last_beta_dword = FALSE;
1547 char prefix[128];
1548
1549 switch (fvf & D3DFVF_POSITION_MASK) {
1550 case D3DFVF_XYZ: pos_dim = 3; break;
1551 case D3DFVF_XYZRHW: pos_dim = 4; break;
1552 case D3DFVF_XYZB1:
1553 case D3DFVF_XYZB2:
1554 case D3DFVF_XYZB3:
1555 case D3DFVF_XYZB4:
1556 case D3DFVF_XYZB5:
1557 pos_dim = (fvf & D3DFVF_POSITION_MASK) - D3DFVF_XYZB1 + 1;
1559 {
1560 pos_dim--;
1561 last_beta_dword = TRUE;
1562 }
1563 break;
1564 case D3DFVF_XYZW: pos_dim = 4; break;
1565 }
1566 sprintf(prefix, "vertex[%lu] position, ", i);
1567 check_floats_(line, prefix, got_float, exp_float, pos_dim);
1568 exp_float += pos_dim;
1569 got_float += pos_dim;
1570
1571 if (last_beta_dword) {
1572 ok_(__FILE__,line)(*(DWORD*)exp_float == *(DWORD*)got_float,
1573 "Vertex[%lu]: Expected last beta %08lx, got %08lx\n", i, *(DWORD*)exp_float, *(DWORD*)got_float);
1574 exp_float++;
1575 got_float++;
1576 }
1577
1578 if (fvf & D3DFVF_NORMAL) {
1579 sprintf(prefix, "vertex[%lu] normal, ", i);
1580 check_floats_(line, prefix, got_float, exp_float, 3);
1581 exp_float += 3;
1582 got_float += 3;
1583 }
1584 if (fvf & D3DFVF_PSIZE) {
1585 ok_(__FILE__,line)(compare(*exp_float, *got_float),
1586 "Vertex[%lu]: Expected psize %g, got %g\n", i, *exp_float, *got_float);
1587 exp_float++;
1588 got_float++;
1589 }
1590 if (fvf & D3DFVF_DIFFUSE) {
1591 ok_(__FILE__,line)(*(DWORD*)exp_float == *(DWORD*)got_float,
1592 "Vertex[%lu]: Expected diffuse %08lx, got %08lx\n", i, *(DWORD*)exp_float, *(DWORD*)got_float);
1593 exp_float++;
1594 got_float++;
1595 }
1596 if (fvf & D3DFVF_SPECULAR) {
1597 ok_(__FILE__,line)(*(DWORD*)exp_float == *(DWORD*)got_float,
1598 "Vertex[%lu]: Expected specular %08lx, got %08lx\n", i, *(DWORD*)exp_float, *(DWORD*)got_float);
1599 exp_float++;
1600 got_float++;
1601 }
1602
1603 texcount = (fvf & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
1604 for (j = 0; j < texcount; j++) {
1605 DWORD dim = (((fvf >> (16 + 2 * j)) + 1) & 0x03) + 1;
1606 sprintf(prefix, "vertex[%lu] texture, ", i);
1607 check_floats_(line, prefix, got_float, exp_float, dim);
1608 exp_float += dim;
1609 got_float += dim;
1610 }
1611
1612 vertices = (BYTE*)vertices + vertex_size;
1613 mesh_vertices = (BYTE*)mesh_vertices + vertex_size;
1614 }
1615 }
1616
1617 mesh->lpVtbl->UnlockVertexBuffer(mesh);
1618}
#define D3DFVF_DIFFUSE
Definition: d3d8types.h:122
#define D3DFVF_XYZ
Definition: d3d8types.h:113
#define D3DFVF_TEXCOUNT_SHIFT
Definition: d3d8types.h:125
#define D3DFVF_XYZB1
Definition: d3d8types.h:115
#define D3DFVF_LASTBETA_UBYTE4
Definition: d3d8types.h:135
#define D3DFVF_XYZB5
Definition: d3d8types.h:119
#define D3DFVF_XYZRHW
Definition: d3d8types.h:114
#define D3DFVF_XYZB4
Definition: d3d8types.h:118
#define D3DFVF_NORMAL
Definition: d3d8types.h:120
#define D3DFVF_XYZB3
Definition: d3d8types.h:117
#define D3DFVF_XYZB2
Definition: d3d8types.h:116
#define D3DFVF_TEXCOUNT_MASK
Definition: d3d8types.h:124
#define D3DFVF_PSIZE
Definition: d3d8types.h:121
#define D3DFVF_SPECULAR
Definition: d3d8types.h:123
#define D3DFVF_POSITION_MASK
Definition: d3d8types.h:112
#define D3DFVF_LASTBETA_D3DCOLOR
Definition: d3d9types.h:169
#define D3DFVF_XYZW
Definition: d3d9types.h:152
static void check_floats_(int line, const char *prefix, const float *got, const float *exp, int dim)
Definition: mesh.c:66

Referenced by test_LoadMeshFromX_().

◆ check_vertex_components()

static void check_vertex_components ( int  line,
int  mesh_number,
int  vertex_number,
BYTE *  got_ptr,
const BYTE *  exp_ptr,
D3DVERTEXELEMENT9 *  declaration 
)
static

Definition at line 6689 of file mesh.c.

6690{
6691 const char *usage_strings[] =
6692 {
6693 "position",
6694 "blend weight",
6695 "blend indices",
6696 "normal",
6697 "point size",
6698 "texture coordinates",
6699 "tangent",
6700 "binormal",
6701 "tessellation factor",
6702 "position transformed",
6703 "color",
6704 "fog",
6705 "depth",
6706 "sample"
6707 };
6708 D3DVERTEXELEMENT9 *decl_ptr;
6709 const float PRECISION = 1e-5f;
6710
6711 for (decl_ptr = declaration; decl_ptr->Stream != 0xFF; decl_ptr++)
6712 {
6713 switch (decl_ptr->Type)
6714 {
6715 case D3DDECLTYPE_FLOAT1:
6716 {
6717 FLOAT *got = (FLOAT*)(got_ptr + decl_ptr->Offset);
6718 FLOAT *exp = (FLOAT*)(exp_ptr + decl_ptr->Offset);
6719 FLOAT diff = fabsf(*got - *exp);
6720 ok_(__FILE__,line)(diff <= PRECISION, "Mesh %d: Got %f for vertex %d %s, expected %f.\n",
6721 mesh_number, *got, vertex_number, usage_strings[decl_ptr->Usage], *exp);
6722 break;
6723 }
6724 case D3DDECLTYPE_FLOAT2:
6725 {
6726 D3DXVECTOR2 *got = (D3DXVECTOR2*)(got_ptr + decl_ptr->Offset);
6727 D3DXVECTOR2 *exp = (D3DXVECTOR2*)(exp_ptr + decl_ptr->Offset);
6728 FLOAT diff = max(fabsf(got->x - exp->x), fabsf(got->y - exp->y));
6729 ok_(__FILE__,line)(diff <= PRECISION, "Mesh %d: Got (%f, %f) for vertex %d %s, expected (%f, %f).\n",
6730 mesh_number, got->x, got->y, vertex_number, usage_strings[decl_ptr->Usage], exp->x, exp->y);
6731 break;
6732 }
6733 case D3DDECLTYPE_FLOAT3:
6734 {
6735 D3DXVECTOR3 *got = (D3DXVECTOR3*)(got_ptr + decl_ptr->Offset);
6736 D3DXVECTOR3 *exp = (D3DXVECTOR3*)(exp_ptr + decl_ptr->Offset);
6737 FLOAT diff = max(fabsf(got->x - exp->x), fabsf(got->y - exp->y));
6738 diff = max(diff, fabsf(got->z - exp->z));
6739 ok_(__FILE__,line)(diff <= PRECISION, "Mesh %d: Got (%f, %f, %f) for vertex %d %s, expected (%f, %f, %f).\n",
6740 mesh_number, got->x, got->y, got->z, vertex_number, usage_strings[decl_ptr->Usage], exp->x, exp->y, exp->z);
6741 break;
6742 }
6743 case D3DDECLTYPE_FLOAT4:
6744 {
6745 D3DXVECTOR4 *got = (D3DXVECTOR4*)(got_ptr + decl_ptr->Offset);
6746 D3DXVECTOR4 *exp = (D3DXVECTOR4*)(exp_ptr + decl_ptr->Offset);
6747 FLOAT diff = max(fabsf(got->x - exp->x), fabsf(got->y - exp->y));
6748 diff = max(diff, fabsf(got->z - exp->z));
6749 diff = max(diff, fabsf(got->w - exp->w));
6750 ok_(__FILE__,line)(diff <= PRECISION, "Mesh %d: Got (%f, %f, %f, %f) for vertex %d %s, expected (%f, %f, %f, %f).\n",
6751 mesh_number, got->x, got->y, got->z, got->w, vertex_number, usage_strings[decl_ptr->Usage], exp->x, exp->y, exp->z, got->w);
6752 break;
6753 }
6755 {
6756 BYTE *got = got_ptr + decl_ptr->Offset;
6757 const BYTE *exp = exp_ptr + decl_ptr->Offset;
6758 BOOL same_color = got[0] == exp[0] && got[1] == exp[1]
6759 && got[2] == exp[2] && got[3] == exp[3];
6760 const char *color_types[] = {"diffuse", "specular", "undefined color"};
6761 BYTE usage_index = decl_ptr->UsageIndex;
6762 if (usage_index > 1) usage_index = 2;
6763 ok_(__FILE__,line)(same_color, "Mesh %d: Got (%u, %u, %u, %u) for vertex %d %s, expected (%u, %u, %u, %u).\n",
6764 mesh_number, got[0], got[1], got[2], got[3], vertex_number, color_types[usage_index], exp[0], exp[1], exp[2], exp[3]);
6765 break;
6766 }
6767 case D3DDECLTYPE_UBYTE4:
6769 {
6770 BYTE *got = got_ptr + decl_ptr->Offset;
6771 const BYTE *exp = exp_ptr + decl_ptr->Offset;
6772 BOOL same = got[0] == exp[0] && got[1] == exp[1]
6773 && got[2] == exp[2] && got[3] == exp[3];
6774 ok_(__FILE__,line)(same, "Mesh %d: Got (%u, %u, %u, %u) for vertex %d %s, expected (%u, %u, %u, %u).\n",
6775 mesh_number, got[0], got[1], got[2], got[3], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1], exp[2], exp[3]);
6776 break;
6777 }
6778 case D3DDECLTYPE_SHORT2:
6780 {
6781 SHORT *got = (SHORT*)(got_ptr + decl_ptr->Offset);
6782 SHORT *exp = (SHORT*)(exp_ptr + decl_ptr->Offset);
6783 BOOL same = got[0] == exp[0] && got[1] == exp[1];
6784 ok_(__FILE__,line)(same, "Mesh %d: Got (%hd, %hd) for vertex %d %s, expected (%hd, %hd).\n",
6785 mesh_number, got[0], got[1], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1]);
6786 break;
6787 }
6788 case D3DDECLTYPE_SHORT4:
6790 {
6791 SHORT *got = (SHORT*)(got_ptr + decl_ptr->Offset);
6792 SHORT *exp = (SHORT*)(exp_ptr + decl_ptr->Offset);
6793 BOOL same = got[0] == exp[0] && got[1] == exp[1]
6794 && got[2] == exp[2] && got[3] == exp[3];
6795 ok_(__FILE__,line)(same, "Mesh %d: Got (%hd, %hd, %hd, %hd) for vertex %d %s, expected (%hd, %hd, %hd, %hd).\n",
6796 mesh_number, got[0], got[1], got[2], got[3], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1], exp[2], exp[3]);
6797 break;
6798 }
6800 {
6801 USHORT *got = (USHORT*)(got_ptr + decl_ptr->Offset);
6802 USHORT *exp = (USHORT*)(exp_ptr + decl_ptr->Offset);
6803 BOOL same = got[0] == exp[0] && got[1] == exp[1];
6804 ok_(__FILE__,line)(same, "Mesh %d: Got (%hu, %hu) for vertex %d %s, expected (%hu, %hu).\n",
6805 mesh_number, got[0], got[1], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1]);
6806 break;
6807 }
6809 {
6810 USHORT *got = (USHORT*)(got_ptr + decl_ptr->Offset);
6811 USHORT *exp = (USHORT*)(exp_ptr + decl_ptr->Offset);
6812 BOOL same = got[0] == exp[0] && got[1] == exp[1]
6813 && got[2] == exp[2] && got[3] == exp[3];
6814 ok_(__FILE__,line)(same, "Mesh %d: Got (%hu, %hu, %hu, %hu) for vertex %d %s, expected (%hu, %hu, %hu, %hu).\n",
6815 mesh_number, got[0], got[1], got[2], got[3], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1], exp[2], exp[3]);
6816 break;
6817 }
6818 case D3DDECLTYPE_UDEC3:
6819 {
6820 DWORD *got = (DWORD*)(got_ptr + decl_ptr->Offset);
6821 DWORD *exp = (DWORD*)(exp_ptr + decl_ptr->Offset);
6822 BOOL same = memcmp(got, exp, sizeof(*got)) == 0;
6823 struct udec3 got_udec3 = dword_to_udec3(*got);
6824 struct udec3 exp_udec3 = dword_to_udec3(*exp);
6825 ok_(__FILE__,line)(same, "Mesh %d: Got (%u, %u, %u, %u) for vertex %d %s, expected (%u, %u, %u, %u).\n",
6826 mesh_number, got_udec3.x, got_udec3.y, got_udec3.z, got_udec3.w, vertex_number, usage_strings[decl_ptr->Usage], exp_udec3.x, exp_udec3.y, exp_udec3.z, exp_udec3.w);
6827
6828 break;
6829 }
6830 case D3DDECLTYPE_DEC3N:
6831 {
6832 DWORD *got = (DWORD*)(got_ptr + decl_ptr->Offset);
6833 DWORD *exp = (DWORD*)(exp_ptr + decl_ptr->Offset);
6834 BOOL same = memcmp(got, exp, sizeof(*got)) == 0;
6835 struct dec3n got_dec3n = dword_to_dec3n(*got);
6836 struct dec3n exp_dec3n = dword_to_dec3n(*exp);
6837 ok_(__FILE__,line)(same, "Mesh %d: Got (%d, %d, %d, %d) for vertex %d %s, expected (%d, %d, %d, %d).\n",
6838 mesh_number, got_dec3n.x, got_dec3n.y, got_dec3n.z, got_dec3n.w, vertex_number, usage_strings[decl_ptr->Usage], exp_dec3n.x, exp_dec3n.y, exp_dec3n.z, exp_dec3n.w);
6839 break;
6840 }
6842 {
6843 WORD *got = (WORD*)(got_ptr + decl_ptr->Offset);
6844 WORD *exp = (WORD*)(exp_ptr + decl_ptr->Offset);
6845 BOOL same = got[0] == exp[0] && got[1] == exp[1];
6846 ok_(__FILE__,line)(same, "Mesh %d: Got (%hx, %hx) for vertex %d %s, expected (%hx, %hx).\n",
6847 mesh_number, got[0], got[1], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1]);
6848 break;
6849 }
6851 {
6852 WORD *got = (WORD*)(got_ptr + decl_ptr->Offset);
6853 WORD *exp = (WORD*)(exp_ptr + decl_ptr->Offset);
6854 BOOL same = got[0] == exp[0] && got[1] == exp[1]
6855 && got[2] == exp[2] && got[3] == exp[3];
6856 ok_(__FILE__,line)(same, "Mesh %d: Got (%hx, %hx, %hx, %hx) for vertex %d %s, expected (%hx, %hx, %hx, %hx).\n",
6857 mesh_number, got[0], got[1], got[2], got[3], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1], exp[2], exp[3]);
6858 break;
6859 }
6860 default:
6861 break;
6862 }
6863 }
6864}
@ D3DDECLTYPE_UBYTE4
Definition: d3d9types.h:276
@ D3DDECLTYPE_SHORT2
Definition: d3d9types.h:277
@ D3DDECLTYPE_FLOAT3
Definition: d3d9types.h:273
@ D3DDECLTYPE_FLOAT1
Definition: d3d9types.h:271
@ D3DDECLTYPE_SHORT2N
Definition: d3d9types.h:281
@ D3DDECLTYPE_FLOAT16_4
Definition: d3d9types.h:288
@ D3DDECLTYPE_FLOAT16_2
Definition: d3d9types.h:287
@ D3DDECLTYPE_D3DCOLOR
Definition: d3d9types.h:275
@ D3DDECLTYPE_UDEC3
Definition: d3d9types.h:285
@ D3DDECLTYPE_SHORT4
Definition: d3d9types.h:278
@ D3DDECLTYPE_UBYTE4N
Definition: d3d9types.h:280
@ D3DDECLTYPE_USHORT4N
Definition: d3d9types.h:284
@ D3DDECLTYPE_DEC3N
Definition: d3d9types.h:286
@ D3DDECLTYPE_SHORT4N
Definition: d3d9types.h:282
@ D3DDECLTYPE_FLOAT2
Definition: d3d9types.h:272
@ D3DDECLTYPE_FLOAT4
Definition: d3d9types.h:274
@ D3DDECLTYPE_USHORT2N
Definition: d3d9types.h:283
static struct udec3 dword_to_udec3(DWORD d)
Definition: mesh.c:6748
static struct dec3n dword_to_dec3n(DWORD d)
Definition: mesh.c:6793
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
_ACRTIMP float __cdecl fabsf(float)
#define PRECISION
Definition: pchw.c:28
short SHORT
Definition: pedump.c:59
unsigned short USHORT
Definition: pedump.c:61
FLOAT x
Definition: d3dx9math.h:64
FLOAT y
Definition: d3dx9math.h:64
Definition: mesh.c:6786
INT w
Definition: mesh.c:6790
INT y
Definition: mesh.c:6788
INT z
Definition: mesh.c:6789
INT x
Definition: mesh.c:6787
Definition: mesh.c:6741
UINT w
Definition: mesh.c:6745
UINT x
Definition: mesh.c:6742
UINT y
Definition: mesh.c:6743
UINT z
Definition: mesh.c:6744
#define max(a, b)
Definition: svc.c:63

Referenced by test_clone_mesh(), and test_weld_vertices().

◆ clear_normals()

static HRESULT clear_normals ( ID3DXMesh *  mesh)
static

Definition at line 10783 of file mesh.c.

10784{
10785 HRESULT hr;
10786 BYTE *vertices;
10787 size_t normal_size;
10788 DWORD i, num_vertices, vertex_stride;
10789 const D3DXVECTOR4 normal = {NAN, NAN, NAN, NAN};
10790 D3DVERTEXELEMENT9 *normal_declaration = NULL;
10792
10793 if (FAILED(hr = mesh->lpVtbl->GetDeclaration(mesh, declaration)))
10794 return hr;
10795
10796 for (i = 0; declaration[i].Stream != 0xff; i++)
10797 {
10798 if (declaration[i].Usage == D3DDECLUSAGE_NORMAL && !declaration[i].UsageIndex)
10799 {
10800 normal_declaration = &declaration[i];
10801 break;
10802 }
10803 }
10804
10805 if (!normal_declaration)
10806 return D3DERR_INVALIDCALL;
10807
10808 if (normal_declaration->Type == D3DDECLTYPE_FLOAT3)
10809 {
10810 normal_size = sizeof(D3DXVECTOR3);
10811 }
10812 else if (normal_declaration->Type == D3DDECLTYPE_FLOAT4)
10813 {
10814 normal_size = sizeof(D3DXVECTOR4);
10815 }
10816 else
10817 {
10818 trace("Cannot clear normals\n");
10819 return E_NOTIMPL;
10820 }
10821
10822 num_vertices = mesh->lpVtbl->GetNumVertices(mesh);
10823 vertex_stride = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
10824
10825 if (FAILED(hr = mesh->lpVtbl->LockVertexBuffer(mesh, 0, (void **)&vertices)))
10826 return hr;
10827
10828 vertices += normal_declaration->Offset;
10829
10830 for (i = 0; i < num_vertices; i++, vertices += vertex_stride)
10831 memcpy(vertices, &normal, normal_size);
10832
10833 return mesh->lpVtbl->UnlockVertexBuffer(mesh);
10834}
#define trace
Definition: atltest.h:70
#define D3DERR_INVALIDCALL
Definition: d3d10_private.h:42
@ D3DDECLUSAGE_NORMAL
Definition: d3d9types.h:239
#define D3DDECL_END()
Definition: d3d9types.h:329
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NAN
Definition: math.h:273
struct _D3DVECTOR D3DXVECTOR3
Definition: d3dx9math.h:97
@ MAX_FVF_DECL_SIZE
Definition: d3dx9mesh.h:41
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:384
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
@ normal
Definition: optimize.h:166

Referenced by test_compute_normals().

◆ compare()

static BOOL compare ( FLOAT  u,
FLOAT  v 
)
static

Definition at line 50 of file mesh.c.

51{
52 return (fabs(u-v) < admitted_error);
53}
_ACRTIMP double __cdecl fabs(double)
const GLdouble * v
Definition: gl.h:2040
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define admitted_error
Definition: mesh.c:37

◆ compare_elements()

static void compare_elements ( const D3DVERTEXELEMENT9 *  elements,
const D3DVERTEXELEMENT9 *  expected_elements,
unsigned int  line,
unsigned int  test_id 
)
static

Definition at line 601 of file mesh.c.

603{
605 unsigned int i;
606
607 for (i = 0; i < MAX_FVF_DECL_SIZE; i++)
608 {
609 int end1 = memcmp(&elements[i], &last, sizeof(last));
610 int end2 = memcmp(&expected_elements[i], &last, sizeof(last));
611 int status;
612
613 if (!end1 && !end2) break;
614
615 status = !end1 ^ !end2;
616 ok(!status, "Line %u, test %u: Mismatch in size, test declaration is %s than expected.\n",
617 line, test_id, end1 ? "shorter" : "longer");
618 if (status)
619 {
620 print_elements(elements);
621 break;
622 }
623
624 status = memcmp(&elements[i], &expected_elements[i], sizeof(D3DVERTEXELEMENT9));
625 ok(!status, "Line %u, test %u: Mismatch in element %u.\n", line, test_id, i);
626 if (status)
627 {
628 print_elements(elements);
629 break;
630 }
631 }
632}
static void print_elements(const D3DVERTEXELEMENT9 *elements)
Definition: mesh.c:585
static const LARGE_INTEGER *static const HANDLE const LARGE_INTEGER *static PSLIST_ENTRY PSLIST_ENTRY last
Definition: sync.c:64
Definition: ps.c:97

Referenced by test_create_skin_info(), test_fvf_to_decl(), and test_load_skin_mesh_from_xof().

◆ compare_face()

static BOOL compare_face ( face  a,
face  b 
)
static

Definition at line 96 of file mesh.c.

97{
98 return (a[0]==b[0] && a[1] == b[1] && a[2] == b[2]);
99}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by compare_mesh().

◆ compare_mesh()

static void compare_mesh ( const char *  name,
ID3DXMesh *  d3dxmesh,
struct mesh *  mesh 
)
static

Definition at line 226 of file mesh.c.

227{
228 HRESULT hr;
229 DWORD number_of_vertices, number_of_faces;
230 IDirect3DVertexBuffer9 *vertex_buffer;
231 IDirect3DIndexBuffer9 *index_buffer;
232 D3DVERTEXBUFFER_DESC vertex_buffer_description;
233 D3DINDEXBUFFER_DESC index_buffer_description;
234 struct vertex *vertices;
235 face *faces;
236 int expected, i;
237
238 number_of_vertices = d3dxmesh->lpVtbl->GetNumVertices(d3dxmesh);
239 ok(number_of_vertices == mesh->number_of_vertices, "Test %s, result %lu, expected %ld\n",
240 name, number_of_vertices, mesh->number_of_vertices);
241
242 number_of_faces = d3dxmesh->lpVtbl->GetNumFaces(d3dxmesh);
243 ok(number_of_faces == mesh->number_of_faces, "Test %s, result %lu, expected %ld\n",
244 name, number_of_faces, mesh->number_of_faces);
245
246 /* vertex buffer */
247 hr = d3dxmesh->lpVtbl->GetVertexBuffer(d3dxmesh, &vertex_buffer);
248 ok(hr == D3D_OK, "Test %s, result %lx, expected 0 (D3D_OK)\n", name, hr);
249
250 if (hr != D3D_OK)
251 {
252 skip("Couldn't get vertex buffer\n");
253 }
254 else
255 {
256 hr = IDirect3DVertexBuffer9_GetDesc(vertex_buffer, &vertex_buffer_description);
257 ok(hr == D3D_OK, "Test %s, result %lx, expected 0 (D3D_OK)\n", name, hr);
258
259 if (hr != D3D_OK)
260 {
261 skip("Couldn't get vertex buffer description\n");
262 }
263 else
264 {
265 ok(vertex_buffer_description.Format == D3DFMT_VERTEXDATA, "Test %s, result %x, expected %x (D3DFMT_VERTEXDATA)\n",
266 name, vertex_buffer_description.Format, D3DFMT_VERTEXDATA);
267 ok(vertex_buffer_description.Type == D3DRTYPE_VERTEXBUFFER, "Test %s, result %x, expected %x (D3DRTYPE_VERTEXBUFFER)\n",
268 name, vertex_buffer_description.Type, D3DRTYPE_VERTEXBUFFER);
269 ok(vertex_buffer_description.Usage == 0, "Test %s, result %lx, expected %x\n", name, vertex_buffer_description.Usage, 0);
270 ok(vertex_buffer_description.Pool == D3DPOOL_MANAGED, "Test %s, result %x, expected %x (D3DPOOL_MANAGED)\n",
271 name, vertex_buffer_description.Pool, D3DPOOL_MANAGED);
272 ok(vertex_buffer_description.FVF == mesh->fvf, "Test %s, result %lx, expected %lx\n",
273 name, vertex_buffer_description.FVF, mesh->fvf);
274 if (mesh->fvf == 0)
275 {
276 expected = number_of_vertices * mesh->vertex_size;
277 }
278 else
279 {
280 expected = number_of_vertices * D3DXGetFVFVertexSize(mesh->fvf);
281 }
282 ok(vertex_buffer_description.Size == expected, "Test %s, result %x, expected %x\n",
283 name, vertex_buffer_description.Size, expected);
284 }
285
286 /* specify offset and size to avoid potential overruns */
287 hr = IDirect3DVertexBuffer9_Lock(vertex_buffer, 0, number_of_vertices * sizeof(D3DXVECTOR3) * 2,
288 (void **)&vertices, D3DLOCK_DISCARD);
289 ok(hr == D3D_OK, "Test %s, result %lx, expected 0 (D3D_OK)\n", name, hr);
290
291 if (hr != D3D_OK)
292 {
293 skip("Couldn't lock vertex buffer\n");
294 }
295 else
296 {
297 for (i = 0; i < number_of_vertices; i++)
298 {
299 ok(compare_vec3(vertices[i].position, mesh->vertices[i].position),
300 "Test %s, vertex position %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i,
301 vertices[i].position.x, vertices[i].position.y, vertices[i].position.z,
302 mesh->vertices[i].position.x, mesh->vertices[i].position.y, mesh->vertices[i].position.z);
303 ok(compare_vec3(vertices[i].normal, mesh->vertices[i].normal),
304 "Test %s, vertex normal %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i,
305 vertices[i].normal.x, vertices[i].normal.y, vertices[i].normal.z,
306 mesh->vertices[i].normal.x, mesh->vertices[i].normal.y, mesh->vertices[i].normal.z);
307 }
308
310 }
311
313 }
314
315 /* index buffer */
316 hr = d3dxmesh->lpVtbl->GetIndexBuffer(d3dxmesh, &index_buffer);
317 ok(hr == D3D_OK, "Test %s, result %lx, expected 0 (D3D_OK)\n", name, hr);
318
319 if (!index_buffer)
320 {
321 skip("Couldn't get index buffer\n");
322 }
323 else
324 {
325 hr = IDirect3DIndexBuffer9_GetDesc(index_buffer, &index_buffer_description);
326 ok(hr == D3D_OK, "Test %s, result %lx, expected 0 (D3D_OK)\n", name, hr);
327
328 if (hr != D3D_OK)
329 {
330 skip("Couldn't get index buffer description\n");
331 }
332 else
333 {
334 ok(index_buffer_description.Format == D3DFMT_INDEX16, "Test %s, result %x, expected %x (D3DFMT_INDEX16)\n",
335 name, index_buffer_description.Format, D3DFMT_INDEX16);
336 ok(index_buffer_description.Type == D3DRTYPE_INDEXBUFFER, "Test %s, result %x, expected %x (D3DRTYPE_INDEXBUFFER)\n",
337 name, index_buffer_description.Type, D3DRTYPE_INDEXBUFFER);
338 ok(index_buffer_description.Usage == 0, "Test %s, result %#lx, expected %#x.\n",
339 name, index_buffer_description.Usage, 0);
340 ok(index_buffer_description.Pool == D3DPOOL_MANAGED, "Test %s, result %x, expected %x (D3DPOOL_MANAGED)\n",
341 name, index_buffer_description.Pool, D3DPOOL_MANAGED);
342 expected = number_of_faces * sizeof(WORD) * 3;
343 ok(index_buffer_description.Size == expected, "Test %s, result %x, expected %x\n",
344 name, index_buffer_description.Size, expected);
345 }
346
347 /* specify offset and size to avoid potential overruns */
348 hr = IDirect3DIndexBuffer9_Lock(index_buffer, 0, number_of_faces * sizeof(WORD) * 3,
349 (void **)&faces, D3DLOCK_DISCARD);
350 ok(hr == D3D_OK, "Test %s, result %lx, expected 0 (D3D_OK)\n", name, hr);
351
352 if (hr != D3D_OK)
353 {
354 skip("Couldn't lock index buffer\n");
355 }
356 else
357 {
358 for (i = 0; i < number_of_faces; i++)
359 {
360 ok(compare_face(faces[i], mesh->faces[i]),
361 "Test %s, face %d, result (%u, %u, %u), expected (%u, %u, %u)\n", name, i,
362 faces[i][0], faces[i][1], faces[i][2],
363 mesh->faces[i][0], mesh->faces[i][1], mesh->faces[i][2]);
364 }
365
366 IDirect3DIndexBuffer9_Unlock(index_buffer);
367 }
368
369 IDirect3DIndexBuffer9_Release(index_buffer);
370 }
371}
#define skip(...)
Definition: atltest.h:64
#define D3DLOCK_DISCARD
Definition: d3d8types.h:72
@ D3DFMT_VERTEXDATA
Definition: d3d8types.h:648
@ D3DFMT_INDEX16
Definition: d3d8types.h:649
@ D3DRTYPE_INDEXBUFFER
Definition: d3d8types.h:816
@ D3DRTYPE_VERTEXBUFFER
Definition: d3d8types.h:815
@ D3DPOOL_MANAGED
Definition: d3d8types.h:710
#define IDirect3DIndexBuffer9_Unlock(p)
Definition: d3d9.h:604
#define IDirect3DVertexBuffer9_Unlock(p)
Definition: d3d9.h:536
#define IDirect3DVertexBuffer9_Release(p)
Definition: d3d9.h:524
#define IDirect3DVertexBuffer9_Lock(p, a, b, c, d)
Definition: d3d9.h:535
#define IDirect3DVertexBuffer9_GetDesc(p, a)
Definition: d3d9.h:537
#define IDirect3DIndexBuffer9_GetDesc(p, a)
Definition: d3d9.h:605
#define IDirect3DIndexBuffer9_Lock(p, a, b, c, d)
Definition: d3d9.h:603
#define IDirect3DIndexBuffer9_Release(p)
Definition: d3d9.h:592
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
static BOOL compare_face(face a, face b)
Definition: mesh.c:96
static BOOL compare_vec3(D3DXVECTOR3 u, D3DXVECTOR3 v)
Definition: mesh.c:55
D3DRESOURCETYPE Type
Definition: d3d8types.h:1053
D3DRESOURCETYPE Type
Definition: d3d8types.h:1189
DWORD number_of_vertices
Definition: mesh.c:190
struct vertex * vertices
Definition: mesh.c:191
DWORD fvf
Definition: mesh.c:196
DWORD number_of_faces
Definition: mesh.c:193
face * faces
Definition: mesh.c:194
UINT vertex_size
Definition: mesh.c:197
Definition: mesh.c:4665
D3DXVECTOR3 position
Definition: mesh.c:4666

Referenced by D3DXCreateMeshFVFTest(), D3DXCreateMeshTest(), test_box(), test_cylinder(), test_polygon(), test_sphere(), and test_torus().

◆ compare_normals()

static void compare_normals ( unsigned int  line,
const char *  test_name,
ID3DXMesh *  mesh,
const D3DXVECTOR3 *  normals,
unsigned int  num_normals 
)
static

Definition at line 10836 of file mesh.c.

10838{
10839 unsigned int i;
10840 BYTE *vertices;
10841 DWORD num_vertices, vertex_stride;
10842 D3DVERTEXELEMENT9 *normal_declaration = NULL;
10844
10845 if (FAILED(mesh->lpVtbl->GetDeclaration(mesh, declaration)))
10846 {
10847 ok_(__FILE__, line)(0, "%s: Failed to get declaration\n", test_name);
10848 return;
10849 }
10850
10851 for (i = 0; declaration[i].Stream != 0xff; i++)
10852 {
10853 if (declaration[i].Usage == D3DDECLUSAGE_NORMAL && !declaration[i].UsageIndex)
10854 {
10855 normal_declaration = &declaration[i];
10856 break;
10857 }
10858 }
10859
10860 if (!normal_declaration)
10861 {
10862 ok_(__FILE__, line)(0, "%s: Mesh has no normals\n", test_name);
10863 return;
10864 }
10865
10866 if (normal_declaration->Type != D3DDECLTYPE_FLOAT3 && normal_declaration->Type != D3DDECLTYPE_FLOAT4)
10867 {
10868 ok_(__FILE__, line)(0, "%s: Mesh has invalid normals type\n", test_name);
10869 return;
10870 }
10871
10872 num_vertices = mesh->lpVtbl->GetNumVertices(mesh);
10873 vertex_stride = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
10874
10875 ok_(__FILE__, line)(num_vertices == num_normals, "%s: Expected %u vertices, got %lu\n", test_name,
10876 num_normals, num_vertices);
10877
10878 if (FAILED(mesh->lpVtbl->LockVertexBuffer(mesh, 0, (void **)&vertices)))
10879 {
10880 ok_(__FILE__, line)(0, "%s: Failed to compare normals\n", test_name);
10881 return;
10882 }
10883
10884 vertices += normal_declaration->Offset;
10885
10886 for (i = 0; i < min(num_vertices, num_normals); i++, vertices += vertex_stride)
10887 {
10888 if (normal_declaration->Type == D3DDECLTYPE_FLOAT3)
10889 {
10890 const D3DXVECTOR3 *n = (D3DXVECTOR3 *)vertices;
10891 ok_(__FILE__, line)(compare_vec3(*n, normals[i]),
10892 "%s: normal %2u, expected (%f, %f, %f), got (%f, %f, %f)\n",
10893 test_name, i, normals[i].x, normals[i].y, normals[i].z, n->x, n->y, n->z);
10894 }
10895 else
10896 {
10897 const D3DXVECTOR4 *n = (D3DXVECTOR4 *)vertices;
10898 const D3DXVECTOR4 normal = {normals[i].x, normals[i].y, normals[i].z, 1.0f};
10899 ok_(__FILE__, line)(compare_vec4(*n, normal),
10900 "%s: normal %2u, expected (%f, %f, %f, %f), got (%f, %f, %f, %f)\n",
10901 test_name, i, normals[i].x, normals[i].y, normals[i].z, 1.0f,
10902 n->x, n->y, n->z, n->w);
10903 }
10904 }
10905
10906 mesh->lpVtbl->UnlockVertexBuffer(mesh);
10907}
GLdouble n
Definition: glext.h:7729
static BOOL compare_vec4(D3DXVECTOR4 u, D3DXVECTOR4 v)
Definition: mesh.c:60
static const char * test_name
Definition: run.c:194

Referenced by test_compute_normals().

◆ compare_text_outline_mesh()

static void compare_text_outline_mesh ( const char *  name,
ID3DXMesh *  d3dxmesh,
struct mesh *  mesh,
size_t  textlen,
float  extrusion,
const struct glyphinfo *  glyphs 
)
static

Definition at line 4175 of file mesh.c.

4177{
4178 HRESULT hr;
4179 DWORD number_of_vertices, number_of_faces;
4180 IDirect3DVertexBuffer9 *vertex_buffer = NULL;
4181 IDirect3DIndexBuffer9 *index_buffer = NULL;
4182 D3DVERTEXBUFFER_DESC vertex_buffer_description;
4183 D3DINDEXBUFFER_DESC index_buffer_description;
4184 struct vertex *vertices = NULL;
4185 face *faces = NULL;
4186 int expected, i;
4187 int vtx_idx1, face_idx1, vtx_idx2, face_idx2;
4188
4189 number_of_vertices = d3dxmesh->lpVtbl->GetNumVertices(d3dxmesh);
4190 number_of_faces = d3dxmesh->lpVtbl->GetNumFaces(d3dxmesh);
4191
4192 hr = d3dxmesh->lpVtbl->GetVertexBuffer(d3dxmesh, &vertex_buffer);
4193 ok(hr == D3D_OK, "Test %s, unexpected hr %#lx.\n", name, hr);
4194 hr = IDirect3DVertexBuffer9_GetDesc(vertex_buffer, &vertex_buffer_description);
4195 ok(hr == D3D_OK, "Test %s, unexpected hr %#lx.\n", name, hr);
4196 ok(vertex_buffer_description.Format == D3DFMT_VERTEXDATA, "Test %s, unexpected format %u.\n",
4197 name, vertex_buffer_description.Format);
4198 ok(vertex_buffer_description.Type == D3DRTYPE_VERTEXBUFFER, "Test %s, unexpected resource type %u.\n",
4199 name, vertex_buffer_description.Type);
4200 ok(!vertex_buffer_description.Usage, "Test %s, unexpected usage %#lx.\n", name, vertex_buffer_description.Usage);
4201 ok(vertex_buffer_description.Pool == D3DPOOL_MANAGED, "Test %s, unexpected pool %u.\n",
4202 name, vertex_buffer_description.Pool);
4203 ok(vertex_buffer_description.FVF == mesh->fvf, "Test %s, unexpected FVF %#lx (expected %#lx).\n",
4204 name, vertex_buffer_description.FVF, mesh->fvf);
4205 if (!mesh->fvf)
4206 expected = number_of_vertices * mesh->vertex_size;
4207 else
4208 expected = number_of_vertices * D3DXGetFVFVertexSize(mesh->fvf);
4209 ok(vertex_buffer_description.Size == expected, "Test %s, unexpected size %u (expected %u).\n",
4210 name, vertex_buffer_description.Size, expected);
4211
4212 hr = d3dxmesh->lpVtbl->GetIndexBuffer(d3dxmesh, &index_buffer);
4213 ok(hr == D3D_OK, "Test %s, unexpected hr %#lx.\n", name, hr);
4214 hr = IDirect3DIndexBuffer9_GetDesc(index_buffer, &index_buffer_description);
4215 ok(hr == D3D_OK, "Test %s, unexpected hr %#lx.\n", name, hr);
4216 ok(index_buffer_description.Format == D3DFMT_INDEX16, "Test %s, unexpected format %u.\n",
4217 name, index_buffer_description.Format);
4218 ok(index_buffer_description.Type == D3DRTYPE_INDEXBUFFER, "Test %s, unexpected resource type %u.\n",
4219 name, index_buffer_description.Type);
4220 ok(!index_buffer_description.Usage, "Test %s, unexpected usage %#lx.\n",
4221 name, index_buffer_description.Usage);
4222 ok(index_buffer_description.Pool == D3DPOOL_MANAGED, "Test %s, unexpected pool %u.\n",
4223 name, index_buffer_description.Pool);
4224 expected = number_of_faces * sizeof(WORD) * 3;
4225 ok(index_buffer_description.Size == expected, "Test %s, unexpected size %u.\n",
4226 name, index_buffer_description.Size);
4227
4228 hr = IDirect3DVertexBuffer9_Lock(vertex_buffer, 0, number_of_vertices * sizeof(D3DXVECTOR3) * 2,
4229 (void **)&vertices, D3DLOCK_DISCARD);
4230 ok(hr == D3D_OK, "Test %s, unexpected hr %#lx.\n", name, hr);
4231 hr = IDirect3DIndexBuffer9_Lock(index_buffer, 0, number_of_faces * sizeof(WORD) * 3,
4232 (void **)&faces, D3DLOCK_DISCARD);
4233 ok(hr == D3D_OK, "Test %s, unexpected hr %#lx.\n", name, hr);
4234 face_idx1 = 0;
4235 vtx_idx2 = 0;
4236 face_idx2 = 0;
4237 vtx_idx1 = 0;
4238 for (i = 0; i < textlen; i++)
4239 {
4240 int nb_outline_vertices1, nb_outline_faces1;
4241 int nb_outline_vertices2, nb_outline_faces2;
4242 int nb_back_vertices, nb_back_faces;
4243 int first_vtx1, first_vtx2;
4244 int first_face1, first_face2;
4245 int j;
4246
4247 first_vtx1 = vtx_idx1;
4248 first_vtx2 = vtx_idx2;
4249 /* Glyphs without outlines do not generate any vertices. */
4250 if (glyphs[i].outlines.count > 0)
4251 {
4252 for (; vtx_idx1 < number_of_vertices; vtx_idx1++)
4253 {
4254 if (vertices[vtx_idx1].normal.z != 0)
4255 break;
4256 }
4257
4258 for (; vtx_idx2 < mesh->number_of_vertices; vtx_idx2++)
4259 {
4260 if (mesh->vertices[vtx_idx2].normal.z != 0)
4261 break;
4262 }
4263 }
4264 nb_outline_vertices1 = vtx_idx1 - first_vtx1;
4265 nb_outline_vertices2 = vtx_idx2 - first_vtx2;
4266 ok(nb_outline_vertices1 == nb_outline_vertices2,
4267 "Test %s, glyph %d, outline vertex count result %d, expected %d\n", name, i,
4268 nb_outline_vertices1, nb_outline_vertices2);
4269
4270 for (j = 0; j < min(nb_outline_vertices1, nb_outline_vertices2); j++)
4271 {
4272 vtx_idx1 = first_vtx1 + j;
4273 vtx_idx2 = first_vtx2 + j;
4274 ok(compare_vec3(vertices[vtx_idx1].position, mesh->vertices[vtx_idx2].position),
4275 "Test %s, glyph %d, vertex position %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4276 vertices[vtx_idx1].position.x, vertices[vtx_idx1].position.y, vertices[vtx_idx1].position.z,
4277 mesh->vertices[vtx_idx2].position.x, mesh->vertices[vtx_idx2].position.y, mesh->vertices[vtx_idx2].position.z);
4278 ok(compare_vec3(vertices[vtx_idx1].normal, mesh->vertices[first_vtx2 + j].normal),
4279 "Test %s, glyph %d, vertex normal %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4280 vertices[vtx_idx1].normal.x, vertices[vtx_idx1].normal.y, vertices[vtx_idx1].normal.z,
4281 mesh->vertices[vtx_idx2].normal.x, mesh->vertices[vtx_idx2].normal.y, mesh->vertices[vtx_idx2].normal.z);
4282 }
4283 vtx_idx1 = first_vtx1 + nb_outline_vertices1;
4284 vtx_idx2 = first_vtx2 + nb_outline_vertices2;
4285
4286 first_face1 = face_idx1;
4287 first_face2 = face_idx2;
4288 for (; face_idx1 < number_of_faces; face_idx1++)
4289 {
4290 if (faces[face_idx1][0] >= vtx_idx1 ||
4291 faces[face_idx1][1] >= vtx_idx1 ||
4292 faces[face_idx1][2] >= vtx_idx1)
4293 break;
4294 }
4295 for (; face_idx2 < mesh->number_of_faces; face_idx2++)
4296 {
4297 if (mesh->faces[face_idx2][0] >= vtx_idx2 ||
4298 mesh->faces[face_idx2][1] >= vtx_idx2 ||
4299 mesh->faces[face_idx2][2] >= vtx_idx2)
4300 break;
4301 }
4302 nb_outline_faces1 = face_idx1 - first_face1;
4303 nb_outline_faces2 = face_idx2 - first_face2;
4304 ok(nb_outline_faces1 == nb_outline_faces2,
4305 "Test %s, glyph %d, outline face count result %d, expected %d\n", name, i,
4306 nb_outline_faces1, nb_outline_faces2);
4307
4308 for (j = 0; j < min(nb_outline_faces1, nb_outline_faces2); j++)
4309 {
4310 face_idx1 = first_face1 + j;
4311 face_idx2 = first_face2 + j;
4312 ok(faces[face_idx1][0] - first_vtx1 == mesh->faces[face_idx2][0] - first_vtx2 &&
4313 faces[face_idx1][1] - first_vtx1 == mesh->faces[face_idx2][1] - first_vtx2 &&
4314 faces[face_idx1][2] - first_vtx1 == mesh->faces[face_idx2][2] - first_vtx2,
4315 "Test %s, glyph %d, face %d, result (%d, %d, %d), expected (%d, %d, %d)\n", name, i, face_idx1,
4316 faces[face_idx1][0], faces[face_idx1][1], faces[face_idx1][2],
4317 mesh->faces[face_idx2][0] - first_vtx2 + first_vtx1,
4318 mesh->faces[face_idx2][1] - first_vtx2 + first_vtx1,
4319 mesh->faces[face_idx2][2] - first_vtx2 + first_vtx1);
4320 }
4321 face_idx1 = first_face1 + nb_outline_faces1;
4322 face_idx2 = first_face2 + nb_outline_faces2;
4323
4324 /* partial test on back vertices and faces */
4325 first_vtx1 = vtx_idx1;
4326 for (; vtx_idx1 < number_of_vertices; vtx_idx1++) {
4327 struct vertex vtx;
4328
4329 if (vertices[vtx_idx1].normal.z != 1.0f)
4330 break;
4331
4332 vtx.position.z = 0.0f;
4333 vtx.normal.x = 0.0f;
4334 vtx.normal.y = 0.0f;
4335 vtx.normal.z = 1.0f;
4336 ok(compare(vertices[vtx_idx1].position.z, vtx.position.z),
4337 "Test %s, glyph %d, vertex position.z %d, result %g, expected %g\n", name, i, vtx_idx1,
4338 vertices[vtx_idx1].position.z, vtx.position.z);
4339 ok(compare_vec3(vertices[vtx_idx1].normal, vtx.normal),
4340 "Test %s, glyph %d, vertex normal %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4341 vertices[vtx_idx1].normal.x, vertices[vtx_idx1].normal.y, vertices[vtx_idx1].normal.z,
4342 vtx.normal.x, vtx.normal.y, vtx.normal.z);
4343 }
4344 nb_back_vertices = vtx_idx1 - first_vtx1;
4345 first_face1 = face_idx1;
4346 for (; face_idx1 < number_of_faces; face_idx1++)
4347 {
4348 const D3DXVECTOR3 *vtx1, *vtx2, *vtx3;
4350 D3DXVECTOR3 v1 = {0, 0, 0};
4351 D3DXVECTOR3 v2 = {0, 0, 0};
4352 D3DXVECTOR3 forward = {0.0f, 0.0f, 1.0f};
4353
4354 if (faces[face_idx1][0] >= vtx_idx1 ||
4355 faces[face_idx1][1] >= vtx_idx1 ||
4356 faces[face_idx1][2] >= vtx_idx1)
4357 break;
4358
4359 vtx1 = &vertices[faces[face_idx1][0]].position;
4360 vtx2 = &vertices[faces[face_idx1][1]].position;
4361 vtx3 = &vertices[faces[face_idx1][2]].position;
4362
4363 D3DXVec3Subtract(&v1, vtx2, vtx1);
4364 D3DXVec3Subtract(&v2, vtx3, vtx2);
4365 D3DXVec3Cross(&normal, &v1, &v2);
4367 ok(!D3DXVec3Length(&normal) || compare_vec3(normal, forward),
4368 "Test %s, glyph %d, face %d normal, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, face_idx1,
4369 normal.x, normal.y, normal.z, forward.x, forward.y, forward.z);
4370 }
4371 nb_back_faces = face_idx1 - first_face1;
4372
4373 /* compare front and back faces & vertices */
4374 if (extrusion == 0.0f) {
4375 /* Oddly there are only back faces in this case */
4376 nb_back_vertices /= 2;
4377 nb_back_faces /= 2;
4378 face_idx1 -= nb_back_faces;
4379 vtx_idx1 -= nb_back_vertices;
4380 }
4381 for (j = 0; j < nb_back_vertices; j++)
4382 {
4383 struct vertex vtx = vertices[first_vtx1];
4384 vtx.position.z = -extrusion;
4385 vtx.normal.x = 0.0f;
4386 vtx.normal.y = 0.0f;
4387 vtx.normal.z = extrusion == 0.0f ? 1.0f : -1.0f;
4388 ok(compare_vec3(vertices[vtx_idx1].position, vtx.position),
4389 "Test %s, glyph %d, vertex position %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4390 vertices[vtx_idx1].position.x, vertices[vtx_idx1].position.y, vertices[vtx_idx1].position.z,
4391 vtx.position.x, vtx.position.y, vtx.position.z);
4392 ok(compare_vec3(vertices[vtx_idx1].normal, vtx.normal),
4393 "Test %s, glyph %d, vertex normal %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4394 vertices[vtx_idx1].normal.x, vertices[vtx_idx1].normal.y, vertices[vtx_idx1].normal.z,
4395 vtx.normal.x, vtx.normal.y, vtx.normal.z);
4396 vtx_idx1++;
4397 first_vtx1++;
4398 }
4399 for (j = 0; j < nb_back_faces; j++)
4400 {
4401 int f1, f2;
4402 if (extrusion == 0.0f) {
4403 f1 = 1;
4404 f2 = 2;
4405 } else {
4406 f1 = 2;
4407 f2 = 1;
4408 }
4409 ok(faces[face_idx1][0] == faces[first_face1][0] + nb_back_vertices &&
4410 faces[face_idx1][1] == faces[first_face1][f1] + nb_back_vertices &&
4411 faces[face_idx1][2] == faces[first_face1][f2] + nb_back_vertices,
4412 "Test %s, glyph %d, face %d, result (%d, %d, %d), expected (%d, %d, %d)\n", name, i, face_idx1,
4413 faces[face_idx1][0], faces[face_idx1][1], faces[face_idx1][2],
4414 faces[first_face1][0] - nb_back_faces,
4415 faces[first_face1][f1] - nb_back_faces,
4416 faces[first_face1][f2] - nb_back_faces);
4417 first_face1++;
4418 face_idx1++;
4419 }
4420
4421 /* skip to the outline for the next glyph */
4422 for (; vtx_idx2 < mesh->number_of_vertices; vtx_idx2++) {
4423 if (mesh->vertices[vtx_idx2].normal.z == 0)
4424 break;
4425 }
4426 for (; face_idx2 < mesh->number_of_faces; face_idx2++)
4427 {
4428 if (mesh->faces[face_idx2][0] >= vtx_idx2 ||
4429 mesh->faces[face_idx2][1] >= vtx_idx2 ||
4430 mesh->faces[face_idx2][2] >= vtx_idx2) break;
4431 }
4432 }
4433
4434 IDirect3DIndexBuffer9_Unlock(index_buffer);
4436 IDirect3DIndexBuffer9_Release(index_buffer);
4438}
D3DXVECTOR3 *WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv)
Definition: math.c:1805
GLfloat GLfloat v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
#define f2(x, y, z)
Definition: sha1.c:31
#define f1(x, y, z)
Definition: sha1.c:30
D3DXVECTOR3 normal
Definition: mesh.c:4667

Referenced by test_createtext().

◆ compare_vec3()

static BOOL compare_vec3 ( D3DXVECTOR3  u,
D3DXVECTOR3  v 
)
static

Definition at line 55 of file mesh.c.

56{
57 return ( compare(u.x, v.x) && compare(u.y, v.y) && compare(u.z, v.z) );
58}
Definition: bug.cpp:8

Referenced by compare_mesh(), compare_normals(), compare_text_outline_mesh(), D3DXComputeBoundingBoxTest(), and D3DXComputeBoundingSphereTest().

◆ compare_vec4()

static BOOL compare_vec4 ( D3DXVECTOR4  u,
D3DXVECTOR4  v 
)
static

Definition at line 60 of file mesh.c.

61{
62 return compare(u.x, v.x) && compare(u.y, v.y) && compare(u.z, v.z) && compare(u.w, v.w);
63}

Referenced by compare_normals().

◆ compute_box()

static BOOL compute_box ( struct mesh *  mesh,
float  width,
float  height,
float  depth 
)
static

Definition at line 2772 of file mesh.c.

2773{
2774 unsigned int i, face;
2775 static const D3DXVECTOR3 unit_box[] =
2776 {
2777 {-1.0f, -1.0f, -1.0f}, {-1.0f, -1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, -1.0f},
2778 {-1.0f, 1.0f, -1.0f}, {-1.0f, 1.0f, 1.0f}, { 1.0f, 1.0f, 1.0f}, { 1.0f, 1.0f, -1.0f},
2779 { 1.0f, 1.0f, -1.0f}, { 1.0f, 1.0f, 1.0f}, { 1.0f, -1.0f, 1.0f}, { 1.0f, -1.0f, -1.0f},
2780 {-1.0f, -1.0f, 1.0f}, {-1.0f, -1.0f, -1.0f}, { 1.0f, -1.0f, -1.0f}, { 1.0f, -1.0f, 1.0f},
2781 {-1.0f, -1.0f, 1.0f}, { 1.0f, -1.0f, 1.0f}, { 1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f},
2782 {-1.0f, -1.0f, -1.0f}, {-1.0f, 1.0f, -1.0f}, { 1.0f, 1.0f, -1.0f}, { 1.0f, -1.0f, -1.0f}
2783 };
2784 static const D3DXVECTOR3 normals[] =
2785 {
2786 {-1.0f, 0.0f, 0.0f}, { 0.0f, 1.0f, 0.0f}, { 1.0f, 0.0f, 0.0f},
2787 { 0.0f, -1.0f, 0.0f}, { 0.0f, 0.0f, 1.0f}, { 0.0f, 0.0f, -1.0f}
2788 };
2789
2790 if (!new_mesh(mesh, 24, 12))
2791 {
2792 return FALSE;
2793 }
2794
2795 width /= 2.0f;
2796 height /= 2.0f;
2797 depth /= 2.0f;
2798
2799 for (i = 0; i < 24; i++)
2800 {
2801 mesh->vertices[i].position.x = width * unit_box[i].x;
2802 mesh->vertices[i].position.y = height * unit_box[i].y;
2803 mesh->vertices[i].position.z = depth * unit_box[i].z;
2804 mesh->vertices[i].normal.x = normals[i / 4].x;
2805 mesh->vertices[i].normal.y = normals[i / 4].y;
2806 mesh->vertices[i].normal.z = normals[i / 4].z;
2807 }
2808
2809 face = 0;
2810 for (i = 0; i < 12; i++)
2811 {
2812 mesh->faces[i][0] = face++;
2813 mesh->faces[i][1] = face++;
2814 mesh->faces[i][2] = (i % 2) ? face - 4 : face;
2815 }
2816
2817 return TRUE;
2818}
WORD face[3]
Definition: mesh.c:4854
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
static BOOL new_mesh(struct mesh *mesh, DWORD number_of_vertices, DWORD number_of_faces)
Definition: mesh.c:206

Referenced by test_box().

◆ compute_cylinder()

static BOOL compute_cylinder ( struct mesh *  mesh,
FLOAT  radius1,
FLOAT  radius2,
FLOAT  length,
UINT  slices,
UINT  stacks 
)
static

Definition at line 3302 of file mesh.c.

3303{
3304 float theta_step, theta_start;
3305 struct sincos_table theta;
3306 FLOAT delta_radius, radius, radius_step;
3307 FLOAT z, z_step, z_normal;
3308 DWORD number_of_vertices, number_of_faces;
3309 DWORD vertex, face;
3310 int slice, stack;
3311
3312 /* theta = angle on xy plane wrt x axis */
3313 theta_step = -2 * D3DX_PI / slices;
3314 theta_start = D3DX_PI / 2;
3315
3316 if (!compute_sincos_table(&theta, theta_start, theta_step, slices))
3317 {
3318 return FALSE;
3319 }
3320
3321 number_of_vertices = 2 + (slices * (3 + stacks));
3322 number_of_faces = 2 * slices + stacks * (2 * slices);
3323
3324 if (!new_mesh(mesh, number_of_vertices, number_of_faces))
3325 {
3326 free_sincos_table(&theta);
3327 return FALSE;
3328 }
3329
3330 vertex = 0;
3331 face = 0;
3332
3333 delta_radius = radius1 - radius2;
3334 radius = radius1;
3335 radius_step = delta_radius / stacks;
3336
3337 z = -length / 2;
3338 z_step = length / stacks;
3339 z_normal = delta_radius / length;
3340 if (isnan(z_normal))
3341 {
3342 z_normal = 0.0f;
3343 }
3344
3345 mesh->vertices[vertex].normal.x = 0.0f;
3346 mesh->vertices[vertex].normal.y = 0.0f;
3347 mesh->vertices[vertex].normal.z = -1.0f;
3348 mesh->vertices[vertex].position.x = 0.0f;
3349 mesh->vertices[vertex].position.y = 0.0f;
3350 mesh->vertices[vertex++].position.z = z;
3351
3352 for (slice = 0; slice < slices; slice++, vertex++)
3353 {
3354 mesh->vertices[vertex].normal.x = 0.0f;
3355 mesh->vertices[vertex].normal.y = 0.0f;
3356 mesh->vertices[vertex].normal.z = -1.0f;
3357 mesh->vertices[vertex].position.x = radius * theta.cos[slice];
3358 mesh->vertices[vertex].position.y = radius * theta.sin[slice];
3359 mesh->vertices[vertex].position.z = z;
3360
3361 if (slice > 0)
3362 {
3363 mesh->faces[face][0] = 0;
3364 mesh->faces[face][1] = slice;
3365 mesh->faces[face++][2] = slice + 1;
3366 }
3367 }
3368
3369 mesh->faces[face][0] = 0;
3370 mesh->faces[face][1] = slice;
3371 mesh->faces[face++][2] = 1;
3372
3373 for (stack = 1; stack <= stacks+1; stack++)
3374 {
3375 for (slice = 0; slice < slices; slice++, vertex++)
3376 {
3377 mesh->vertices[vertex].normal.x = theta.cos[slice];
3378 mesh->vertices[vertex].normal.y = theta.sin[slice];
3379 mesh->vertices[vertex].normal.z = z_normal;
3381 mesh->vertices[vertex].position.x = radius * theta.cos[slice];
3382 mesh->vertices[vertex].position.y = radius * theta.sin[slice];
3383 mesh->vertices[vertex].position.z = z;
3384
3385 if (stack > 1 && slice > 0)
3386 {
3387 mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3388 mesh->faces[face][1] = vertex_index(slices, slice-1, stack);
3389 mesh->faces[face++][2] = vertex_index(slices, slice, stack-1);
3390
3391 mesh->faces[face][0] = vertex_index(slices, slice, stack-1);
3392 mesh->faces[face][1] = vertex_index(slices, slice-1, stack);
3393 mesh->faces[face++][2] = vertex_index(slices, slice, stack);
3394 }
3395 }
3396
3397 if (stack > 1)
3398 {
3399 mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3400 mesh->faces[face][1] = vertex_index(slices, slice-1, stack);
3401 mesh->faces[face++][2] = vertex_index(slices, 0, stack-1);
3402
3403 mesh->faces[face][0] = vertex_index(slices, 0, stack-1);
3404 mesh->faces[face][1] = vertex_index(slices, slice-1, stack);
3405 mesh->faces[face++][2] = vertex_index(slices, 0, stack);
3406 }
3407
3408 if (stack < stacks + 1)
3409 {
3410 z += z_step;
3411 radius -= radius_step;
3412 }
3413 }
3414
3415 for (slice = 0; slice < slices; slice++, vertex++)
3416 {
3417 mesh->vertices[vertex].normal.x = 0.0f;
3418 mesh->vertices[vertex].normal.y = 0.0f;
3419 mesh->vertices[vertex].normal.z = 1.0f;
3420 mesh->vertices[vertex].position.x = radius * theta.cos[slice];
3421 mesh->vertices[vertex].position.y = radius * theta.sin[slice];
3422 mesh->vertices[vertex].position.z = z;
3423
3424 if (slice > 0)
3425 {
3426 mesh->faces[face][0] = vertex_index(slices, slice-1, stack);
3427 mesh->faces[face][1] = number_of_vertices - 1;
3428 mesh->faces[face++][2] = vertex_index(slices, slice, stack);
3429 }
3430 }
3431
3432 mesh->vertices[vertex].position.x = 0.0f;
3433 mesh->vertices[vertex].position.y = 0.0f;
3434 mesh->vertices[vertex].position.z = z;
3435 mesh->vertices[vertex].normal.x = 0.0f;
3436 mesh->vertices[vertex].normal.y = 0.0f;
3437 mesh->vertices[vertex].normal.z = 1.0f;
3438
3439 mesh->faces[face][0] = vertex_index(slices, slice-1, stack);
3440 mesh->faces[face][1] = number_of_vertices - 1;
3441 mesh->faces[face][2] = vertex_index(slices, 0, stack);
3442
3443 free_sincos_table(&theta);
3444
3445 return TRUE;
3446}
static void free_sincos_table(struct sincos_table *sincos_table)
Definition: mesh.c:4862
static BOOL compute_sincos_table(struct sincos_table *sincos_table, float angle_start, float angle_step, int n)
Definition: mesh.c:4869
static WORD vertex_index(UINT slices, int slice, int stack)
Definition: mesh.c:4897
#define isnan(x)
Definition: math.h:360
#define D3DX_PI
Definition: d3dx9math.h:27
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLdouble GLdouble z
Definition: glext.h:5874
Definition: format.c:80

Referenced by test_cylinder().

◆ compute_normals_D3DXComputeNormals()

static HRESULT compute_normals_D3DXComputeNormals ( ID3DXMesh *  mesh,
const DWORD *  adjacency 
)
static

Definition at line 10909 of file mesh.c.

10910{
10911 return D3DXComputeNormals((ID3DXBaseMesh *)mesh, adjacency);
10912}
HRESULT WINAPI D3DXComputeNormals(struct ID3DXBaseMesh *mesh, const DWORD *adjacency)
Definition: mesh.c:7637

Referenced by test_compute_normals().

◆ compute_normals_D3DXComputeTangentFrameEx()

static HRESULT compute_normals_D3DXComputeTangentFrameEx ( ID3DXMesh *  mesh,
const DWORD *  adjacency 
)
static

Definition at line 10914 of file mesh.c.

10915{
10918 adjacency, -1.01f, -0.01f, -1.01f, NULL, NULL);
10919}
HRESULT WINAPI D3DXComputeTangentFrameEx(ID3DXMesh *mesh, DWORD texture_in_semantic, DWORD texture_in_index, DWORD u_partial_out_semantic, DWORD u_partial_out_index, DWORD v_partial_out_semantic, DWORD v_partial_out_index, DWORD normal_out_semantic, DWORD normal_out_index, DWORD options, const DWORD *adjacency, float partial_edge_threshold, float singular_point_threshold, float normal_edge_threshold, ID3DXMesh **mesh_out, ID3DXBuffer **vertex_mapping)
Definition: mesh.c:7409
#define D3DX_DEFAULT
Definition: d3dx9.h:24
@ D3DXTANGENT_CALCULATE_NORMALS
Definition: d3dx9mesh.h:121
@ D3DXTANGENT_GENERATE_IN_PLACE
Definition: d3dx9mesh.h:122

Referenced by test_compute_normals().

◆ compute_polygon()

static BOOL compute_polygon ( struct mesh *  mesh,
float  length,
unsigned int  sides 
)
static

Definition at line 2906 of file mesh.c.

2907{
2908 unsigned int i;
2909 float angle, scale;
2910
2911 if (!new_mesh(mesh, sides + 1, sides))
2912 return FALSE;
2913
2914 angle = D3DX_PI / sides;
2915 scale = 0.5f * length / sinf(angle);
2916 angle *= 2.0f;
2917
2918 mesh->vertices[0].position.x = 0.0f;
2919 mesh->vertices[0].position.y = 0.0f;
2920 mesh->vertices[0].position.z = 0.0f;
2921 mesh->vertices[0].normal.x = 0.0f;
2922 mesh->vertices[0].normal.y = 0.0f;
2923 mesh->vertices[0].normal.z = 1.0f;
2924
2925 for (i = 0; i < sides; ++i)
2926 {
2927 mesh->vertices[i + 1].position.x = cosf(angle * i) * scale;
2928 mesh->vertices[i + 1].position.y = sinf(angle * i) * scale;
2929 mesh->vertices[i + 1].position.z = 0.0f;
2930 mesh->vertices[i + 1].normal.x = 0.0f;
2931 mesh->vertices[i + 1].normal.y = 0.0f;
2932 mesh->vertices[i + 1].normal.z = 1.0f;
2933
2934 mesh->faces[i][0] = 0;
2935 mesh->faces[i][1] = i + 1;
2936 mesh->faces[i][2] = i + 2;
2937 }
2938
2939 mesh->faces[sides - 1][2] = 1;
2940
2941 return TRUE;
2942}
_ACRTIMP float __cdecl cosf(float)
Definition: cosf.c:13
_ACRTIMP float __cdecl sinf(float)
Definition: sinf.c:13
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLfloat angle
Definition: glext.h:10853

Referenced by test_polygon().

◆ compute_sincos_table()

static BOOL compute_sincos_table ( struct sincos_table *  sincos_table,
float  angle_start,
float  angle_step,
int  n 
)
static

Definition at line 3053 of file mesh.c.

3054{
3055 float angle;
3056 int i;
3057
3058 sincos_table->sin = malloc(n * sizeof(*sincos_table->sin));
3059 if (!sincos_table->sin)
3060 {
3061 return FALSE;
3062 }
3063 sincos_table->cos = malloc(n * sizeof(*sincos_table->cos));
3064 if (!sincos_table->cos)
3065 {
3067 return FALSE;
3068 }
3069
3070 angle = angle_start;
3071 for (i = 0; i < n; i++)
3072 {
3073 sincos_table->sin[i] = sin(angle);
3074 sincos_table->cos[i] = cos(angle);
3075 angle += angle_step;
3076 }
3077
3078 return TRUE;
3079}
_ACRTIMP double __cdecl sin(double)
Definition: sin.c:21
float * sin
Definition: mesh.c:4858
float * cos
Definition: mesh.c:4859

◆ compute_sphere()

static BOOL compute_sphere ( struct mesh *  mesh,
FLOAT  radius,
UINT  slices,
UINT  stacks 
)
static

Definition at line 3087 of file mesh.c.

3088{
3089 float theta_step, theta_start;
3090 struct sincos_table theta;
3091 float phi_step, phi_start;
3092 struct sincos_table phi;
3093 DWORD number_of_vertices, number_of_faces;
3094 DWORD vertex, face;
3095 int slice, stack;
3096
3097 /* theta = angle on xy plane wrt x axis */
3098 theta_step = D3DX_PI / stacks;
3099 theta_start = theta_step;
3100
3101 /* phi = angle on xz plane wrt z axis */
3102 phi_step = -2 * D3DX_PI / slices;
3103 phi_start = D3DX_PI / 2;
3104
3105 if (!compute_sincos_table(&theta, theta_start, theta_step, stacks))
3106 {
3107 return FALSE;
3108 }
3109 if (!compute_sincos_table(&phi, phi_start, phi_step, slices))
3110 {
3111 free_sincos_table(&theta);
3112 return FALSE;
3113 }
3114
3115 number_of_vertices = 2 + slices * (stacks-1);
3116 number_of_faces = 2 * slices + (stacks - 2) * (2 * slices);
3117
3118 if (!new_mesh(mesh, number_of_vertices, number_of_faces))
3119 {
3120 free_sincos_table(&phi);
3121 free_sincos_table(&theta);
3122 return FALSE;
3123 }
3124
3125 vertex = 0;
3126 face = 0;
3127
3128 mesh->vertices[vertex].normal.x = 0.0f;
3129 mesh->vertices[vertex].normal.y = 0.0f;
3130 mesh->vertices[vertex].normal.z = 1.0f;
3131 mesh->vertices[vertex].position.x = 0.0f;
3132 mesh->vertices[vertex].position.y = 0.0f;
3133 mesh->vertices[vertex].position.z = radius;
3134 vertex++;
3135
3136 for (stack = 0; stack < stacks - 1; stack++)
3137 {
3138 for (slice = 0; slice < slices; slice++)
3139 {
3140 mesh->vertices[vertex].normal.x = theta.sin[stack] * phi.cos[slice];
3141 mesh->vertices[vertex].normal.y = theta.sin[stack] * phi.sin[slice];
3142 mesh->vertices[vertex].normal.z = theta.cos[stack];
3143 mesh->vertices[vertex].position.x = radius * theta.sin[stack] * phi.cos[slice];
3144 mesh->vertices[vertex].position.y = radius * theta.sin[stack] * phi.sin[slice];
3145 mesh->vertices[vertex].position.z = radius * theta.cos[stack];
3146 vertex++;
3147
3148 if (slice > 0)
3149 {
3150 if (stack == 0)
3151 {
3152 /* top stack is triangle fan */
3153 mesh->faces[face][0] = 0;
3154 mesh->faces[face][1] = slice + 1;
3155 mesh->faces[face][2] = slice;
3156 face++;
3157 }
3158 else
3159 {
3160 /* stacks in between top and bottom are quad strips */
3161 mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3162 mesh->faces[face][1] = vertex_index(slices, slice, stack-1);
3163 mesh->faces[face][2] = vertex_index(slices, slice-1, stack);
3164 face++;
3165
3166 mesh->faces[face][0] = vertex_index(slices, slice, stack-1);
3167 mesh->faces[face][1] = vertex_index(slices, slice, stack);
3168 mesh->faces[face][2] = vertex_index(slices, slice-1, stack);
3169 face++;
3170 }
3171 }
3172 }
3173
3174 if (stack == 0)
3175 {
3176 mesh->faces[face][0] = 0;
3177 mesh->faces[face][1] = 1;
3178 mesh->faces[face][2] = slice;
3179 face++;
3180 }
3181 else
3182 {
3183 mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3184 mesh->faces[face][1] = vertex_index(slices, 0, stack-1);
3185 mesh->faces[face][2] = vertex_index(slices, slice-1, stack);
3186 face++;
3187
3188 mesh->faces[face][0] = vertex_index(slices, 0, stack-1);
3189 mesh->faces[face][1] = vertex_index(slices, 0, stack);
3190 mesh->faces[face][2] = vertex_index(slices, slice-1, stack);
3191 face++;
3192 }
3193 }
3194
3195 mesh->vertices[vertex].position.x = 0.0f;
3196 mesh->vertices[vertex].position.y = 0.0f;
3197 mesh->vertices[vertex].position.z = -radius;
3198 mesh->vertices[vertex].normal.x = 0.0f;
3199 mesh->vertices[vertex].normal.y = 0.0f;
3200 mesh->vertices[vertex].normal.z = -1.0f;
3201
3202 /* bottom stack is triangle fan */
3203 for (slice = 1; slice < slices; slice++)
3204 {
3205 mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3206 mesh->faces[face][1] = vertex_index(slices, slice, stack-1);
3207 mesh->faces[face][2] = vertex;
3208 face++;
3209 }
3210
3211 mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3212 mesh->faces[face][1] = vertex_index(slices, 0, stack-1);
3213 mesh->faces[face][2] = vertex;
3214
3215 free_sincos_table(&phi);
3216 free_sincos_table(&theta);
3217
3218 return TRUE;
3219}

Referenced by test_sphere().

◆ compute_text_mesh()

static void compute_text_mesh ( struct mesh *  mesh,
const char *  text,
float  deviation,
float  extrusion,
float  otmEMSquare,
const struct glyphinfo *  glyphs 
)
static

Definition at line 4031 of file mesh.c.

4033{
4034 DWORD nb_vertices, nb_faces;
4035 DWORD nb_corners, nb_outline_points;
4036 int textlen = 0;
4037 int i;
4038 struct vertex *vertex_ptr;
4039 face *face_ptr;
4040
4041 textlen = strlen(text);
4042
4043 /* corner points need an extra vertex for the different side faces normals */
4044 nb_corners = 0;
4045 nb_outline_points = 0;
4046 for (i = 0; i < textlen; i++)
4047 {
4048 int j;
4049 for (j = 0; j < glyphs[i].outlines.count; j++)
4050 {
4051 int k;
4052 struct outline *outline = &glyphs[i].outlines.items[j];
4053 nb_outline_points += outline->count;
4054 nb_corners++; /* first outline point always repeated as a corner */
4055 for (k = 1; k < outline->count; k++)
4056 if (outline->items[k].corner)
4057 nb_corners++;
4058 }
4059 }
4060
4061 nb_vertices = (nb_outline_points + nb_corners) * 2 + textlen;
4062 nb_faces = nb_outline_points * 2;
4063
4064 ok(new_mesh(mesh, nb_vertices, nb_faces), "Failed to create reference text mesh.\n");
4065
4066 /* convert 2D vertices and faces into 3D mesh */
4067 vertex_ptr = mesh->vertices;
4068 face_ptr = mesh->faces;
4069 for (i = 0; i < textlen; i++)
4070 {
4071 int j;
4072
4073 /* side vertices and faces */
4074 for (j = 0; j < glyphs[i].outlines.count; j++)
4075 {
4076 struct vertex *outline_vertices = vertex_ptr;
4077 struct outline *outline = &glyphs[i].outlines.items[j];
4078 int k;
4079 struct point2d *prevpt = &outline->items[outline->count - 1];
4080 struct point2d *pt = &outline->items[0];
4081
4082 for (k = 1; k <= outline->count; k++)
4083 {
4084 struct vertex vtx;
4085 struct point2d *nextpt = &outline->items[k % outline->count];
4086 WORD vtx_idx = vertex_ptr - mesh->vertices;
4088
4089 if (pt->corner == POINTTYPE_CURVE_START)
4090 D3DXVec2Subtract(&vec, &pt->pos, &prevpt->pos);
4091 else if (pt->corner)
4092 D3DXVec2Subtract(&vec, &nextpt->pos, &pt->pos);
4093 else
4094 D3DXVec2Subtract(&vec, &nextpt->pos, &prevpt->pos);
4096 vtx.normal.x = -vec.y;
4097 vtx.normal.y = vec.x;
4098 vtx.normal.z = 0;
4099
4100 vtx.position.x = pt->pos.x + glyphs[i].offset_x;
4101 vtx.position.y = pt->pos.y;
4102 vtx.position.z = 0;
4103 *vertex_ptr++ = vtx;
4104
4105 vtx.position.z = -extrusion;
4106 *vertex_ptr++ = vtx;
4107
4108 vtx.position.x = nextpt->pos.x + glyphs[i].offset_x;
4109 vtx.position.y = nextpt->pos.y;
4110 if (pt->corner && nextpt->corner && nextpt->corner != POINTTYPE_CURVE_END) {
4111 vtx.position.z = -extrusion;
4112 *vertex_ptr++ = vtx;
4113 vtx.position.z = 0;
4114 *vertex_ptr++ = vtx;
4115
4116 (*face_ptr)[0] = vtx_idx;
4117 (*face_ptr)[1] = vtx_idx + 2;
4118 (*face_ptr)[2] = vtx_idx + 1;
4119 face_ptr++;
4120
4121 (*face_ptr)[0] = vtx_idx;
4122 (*face_ptr)[1] = vtx_idx + 3;
4123 (*face_ptr)[2] = vtx_idx + 2;
4124 face_ptr++;
4125 } else {
4126 if (nextpt->corner) {
4127 if (nextpt->corner == POINTTYPE_CURVE_END) {
4128 struct point2d *nextpt2 = &outline->items[(k + 1) % outline->count];
4129 D3DXVec2Subtract(&vec, &nextpt2->pos, &nextpt->pos);
4130 } else {
4131 D3DXVec2Subtract(&vec, &nextpt->pos, &pt->pos);
4132 }
4134 vtx.normal.x = -vec.y;
4135 vtx.normal.y = vec.x;
4136
4137 vtx.position.z = 0;
4138 *vertex_ptr++ = vtx;
4139 vtx.position.z = -extrusion;
4140 *vertex_ptr++ = vtx;
4141 }
4142
4143 (*face_ptr)[0] = vtx_idx;
4144 (*face_ptr)[1] = vtx_idx + 3;
4145 (*face_ptr)[2] = vtx_idx + 1;
4146 face_ptr++;
4147
4148 (*face_ptr)[0] = vtx_idx;
4149 (*face_ptr)[1] = vtx_idx + 2;
4150 (*face_ptr)[2] = vtx_idx + 3;
4151 face_ptr++;
4152 }
4153
4154 prevpt = pt;
4155 pt = nextpt;
4156 }
4157 if (!pt->corner) {
4158 *vertex_ptr++ = *outline_vertices++;
4159 *vertex_ptr++ = *outline_vertices++;
4160 }
4161 }
4162
4163 /* FIXME: compute expected faces */
4164 /* Add placeholder to separate glyph outlines */
4165 vertex_ptr->position.x = 0;
4166 vertex_ptr->position.y = 0;
4167 vertex_ptr->position.z = 0;
4168 vertex_ptr->normal.x = 0;
4169 vertex_ptr->normal.y = 0;
4170 vertex_ptr->normal.z = 1;
4171 vertex_ptr++;
4172 }
4173}
D3DXVECTOR2 *WINAPI D3DXVec2Normalize(D3DXVECTOR2 *pout, const D3DXVECTOR2 *pv)
Definition: math.c:1659
const WCHAR * text
Definition: package.c:1826
FT_Pos x
Definition: ftimage.h:77
FT_Pos y
Definition: ftimage.h:78
float offset_x
Definition: mesh.c:5472
struct outline_array outlines
Definition: mesh.c:5469

Referenced by test_createtext().

◆ compute_torus()

static BOOL compute_torus ( struct mesh *  mesh,
float  innerradius,
float  outerradius,
UINT  sides,
UINT  rings 
)
static

Definition at line 3553 of file mesh.c.

3554{
3555 float phi, phi_step, sin_phi, cos_phi;
3556 float theta, theta_step, sin_theta, cos_theta;
3557 unsigned int numvert, numfaces, i, j;
3558
3559 numvert = sides * rings;
3560 numfaces = numvert * 2;
3561
3562 if (!new_mesh(mesh, numvert, numfaces))
3563 return FALSE;
3564
3565 phi_step = D3DX_PI / sides * 2.0f;
3566 theta_step = D3DX_PI / rings * -2.0f;
3567
3568 theta = 0.0f;
3569
3570 for (i = 0; i < rings; ++i)
3571 {
3572 phi = 0.0f;
3573
3574 cos_theta = cosf(theta);
3575 sin_theta = sinf(theta);
3576
3577 for (j = 0; j < sides; ++j)
3578 {
3579 sin_phi = sinf(phi);
3580 cos_phi = cosf(phi);
3581
3582 mesh->vertices[i * sides + j].position.x = (innerradius * cos_phi + outerradius) * cos_theta;
3583 mesh->vertices[i * sides + j].position.y = (innerradius * cos_phi + outerradius) * sin_theta;
3584 mesh->vertices[i * sides + j].position.z = innerradius * sin_phi;
3585 mesh->vertices[i * sides + j].normal.x = cos_phi * cos_theta;
3586 mesh->vertices[i * sides + j].normal.y = cos_phi * sin_theta;
3587 mesh->vertices[i * sides + j].normal.z = sin_phi;
3588
3589 phi += phi_step;
3590 }
3591
3592 theta += theta_step;
3593 }
3594
3595 for (i = 0; i < numfaces - sides * 2; ++i)
3596 {
3597 mesh->faces[i][0] = i % 2 ? i / 2 + sides : i / 2;
3598 mesh->faces[i][1] = (i / 2 + 1) % sides ? i / 2 + 1 : i / 2 + 1 - sides;
3599 mesh->faces[i][2] = (i + 1) % (sides * 2) ? (i + 1) / 2 + sides : (i + 1) / 2;
3600 }
3601
3602 for (j = 0; i < numfaces; ++i, ++j)
3603 {
3604 mesh->faces[i][0] = i % 2 ? j / 2 : i / 2;
3605 mesh->faces[i][1] = (i / 2 + 1) % sides ? i / 2 + 1 : i / 2 + 1 - sides;
3606 mesh->faces[i][2] = i == numfaces - 1 ? 0 : (j + 1) / 2;
3607 }
3608
3609 return TRUE;
3610}

Referenced by test_torus().

◆ convert_fixed_to_float()

static D3DXVECTOR2 * convert_fixed_to_float ( POINTFX *  pt,
int  count,
float  emsquare 
)
inlinestatic

Definition at line 3772 of file mesh.c.

3773{
3775 while (count--) {
3776 D3DXVECTOR2 *pt_flt = (D3DXVECTOR2*)pt;
3777 pt_flt->x = (pt->x.value + pt->x.fract / (float)0x10000) / emsquare;
3778 pt_flt->y = (pt->y.value + pt->y.fract / (float)0x10000) / emsquare;
3779 pt++;
3780 }
3781 return ret;
3782}
GLuint GLuint GLsizei count
Definition: gl.h:1545
static float(__cdecl *square_half_float)(float x
char * value
Definition: wpp.c:53

◆ create_outline()

static HRESULT create_outline ( struct glyphinfo *  glyph,
void *  raw_outline,
int  datasize,
float  max_deviation,
float  emsquare 
)
static

Definition at line 3869 of file mesh.c.

3871{
3872 const float cos_45 = cos(D3DXToRadian(45.0f));
3873 const float cos_90 = cos(D3DXToRadian(90.0f));
3874 TTPOLYGONHEADER *header = (TTPOLYGONHEADER *)raw_outline;
3875
3876 while ((char *)header < (char *)raw_outline + datasize)
3877 {
3878 TTPOLYCURVE *curve = (TTPOLYCURVE *)(header + 1);
3879 struct point2d *lastpt, *pt;
3880 D3DXVECTOR2 lastdir;
3881 D3DXVECTOR2 *pt_flt;
3882 int j;
3883 struct outline *outline = add_outline(&glyph->outlines);
3884
3885 if (!outline)
3886 return E_OUTOFMEMORY;
3887
3888 pt = add_point(outline);
3889 if (!pt)
3890 return E_OUTOFMEMORY;
3891 pt_flt = convert_fixed_to_float(&header->pfxStart, 1, emsquare);
3892 pt->pos = *pt_flt;
3893 pt->corner = POINTTYPE_CORNER;
3894
3895 if (header->dwType != TT_POLYGON_TYPE)
3896 trace("Unknown header type %ld\n", header->dwType);
3897
3898 while ((char *)curve < (char *)header + header->cb)
3899 {
3900 D3DXVECTOR2 bezier_start = outline->items[outline->count - 1].pos;
3901 BOOL to_curve = curve->wType != TT_PRIM_LINE && curve->cpfx > 1;
3902
3903 if (!curve->cpfx) {
3904 curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
3905 continue;
3906 }
3907
3908 pt_flt = convert_fixed_to_float(curve->apfx, curve->cpfx, emsquare);
3909
3910 attempt_line_merge(outline, outline->count - 1, &pt_flt[0], to_curve);
3911
3912 if (to_curve)
3913 {
3914 HRESULT hr;
3915 int count = curve->cpfx;
3916 j = 0;
3917
3918 while (count > 2)
3919 {
3920 D3DXVECTOR2 bezier_end;
3921
3922 D3DXVec2Scale(&bezier_end, D3DXVec2Add(&bezier_end, &pt_flt[j], &pt_flt[j+1]), 0.5f);
3923 hr = add_bezier_points(outline, &bezier_start, &pt_flt[j], &bezier_end, max_deviation);
3924 if (hr != S_OK)
3925 return hr;
3926 bezier_start = bezier_end;
3927 count--;
3928 j++;
3929 }
3930 hr = add_bezier_points(outline, &bezier_start, &pt_flt[j], &pt_flt[j+1], max_deviation);
3931 if (hr != S_OK)
3932 return hr;
3933
3934 pt = add_point(outline);
3935 if (!pt)
3936 return E_OUTOFMEMORY;
3937 j++;
3938 pt->pos = pt_flt[j];
3939 pt->corner = POINTTYPE_CURVE_END;
3940 } else {
3941 for (j = 0; j < curve->cpfx; j++)
3942 {
3943 pt = add_point(outline);
3944 if (!pt)
3945 return E_OUTOFMEMORY;
3946 pt->pos = pt_flt[j];
3947 pt->corner = POINTTYPE_CORNER;
3948 }
3949 }
3950
3951 curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
3952 }
3953
3954 /* remove last point if the next line continues the last line */
3955 if (outline->count >= 3) {
3956 BOOL to_curve;
3957
3958 lastpt = &outline->items[outline->count - 1];
3959 pt = &outline->items[0];
3960 if (pt->pos.x == lastpt->pos.x && pt->pos.y == lastpt->pos.y) {
3961 if (lastpt->corner == POINTTYPE_CURVE_END)
3962 {
3963 if (pt->corner == POINTTYPE_CURVE_START)
3964 pt->corner = POINTTYPE_CURVE_MIDDLE;
3965 else
3966 pt->corner = POINTTYPE_CURVE_END;
3967 }
3968 outline->count--;
3969 } else {
3970 /* outline closed with a line from end to start point */
3972 }
3973 lastpt = &outline->items[0];
3974 to_curve = lastpt->corner != POINTTYPE_CORNER && lastpt->corner != POINTTYPE_CURVE_END;
3975 if (lastpt->corner == POINTTYPE_CURVE_START)
3976 lastpt->corner = POINTTYPE_CORNER;
3977 pt = &outline->items[1];
3978 if (attempt_line_merge(outline, 0, &pt->pos, to_curve))
3979 *lastpt = outline->items[outline->count];
3980 }
3981
3982 lastpt = &outline->items[outline->count - 1];
3983 pt = &outline->items[0];
3984 unit_vec2(&lastdir, &lastpt->pos, &pt->pos);
3985 for (j = 0; j < outline->count; j++)
3986 {
3987 D3DXVECTOR2 curdir;
3988
3989 lastpt = pt;
3990 pt = &outline->items[(j + 1) % outline->count];
3991 unit_vec2(&curdir, &lastpt->pos, &pt->pos);
3992
3993 switch (lastpt->corner)
3994 {
3997 if (!is_direction_similar(&lastdir, &curdir, cos_45))
3998 lastpt->corner = POINTTYPE_CORNER;
3999 break;
4001 if (!is_direction_similar(&lastdir, &curdir, cos_90))
4002 lastpt->corner = POINTTYPE_CORNER;
4003 else
4004 lastpt->corner = POINTTYPE_CURVE;
4005 break;
4006 default:
4007 break;
4008 }
4009 lastdir = curdir;
4010 }
4011
4012 header = (TTPOLYGONHEADER *)((char *)header + header->cb);
4013 }
4014 return S_OK;
4015}
static SIZE_T datasize
Definition: asm.c:30
static D3DXVECTOR2 * convert_fixed_to_float(POINTFX *pt, int count, unsigned int emsquare)
Definition: mesh.c:5567
static struct outline * add_outline(struct outline_array *array)
Definition: mesh.c:5525
static BOOL attempt_line_merge(struct outline *outline, int pt_index, const D3DXVECTOR2 *nextpt, BOOL to_curve, const struct cos_table *table)
Definition: mesh.c:5627
POINTFX apfx[1]
Definition: wingdi.h:3160
#define TT_POLYGON_TYPE
Definition: wingdi.h:1318
#define TT_PRIM_LINE
Definition: wingdi.h:1319

◆ D3DXBoundProbeTest()

static void D3DXBoundProbeTest ( void  )
static

Definition at line 373 of file mesh.c.

374{
375 BOOL result;
376 D3DXVECTOR3 bottom_point, center, top_point, raydirection, rayposition;
377 FLOAT radius;
378
379/*____________Test the Box case___________________________*/
380 bottom_point.x = -3.0f; bottom_point.y = -2.0f; bottom_point.z = -1.0f;
381 top_point.x = 7.0f; top_point.y = 8.0f; top_point.z = 9.0f;
382
383 raydirection.x = -4.0f; raydirection.y = -5.0f; raydirection.z = -6.0f;
384 rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 11.0f;
385 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
386 ok(result == TRUE, "expected TRUE, received FALSE\n");
387
388 raydirection.x = 4.0f; raydirection.y = 5.0f; raydirection.z = 6.0f;
389 rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 11.0f;
390 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
391 ok(result == FALSE, "expected FALSE, received TRUE\n");
392
393 rayposition.x = -4.0f; rayposition.y = 1.0f; rayposition.z = -2.0f;
394 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
395 ok(result == TRUE, "expected TRUE, received FALSE\n");
396
397 bottom_point.x = 1.0f; bottom_point.y = 0.0f; bottom_point.z = 0.0f;
398 top_point.x = 1.0f; top_point.y = 0.0f; top_point.z = 0.0f;
399 rayposition.x = 0.0f; rayposition.y = 1.0f; rayposition.z = 0.0f;
400 raydirection.x = 0.0f; raydirection.y = 3.0f; raydirection.z = 0.0f;
401 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
402 ok(result == FALSE, "expected FALSE, received TRUE\n");
403
404 bottom_point.x = 1.0f; bottom_point.y = 2.0f; bottom_point.z = 3.0f;
405 top_point.x = 10.0f; top_point.y = 15.0f; top_point.z = 20.0f;
406
407 raydirection.x = 7.0f; raydirection.y = 8.0f; raydirection.z = 9.0f;
408 rayposition.x = 3.0f; rayposition.y = 7.0f; rayposition.z = -6.0f;
409 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
410 ok(result == TRUE, "expected TRUE, received FALSE\n");
411
412 bottom_point.x = 0.0f; bottom_point.y = 0.0f; bottom_point.z = 0.0f;
413 top_point.x = 1.0f; top_point.y = 1.0f; top_point.z = 1.0f;
414
415 raydirection.x = 0.0f; raydirection.y = 1.0f; raydirection.z = .0f;
416 rayposition.x = -3.0f; rayposition.y = 0.0f; rayposition.z = 0.0f;
417 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
418 ok(result == FALSE, "expected FALSE, received TRUE\n");
419
420 raydirection.x = 1.0f; raydirection.y = 0.0f; raydirection.z = .0f;
421 rayposition.x = -3.0f; rayposition.y = 0.0f; rayposition.z = 0.0f;
422 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
423 ok(result == TRUE, "expected TRUE, received FALSE\n");
424
425/*____________Test the Sphere case________________________*/
426 radius = sqrt(77.0f);
427 center.x = 1.0f; center.y = 2.0f; center.z = 3.0f;
428 raydirection.x = 2.0f; raydirection.y = -4.0f; raydirection.z = 2.0f;
429 rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 9.0f;
430 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
431 ok(result == TRUE, "Got unexpected result %#x.\n", result);
432
433 rayposition.x = 45.0f; rayposition.y = -75.0f; rayposition.z = 49.0f;
434 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
435 ok(result == FALSE, "Got unexpected result %#x.\n", result);
436
437 raydirection.x = -2.0f; raydirection.y = 4.0f; raydirection.z = -2.0f;
438 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
439 ok(result == TRUE, "Got unexpected result %#x.\n", result);
440
441 rayposition.x = 5.0f; rayposition.y = 11.0f; rayposition.z = 9.0f;
442 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
443 ok(result == FALSE, "Got unexpected result %#x.\n", result);
444
445 raydirection.x = 2.0f; raydirection.y = -4.0f; raydirection.z = 2.0f;
446 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
447 ok(result == FALSE, "Got unexpected result %#x.\n", result);
448
449 radius = 1.0f;
450 rayposition.x = 2.0f; rayposition.y = 2.0f; rayposition.z = 3.0f;
451 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
452 ok(result == FALSE, "Got unexpected result %#x.\n", result);
453
454 raydirection.x = 0.0f; raydirection.y = 0.0f; raydirection.z = 1.0f;
455 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
456 ok(result == TRUE, "Got unexpected result %#x.\n", result);
457
458 if (0)
459 {
460 /* All these crash on native. */
461 D3DXSphereBoundProbe(&center, radius, &rayposition, NULL);
462 D3DXSphereBoundProbe(&center, radius, NULL, &raydirection);
463 D3DXSphereBoundProbe(NULL, radius, &rayposition, &raydirection);
464 }
465}
BOOL WINAPI D3DXSphereBoundProbe(const D3DXVECTOR3 *center, float radius, const D3DXVECTOR3 *ray_position, const D3DXVECTOR3 *ray_direction)
Definition: mesh.c:2411
BOOL WINAPI D3DXBoxBoundProbe(const D3DXVECTOR3 *pmin, const D3DXVECTOR3 *pmax, const D3DXVECTOR3 *prayposition, const D3DXVECTOR3 *praydirection)
Definition: mesh.c:1909
_ACRTIMP double __cdecl sqrt(double)
Definition: sqrt.c:5
GLuint64EXT * result
Definition: glext.h:11304

Referenced by START_TEST().

◆ D3DXComputeBoundingBoxTest()

static void D3DXComputeBoundingBoxTest ( void  )
static

Definition at line 467 of file mesh.c.

468{
469 D3DXVECTOR3 exp_max, exp_min, got_max, got_min, vertex[5];
470 HRESULT hr;
471
472 vertex[0].x = 1.0f; vertex[0].y = 1.0f; vertex[0].z = 1.0f;
473 vertex[1].x = 1.0f; vertex[1].y = 1.0f; vertex[1].z = 1.0f;
474 vertex[2].x = 1.0f; vertex[2].y = 1.0f; vertex[2].z = 1.0f;
475 vertex[3].x = 1.0f; vertex[3].y = 1.0f; vertex[3].z = 1.0f;
476 vertex[4].x = 9.0f; vertex[4].y = 9.0f; vertex[4].z = 9.0f;
477
478 exp_min.x = 1.0f; exp_min.y = 1.0f; exp_min.z = 1.0f;
479 exp_max.x = 9.0f; exp_max.y = 9.0f; exp_max.z = 9.0f;
480
482
483 ok( hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
484 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);
485 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);
486
487/*________________________*/
488
489 vertex[0].x = 2.0f; vertex[0].y = 5.9f; vertex[0].z = -1.2f;
490 vertex[1].x = -1.87f; vertex[1].y = 7.9f; vertex[1].z = 7.4f;
491 vertex[2].x = 7.43f; vertex[2].y = -0.9f; vertex[2].z = 11.9f;
492 vertex[3].x = -6.92f; vertex[3].y = 6.3f; vertex[3].z = -3.8f;
493 vertex[4].x = 11.4f; vertex[4].y = -8.1f; vertex[4].z = 4.5f;
494
495 exp_min.x = -6.92f; exp_min.y = -8.1f; exp_min.z = -3.80f;
496 exp_max.x = 11.4f; exp_max.y = 7.90f; exp_max.z = 11.9f;
497
499
500 ok( hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
501 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);
502 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);
503
504/*________________________*/
505
506 vertex[0].x = 2.0f; vertex[0].y = 5.9f; vertex[0].z = -1.2f;
507 vertex[1].x = -1.87f; vertex[1].y = 7.9f; vertex[1].z = 7.4f;
508 vertex[2].x = 7.43f; vertex[2].y = -0.9f; vertex[2].z = 11.9f;
509 vertex[3].x = -6.92f; vertex[3].y = 6.3f; vertex[3].z = -3.8f;
510 vertex[4].x = 11.4f; vertex[4].y = -8.1f; vertex[4].z = 4.5f;
511
512 exp_min.x = -6.92f; exp_min.y = -0.9f; exp_min.z = -3.8f;
513 exp_max.x = 7.43f; exp_max.y = 7.90f; exp_max.z = 11.9f;
514
516
517 ok( hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
518 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);
519 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);
520
521/*________________________*/
523 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
524
525/*________________________*/
527 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
528
529/*________________________*/
531 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
532}
HRESULT WINAPI D3DXComputeBoundingBox(const D3DXVECTOR3 *pfirstposition, DWORD numvertices, DWORD dwstride, D3DXVECTOR3 *pmin, D3DXVECTOR3 *pmax)
Definition: mesh.c:1962

Referenced by START_TEST().

◆ D3DXComputeBoundingSphereTest()

static void D3DXComputeBoundingSphereTest ( void  )
static

Definition at line 534 of file mesh.c.

535{
536 D3DXVECTOR3 exp_cen, got_cen, vertex[5];
537 FLOAT exp_rad, got_rad;
538 HRESULT hr;
539
540 vertex[0].x = 1.0f; vertex[0].y = 1.0f; vertex[0].z = 1.0f;
541 vertex[1].x = 1.0f; vertex[1].y = 1.0f; vertex[1].z = 1.0f;
542 vertex[2].x = 1.0f; vertex[2].y = 1.0f; vertex[2].z = 1.0f;
543 vertex[3].x = 1.0f; vertex[3].y = 1.0f; vertex[3].z = 1.0f;
544 vertex[4].x = 9.0f; vertex[4].y = 9.0f; vertex[4].z = 9.0f;
545
546 exp_rad = 6.928203f;
547 exp_cen.x = 5.0; exp_cen.y = 5.0; exp_cen.z = 5.0;
548
550
551 ok( hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
552 ok( compare(exp_rad, got_rad), "Expected radius: %f, got radius: %f\n", exp_rad, got_rad);
553 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);
554
555/*________________________*/
556
557 vertex[0].x = 2.0f; vertex[0].y = 5.9f; vertex[0].z = -1.2f;
558 vertex[1].x = -1.87f; vertex[1].y = 7.9f; vertex[1].z = 7.4f;
559 vertex[2].x = 7.43f; vertex[2].y = -0.9f; vertex[2].z = 11.9f;
560 vertex[3].x = -6.92f; vertex[3].y = 6.3f; vertex[3].z = -3.8f;
561 vertex[4].x = 11.4f; vertex[4].y = -8.1f; vertex[4].z = 4.5f;
562
563 exp_rad = 13.707883f;
564 exp_cen.x = 2.408f; exp_cen.y = 2.22f; exp_cen.z = 3.76f;
565
567
568 ok( hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
569 ok( compare(exp_rad, got_rad), "Expected radius: %f, got radius: %f\n", exp_rad, got_rad);
570 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);
571
572/*________________________*/
574 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
575
576/*________________________*/
578 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
579
580/*________________________*/
582 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
583}
HRESULT WINAPI D3DXComputeBoundingSphere(const D3DXVECTOR3 *pfirstposition, DWORD numvertices, DWORD dwstride, D3DXVECTOR3 *pcenter, float *pradius)
Definition: mesh.c:1990

Referenced by START_TEST().

◆ D3DXCreateAnimationControllerTest()

static void D3DXCreateAnimationControllerTest ( void  )
static

Definition at line 11350 of file mesh.c.

11351{
11352 HRESULT hr;
11353 ID3DXAnimationController *animation;
11354 UINT value;
11355
11356 hr = D3DXCreateAnimationController(0, 0, 0, 0, NULL);
11357 ok(hr == D3D_OK, "Got unexpected hr returned %#lx.\n", hr);
11358
11359 animation = (void*)0xdeadbeef;
11360 hr = D3DXCreateAnimationController(0, 1, 1, 1, &animation);
11361 ok(hr == D3D_OK, "Got unexpected hr returned %#lx.\n", hr);
11362 ok(animation == (void*)0xdeadbeef, "Got unexpected animation %p.\n", animation);
11363
11364 animation = (void*)0xdeadbeef;
11365 hr = D3DXCreateAnimationController(1, 0, 1, 1, &animation);
11366 ok(hr == D3D_OK, "Got unexpected hr returned %#lx.\n", hr);
11367 ok(animation == (void*)0xdeadbeef, "Got unexpected animation %p.\n", animation);
11368
11369 animation = (void*)0xdeadbeef;
11370 hr = D3DXCreateAnimationController(1, 1, 0, 1, &animation);
11371 ok(hr == D3D_OK, "Got unexpected hr returned %#lx.\n", hr);
11372 ok(animation == (void*)0xdeadbeef, "Got unexpected animation %p.\n", animation);
11373
11374 animation = (void*)0xdeadbeef;
11375 hr = D3DXCreateAnimationController(1, 1, 1, 0, &animation);
11376 ok(hr == D3D_OK, "Got unexpected hr returned %#lx.\n", hr);
11377 ok(animation == (void*)0xdeadbeef, "Got unexpected animation %p.\n", animation);
11378
11379 hr = D3DXCreateAnimationController(1, 1, 1, 1, &animation);
11380 ok(hr == D3D_OK, "Got unexpected hr returned %#lx.\n", hr);
11381
11382 value = animation->lpVtbl->GetMaxNumAnimationOutputs(animation);
11383 ok(value == 1, "Got unexpected value %u.\n", value);
11384
11385 value = animation->lpVtbl->GetMaxNumAnimationSets(animation);
11386 ok(value == 1, "Got unexpected value %u.\n", value);
11387
11388 value = animation->lpVtbl->GetMaxNumTracks(animation);
11389 ok(value == 1, "Got unexpected value %u.\n", value);
11390
11391 value = animation->lpVtbl->GetMaxNumEvents(animation);
11392 ok(value == 1, "Got unexpected value %u.\n", value);
11393
11394 animation->lpVtbl->Release(animation);
11395
11396 hr = D3DXCreateAnimationController(100, 101, 102, 103, &animation);
11397 ok(hr == D3D_OK, "Got unexpected hr returned %#lx.\n", hr);
11398
11399 value = animation->lpVtbl->GetMaxNumAnimationOutputs(animation);
11400 ok(value == 100, "Got unexpected value %u.\n", value);
11401
11402 value = animation->lpVtbl->GetMaxNumAnimationSets(animation);
11403 ok(value == 101, "Got unexpected value %u.\n", value);
11404
11405 value = animation->lpVtbl->GetMaxNumTracks(animation);
11406 ok(value == 102, "Got unexpected value %u.\n", value);
11407
11408 value = animation->lpVtbl->GetMaxNumEvents(animation);
11409 ok(value == 103, "Got unexpected value %u.\n", value);
11410
11411 animation->lpVtbl->Release(animation);
11412}
HRESULT WINAPI D3DXCreateAnimationController(UINT max_outputs, UINT max_sets, UINT max_tracks, UINT max_events, ID3DXAnimationController **controller)
Definition: animation.c:444
unsigned int UINT
Definition: sysinfo.c:13
Definition: pdh_main.c:64

Referenced by START_TEST().

◆ D3DXCreateBoxTest()

static void D3DXCreateBoxTest ( void  )
static

Definition at line 2851 of file mesh.c.

2852{
2853 HRESULT hr;
2855 ID3DXMesh* box;
2856 ID3DXBuffer* ppBuffer;
2857 DWORD *buffer;
2858 static const DWORD adjacency[36]=
2859 {6, 9, 1, 2, 10, 0,
2860 1, 9, 3, 4, 10, 2,
2861 3, 8, 5, 7, 11, 4,
2862 0, 11, 7, 5, 8, 6,
2863 7, 4, 9, 2, 0, 8,
2864 1, 3, 11, 5, 6, 10};
2865 unsigned int i;
2866 struct test_context *test_context;
2867
2868 if (!(test_context = new_test_context()))
2869 {
2870 skip("Couldn't create test context\n");
2871 return;
2872 }
2874
2875 hr = D3DXCreateBox(device,2.0f,20.0f,4.9f,NULL, &ppBuffer);
2876 ok(hr==D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#lx\n", hr);
2877
2878 hr = D3DXCreateBox(NULL,22.0f,20.0f,4.9f,&box, &ppBuffer);
2879 ok(hr==D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#lx\n", hr);
2880
2881 hr = D3DXCreateBox(device,-2.0f,20.0f,4.9f,&box, &ppBuffer);
2882 ok(hr==D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#lx\n", hr);
2883
2884 hr = D3DXCreateBox(device,22.0f,-20.0f,4.9f,&box, &ppBuffer);
2885 ok(hr==D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#lx\n", hr);
2886
2887 hr = D3DXCreateBox(device,22.0f,20.0f,-4.9f,&box, &ppBuffer);
2888 ok(hr==D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#lx\n", hr);
2889
2890 ppBuffer = NULL;
2891 hr = D3DXCreateBox(device,10.9f,20.0f,4.9f,&box, &ppBuffer);
2892 ok(hr==D3D_OK, "Expected D3D_OK, received %#lx\n", hr);
2893
2895 for(i=0; i<36; i++)
2896 ok(adjacency[i]==buffer[i], "expected adjacency %d: %#lx, received %#lx\n",i,adjacency[i], buffer[i]);
2897
2898 box->lpVtbl->Release(box);
2899 ID3DXBuffer_Release(ppBuffer);
2900
2901 test_box(device, 10.9f, 20.0f, 4.9f);
2902
2904}
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
HRESULT WINAPI D3DXCreateBox(struct IDirect3DDevice9 *device, float width, float height, float depth, struct ID3DXMesh **mesh, struct ID3DXBuffer **adjacency)
Definition: mesh.c:4760
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
DWORD IDirect3DDevice9
Definition: dxva2api.idl:22
GLuint buffer
Definition: glext.h:5915
static struct test_context * new_test_context(void)
Definition: mesh.c:112
static void test_box(IDirect3DDevice9 *device, float width, float height, float depth)
Definition: mesh.c:2820
static void free_test_context(struct test_context *test_context)
Definition: mesh.c:171
Definition: palette.c:466
ID3D11Device * device
Definition: hlsl_d3d11.c:90

Referenced by START_TEST().

◆ D3DXCreateCylinderTest()

static void D3DXCreateCylinderTest ( void  )
static

Definition at line 3480 of file mesh.c.

3481{
3482 HRESULT hr;
3484 ID3DXMesh* cylinder = NULL;
3485 struct test_context *test_context;
3486
3487 hr = D3DXCreateCylinder(NULL, 0.0f, 0.0f, 0.0f, 0, 0, NULL, NULL);
3488 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3489
3490 hr = D3DXCreateCylinder(NULL, 1.0f, 1.0f, 1.0f, 2, 1, &cylinder, NULL);
3491 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3492
3493 if (!(test_context = new_test_context()))
3494 {
3495 skip("Couldn't create test context\n");
3496 return;
3497 }
3499
3500 hr = D3DXCreateCylinder(device, -0.1f, 1.0f, 1.0f, 2, 1, &cylinder, NULL);
3501 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3502
3503 hr = D3DXCreateCylinder(device, 0.0f, 1.0f, 1.0f, 2, 1, &cylinder, NULL);
3504 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n",hr);
3505
3506 if (SUCCEEDED(hr) && cylinder)
3507 {
3508 cylinder->lpVtbl->Release(cylinder);
3509 }
3510
3511 hr = D3DXCreateCylinder(device, 1.0f, -0.1f, 1.0f, 2, 1, &cylinder, NULL);
3512 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3513
3514 hr = D3DXCreateCylinder(device, 1.0f, 0.0f, 1.0f, 2, 1, &cylinder, NULL);
3515 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n",hr);
3516
3517 if (SUCCEEDED(hr) && cylinder)
3518 {
3519 cylinder->lpVtbl->Release(cylinder);
3520 }
3521
3522 hr = D3DXCreateCylinder(device, 1.0f, 1.0f, -0.1f, 2, 1, &cylinder, NULL);
3523 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3524
3525 /* Test with length == 0.0f succeeds */
3526 hr = D3DXCreateCylinder(device, 1.0f, 1.0f, 0.0f, 2, 1, &cylinder, NULL);
3527 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n",hr);
3528
3529 if (SUCCEEDED(hr) && cylinder)
3530 {
3531 cylinder->lpVtbl->Release(cylinder);
3532 }
3533
3534 hr = D3DXCreateCylinder(device, 1.0f, 1.0f, 1.0f, 1, 1, &cylinder, NULL);
3535 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3536
3537 hr = D3DXCreateCylinder(device, 1.0f, 1.0f, 1.0f, 2, 0, &cylinder, NULL);
3538 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3539
3540 hr = D3DXCreateCylinder(device, 1.0f, 1.0f, 1.0f, 2, 1, NULL, NULL);
3541 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3542
3543 test_cylinder(device, 0.0f, 0.0f, 0.0f, 2, 1);
3544 test_cylinder(device, 1.0f, 1.0f, 1.0f, 2, 1);
3545 test_cylinder(device, 1.0f, 1.0f, 2.0f, 3, 4);
3546 test_cylinder(device, 3.0f, 2.0f, 4.0f, 3, 4);
3547 test_cylinder(device, 2.0f, 3.0f, 4.0f, 3, 4);
3548 test_cylinder(device, 3.0f, 4.0f, 5.0f, 11, 20);
3549
3551}
GLUquadricObj * cylinder
Definition: cylfrac.c:44
HRESULT WINAPI D3DXCreateCylinder(struct IDirect3DDevice9 *device, float radius1, float radius2, float length, UINT slices, UINT stacks, struct ID3DXMesh **mesh, struct ID3DXBuffer **adjacency)
Definition: mesh.c:5082
static void test_cylinder(IDirect3DDevice9 *device, FLOAT radius1, FLOAT radius2, FLOAT length, UINT slices, UINT stacks)
Definition: mesh.c:3448

Referenced by START_TEST().

◆ D3DXCreateKeyframedAnimationSetTest()

static void D3DXCreateKeyframedAnimationSetTest ( void  )
static

Definition at line 11414 of file mesh.c.

11415{
11416 ID3DXKeyframedAnimationSet *set;
11418 unsigned int count;
11419 const char *name;
11420 HRESULT hr;
11421
11422 hr = D3DXCreateKeyframedAnimationSet("wine_bottle", 5.0, D3DXPLAY_LOOP, 0, 0, NULL, &set);
11423 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
11424
11425 hr = D3DXCreateKeyframedAnimationSet("wine_bottle", 5.0, D3DXPLAY_LOOP, 10, 0, NULL, &set);
11426 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
11427
11428 name = set->lpVtbl->GetName(set);
11429 ok(!strcmp(name, "wine_bottle"), "Got unexpected name %s.\n", debugstr_a(name));
11430
11431 type = set->lpVtbl->GetPlaybackType(set);
11432 ok(type == D3DXPLAY_LOOP, "Got unexpected value %u.\n", type);
11433
11434 count = set->lpVtbl->GetNumAnimations(set);
11435 ok(!count, "Got unexpected value %u.\n", count);
11436
11437 set->lpVtbl->Release(set);
11438}
HRESULT WINAPI D3DXCreateKeyframedAnimationSet(const char *name, double ticks_per_second, D3DXPLAYBACK_TYPE playback_type, UINT animation_count, UINT callback_key_count, const D3DXKEY_CALLBACK *callback_keys, ID3DXKeyframedAnimationSet **animation_set)
Definition: animation.c:858
Definition: _set.h:50
enum _D3DXPLAYBACK_TYPE D3DXPLAYBACK_TYPE
@ D3DXPLAY_LOOP
Definition: d3dx9anim.h:44
#define debugstr_a
Definition: kernel32.h:31

Referenced by START_TEST().

◆ D3DXCreateMeshFVFTest()

static void D3DXCreateMeshFVFTest ( void  )
static

Definition at line 1399 of file mesh.c.

1400{
1401 HRESULT hr;
1402 IDirect3DDevice9 *device, *test_device;
1403 ID3DXMesh *d3dxmesh;
1404 int i, size;
1406 DWORD options;
1407 struct mesh mesh;
1408 struct test_context *test_context;
1409
1410 static const D3DVERTEXELEMENT9 decl[] =
1411 {
1414 D3DDECL_END(),
1415 };
1416
1417 hr = D3DXCreateMeshFVF(0, 0, 0, 0, NULL, NULL);
1418 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1419
1421 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1422
1424 if (!test_context)
1425 {
1426 skip("Couldn't create test context\n");
1427 return;
1428 }
1430
1432 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1433
1435 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1436
1437 hr = D3DXCreateMeshFVF(1, 3, 0, D3DFVF_XYZ | D3DFVF_NORMAL, device, &d3dxmesh);
1438 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
1439
1440 if (hr == D3D_OK)
1441 {
1442 d3dxmesh->lpVtbl->Release(d3dxmesh);
1443 }
1444
1445 hr = D3DXCreateMeshFVF(1, 3, D3DXMESH_MANAGED, 0xdeadbeef, device, &d3dxmesh);
1446 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1447
1449 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1450
1452 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
1453
1454 if (hr == D3D_OK)
1455 {
1456 /* device */
1457 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh, NULL);
1458 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1459
1460 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh, &test_device);
1461 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
1462 ok(test_device == device, "Got result %p, expected %p\n", test_device, device);
1463
1464 if (hr == D3D_OK)
1465 {
1467 }
1468
1469 /* declaration */
1470 hr = d3dxmesh->lpVtbl->GetDeclaration(d3dxmesh, NULL);
1471 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1472
1473 hr = d3dxmesh->lpVtbl->GetDeclaration(d3dxmesh, test_decl);
1474 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
1475
1476 if (hr == D3D_OK)
1477 {
1478 size = ARRAY_SIZE(decl);
1479 for (i = 0; i < size - 1; i++)
1480 {
1481 ok(test_decl[i].Stream == decl[i].Stream, "Returned stream %d, expected %d\n", test_decl[i].Stream, decl[i].Stream);
1482 ok(test_decl[i].Type == decl[i].Type, "Returned type %d, expected %d\n", test_decl[i].Type, decl[i].Type);
1483 ok(test_decl[i].Method == decl[i].Method, "Returned method %d, expected %d\n", test_decl[i].Method, decl[i].Method);
1484 ok(test_decl[i].Usage == decl[i].Usage, "Returned usage %d, expected %d\n", test_decl[i].Usage, decl[i].Usage);
1485 ok(test_decl[i].UsageIndex == decl[i].UsageIndex, "Returned usage index %d, expected %d\n",
1486 test_decl[i].UsageIndex, decl[i].UsageIndex);
1487 ok(test_decl[i].Offset == decl[i].Offset, "Returned offset %d, expected %d\n", test_decl[i].Offset, decl[i].Offset);
1488 }
1489 ok(decl[size-1].Stream == 0xFF, "Returned too long vertex declaration\n"); /* end element */
1490 }
1491
1492 /* options */
1493 options = d3dxmesh->lpVtbl->GetOptions(d3dxmesh);
1494 ok(options == D3DXMESH_MANAGED, "Got result %lx, expected %x (D3DXMESH_MANAGED)\n", options, D3DXMESH_MANAGED);
1495
1496 /* rest */
1497 if (!new_mesh(&mesh, 3, 1))
1498 {
1499 skip("Couldn't create mesh\n");
1500 }
1501 else
1502 {
1504 memset(mesh.faces, 0, mesh.number_of_faces * sizeof(*mesh.faces));
1506
1507 compare_mesh("createmeshfvf", d3dxmesh, &mesh);
1508
1509 free_mesh(&mesh);
1510 }
1511
1512 d3dxmesh->lpVtbl->Release(d3dxmesh);
1513 }
1514
1516}
Type
Definition: Type.h:7
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1336
@ D3DDECLUSAGE_POSITION
Definition: d3d9types.h:236
@ D3DDECLMETHOD_DEFAULT
Definition: d3d9types.h:258
HRESULT WINAPI D3DXCreateMeshFVF(DWORD face_count, DWORD vertex_count, DWORD options, DWORD fvf, struct IDirect3DDevice9 *device, struct ID3DXMesh **mesh)
Definition: mesh.c:2577
@ D3DXMESH_MANAGED
Definition: d3dx9mesh.h:64
GLsizeiptr size
Definition: glext.h:5919
static void free_mesh(struct mesh *mesh)
Definition: mesh.c:200
static void compare_mesh(const char *name, ID3DXMesh *d3dxmesh, struct mesh *mesh)
Definition: mesh.c:226
static IStream Stream
Definition: htmldoc.c:1115
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ D3DXCreateMeshTest()

static void D3DXCreateMeshTest ( void  )
static

Definition at line 1193 of file mesh.c.

1194{
1195 HRESULT hr;
1196 IDirect3DDevice9 *device, *test_device;
1197 ID3DXMesh *d3dxmesh;
1198 int i, size;
1200 DWORD options;
1201 struct mesh mesh;
1202 struct test_context *test_context;
1203
1204 static const D3DVERTEXELEMENT9 decl1[] =
1205 {
1208 D3DDECL_END(),
1209 };
1210
1211 static const D3DVERTEXELEMENT9 decl2[] =
1212 {
1218 /* 8 bytes padding */
1220 D3DDECL_END(),
1221 };
1222
1223 static const D3DVERTEXELEMENT9 decl3[] =
1224 {
1227 D3DDECL_END(),
1228 };
1229
1230 hr = D3DXCreateMesh(0, 0, 0, NULL, NULL, NULL);
1231 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1232
1233 hr = D3DXCreateMesh(1, 3, D3DXMESH_MANAGED, decl1, NULL, &d3dxmesh);
1234 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1235
1237 if (!test_context)
1238 {
1239 skip("Couldn't create test context\n");
1240 return;
1241 }
1243
1244 hr = D3DXCreateMesh(0, 3, D3DXMESH_MANAGED, decl1, device, &d3dxmesh);
1245 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1246
1247 hr = D3DXCreateMesh(1, 0, D3DXMESH_MANAGED, decl1, device, &d3dxmesh);
1248 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1249
1250 hr = D3DXCreateMesh(1, 3, 0, decl1, device, &d3dxmesh);
1251 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
1252
1253 if (hr == D3D_OK)
1254 {
1255 d3dxmesh->lpVtbl->Release(d3dxmesh);
1256 }
1257
1258 hr = D3DXCreateMesh(1, 3, D3DXMESH_MANAGED, 0, device, &d3dxmesh);
1259 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1260
1261 hr = D3DXCreateMesh(1, 3, D3DXMESH_MANAGED, decl1, device, NULL);
1262 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1263
1264 hr = D3DXCreateMesh(1, 3, D3DXMESH_MANAGED, decl1, device, &d3dxmesh);
1265 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
1266
1267 if (hr == D3D_OK)
1268 {
1269 /* device */
1270 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh, NULL);
1271 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1272
1273 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh, &test_device);
1274 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
1275 ok(test_device == device, "Got result %p, expected %p\n", test_device, device);
1276
1277 if (hr == D3D_OK)
1278 {
1280 }
1281
1282 /* declaration */
1283 hr = d3dxmesh->lpVtbl->GetDeclaration(d3dxmesh, NULL);
1284 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1285
1286 hr = d3dxmesh->lpVtbl->GetDeclaration(d3dxmesh, test_decl);
1287 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
1288
1289 if (hr == D3D_OK)
1290 {
1291 size = ARRAY_SIZE(decl1);
1292 for (i = 0; i < size - 1; i++)
1293 {
1294 ok(test_decl[i].Stream == decl1[i].Stream, "Returned stream %d, expected %d\n", test_decl[i].Stream, decl1[i].Stream);
1295 ok(test_decl[i].Type == decl1[i].Type, "Returned type %d, expected %d\n", test_decl[i].Type, decl1[i].Type);
1296 ok(test_decl[i].Method == decl1[i].Method, "Returned method %d, expected %d\n", test_decl[i].Method, decl1[i].Method);
1297 ok(test_decl[i].Usage == decl1[i].Usage, "Returned usage %d, expected %d\n", test_decl[i].Usage, decl1[i].Usage);
1298 ok(test_decl[i].UsageIndex == decl1[i].UsageIndex, "Returned usage index %d, expected %d\n", test_decl[i].UsageIndex, decl1[i].UsageIndex);
1299 ok(test_decl[i].Offset == decl1[i].Offset, "Returned offset %d, expected %d\n", test_decl[i].Offset, decl1[i].Offset);
1300 }
1301 ok(decl1[size-1].Stream == 0xFF, "Returned too long vertex declaration\n"); /* end element */
1302 }
1303
1304 /* options */
1305 options = d3dxmesh->lpVtbl->GetOptions(d3dxmesh);
1306 ok(options == D3DXMESH_MANAGED, "Got result %lx, expected %x (D3DXMESH_MANAGED)\n", options, D3DXMESH_MANAGED);
1307
1308 /* rest */
1309 if (!new_mesh(&mesh, 3, 1))
1310 {
1311 skip("Couldn't create mesh\n");
1312 }
1313 else
1314 {
1316 memset(mesh.faces, 0, mesh.number_of_faces * sizeof(*mesh.faces));
1318
1319 compare_mesh("createmesh1", d3dxmesh, &mesh);
1320
1321 free_mesh(&mesh);
1322 }
1323
1324 d3dxmesh->lpVtbl->Release(d3dxmesh);
1325 }
1326
1327 /* Test a declaration that can't be converted to an FVF. */
1328 hr = D3DXCreateMesh(1, 3, D3DXMESH_MANAGED, decl2, device, &d3dxmesh);
1329 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
1330
1331 if (hr == D3D_OK)
1332 {
1333 /* device */
1334 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh, NULL);
1335 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1336
1337 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh, &test_device);
1338 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
1339 ok(test_device == device, "Got result %p, expected %p\n", test_device, device);
1340
1341 if (hr == D3D_OK)
1342 {
1344 }
1345
1346 /* declaration */
1347 hr = d3dxmesh->lpVtbl->GetDeclaration(d3dxmesh, test_decl);
1348 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
1349
1350 if (hr == D3D_OK)
1351 {
1352 size = ARRAY_SIZE(decl2);
1353 for (i = 0; i < size - 1; i++)
1354 {
1355 ok(test_decl[i].Stream == decl2[i].Stream, "Returned stream %d, expected %d\n", test_decl[i].Stream, decl2[i].Stream);
1356 ok(test_decl[i].Type == decl2[i].Type, "Returned type %d, expected %d\n", test_decl[i].Type, decl2[i].Type);
1357 ok(test_decl[i].Method == decl2[i].Method, "Returned method %d, expected %d\n", test_decl[i].Method, decl2[i].Method);
1358 ok(test_decl[i].Usage == decl2[i].Usage, "Returned usage %d, expected %d\n", test_decl[i].Usage, decl2[i].Usage);
1359 ok(test_decl[i].UsageIndex == decl2[i].UsageIndex, "Returned usage index %d, expected %d\n", test_decl[i].UsageIndex, decl2[i].UsageIndex);
1360 ok(test_decl[i].Offset == decl2[i].Offset, "Returned offset %d, expected %d\n", test_decl[i].Offset, decl2[i].Offset);
1361 }
1362 ok(decl2[size-1].Stream == 0xFF, "Returned too long vertex declaration\n"); /* end element */
1363 }
1364
1365 /* options */
1366 options = d3dxmesh->lpVtbl->GetOptions(d3dxmesh);
1367 ok(options == D3DXMESH_MANAGED, "Got result %lx, expected %x (D3DXMESH_MANAGED)\n", options, D3DXMESH_MANAGED);
1368
1369 /* rest */
1370 if (!new_mesh(&mesh, 3, 1))
1371 {
1372 skip("Couldn't create mesh\n");
1373 }
1374 else
1375 {
1377 memset(mesh.faces, 0, mesh.number_of_faces * sizeof(*mesh.faces));
1378 mesh.fvf = 0;
1379 mesh.vertex_size = 60;
1380
1381 compare_mesh("createmesh2", d3dxmesh, &mesh);
1382
1383 free_mesh(&mesh);
1384 }
1385
1386 mesh.vertex_size = d3dxmesh->lpVtbl->GetNumBytesPerVertex(d3dxmesh);
1387 ok(mesh.vertex_size == 60, "Got vertex size %u, expected %u\n", mesh.vertex_size, 60);
1388
1389 d3dxmesh->lpVtbl->Release(d3dxmesh);
1390 }
1391
1392 /* Test a declaration with multiple streams. */
1393 hr = D3DXCreateMesh(1, 3, D3DXMESH_MANAGED, decl3, device, &d3dxmesh);
1394 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1395
1397}
@ D3DDECLUSAGE_TEXCOORD
Definition: d3d9types.h:241
@ D3DDECLUSAGE_PSIZE
Definition: d3d9types.h:240
@ D3DDECLUSAGE_COLOR
Definition: d3d9types.h:246
HRESULT WINAPI D3DXCreateMesh(DWORD numfaces, DWORD numvertices, DWORD options, const D3DVERTEXELEMENT9 *declaration, struct IDirect3DDevice9 *device, struct ID3DXMesh **mesh)
Definition: mesh.c:2431

Referenced by START_TEST().

◆ D3DXCreatePolygonTest()

static void D3DXCreatePolygonTest ( void  )
static

Definition at line 2976 of file mesh.c.

2977{
2978 HRESULT hr;
2980 ID3DXMesh *polygon;
2981 ID3DXBuffer *adjacency;
2982 DWORD (*buffer)[3], buffer_size;
2983 unsigned int i;
2984 struct test_context *test_context;
2985
2986 if (!(test_context = new_test_context()))
2987 {
2988 skip("Couldn't create test context\n");
2989 return;
2990 }
2992
2993 hr = D3DXCreatePolygon(device, 2.0f, 11, NULL, &adjacency);
2994 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#lx\n", hr);
2995
2996 hr = D3DXCreatePolygon(NULL, 2.0f, 11, &polygon, &adjacency);
2997 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#lx\n", hr);
2998
2999 hr = D3DXCreatePolygon(device, -2.0f, 11, &polygon, &adjacency);
3000 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#lx\n", hr);
3001
3002 polygon = (void *)0xdeadbeef;
3003 adjacency = (void *)0xdeadbeef;
3004 hr = D3DXCreatePolygon(device, 2.0f, 0, &polygon, &adjacency);
3005 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#lx\n", hr);
3006 ok(polygon == (void *)0xdeadbeef, "Polygon was changed to %p\n", polygon);
3007 ok(adjacency == (void *)0xdeadbeef, "Adjacency was changed to %p\n", adjacency);
3008
3009 hr = D3DXCreatePolygon(device, 2.0f, 2, &polygon, &adjacency);
3010 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#lx\n", hr);
3011
3012 adjacency = NULL;
3013 hr = D3DXCreatePolygon(device, 3.0f, 11, &polygon, &adjacency);
3014 ok(hr == D3D_OK, "Expected D3D_OK, received %#lx\n", hr);
3015
3017 ok(buffer_size == 33 * sizeof(DWORD), "Wrong adjacency buffer size %lu\n", buffer_size);
3018
3020 for (i = 0; i < 11; ++i)
3021 {
3022 ok(buffer[i][0] == (i + 10) % 11, "Wrong adjacency[%d][0] = %lu\n", i, buffer[i][0]);
3023 ok(buffer[i][1] == ~0U, "Wrong adjacency[%d][1] = %lu\n", i, buffer[i][1]);
3024 ok(buffer[i][2] == (i + 1) % 11, "Wrong adjacency[%d][2] = %lu\n", i, buffer[i][2]);
3025 }
3026
3027 polygon->lpVtbl->Release(polygon);
3028 ID3DXBuffer_Release(adjacency);
3029
3030 test_polygon(device, 2.0f, 3);
3031 test_polygon(device, 10.0f, 3);
3032 test_polygon(device, 10.0f, 5);
3033 test_polygon(device, 10.0f, 10);
3034 test_polygon(device, 20.0f, 10);
3035 test_polygon(device, 20.0f, 32000);
3036
3038}
#define U(x)
Definition: wordpad.c:45
HRESULT WINAPI D3DXCreatePolygon(struct IDirect3DDevice9 *device, float length, UINT sides, struct ID3DXMesh **mesh, struct ID3DXBuffer **adjacency)
Definition: mesh.c:4670
#define ID3DXBuffer_GetBufferSize(p)
Definition: d3dx9core.h:86
static void test_polygon(void)
Definition: graphicspath.c:799
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95

Referenced by START_TEST().

◆ D3DXCreateSphereTest()

static void D3DXCreateSphereTest ( void  )
static

Definition at line 3253 of file mesh.c.

3254{
3255 HRESULT hr;
3257 ID3DXMesh* sphere = NULL;
3258 struct test_context *test_context;
3259
3260 hr = D3DXCreateSphere(NULL, 0.0f, 0, 0, NULL, NULL);
3261 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3262
3263 hr = D3DXCreateSphere(NULL, 0.1f, 0, 0, NULL, NULL);
3264 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3265
3266 hr = D3DXCreateSphere(NULL, 0.0f, 1, 0, NULL, NULL);
3267 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3268
3269 hr = D3DXCreateSphere(NULL, 0.0f, 0, 1, NULL, NULL);
3270 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3271
3272 if (!(test_context = new_test_context()))
3273 {
3274 skip("Couldn't create test context\n");
3275 return;
3276 }
3278
3279 hr = D3DXCreateSphere(device, 1.0f, 1, 1, &sphere, NULL);
3280 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3281
3282 hr = D3DXCreateSphere(device, 1.0f, 2, 1, &sphere, NULL);
3283 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
3284
3285 hr = D3DXCreateSphere(device, 1.0f, 1, 2, &sphere, NULL);
3286 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
3287
3288 hr = D3DXCreateSphere(device, -0.1f, 1, 2, &sphere, NULL);
3289 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
3290
3291 test_sphere(device, 0.0f, 2, 2);
3292 test_sphere(device, 1.0f, 2, 2);
3293 test_sphere(device, 1.0f, 3, 2);
3294 test_sphere(device, 1.0f, 4, 4);
3295 test_sphere(device, 1.0f, 3, 4);
3296 test_sphere(device, 5.0f, 6, 7);
3297 test_sphere(device, 10.0f, 11, 12);
3298
3300}
HRESULT WINAPI D3DXCreateSphere(struct IDirect3DDevice9 *device, float radius, UINT slices, UINT stacks, struct ID3DXMesh **mesh, struct ID3DXBuffer **adjacency)
Definition: mesh.c:4902
static void test_sphere(IDirect3DDevice9 *device, FLOAT radius, UINT slices, UINT stacks)
Definition: mesh.c:3221

Referenced by START_TEST().

◆ D3DXCreateTextTest()

static void D3DXCreateTextTest ( void  )
static

Definition at line 4524 of file mesh.c.

4525{
4526 HRESULT hr;
4527 HDC hdc;
4529 ID3DXMesh* d3dxmesh = NULL;
4530 HFONT hFont;
4532 int number_of_vertices;
4533 int number_of_faces;
4534 struct test_context *test_context;
4535
4536 if (!(test_context = new_test_context()))
4537 {
4538 skip("Couldn't create test context\n");
4539 return;
4540 }
4542
4544
4548 GetOutlineTextMetricsA(hdc, sizeof(otm), &otm);
4549
4550 hr = D3DXCreateTextA(device, hdc, "wine", 0.001f, 0.4f, NULL, NULL, NULL);
4551 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
4552
4553 /* D3DXCreateTextA page faults from passing NULL text */
4554
4555 hr = D3DXCreateTextW(device, hdc, NULL, 0.001f, 0.4f, &d3dxmesh, NULL, NULL);
4556 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
4557
4558 hr = D3DXCreateTextA(device, hdc, "", 0.001f, 0.4f, &d3dxmesh, NULL, NULL);
4559 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
4560
4561 hr = D3DXCreateTextA(device, hdc, " ", 0.001f, 0.4f, &d3dxmesh, NULL, NULL);
4562 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
4563
4564 hr = D3DXCreateTextA(NULL, hdc, "wine", 0.001f, 0.4f, &d3dxmesh, NULL, NULL);
4565 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
4566
4567 hr = D3DXCreateTextA(device, NULL, "wine", 0.001f, 0.4f, &d3dxmesh, NULL, NULL);
4568 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
4569
4570 hr = D3DXCreateTextA(device, hdc, "wine", -FLT_MIN, 0.4f, &d3dxmesh, NULL, NULL);
4571 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
4572
4573 hr = D3DXCreateTextA(device, hdc, "wine", 0.001f, -FLT_MIN, &d3dxmesh, NULL, NULL);
4574 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
4575
4576 /* deviation = 0.0f treated as if deviation = 1.0f / otm.otmEMSquare */
4577 hr = D3DXCreateTextA(device, hdc, "wine", 1.0f / otm.otmEMSquare, 0.4f, &d3dxmesh, NULL, NULL);
4578 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
4579 number_of_vertices = d3dxmesh->lpVtbl->GetNumVertices(d3dxmesh);
4580 number_of_faces = d3dxmesh->lpVtbl->GetNumFaces(d3dxmesh);
4581 d3dxmesh->lpVtbl->Release(d3dxmesh);
4582
4583 hr = D3DXCreateTextA(device, hdc, "wine", 0.0f, 0.4f, &d3dxmesh, NULL, NULL);
4584 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
4585 ok(number_of_vertices == d3dxmesh->lpVtbl->GetNumVertices(d3dxmesh),
4586 "Got %ld vertices, expected %d\n",
4587 d3dxmesh->lpVtbl->GetNumVertices(d3dxmesh), number_of_vertices);
4588 ok(number_of_faces == d3dxmesh->lpVtbl->GetNumFaces(d3dxmesh),
4589 "Got %ld faces, expected %d\n",
4590 d3dxmesh->lpVtbl->GetNumVertices(d3dxmesh), number_of_faces);
4591 d3dxmesh->lpVtbl->Release(d3dxmesh);
4592
4593if (0)
4594{
4595 /* too much detail requested, so will appear to hang */
4596 trace("Waiting for D3DXCreateText to finish with deviation = FLT_MIN ...\n");
4597 hr = D3DXCreateTextA(device, hdc, "wine", FLT_MIN, 0.4f, &d3dxmesh, NULL, NULL);
4598 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
4599 if (SUCCEEDED(hr) && d3dxmesh) d3dxmesh->lpVtbl->Release(d3dxmesh);
4600 trace("D3DXCreateText finish with deviation = FLT_MIN\n");
4601}
4602
4603 hr = D3DXCreateTextA(device, hdc, "wine", 0.001f, 0.4f, &d3dxmesh, NULL, NULL);
4604 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
4605 if (SUCCEEDED(hr) && d3dxmesh) d3dxmesh->lpVtbl->Release(d3dxmesh);
4606
4607 test_createtext(device, hdc, "wine", FLT_MAX, 0.4f);
4608 test_createtext(device, hdc, "wine", 0.001f, FLT_MIN);
4609 test_createtext(device, hdc, "wine", 0.001f, 0.0f);
4610 test_createtext(device, hdc, "wine", 0.001f, FLT_MAX);
4611 test_createtext(device, hdc, "wine", 0.0f, 1.0f);
4612 test_createtext(device, hdc, " wine", 1.0f, 0.0f);
4613 test_createtext(device, hdc, "wine ", 1.0f, 0.0f);
4614 test_createtext(device, hdc, "wi ne", 1.0f, 0.0f);
4615
4616 DeleteDC(hdc);
4618
4620}
HFONT hFont
Definition: main.c:53
HRESULT WINAPI D3DXCreateTextA(struct IDirect3DDevice9 *device, HDC hdc, const char *text, float deviation, float extrusion, struct ID3DXMesh **mesh, struct ID3DXBuffer **adjacency, GLYPHMETRICSFLOAT *glyphmetrics)
Definition: mesh.c:5284
HRESULT WINAPI D3DXCreateTextW(struct IDirect3DDevice9 *device, HDC hdc, const WCHAR *text, float deviation, float extrusion, struct ID3DXMesh **mesh_ptr, struct ID3DXBuffer **adjacency, GLYPHMETRICSFLOAT *glyphmetrics)
Definition: mesh.c:6192
#define FLT_MAX
Definition: float.h:37
#define FLT_MIN
Definition: float.h:40
pKey DeleteObject()
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static void test_createtext(IDirect3DDevice9 *device, HDC hdc, const char *text, float deviation, float extrusion)
Definition: mesh.c:4440
#define DEFAULT_PITCH
Definition: wingdi.h:443
UINT WINAPI GetOutlineTextMetricsA(_In_ HDC hdc, _In_ UINT cjCopy, _Out_writes_bytes_opt_(cjCopy) LPOUTLINETEXTMETRICA potm)
#define DEFAULT_QUALITY
Definition: wingdi.h:436
#define FF_DONTCARE
Definition: wingdi.h:448
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
#define FW_NORMAL
Definition: wingdi.h:373
HFONT WINAPI CreateFontA(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCSTR)
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by START_TEST().

◆ D3DXCreateTorusTest()

static void D3DXCreateTorusTest ( void  )
static

Definition at line 3644 of file mesh.c.

3645{
3646 HRESULT hr;
3648 ID3DXMesh* torus = NULL;
3649 struct test_context *test_context;
3650
3651 if (!(test_context = new_test_context()))
3652 {
3653 skip("Couldn't create test context\n");
3654 return;
3655 }
3657
3658 hr = D3DXCreateTorus(NULL, 0.0f, 0.0f, 3, 3, &torus, NULL);
3659 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx, expected %#lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
3660
3661 hr = D3DXCreateTorus(device, -1.0f, 0.0f, 3, 3, &torus, NULL);
3662 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx, expected %#lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
3663
3664 hr = D3DXCreateTorus(device, 0.0f, -1.0f, 3, 3, &torus, NULL);
3665 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx, expected %#lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
3666
3667 hr = D3DXCreateTorus(device, 0.0f, 0.0f, 2, 3, &torus, NULL);
3668 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx, expected %#lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
3669
3670 hr = D3DXCreateTorus(device, 0.0f, 0.0f, 3, 2, &torus, NULL);
3671 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx, expected %#lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
3672
3673 hr = D3DXCreateTorus(device, 0.0f, 0.0f, 3, 3, NULL, NULL);
3674 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx, expected %#lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
3675
3676 test_torus(device, 0.0f, 0.0f, 3, 3);
3677 test_torus(device, 1.0f, 1.0f, 3, 3);
3678 test_torus(device, 1.0f, 1.0f, 32, 64);
3679 test_torus(device, 0.0f, 1.0f, 5, 5);
3680 test_torus(device, 1.0f, 0.0f, 5, 5);
3681 test_torus(device, 5.0f, 0.2f, 8, 8);
3682 test_torus(device, 0.2f, 1.0f, 60, 3);
3683 test_torus(device, 0.2f, 1.0f, 8, 70);
3684
3686}
HRESULT WINAPI D3DXCreateTorus(struct IDirect3DDevice9 *device, float innerradius, float outerradius, UINT sides, UINT rings, struct ID3DXMesh **mesh, ID3DXBuffer **adjacency)
Definition: mesh.c:5308
static void test_torus(IDirect3DDevice9 *device, float innerradius, float outerradius, UINT sides, UINT rings)
Definition: mesh.c:3612

Referenced by START_TEST().

◆ D3DXGenerateAdjacencyTest()

static void D3DXGenerateAdjacencyTest ( void  )
static

Definition at line 4744 of file mesh.c.

4745{
4746 HRESULT hr;
4748 ID3DXMesh *d3dxmesh = NULL;
4749 D3DXVECTOR3 *vertices = NULL;
4750 WORD *indices = NULL;
4751 int i;
4752 struct {
4753 DWORD num_vertices;
4754 D3DXVECTOR3 vertices[6];
4755 DWORD num_faces;
4756 WORD indices[3 * 3];
4757 FLOAT epsilon;
4758 DWORD adjacency[3 * 3];
4759 } test_data[] = {
4760 { /* for epsilon < 0, indices must match for faces to be adjacent */
4761 4, {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 1.0, 0.0}},
4762 2, {0, 1, 2, 0, 2, 3},
4763 -1.0,
4764 {-1, -1, 1, 0, -1, -1},
4765 },
4766 {
4767 6, {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 1.0, 0.0}},
4768 2, {0, 1, 2, 3, 4, 5},
4769 -1.0,
4770 {-1, -1, -1, -1, -1, -1},
4771 },
4772 { /* for epsilon == 0, indices or vertices must match for faces to be adjacent */
4773 6, {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 1.0, 0.0}},
4774 2, {0, 1, 2, 3, 4, 5},
4775 0.0,
4776 {-1, -1, 1, 0, -1, -1},
4777 },
4778 { /* for epsilon > 0, vertices must be less than (but NOT equal to) epsilon distance away */
4779 6, {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 0.0, 0.25}, {1.0, 1.0, 0.25}, {0.0, 1.0, 0.25}},
4780 2, {0, 1, 2, 3, 4, 5},
4781 0.25,
4782 {-1, -1, -1, -1, -1, -1},
4783 },
4784 { /* for epsilon > 0, vertices must be less than (but NOT equal to) epsilon distance away */
4785 6, {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 0.0, 0.25}, {1.0, 1.0, 0.25}, {0.0, 1.0, 0.25}},
4786 2, {0, 1, 2, 3, 4, 5},
4787 0.250001,
4788 {-1, -1, 1, 0, -1, -1},
4789 },
4790 { /* length between vertices are compared to epsilon, not the individual dimension deltas */
4791 6, {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 0.25, 0.25}, {1.0, 1.25, 0.25}, {0.0, 1.25, 0.25}},
4792 2, {0, 1, 2, 3, 4, 5},
4793 0.353, /* < sqrt(0.25*0.25 + 0.25*0.25) */
4794 {-1, -1, -1, -1, -1, -1},
4795 },
4796 {
4797 6, {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 0.25, 0.25}, {1.0, 1.25, 0.25}, {0.0, 1.25, 0.25}},
4798 2, {0, 1, 2, 3, 4, 5},
4799 0.354, /* > sqrt(0.25*0.25 + 0.25*0.25) */
4800 {-1, -1, 1, 0, -1, -1},
4801 },
4802 { /* adjacent faces must have opposite winding orders at the shared edge */
4803 4, {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 1.0, 0.0}},
4804 2, {0, 1, 2, 0, 3, 2},
4805 0.0,
4806 {-1, -1, -1, -1, -1, -1},
4807 },
4808 };
4809 struct test_context *test_context;
4810
4811 if (!(test_context = new_test_context()))
4812 {
4813 skip("Couldn't create test context\n");
4814 return;
4815 }
4817
4818 for (i = 0; i < ARRAY_SIZE(test_data); i++)
4819 {
4820 DWORD adjacency[ARRAY_SIZE(test_data[0].adjacency)];
4821 int j;
4822
4823 if (d3dxmesh) d3dxmesh->lpVtbl->Release(d3dxmesh);
4824 d3dxmesh = NULL;
4825
4826 hr = D3DXCreateMeshFVF(test_data[i].num_faces, test_data[i].num_vertices, 0, D3DFVF_XYZ, device, &d3dxmesh);
4827 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
4828
4829 hr = d3dxmesh->lpVtbl->LockVertexBuffer(d3dxmesh, D3DLOCK_DISCARD, (void**)&vertices);
4830 ok(hr == D3D_OK, "test %d: Got result %lx, expected %lx (D3D_OK)\n", i, hr, D3D_OK);
4831 if (FAILED(hr)) continue;
4832 CopyMemory(vertices, test_data[i].vertices, test_data[i].num_vertices * sizeof(test_data[0].vertices[0]));
4833 d3dxmesh->lpVtbl->UnlockVertexBuffer(d3dxmesh);
4834
4835 hr = d3dxmesh->lpVtbl->LockIndexBuffer(d3dxmesh, D3DLOCK_DISCARD, (void**)&indices);
4836 ok(hr == D3D_OK, "test %d: Got result %lx, expected %lx (D3D_OK)\n", i, hr, D3D_OK);
4837 if (FAILED(hr)) continue;
4838 CopyMemory(indices, test_data[i].indices, test_data[i].num_faces * 3 * sizeof(test_data[0].indices[0]));
4839 d3dxmesh->lpVtbl->UnlockIndexBuffer(d3dxmesh);
4840
4841 if (i == 0) {
4842 hr = d3dxmesh->lpVtbl->GenerateAdjacency(d3dxmesh, 0.0f, NULL);
4843 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
4844 }
4845
4846 hr = d3dxmesh->lpVtbl->GenerateAdjacency(d3dxmesh, test_data[i].epsilon, adjacency);
4847 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
4848 if (FAILED(hr)) continue;
4849
4850 for (j = 0; j < test_data[i].num_faces * 3; j++)
4851 ok(adjacency[j] == test_data[i].adjacency[j],
4852 "Test %d adjacency %d: Got result %lu, expected %lu\n", i, j,
4853 adjacency[j], test_data[i].adjacency[j]);
4854 }
4855 if (d3dxmesh) d3dxmesh->lpVtbl->Release(d3dxmesh);
4856
4858}
nsrefcnt Release()
#define CopyMemory
Definition: minwinbase.h:29

Referenced by START_TEST().

◆ D3DXGetFVFVertexSizeTest()

static void D3DXGetFVFVertexSizeTest ( void  )
static

Definition at line 1002 of file mesh.c.

1003{
1004 UINT got;
1005
1007
1009
1011
1013
1015
1017 D3DFVF_XYZ |
1018 D3DFVF_TEX1 |
1019 D3DFVF_TEXCOORDSIZE1(0), 16);
1021 D3DFVF_XYZ |
1022 D3DFVF_TEX2 |
1024 D3DFVF_TEXCOORDSIZE1(1), 20);
1025
1027 D3DFVF_XYZ |
1028 D3DFVF_TEX1 |
1029 D3DFVF_TEXCOORDSIZE2(0), 20);
1030
1032 D3DFVF_XYZ |
1033 D3DFVF_TEX2 |
1035 D3DFVF_TEXCOORDSIZE2(1), 28);
1036
1038 D3DFVF_XYZ |
1039 D3DFVF_TEX6 |
1045 D3DFVF_TEXCOORDSIZE2(5), 60);
1046
1048 D3DFVF_XYZ |
1049 D3DFVF_TEX8 |
1057 D3DFVF_TEXCOORDSIZE2(7), 76);
1058
1060 D3DFVF_XYZ |
1061 D3DFVF_TEX1 |
1062 D3DFVF_TEXCOORDSIZE3(0), 24);
1063
1065 D3DFVF_XYZ |
1066 D3DFVF_TEX4 |
1070 D3DFVF_TEXCOORDSIZE3(3), 60);
1071
1073 D3DFVF_XYZ |
1074 D3DFVF_TEX1 |
1075 D3DFVF_TEXCOORDSIZE4(0), 28);
1076
1078 D3DFVF_XYZ |
1079 D3DFVF_TEX2 |
1081 D3DFVF_TEXCOORDSIZE4(1), 44);
1082
1084 D3DFVF_XYZ |
1085 D3DFVF_TEX3 |
1088 D3DFVF_TEXCOORDSIZE4(2), 60);
1089
1091 D3DFVF_XYZB5 |
1095 D3DFVF_TEX8 |
1103 D3DFVF_TEXCOORDSIZE4(7), 180);
1104}
#define D3DFVF_TEX4
Definition: d3d8types.h:130
#define D3DFVF_TEX6
Definition: d3d8types.h:132
#define D3DFVF_TEXCOORDSIZE4(CoordIndex)
Definition: d3d8types.h:67
#define D3DFVF_TEXCOORDSIZE3(CoordIndex)
Definition: d3d8types.h:66
#define D3DFVF_TEXCOORDSIZE2(CoordIndex)
Definition: d3d8types.h:65
#define D3DFVF_TEX3
Definition: d3d8types.h:129
#define D3DFVF_TEXCOORDSIZE1(CoordIndex)
Definition: d3d8types.h:64
#define D3DFVF_TEX2
Definition: d3d8types.h:128
#define D3DFVF_TEX8
Definition: d3d8types.h:134
#define D3DFVF_TEX1
Definition: d3d8types.h:127
#define compare_vertex_sizes(type, exp)
Definition: mesh.c:39

Referenced by START_TEST().

◆ D3DXIntersectTriTest()

static void D3DXIntersectTriTest ( void  )
static

Definition at line 1106 of file mesh.c.

1107{
1108 BOOL exp_res, got_res;
1109 D3DXVECTOR3 position, ray, vertex[3];
1110 FLOAT exp_dist, got_dist, exp_u, got_u, exp_v, got_v;
1111
1112 vertex[0].x = 1.0f; vertex[0].y = 0.0f; vertex[0].z = 0.0f;
1113 vertex[1].x = 2.0f; vertex[1].y = 0.0f; vertex[1].z = 0.0f;
1114 vertex[2].x = 1.0f; vertex[2].y = 1.0f; vertex[2].z = 0.0f;
1115
1116 position.x = -14.5f; position.y = -23.75f; position.z = -32.0f;
1117
1118 ray.x = 2.0f; ray.y = 3.0f; ray.z = 4.0f;
1119
1120 exp_res = TRUE; exp_u = 0.5f; exp_v = 0.25f; exp_dist = 8.0f;
1121
1122 got_res = D3DXIntersectTri(&vertex[0], &vertex[1], &vertex[2], &position, &ray, &got_u, &got_v, &got_dist);
1123 ok(got_res == exp_res, "Expected result %d, got %d.\n", exp_res, got_res);
1124 ok(compare(exp_u, got_u), "Expected u %f, got %f.\n", exp_u, got_u);
1125 ok(compare(exp_v, got_v), "Expected v %f, got %f.\n", exp_v, got_v);
1126 ok(compare(exp_dist, got_dist), "Expected distance %f, got %f.\n", exp_dist, got_dist);
1127
1128 got_res = D3DXIntersectTri(&vertex[0], &vertex[1], &vertex[2], &position, &ray, NULL, NULL, NULL);
1129 ok(got_res == exp_res, "Expected result %d, got %d.\n", exp_res, got_res);
1130
1131 vertex[2].x = 1.0f; vertex[2].y = 0.0f; vertex[2].z = 0.0f;
1132 vertex[1].x = 2.0f; vertex[1].y = 0.0f; vertex[1].z = 0.0f;
1133 vertex[0].x = 1.0f; vertex[0].y = 1.0f; vertex[0].z = 0.0f;
1134
1135 got_u = got_v = got_dist = 0.0f;
1136 got_res = D3DXIntersectTri(&vertex[0], &vertex[1], &vertex[2], &position, &ray, &got_u, &got_v, &got_dist);
1137 ok(got_res == exp_res, "Expected result %d, got %d.\n", exp_res, got_res);
1138 ok(compare(exp_u, got_u), "Expected u %f, got %f.\n", exp_u, got_u);
1139 ok(compare(exp_v, got_v), "Expected v %f, got %f.\n", exp_v, got_v);
1140 ok(compare(exp_dist, got_dist), "Expected distance %f, got %f.\n", exp_dist, got_dist);
1141
1142 vertex[2].x = 1.0f; vertex[2].y = 0.0f; vertex[2].z = 0.0f;
1143 vertex[1].x = 2.0f; vertex[1].y = 0.0f; vertex[1].z = -0.5f;
1144 vertex[0].x = 1.0f; vertex[0].y = 1.0f; vertex[0].z = -1.0f;
1145 exp_u = 0.375f;
1146 exp_v = 0.5625f;
1147 exp_dist = 7.9375f;
1148 got_u = got_v = got_dist = 0.0f;
1149 got_res = D3DXIntersectTri(&vertex[0], &vertex[1], &vertex[2], &position, &ray, &got_u, &got_v, &got_dist);
1150 ok(got_res == exp_res, "Expected result %d, got %d.\n", exp_res, got_res);
1151 ok(compare(exp_u, got_u), "Expected u %f, got %f.\n", exp_u, got_u);
1152 ok(compare(exp_v, got_v), "Expected v %f, got %f.\n", exp_v, got_v);
1153 ok(compare(exp_dist, got_dist), "Expected distance %f, got %f.\n", exp_dist, got_dist);
1154
1155
1156/*Only positive ray is taken in account*/
1157
1158 vertex[0].x = 1.0f; vertex[0].y = 0.0f; vertex[0].z = 0.0f;
1159 vertex[1].x = 2.0f; vertex[1].y = 0.0f; vertex[1].z = 0.0f;
1160 vertex[2].x = 1.0f; vertex[2].y = 1.0f; vertex[2].z = 0.0f;
1161
1162 position.x = 17.5f; position.y = 24.25f; position.z = 32.0f;
1163
1164 ray.x = 2.0f; ray.y = 3.0f; ray.z = 4.0f;
1165
1166 exp_res = FALSE;
1167
1168 got_res = D3DXIntersectTri(&vertex[0],&vertex[1],&vertex[2],&position,&ray,&got_u,&got_v,&got_dist);
1169 ok( got_res == exp_res, "Expected result = %d, got %d\n",exp_res,got_res);
1170
1171 got_res = D3DXIntersectTri(&vertex[0], &vertex[1], &vertex[2], &position, &ray, NULL, NULL, NULL);
1172 ok(got_res == exp_res, "Expected result = %d, got %d\n", exp_res, got_res);
1173
1174/*Intersection between ray and triangle in a same plane is considered as empty*/
1175
1176 vertex[0].x = 4.0f; vertex[0].y = 0.0f; vertex[0].z = 0.0f;
1177 vertex[1].x = 6.0f; vertex[1].y = 0.0f; vertex[1].z = 0.0f;
1178 vertex[2].x = 4.0f; vertex[2].y = 2.0f; vertex[2].z = 0.0f;
1179
1180 position.x = 1.0f; position.y = 1.0f; position.z = 0.0f;
1181
1182 ray.x = 1.0f; ray.y = 0.0f; ray.z = 0.0f;
1183
1184 exp_res = FALSE;
1185
1186 got_res = D3DXIntersectTri(&vertex[0],&vertex[1],&vertex[2],&position,&ray,&got_u,&got_v,&got_dist);
1187 ok( got_res == exp_res, "Expected result = %d, got %d\n",exp_res,got_res);
1188
1189 got_res = D3DXIntersectTri(&vertex[0], &vertex[1], &vertex[2], &position, &ray, NULL, NULL, NULL);
1190 ok(got_res == exp_res, "Expected result = %d, got %d\n", exp_res, got_res);
1191}
BOOL WINAPI D3DXIntersectTri(const D3DXVECTOR3 *p0, const D3DXVECTOR3 *p1, const D3DXVECTOR3 *p2, const D3DXVECTOR3 *praypos, const D3DXVECTOR3 *praydir, float *pu, float *pv, float *pdist)
Definition: mesh.c:2365

Referenced by START_TEST().

◆ D3DXLoadMeshTest()

static void D3DXLoadMeshTest ( void  )
static

Definition at line 2161 of file mesh.c.

2162{
2163 static const char empty_xfile[] = "xof 0303txt 0032";
2164 /*________________________*/
2165 static const char simple_xfile[] =
2166 "xof 0303txt 0032"
2167 "Mesh {"
2168 "3;"
2169 "0.0; 0.0; 0.0;,"
2170 "0.0; 1.0; 0.0;,"
2171 "1.0; 1.0; 0.0;;"
2172 "1;"
2173 "3; 0, 1, 2;;"
2174 "}";
2175 static const WORD simple_index_buffer[] = {0, 1, 2};
2176 static const D3DXVECTOR3 simple_vertex_buffer[] = {
2177 {0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 1.0, 0.0}
2178 };
2179 const DWORD simple_fvf = D3DFVF_XYZ;
2180 static const char framed_xfile[] =
2181 "xof 0303txt 0032"
2182 "template TestData {"
2183 "<12345678-1234-1234-1234-111111111111>"
2184 "DWORD value;"
2185 "}"
2186 "TestData {"
2187 "1;;"
2188 "}"
2189 "Material {"
2190 /* ColorRGBA faceColor; */
2191 "0.0; 0.0; 1.0; 1.0;;"
2192 /* FLOAT power; */
2193 "0.5;"
2194 /* ColorRGB specularColor; */
2195 "1.0; 1.0; 1.0;;"
2196 /* ColorRGB emissiveColor; */
2197 "0.0; 0.0; 0.0;;"
2198 "}"
2199
2200 "Frame {"
2201 "TestData {"
2202 "2;;"
2203 "}"
2204 "Mesh { 3; 0.0; 0.0; 0.0;, 0.0; 1.0; 0.0;, 1.0; 1.0; 0.0;; 1; 3; 0, 1, 2;;"
2205 "TestData {"
2206 "3;;"
2207 "}"
2208 "}"
2209 "FrameTransformMatrix {" /* translation (0.0, 0.0, 2.0) */
2210 "1.0, 0.0, 0.0, 0.0,"
2211 "0.0, 1.0, 0.0, 0.0,"
2212 "0.0, 0.0, 1.0, 0.0,"
2213 "0.0, 0.0, 2.0, 1.0;;"
2214 "}"
2215 "TestData {"
2216 "4;;"
2217 "}"
2218 "Mesh { 3; 0.0; 0.0; 0.0;, 0.0; 1.0; 0.0;, 2.0; 1.0; 0.0;; 1; 3; 0, 1, 2;; }"
2219 "FrameTransformMatrix {" /* translation (0.0, 0.0, 3.0) */
2220 "1.0, 0.0, 0.0, 0.0,"
2221 "0.0, 1.0, 0.0, 0.0,"
2222 "0.0, 0.0, 1.0, 0.0,"
2223 "0.0, 0.0, 3.0, 1.0;;"
2224 "}"
2225 "Mesh { 3; 0.0; 0.0; 0.0;, 0.0; 1.0; 0.0;, 3.0; 1.0; 0.0;; 1; 3; 0, 1, 2;; }"
2226 "}";
2227
2228 static const struct test_user_data framed_xfile_expected_user_data[] =
2229 {
2230 { USER_DATA_TYPE_TOP, &TID_TestDataGuid, 4, 1, 0, 0},
2231 { USER_DATA_TYPE_TOP, &TID_D3DRMMaterial, 44, 0, 0, 0},
2232 { USER_DATA_TYPE_FRAME_CHILD, &TID_TestDataGuid, 4, 2, 0, 0},
2233 { USER_DATA_TYPE_MESH_CHILD, &TID_TestDataGuid, 4, 3, 0, 0},
2234 { USER_DATA_TYPE_FRAME_CHILD, &TID_TestDataGuid, 4, 4, 1, 0},
2235 };
2236
2237 static const char framed_xfile_empty[] =
2238 "xof 0303txt 0032"
2239 "Frame Box01 {"
2240 " Mesh { 0;; 0;;"
2241 " MeshNormals { 0;; 0;; }"
2242 " }"
2243 "}";
2244
2245 static const WORD framed_index_buffer[] = { 0, 1, 2 };
2246 static const D3DXVECTOR3 framed_vertex_buffers[3][3] = {
2247 {{0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 1.0, 0.0}},
2248 {{0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {2.0, 1.0, 0.0}},
2249 {{0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {3.0, 1.0, 0.0}},
2250 };
2251 static const WORD merged_index_buffer[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
2252 /* frame transforms accumulates for D3DXLoadMeshFromX */
2253 static const D3DXVECTOR3 merged_vertex_buffer[] = {
2254 {0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 1.0, 0.0},
2255 {0.0, 0.0, 2.0}, {0.0, 1.0, 2.0}, {2.0, 1.0, 2.0},
2256 {0.0, 0.0, 5.0}, {0.0, 1.0, 5.0}, {3.0, 1.0, 5.0},
2257 };
2258 const DWORD framed_fvf = D3DFVF_XYZ;
2259 /*________________________*/
2260 static const char box_xfile[] =
2261 "xof 0303txt 0032"
2262 "template TestData {"
2263 "<12345678-1234-1234-1234-111111111111>"
2264 "DWORD value;"
2265 "}"
2266 "Mesh {"
2267 "8;" /* DWORD nVertices; */
2268 /* array Vector vertices[nVertices]; */
2269 "0.0; 0.0; 0.0;,"
2270 "0.0; 0.0; 1.0;,"
2271 "0.0; 1.0; 0.0;,"
2272 "0.0; 1.0; 1.0;,"
2273 "1.0; 0.0; 0.0;,"
2274 "1.0; 0.0; 1.0;,"
2275 "1.0; 1.0; 0.0;,"
2276 "1.0; 1.0; 1.0;;"
2277 "6;" /* DWORD nFaces; */
2278 /* array MeshFace faces[nFaces]; */
2279 "4; 0, 1, 3, 2;," /* (left side) */
2280 "4; 2, 3, 7, 6;," /* (top side) */
2281 "4; 6, 7, 5, 4;," /* (right side) */
2282 "4; 1, 0, 4, 5;," /* (bottom side) */
2283 "4; 1, 5, 7, 3;," /* (back side) */
2284 "4; 0, 2, 6, 4;;" /* (front side) */
2285 "MeshNormals {"
2286 "6;" /* DWORD nNormals; */
2287 /* array Vector normals[nNormals]; */
2288 "-1.0; 0.0; 0.0;,"
2289 "0.0; 1.0; 0.0;,"
2290 "1.0; 0.0; 0.0;,"
2291 "0.0; -1.0; 0.0;,"
2292 "0.0; 0.0; 1.0;,"
2293 "0.0; 0.0; -1.0;;"
2294 "6;" /* DWORD nFaceNormals; */
2295 /* array MeshFace faceNormals[nFaceNormals]; */
2296 "4; 0, 0, 0, 0;,"
2297 "4; 1, 1, 1, 1;,"
2298 "4; 2, 2, 2, 2;,"
2299 "4; 3, 3, 3, 3;,"
2300 "4; 4, 4, 4, 4;,"
2301 "4; 5, 5, 5, 5;;"
2302 "}"
2303 "TestData {"
2304 "1;;"
2305 "}"
2306 "MeshMaterialList materials {"
2307 "2;" /* DWORD nMaterials; */
2308 "6;" /* DWORD nFaceIndexes; */
2309 /* array DWORD faceIndexes[nFaceIndexes]; */
2310 "0, 0, 0, 1, 1, 1;;"
2311 "Material {"
2312 /* ColorRGBA faceColor; */
2313 "0.0; 0.0; 1.0; 1.0;;"
2314 /* FLOAT power; */
2315 "0.5;"
2316 /* ColorRGB specularColor; */
2317 "1.0; 1.0; 1.0;;"
2318 /* ColorRGB emissiveColor; */
2319 "0.0; 0.0; 0.0;;"
2320 "}"
2321 "Material {"
2322 /* ColorRGBA faceColor; */
2323 "1.0; 1.0; 1.0; 1.0;;"
2324 /* FLOAT power; */
2325 "1.0;"
2326 /* ColorRGB specularColor; */
2327 "1.0; 1.0; 1.0;;"
2328 /* ColorRGB emissiveColor; */
2329 "0.0; 0.0; 0.0;;"
2330 "TextureFilename { \"texture.jpg\"; }"
2331 "}"
2332 "}"
2333 "TestData {"
2334 "2;;"
2335 "}"
2336
2337 "MeshVertexColors {"
2338 "8;" /* DWORD nVertexColors; */
2339 /* array IndexedColor vertexColors[nVertexColors]; */
2340 "0; 0.0; 0.0; 0.0; 0.0;;"
2341 "1; 0.0; 0.0; 1.0; 0.1;;"
2342 "2; 0.0; 1.0; 0.0; 0.2;;"
2343 "3; 0.0; 1.0; 1.0; 0.3;;"
2344 "4; 1.0; 0.0; 0.0; 0.4;;"
2345 "5; 1.0; 0.0; 1.0; 0.5;;"
2346 "6; 1.0; 1.0; 0.0; 0.6;;"
2347 "7; 1.0; 1.0; 1.0; 0.7;;"
2348 "}"
2349 "MeshTextureCoords {"
2350 "8;" /* DWORD nTextureCoords; */
2351 /* array Coords2d textureCoords[nTextureCoords]; */
2352 "0.0; 1.0;,"
2353 "1.0; 1.0;,"
2354 "0.0; 0.0;,"
2355 "1.0; 0.0;,"
2356 "1.0; 1.0;,"
2357 "0.0; 1.0;,"
2358 "1.0; 0.0;,"
2359 "0.0; 0.0;;"
2360 "}"
2361 "}";
2362 static const struct test_user_data box_xfile_expected_user_data[] =
2363 {
2364 { USER_DATA_TYPE_MESH_CHILD, &TID_TestDataGuid, 4, 1, 0, 2},
2365 { USER_DATA_TYPE_MESH_CHILD, &TID_TestDataGuid, 4, 2, 0, 2},
2366 };
2367
2368 static const WORD box_index_buffer[] = {
2369 0, 1, 3,
2370 0, 3, 2,
2371 8, 9, 7,
2372 8, 7, 6,
2373 10, 11, 5,
2374 10, 5, 4,
2375 12, 13, 14,
2376 12, 14, 15,
2377 16, 17, 18,
2378 16, 18, 19,
2379 20, 21, 22,
2380 20, 22, 23,
2381 };
2382 static const struct {
2383 D3DXVECTOR3 position;
2385 D3DCOLOR diffuse;
2386 D3DXVECTOR2 tex_coords;
2387 } box_vertex_buffer[] = {
2388 {{0.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, 0x00000000, {0.0, 1.0}},
2389 {{0.0, 0.0, 1.0}, {-1.0, 0.0, 0.0}, 0x1a0000ff, {1.0, 1.0}},
2390 {{0.0, 1.0, 0.0}, {-1.0, 0.0, 0.0}, 0x3300ff00, {0.0, 0.0}},
2391 {{0.0, 1.0, 1.0}, {-1.0, 0.0, 0.0}, 0x4d00ffff, {1.0, 0.0}},
2392 {{1.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, 0x66ff0000, {1.0, 1.0}},
2393 {{1.0, 0.0, 1.0}, {1.0, 0.0, 0.0}, 0x80ff00ff, {0.0, 1.0}},
2394 {{1.0, 1.0, 0.0}, {0.0, 1.0, 0.0}, 0x99ffff00, {1.0, 0.0}},
2395 {{1.0, 1.0, 1.0}, {0.0, 1.0, 0.0}, 0xb3ffffff, {0.0, 0.0}},
2396 {{0.0, 1.0, 0.0}, {0.0, 1.0, 0.0}, 0x3300ff00, {0.0, 0.0}},
2397 {{0.0, 1.0, 1.0}, {0.0, 1.0, 0.0}, 0x4d00ffff, {1.0, 0.0}},
2398 {{1.0, 1.0, 0.0}, {1.0, 0.0, 0.0}, 0x99ffff00, {1.0, 0.0}},
2399 {{1.0, 1.0, 1.0}, {1.0, 0.0, 0.0}, 0xb3ffffff, {0.0, 0.0}},
2400 {{0.0, 0.0, 1.0}, {0.0, -1.0, 0.0}, 0x1a0000ff, {1.0, 1.0}},
2401 {{0.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, 0x00000000, {0.0, 1.0}},
2402 {{1.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, 0x66ff0000, {1.0, 1.0}},
2403 {{1.0, 0.0, 1.0}, {0.0, -1.0, 0.0}, 0x80ff00ff, {0.0, 1.0}},
2404 {{0.0, 0.0, 1.0}, {0.0, 0.0, 1.0}, 0x1a0000ff, {1.0, 1.0}},
2405 {{1.0, 0.0, 1.0}, {0.0, 0.0, 1.0}, 0x80ff00ff, {0.0, 1.0}},
2406 {{1.0, 1.0, 1.0}, {0.0, 0.0, 1.0}, 0xb3ffffff, {0.0, 0.0}},
2407 {{0.0, 1.0, 1.0}, {0.0, 0.0, 1.0}, 0x4d00ffff, {1.0, 0.0}},
2408 {{0.0, 0.0, 0.0}, {0.0, 0.0, -1.0}, 0x00000000, {0.0, 1.0}},
2409 {{0.0, 1.0, 0.0}, {0.0, 0.0, -1.0}, 0x3300ff00, {0.0, 0.0}},
2410 {{1.0, 1.0, 0.0}, {0.0, 0.0, -1.0}, 0x99ffff00, {1.0, 0.0}},
2411 {{1.0, 0.0, 0.0}, {0.0, 0.0, -1.0}, 0x66ff0000, {1.0, 1.0}},
2412 };
2413 static const D3DXMATERIAL box_materials[] = {
2414 {
2415 {
2416 {0.0, 0.0, 1.0, 1.0}, /* Diffuse */
2417 {0.0, 0.0, 0.0, 1.0}, /* Ambient */
2418 {1.0, 1.0, 1.0, 1.0}, /* Specular */
2419 {0.0, 0.0, 0.0, 1.0}, /* Emissive */
2420 0.5, /* Power */
2421 },
2422 NULL, /* pTextureFilename */
2423 },
2424 {
2425 {
2426 {1.0, 1.0, 1.0, 1.0}, /* Diffuse */
2427 {0.0, 0.0, 0.0, 1.0}, /* Ambient */
2428 {1.0, 1.0, 1.0, 1.0}, /* Specular */
2429 {0.0, 0.0, 0.0, 1.0}, /* Emissive */
2430 1.0, /* Power */
2431 },
2432 (char *)"texture.jpg", /* pTextureFilename */
2433 },
2434 };
2435 static const char box_anim_xfile[] =
2436 "xof 0303txt 0032"
2437 "Mesh CubeMesh {"
2438 "8;" /* DWORD nVertices; */
2439 /* array Vector vertices[nVertices]; */
2440 "0.0; 0.0; 0.0;,"
2441 "0.0; 0.0; 1.0;,"
2442 "0.0; 1.0; 0.0;,"
2443 "0.0; 1.0; 1.0;,"
2444 "1.0; 0.0; 0.0;,"
2445 "1.0; 0.0; 1.0;,"
2446 "1.0; 1.0; 0.0;,"
2447 "1.0; 1.0; 1.0;;"
2448 "6;" /* DWORD nFaces; */
2449 /* array MeshFace faces[nFaces]; */
2450 "4; 0, 1, 3, 2;," /* left side */
2451 "4; 2, 3, 7, 6;," /* top side */
2452 "4; 6, 7, 5, 4;," /* right side */
2453 "4; 1, 0, 4, 5;," /* bottom side */
2454 "4; 1, 5, 7, 3;," /* back side */
2455 "4; 0, 2, 6, 4;;" /* front side */
2456 "MeshNormals {"
2457 "6;" /* DWORD nNormals; */
2458 /* array Vector normals[nNormals]; */
2459 "-1.0; 0.0; 0.0;,"
2460 "0.0; 1.0; 0.0;,"
2461 "1.0; 0.0; 0.0;,"
2462 "0.0; -1.0; 0.0;,"
2463 "0.0; 0.0; 1.0;,"
2464 "0.0; 0.0; -1.0;;"
2465 "6;" /* DWORD nFaceNormals; */
2466 /* array MeshFace faceNormals[nFaceNormals]; */
2467 "4; 0, 0, 0, 0;,"
2468 "4; 1, 1, 1, 1;,"
2469 "4; 2, 2, 2, 2;,"
2470 "4; 3, 3, 3, 3;,"
2471 "4; 4, 4, 4, 4;,"
2472 "4; 5, 5, 5, 5;;"
2473 "}"
2474 "MeshMaterialList materials {"
2475 "2;" /* DWORD nMaterials; */
2476 "6;" /* DWORD nFaceIndexes; */
2477 /* array DWORD faceIndexes[nFaceIndexes]; */
2478 "0, 0, 0, 1, 1, 1;;"
2479 "Material {"
2480 /* ColorRGBA faceColor; */
2481 "0.0; 0.0; 1.0; 1.0;;"
2482 /* FLOAT power; */
2483 "0.5;"
2484 /* ColorRGB specularColor; */
2485 "1.0; 1.0; 1.0;;"
2486 /* ColorRGB emissiveColor; */
2487 "0.0; 0.0; 0.0;;"
2488 "}"
2489 "Material {"
2490 /* ColorRGBA faceColor; */
2491 "1.0; 1.0; 1.0; 1.0;;"
2492 /* FLOAT power; */
2493 "1.0;"
2494 /* ColorRGB specularColor; */
2495 "1.0; 1.0; 1.0;;"
2496 /* ColorRGB emissiveColor; */
2497 "0.0; 0.0; 0.0;;"
2498 "TextureFilename { \"texture.jpg\"; }"
2499 "}"
2500 "}"
2501 "MeshVertexColors {"
2502 "8;" /* DWORD nVertexColors; */
2503 /* array IndexedColor vertexColors[nVertexColors]; */
2504 "0; 0.0; 0.0; 0.0; 0.0;;"
2505 "1; 0.0; 0.0; 1.0; 0.1;;"
2506 "2; 0.0; 1.0; 0.0; 0.2;;"
2507 "3; 0.0; 1.0; 1.0; 0.3;;"
2508 "4; 1.0; 0.0; 0.0; 0.4;;"
2509 "5; 1.0; 0.0; 1.0; 0.5;;"
2510 "6; 1.0; 1.0; 0.0; 0.6;;"
2511 "7; 1.0; 1.0; 1.0; 0.7;;"
2512 "}"
2513 "MeshTextureCoords {"
2514 "8;" /* DWORD nTextureCoords; */
2515 /* array Coords2d textureCoords[nTextureCoords]; */
2516 "0.0; 1.0;,"
2517 "1.0; 1.0;,"
2518 "0.0; 0.0;,"
2519 "1.0; 0.0;,"
2520 "1.0; 1.0;,"
2521 "0.0; 1.0;,"
2522 "1.0; 0.0;,"
2523 "0.0; 0.0;;"
2524 "}"
2525 "}"
2526 "Frame CubeFrame {"
2527 "FrameTransformMatrix {"
2528 /* Matrix4x4 frameMatrix; */
2529 "1.0, 0.0, 0.0, 0.0,"
2530 "0.0, 1.0, 0.0, 0.0,"
2531 "0.0, 0.0, 1.0, 0.0,"
2532 "0.0, 0.0, 0.0, 1.0;;"
2533 "}"
2534 "{CubeMesh}"
2535 "}"
2536 "AnimationSet AnimationSet0 {"
2537 "Animation Animation0 {"
2538 "{CubeFrame}"
2539 "AnimationKey {"
2540 "2;" /* DWORD keyType; */
2541 "9;" /* DWORD nKeys; */
2542 /* array TimedFloatKeys keys[nKeys]; */
2543 "10; 3; -100.0, 0.0, 0.0;;,"
2544 "20; 3; -75.0, 0.0, 0.0;;,"
2545 "30; 3; -50.0, 0.0, 0.0;;,"
2546 "40; 3; -25.5, 0.0, 0.0;;,"
2547 "50; 3; 0.0, 0.0, 0.0;;,"
2548 "60; 3; 25.5, 0.0, 0.0;;,"
2549 "70; 3; 50.0, 0.0, 0.0;;,"
2550 "80; 3; 75.5, 0.0, 0.0;;,"
2551 "90; 3; 100.0, 0.0, 0.0;;;"
2552 "}"
2553 "}"
2554 "}";
2555
2557 /*________________________*/
2558 static const D3DXMATERIAL default_materials[] = {
2559 {
2560 {
2561 {0.5, 0.5, 0.5, 0.0}, /* Diffuse */
2562 {0.0, 0.0, 0.0, 0.0}, /* Ambient */
2563 {0.5, 0.5, 0.5, 0.0}, /* Specular */
2564 {0.0, 0.0, 0.0, 0.0}, /* Emissive */
2565 0.0, /* Power */
2566 },
2567 NULL, /* pTextureFilename */
2568 }
2569 };
2570 HRESULT hr;
2572 ID3DXMesh *mesh = NULL;
2573 D3DXFRAME *frame_hier = NULL;
2575 struct test_context *test_context;
2576 ID3DXAnimationController *controller;
2578 unsigned int i;
2579 struct test_load_user_data load_user_data;
2580
2581 if (!(test_context = new_test_context()))
2582 {
2583 skip("Couldn't create test context\n");
2584 return;
2585 }
2587
2588 hr = D3DXLoadMeshHierarchyFromXInMemory(NULL, sizeof(simple_xfile) - 1,
2589 D3DXMESH_MANAGED, device, &alloc_hier, NULL, &frame_hier, NULL);
2590 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
2591
2592 hr = D3DXLoadMeshHierarchyFromXInMemory(simple_xfile, 0,
2593 D3DXMESH_MANAGED, device, &alloc_hier, NULL, &frame_hier, NULL);
2594 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
2595
2596 hr = D3DXLoadMeshHierarchyFromXInMemory(simple_xfile, sizeof(simple_xfile) - 1,
2597 D3DXMESH_MANAGED, NULL, &alloc_hier, NULL, &frame_hier, NULL);
2598 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
2599
2600 hr = D3DXLoadMeshHierarchyFromXInMemory(simple_xfile, sizeof(simple_xfile) - 1,
2601 D3DXMESH_MANAGED, device, NULL, NULL, &frame_hier, NULL);
2602 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
2603
2604 hr = D3DXLoadMeshHierarchyFromXInMemory(empty_xfile, sizeof(empty_xfile) - 1,
2605 D3DXMESH_MANAGED, device, &alloc_hier, NULL, &frame_hier, NULL);
2606 ok(hr == E_FAIL, "Expected E_FAIL, got %#lx\n", hr);
2607
2608 hr = D3DXLoadMeshHierarchyFromXInMemory(simple_xfile, sizeof(simple_xfile) - 1,
2610 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
2611
2612 hr = D3DXLoadMeshHierarchyFromXInMemory(simple_xfile, sizeof(simple_xfile) - 1,
2613 D3DXMESH_MANAGED, device, &alloc_hier, NULL, &frame_hier, NULL);
2614 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
2615 container = frame_hier->pMeshContainer;
2616
2617 ok(frame_hier->Name == NULL, "Expected NULL, got '%s'\n", frame_hier->Name);
2618 D3DXMatrixIdentity(&transform);
2620
2621 ok(!strcmp(container->Name, ""), "Expected '', got '%s'\n", container->Name);
2622 ok(container->MeshData.Type == D3DXMESHTYPE_MESH, "Expected %d, got %d\n",
2623 D3DXMESHTYPE_MESH, container->MeshData.Type);
2624 mesh = container->MeshData.pMesh;
2625 check_vertex_buffer(mesh, simple_vertex_buffer, ARRAY_SIZE(simple_vertex_buffer), simple_fvf);
2626 check_index_buffer(mesh, simple_index_buffer, ARRAY_SIZE(simple_index_buffer), sizeof(*simple_index_buffer));
2627 check_materials(container->pMaterials, container->NumMaterials, NULL, 0);
2628 check_generated_effects(container->pMaterials, container->NumMaterials, container->pEffects);
2629 check_generated_adjacency(mesh, container->pAdjacency, 0.0f);
2630 hr = D3DXFrameDestroy(frame_hier, &alloc_hier);
2631 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
2632 frame_hier = NULL;
2633
2634 controller = (ID3DXAnimationController *)0xdeadbeef;
2635 hr = D3DXLoadMeshHierarchyFromXInMemory(box_anim_xfile, sizeof(box_anim_xfile) - 1,
2636 D3DXMESH_MANAGED, device, &alloc_hier, NULL, &frame_hier, &controller);
2637 todo_wine ok(hr == D3D_OK, "Expected D3D_OK, got %#lx.\n", hr);
2638 if (SUCCEEDED(hr))
2639 {
2640 ok(controller != NULL, "Animation Controller NULL.\n");
2641
2642 hr = D3DXFrameDestroy(frame_hier, &alloc_hier);
2643 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx.\n", hr);
2644 if (controller)
2645 controller->lpVtbl->Release(controller);
2646
2647 frame_hier = NULL;
2648 }
2649
2650 controller = (ID3DXAnimationController *)0xdeadbeef;
2651 hr = D3DXLoadMeshHierarchyFromXInMemory(box_xfile, sizeof(box_xfile) - 1,
2652 D3DXMESH_MANAGED, device, &alloc_hier, NULL, &frame_hier, &controller);
2653 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
2654 container = frame_hier->pMeshContainer;
2655
2656 ok(!controller, "Animation Controller returned.\n");
2657 ok(frame_hier->Name == NULL, "Expected NULL, got '%s'\n", frame_hier->Name);
2658 D3DXMatrixIdentity(&transform);
2660
2661 ok(!strcmp(container->Name, ""), "Expected '', got '%s'\n", container->Name);
2662 ok(container->MeshData.Type == D3DXMESHTYPE_MESH, "Expected %d, got %d\n",
2663 D3DXMESHTYPE_MESH, container->MeshData.Type);
2664 mesh = container->MeshData.pMesh;
2665 check_vertex_buffer(mesh, box_vertex_buffer, ARRAY_SIZE(box_vertex_buffer), box_fvf);
2666 check_index_buffer(mesh, box_index_buffer, ARRAY_SIZE(box_index_buffer), sizeof(*box_index_buffer));
2667 check_materials(container->pMaterials, container->NumMaterials, box_materials, ARRAY_SIZE(box_materials));
2668 check_generated_effects(container->pMaterials, container->NumMaterials, container->pEffects);
2669 check_generated_adjacency(mesh, container->pAdjacency, 0.0f);
2670 hr = D3DXFrameDestroy(frame_hier, &alloc_hier);
2671 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
2672 frame_hier = NULL;
2673
2674 init_load_user_data(&load_user_data);
2675 hr = D3DXLoadMeshHierarchyFromXInMemory(box_xfile, sizeof(box_xfile) - 1,
2676 D3DXMESH_MANAGED, device, &alloc_hier, &load_user_data.iface, &frame_hier, &controller);
2677 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
2678 winetest_push_context("box_xfile");
2679 check_user_data(&load_user_data, ARRAY_SIZE(box_xfile_expected_user_data), box_xfile_expected_user_data);
2681 hr = D3DXFrameDestroy(frame_hier, &alloc_hier);
2682 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
2683 frame_hier = NULL;
2684
2685 hr = D3DXLoadMeshHierarchyFromXInMemory(framed_xfile, sizeof(framed_xfile) - 1,
2686 D3DXMESH_MANAGED, device, &alloc_hier, NULL, &frame_hier, NULL);
2687 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
2688 container = frame_hier->pMeshContainer;
2689
2690 ok(!strcmp(frame_hier->Name, ""), "Expected '', got '%s'\n", frame_hier->Name);
2691 /* last frame transform replaces the first */
2692 D3DXMatrixIdentity(&transform);
2693 transform.m[3][2] = 3.0;
2695
2696 for (i = 0; i < 3; ++i)
2697 {
2698 ok(!strcmp(container->Name, ""), "Expected '', got '%s'\n", container->Name);
2699 ok(container->MeshData.Type == D3DXMESHTYPE_MESH, "Expected %d, got %d\n",
2700 D3DXMESHTYPE_MESH, container->MeshData.Type);
2701 mesh = container->MeshData.pMesh;
2702 check_vertex_buffer(mesh, framed_vertex_buffers[i], ARRAY_SIZE(framed_vertex_buffers[0]), framed_fvf);
2703 check_index_buffer(mesh, framed_index_buffer, ARRAY_SIZE(framed_index_buffer), sizeof(*framed_index_buffer));
2704 check_materials(container->pMaterials, container->NumMaterials, NULL, 0);
2705 check_generated_effects(container->pMaterials, container->NumMaterials, container->pEffects);
2706 check_generated_adjacency(mesh, container->pAdjacency, 0.0f);
2707 container = container->pNextMeshContainer;
2708 }
2709 ok(container == NULL, "Expected NULL, got %p\n", container);
2710 hr = D3DXFrameDestroy(frame_hier, &alloc_hier);
2711 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
2712 frame_hier = NULL;
2713
2714 init_load_user_data(&load_user_data);
2715 hr = D3DXLoadMeshHierarchyFromXInMemory(framed_xfile, sizeof(framed_xfile) - 1,
2716 D3DXMESH_MANAGED, device, &alloc_hier, &load_user_data.iface, &frame_hier, NULL);
2717 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
2718 hr = D3DXFrameDestroy(frame_hier, &alloc_hier);
2719 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
2720 winetest_push_context("framed_xfile");
2721 check_user_data(&load_user_data, ARRAY_SIZE(framed_xfile_expected_user_data), framed_xfile_expected_user_data);
2723 frame_hier = NULL;
2724
2725 hr = D3DXLoadMeshHierarchyFromXInMemory(framed_xfile_empty, sizeof(framed_xfile_empty) - 1,
2726 D3DXMESH_MANAGED, device, &alloc_hier, NULL, &frame_hier, NULL);
2727 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2728 container = frame_hier->pMeshContainer;
2729 ok(!strcmp(frame_hier->Name, "Box01"), "Unexpected name %s.\n", debugstr_a(frame_hier->Name));
2730 ok(!container, "Unexpected container %p.\n", container);
2731
2732 hr = D3DXFrameDestroy(frame_hier, &alloc_hier);
2733 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2734 frame_hier = NULL;
2735
2737 device, NULL, NULL, NULL, NULL, &mesh);
2738 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
2739
2740 hr = D3DXLoadMeshFromXInMemory(NULL, sizeof(simple_xfile) - 1, D3DXMESH_MANAGED,
2741 device, NULL, NULL, NULL, NULL, &mesh);
2742 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
2743
2745 device, NULL, NULL, NULL, NULL, &mesh);
2746 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
2747
2748 hr = D3DXLoadMeshFromXInMemory(simple_xfile, sizeof(simple_xfile) - 1, D3DXMESH_MANAGED,
2749 device, NULL, NULL, NULL, NULL, NULL);
2750 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
2751
2752 hr = D3DXLoadMeshFromXInMemory(simple_xfile, sizeof(simple_xfile) - 1, D3DXMESH_MANAGED,
2753 NULL, NULL, NULL, NULL, NULL, &mesh);
2754 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
2755
2756 hr = D3DXLoadMeshFromXInMemory(empty_xfile, sizeof(empty_xfile) - 1, D3DXMESH_MANAGED,
2757 device, NULL, NULL, NULL, NULL, &mesh);
2758 ok(hr == E_FAIL, "Expected E_FAIL, got %#lx\n", hr);
2759
2760 hr = D3DXLoadMeshFromXInMemory(simple_xfile, sizeof(simple_xfile) - 1, D3DXMESH_MANAGED,
2761 device, NULL, NULL, NULL, NULL, &mesh);
2762 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
2763 IUnknown_Release(mesh);
2764
2765 test_LoadMeshFromX(device, simple_xfile, simple_vertex_buffer, simple_fvf, simple_index_buffer, default_materials, TRUE);
2766 test_LoadMeshFromX(device, box_xfile, box_vertex_buffer, box_fvf, box_index_buffer, box_materials, TRUE);
2767 test_LoadMeshFromX(device, framed_xfile, merged_vertex_buffer, framed_fvf, merged_index_buffer, default_materials, FALSE);
2768
2770}
#define E_FAIL
Definition: ddrawi.h:102
HRESULT WINAPI D3DXLoadMeshHierarchyFromXInMemory(const void *memory, DWORD memory_size, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXAllocateHierarchy *alloc_hier, struct ID3DXLoadUserData *load_user_data, D3DXFRAME **frame_hierarchy, struct ID3DXAnimationController **anim_controller)
Definition: mesh.c:3987
HRESULT WINAPI D3DXLoadMeshFromXInMemory(const void *memory, DWORD memory_size, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXBuffer **adjacency_out, struct ID3DXBuffer **materials_out, struct ID3DXBuffer **effects_out, DWORD *num_materials_out, struct ID3DXMesh **mesh_out)
Definition: mesh.c:4297
HRESULT WINAPI D3DXFrameDestroy(D3DXFRAME *frame, ID3DXAllocateHierarchy *alloc_hier)
Definition: mesh.c:4101
@ D3DXMESHTYPE_MESH
Definition: d3dx9anim.h:29
GLuint GLenum GLenum transform
Definition: glext.h:9407
#define todo_wine
Definition: minitest.h:80
static ID3DXAllocateHierarchy alloc_hier
Definition: mesh.c:1991
static void check_user_data(struct test_load_user_data *user_data, unsigned int expected_count, const struct test_user_data *expected)
Definition: mesh.c:2134
#define check_materials(got, got_count, expected, expected_count)
Definition: mesh.c:1676
#define test_LoadMeshFromX(device, xfile_str, vertex_array, fvf, index_array, materials_array, check_adjacency)
Definition: mesh.c:1993
static void init_load_user_data(struct test_load_user_data *data)
Definition: mesh.c:2128
#define check_vertex_buffer(mesh, vertices, num_vertices, fvf)
Definition: mesh.c:1518
#define check_matrix(got, expected)
Definition: mesh.c:1656
#define check_index_buffer(mesh, indices, num_indices, index_size)
Definition: mesh.c:1620
#define check_generated_effects(materials, num_materials, effects)
Definition: mesh.c:1733
#define check_generated_adjacency(mesh, got, epsilon)
Definition: mesh.c:1703
char * Name
Definition: d3dx9anim.h:107
D3DXMATRIX TransformationMatrix
Definition: d3dx9anim.h:108
LPD3DXMESHCONTAINER pMeshContainer
Definition: d3dx9anim.h:109

Referenced by START_TEST().

◆ DEFINE_GUID()

DEFINE_GUID ( TID_TestDataGuid  ,
0x12345678  ,
0x1234  ,
0x1234  ,
0x12  ,
0x34  ,
0x11  ,
0x11  ,
0x11  ,
0x11  ,
0x11  ,
0x11   
)

◆ destroy_mesh_container()

static HRESULT destroy_mesh_container ( LPD3DXMESHCONTAINER  mesh_container)
static

Definition at line 1839 of file mesh.c.

1840{
1841 int i;
1842
1843 if (!mesh_container)
1844 return D3D_OK;
1845 free(mesh_container->Name);
1846 if (mesh_container->MeshData.pMesh)
1847 IUnknown_Release(mesh_container->MeshData.pMesh);
1848 if (mesh_container->pMaterials) {
1849 for (i = 0; i < mesh_container->NumMaterials; i++)
1850 free(mesh_container->pMaterials[i].pTextureFilename);
1851 free(mesh_container->pMaterials);
1852 }
1853 if (mesh_container->pEffects) {
1854 for (i = 0; i < mesh_container->NumMaterials; i++) {
1855 free(mesh_container->pEffects[i].pEffectFilename);
1856 if (mesh_container->pEffects[i].pDefaults) {
1857 int j;
1858 for (j = 0; j < mesh_container->pEffects[i].NumDefaults; j++) {
1859 free(mesh_container->pEffects[i].pDefaults[j].pParamName);
1860 free(mesh_container->pEffects[i].pDefaults[j].pValue);
1861 }
1862 free(mesh_container->pEffects[i].pDefaults);
1863 }
1864 }
1865 free(mesh_container->pEffects);
1866 }
1867 free(mesh_container->pAdjacency);
1868 if (mesh_container->pSkinInfo)
1869 IUnknown_Release(mesh_container->pSkinInfo);
1871 return D3D_OK;
1872}

Referenced by ID3DXAllocateHierarchyImpl_CreateMeshContainer(), and ID3DXAllocateHierarchyImpl_DestroyMeshContainer().

◆ dword_to_dec3n()

static struct dec3n dword_to_dec3n ( DWORD  d)
static

Definition at line 6677 of file mesh.c.

6678{
6679 struct dec3n v;
6680
6681 v.x = d & 0x3ff;
6682 v.y = (d & 0xffc00) >> 10;
6683 v.z = (d & 0x3ff00000) >> 20;
6684 v.w = (d & 0xc0000000) >> 30;
6685
6686 return v;
6687}
#define d
Definition: ke_i.h:81

◆ dword_to_udec3()

static struct udec3 dword_to_udec3 ( DWORD  d)
static

Definition at line 6665 of file mesh.c.

6666{
6667 struct udec3 v;
6668
6669 v.x = d & 0x3ff;
6670 v.y = (d & 0xffc00) >> 10;
6671 v.z = (d & 0x3ff00000) >> 20;
6672 v.w = (d & 0xc0000000) >> 30;
6673
6674 return v;
6675}

◆ free_glyphinfo()

static void free_glyphinfo ( struct glyphinfo *  glyph)
static

Definition at line 4022 of file mesh.c.

4023{
4024 unsigned int i;
4025
4026 for (i = 0; i < glyph->outlines.count; ++i)
4027 free_outline(&glyph->outlines.items[i]);
4028 free(glyph->outlines.items);
4029}
static void free_outline(struct outline *outline)
Definition: mesh.c:4017

Referenced by test_createtext().

◆ free_mesh()

static void free_mesh ( struct mesh *  mesh)
static

◆ free_outline()

static void free_outline ( struct outline *  outline)
static

Definition at line 4017 of file mesh.c.

4018{
4019 free(outline->items);
4020}

Referenced by free_glyphinfo().

◆ free_sincos_table()

static void free_sincos_table ( struct sincos_table *  sincos_table)
static

Definition at line 3046 of file mesh.c.

3047{
3050}

◆ free_test_context()

◆ get_mesh_data()

static ID3DXFileData * get_mesh_data ( const void *  memory,
SIZE_T  length 
)
static

Definition at line 11515 of file mesh.c.

11516{
11517 ID3DXFileData *file_data, *ret = NULL;
11518 ID3DXFileEnumObject *enum_obj = NULL;
11520 ID3DXFile *file;
11521 SIZE_T i, count;
11522 GUID guid;
11523
11524 if (FAILED(D3DXFileCreate(&file)))
11525 return NULL;
11526
11527 if (FAILED(file->lpVtbl->RegisterTemplates(file, D3DRM_XTEMPLATES, D3DRM_XTEMPLATE_BYTES)))
11528 goto cleanup;
11529
11530 source.lpMemory = memory;
11531 source.dSize = length;
11532 if (FAILED(file->lpVtbl->CreateEnumObject(file, &source, D3DXF_FILELOAD_FROMMEMORY, &enum_obj)))
11533 goto cleanup;
11534
11535 if (FAILED(enum_obj->lpVtbl->GetChildren(enum_obj, &count)))
11536 goto cleanup;
11537
11538 for (i = 0; i < count; ++i)
11539 {
11540 if (FAILED(enum_obj->lpVtbl->GetChild(enum_obj, i, &file_data)))
11541 goto cleanup;
11542
11543 if (SUCCEEDED(file_data->lpVtbl->GetType(file_data, &guid))
11544 && IsEqualGUID(&guid, &TID_D3DRMMesh))
11545 {
11546 ret = file_data;
11547 break;
11548 }
11549 else
11550 {
11551 file_data->lpVtbl->Release(file_data);
11552 }
11553 }
11554
11555cleanup:
11556 if (enum_obj)
11557 enum_obj->lpVtbl->Release(enum_obj);
11558 file->lpVtbl->Release(file);
11559
11560 return ret;
11561}
HRESULT WINAPI D3DXFileCreate(ID3DXFile **d3dxfile)
Definition: xfile.c:693
static void cleanup(void)
Definition: main.c:1335
GUID guid
Definition: version.c:147
#define D3DXF_FILELOAD_FROMMEMORY
Definition: d3dx9xof.h:41
static char memory[1024 *256]
Definition: process.c:122
#define D3DRM_XTEMPLATE_BYTES
Definition: rmxftmpl.h:283
unsigned char D3DRM_XTEMPLATES[]
Definition: rmxftmpl.h:6
Definition: fci.c:123
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by test_load_skin_mesh_from_xof().

◆ ID3DXAllocateHierarchyImpl_CreateFrame()

static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_CreateFrame ( ID3DXAllocateHierarchy *  iface,
const char *  name,
D3DXFRAME **  new_frame 
)
static

Definition at line 1819 of file mesh.c.

1821{
1822 D3DXFRAME *frame;
1823
1824 TRACECALLBACK("ID3DXAllocateHierarchyImpl_CreateFrame(%p, '%s', %p)\n", iface, name, new_frame);
1825 frame = calloc(1, sizeof(*frame));
1826 if (!frame)
1827 return E_OUTOFMEMORY;
1828 if (name) {
1829 frame->Name = strdup(name);
1830 if (!frame->Name) {
1831 free(frame);
1832 return E_OUTOFMEMORY;
1833 }
1834 }
1835 *new_frame = frame;
1836 return D3D_OK;
1837}
static char * strdup(const char *buf)
Definition: string.h:83
#define TRACECALLBACK
Definition: mesh.c:35
#define calloc
Definition: rosglue.h:14

◆ ID3DXAllocateHierarchyImpl_CreateMeshContainer()

static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_CreateMeshContainer ( ID3DXAllocateHierarchy *  iface,
const char *  name,
const D3DXMESHDATA *  mesh_data,
const D3DXMATERIAL *  materials,
const D3DXEFFECTINSTANCE *  effects,
DWORD  num_materials,
const DWORD *  adjacency,
ID3DXSkinInfo *  skin_info,
D3DXMESHCONTAINER **  new_mesh_container 
)
static

Definition at line 1880 of file mesh.c.

1884{
1886 int i;
1887
1888 TRACECALLBACK("ID3DXAllocateHierarchyImpl_CreateMeshContainer(%p, '%s', %u, %p, %p, %p, %ld, %p, %p, %p)\n",
1889 iface, name, mesh_data->Type, mesh_data->pMesh, materials, effects,
1890 num_materials, adjacency, skin_info, *new_mesh_container);
1891
1892 mesh_container = calloc(1, sizeof(*mesh_container));
1893 if (!mesh_container)
1894 return E_OUTOFMEMORY;
1895
1896 if (name) {
1897 mesh_container->Name = strdup(name);
1898 if (!mesh_container->Name)
1899 goto error;
1900 }
1901
1902 mesh_container->NumMaterials = num_materials;
1903 if (num_materials) {
1904 mesh_container->pMaterials = malloc(num_materials * sizeof(*materials));
1905 if (!mesh_container->pMaterials)
1906 goto error;
1907
1908 memcpy(mesh_container->pMaterials, materials, num_materials * sizeof(*materials));
1909 for (i = 0; i < num_materials; i++)
1910 mesh_container->pMaterials[i].pTextureFilename = NULL;
1911 for (i = 0; i < num_materials; i++) {
1912 if (materials[i].pTextureFilename) {
1913 mesh_container->pMaterials[i].pTextureFilename = strdup(materials[i].pTextureFilename);
1914 if (!mesh_container->pMaterials[i].pTextureFilename)
1915 goto error;
1916 }
1917 }
1918
1919 mesh_container->pEffects = calloc(num_materials, sizeof(*effects));
1920 if (!mesh_container->pEffects)
1921 goto error;
1922 for (i = 0; i < num_materials; i++) {
1923 int j;
1924 const D3DXEFFECTINSTANCE *effect_src = &effects[i];
1925 D3DXEFFECTINSTANCE *effect_dest = &mesh_container->pEffects[i];
1926
1927 if (effect_src->pEffectFilename) {
1928 effect_dest->pEffectFilename = strdup(effect_src->pEffectFilename);
1929 if (!effect_dest->pEffectFilename)
1930 goto error;
1931 }
1932 effect_dest->pDefaults = calloc(effect_src->NumDefaults, sizeof(*effect_src->pDefaults));
1933 if (!effect_dest->pDefaults)
1934 goto error;
1935 effect_dest->NumDefaults = effect_src->NumDefaults;
1936 for (j = 0; j < effect_src->NumDefaults; j++) {
1937 const D3DXEFFECTDEFAULT *default_src = &effect_src->pDefaults[j];
1938 D3DXEFFECTDEFAULT *default_dest = &effect_dest->pDefaults[j];
1939
1940 if (default_src->pParamName) {
1941 default_dest->pParamName = strdup(default_src->pParamName);
1942 if (!default_dest->pParamName)
1943 goto error;
1944 }
1945 default_dest->NumBytes = default_src->NumBytes;
1946 default_dest->Type = default_src->Type;
1947 default_dest->pValue = malloc(default_src->NumBytes);
1948 memcpy(default_dest->pValue, default_src->pValue, default_src->NumBytes);
1949 }
1950 }
1951 }
1952
1953 ok(adjacency != NULL, "Expected non-NULL adjacency, got NULL\n");
1954 if (adjacency) {
1955 if (mesh_data->Type == D3DXMESHTYPE_MESH || mesh_data->Type == D3DXMESHTYPE_PMESH) {
1956 ID3DXBaseMesh *basemesh = (ID3DXBaseMesh*)mesh_data->pMesh;
1957 DWORD num_faces = basemesh->lpVtbl->GetNumFaces(basemesh);
1958 size_t size = num_faces * sizeof(DWORD) * 3;
1959 mesh_container->pAdjacency = malloc(size);
1960 if (!mesh_container->pAdjacency)
1961 goto error;
1962 memcpy(mesh_container->pAdjacency, adjacency, size);
1963 } else {
1964 ok(mesh_data->Type == D3DXMESHTYPE_PATCHMESH, "Unknown mesh type %u\n", mesh_data->Type);
1965 if (mesh_data->Type == D3DXMESHTYPE_PATCHMESH)
1966 trace("FIXME: copying adjacency data for patch mesh not implemented\n");
1967 }
1968 }
1969
1970 memcpy(&mesh_container->MeshData, mesh_data, sizeof(*mesh_data));
1971 if (mesh_data->pMesh)
1972 IUnknown_AddRef(mesh_data->pMesh);
1973 if (skin_info) {
1974 mesh_container->pSkinInfo = skin_info;
1975 skin_info->lpVtbl->AddRef(skin_info);
1976 }
1977 *new_mesh_container = mesh_container;
1978
1979 return S_OK;
1980error:
1982 return E_OUTOFMEMORY;
1983}
@ D3DXMESHTYPE_PATCHMESH
Definition: d3dx9anim.h:31
@ D3DXMESHTYPE_PMESH
Definition: d3dx9anim.h:30
#define error(str)
Definition: mkdosfs.c:1605
static HRESULT destroy_mesh_container(LPD3DXMESHCONTAINER mesh_container)
Definition: mesh.c:1839
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)
char * pEffectFilename
Definition: d3dx9mesh.h:209

◆ ID3DXAllocateHierarchyImpl_DestroyFrame()

static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_DestroyFrame ( ID3DXAllocateHierarchy *  iface,
LPD3DXFRAME  frame 
)
static

Definition at line 1809 of file mesh.c.

1810{
1811 TRACECALLBACK("ID3DXAllocateHierarchyImpl_DestroyFrame(%p, %p)\n", iface, frame);
1812 if (frame) {
1813 free(frame->Name);
1814 free(frame);
1815 }
1816 return D3D_OK;
1817}

◆ ID3DXAllocateHierarchyImpl_DestroyMeshContainer()

static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_DestroyMeshContainer ( ID3DXAllocateHierarchy *  iface,
LPD3DXMESHCONTAINER  mesh_container 
)
static

Definition at line 1874 of file mesh.c.

1875{
1876 TRACECALLBACK("ID3DXAllocateHierarchyImpl_DestroyMeshContainer(%p, %p)\n", iface, mesh_container);
1878}

◆ impl_from_ID3DXLoadUserData()

static struct test_load_user_data * impl_from_ID3DXLoadUserData ( ID3DXLoadUserData *  iface)
static

Definition at line 2084 of file mesh.c.

2085{
2086 return CONTAINING_RECORD(iface, struct test_load_user_data, iface);
2087}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by load_frame_child_data(), load_mesh_child_data(), and load_top_level_data().

◆ init_dec3n_dword()

static DWORD init_dec3n_dword ( INT  x,
INT  y,
INT  z,
INT  w 
)
static

Definition at line 6653 of file mesh.c.

6654{
6655 DWORD d = 0;
6656
6657 d |= x & 0x3ff;
6658 d |= (y << 10) & 0xffc00;
6659 d |= (z << 20) & 0x3ff00000;
6660 d |= (w << 30) & 0xc0000000;
6661
6662 return d;
6663}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102

Referenced by test_weld_vertices().

◆ init_load_user_data()

static void init_load_user_data ( struct test_load_user_data *  data)
static

Definition at line 2128 of file mesh.c.

2129{
2130 memset(data, 0, sizeof(*data));
2131 data->iface.lpVtbl = &load_user_data_vtbl;
2132}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static const struct ID3DXLoadUserDataVtbl load_user_data_vtbl
Definition: mesh.c:2121

Referenced by D3DXLoadMeshTest().

◆ init_test_mesh()

static HRESULT init_test_mesh ( const DWORD  num_faces,
const DWORD  num_vertices,
const DWORD  options,
const D3DVERTEXELEMENT9 *  declaration,
IDirect3DDevice9 *  device,
ID3DXMesh **  mesh_ptr,
const void *  vertices,
const DWORD  vertex_size,
const DWORD *  indices,
const DWORD *  attributes 
)
static

Definition at line 6527 of file mesh.c.

6533{
6534 HRESULT hr;
6535 void *vertex_buffer;
6536 void *index_buffer;
6537 DWORD *attributes_buffer;
6538 ID3DXMesh *mesh = NULL;
6539
6540 hr = D3DXCreateMesh(num_faces, num_vertices, options, declaration, device, mesh_ptr);
6541 if (FAILED(hr))
6542 {
6543 skip("Couldn't create mesh. Got %lx expected D3D_OK\n", hr);
6544 goto cleanup;
6545 }
6546 mesh = *mesh_ptr;
6547
6548 hr = mesh->lpVtbl->LockVertexBuffer(mesh, 0, &vertex_buffer);
6549 if (FAILED(hr))
6550 {
6551 skip("Couldn't lock vertex buffer.\n");
6552 goto cleanup;
6553 }
6554 memcpy(vertex_buffer, vertices, num_vertices * vertex_size);
6555 hr = mesh->lpVtbl->UnlockVertexBuffer(mesh);
6556 if (FAILED(hr))
6557 {
6558 skip("Couldn't unlock vertex buffer.\n");
6559 goto cleanup;
6560 }
6561
6562 hr = mesh->lpVtbl->LockIndexBuffer(mesh, 0, &index_buffer);
6563 if (FAILED(hr))
6564 {
6565 skip("Couldn't lock index buffer.\n");
6566 goto cleanup;
6567 }
6568 if (options & D3DXMESH_32BIT)
6569 {
6570 if (indices)
6571 memcpy(index_buffer, indices, 3 * num_faces * sizeof(DWORD));
6572 else
6573 {
6574 /* Fill index buffer with 0, 1, 2, ...*/
6575 DWORD *indices_32bit = (DWORD*)index_buffer;
6576 UINT i;
6577 for (i = 0; i < 3 * num_faces; i++)
6578 indices_32bit[i] = i;
6579 }
6580 }
6581 else
6582 {
6583 if (indices)
6584 memcpy(index_buffer, indices, 3 * num_faces * sizeof(WORD));
6585 else
6586 {
6587 /* Fill index buffer with 0, 1, 2, ...*/
6588 WORD *indices_16bit = (WORD*)index_buffer;
6589 UINT i;
6590 for (i = 0; i < 3 * num_faces; i++)
6591 indices_16bit[i] = i;
6592 }
6593 }
6594 hr = mesh->lpVtbl->UnlockIndexBuffer(mesh);
6595 if (FAILED(hr)) {
6596 skip("Couldn't unlock index buffer.\n");
6597 goto cleanup;
6598 }
6599
6600 hr = mesh->lpVtbl->LockAttributeBuffer(mesh, 0, &attributes_buffer);
6601 if (FAILED(hr))
6602 {
6603 skip("Couldn't lock attributes buffer.\n");
6604 goto cleanup;
6605 }
6606
6607 if (attributes)
6608 memcpy(attributes_buffer, attributes, num_faces * sizeof(*attributes));
6609 else
6610 memset(attributes_buffer, 0, num_faces * sizeof(*attributes));
6611
6612 hr = mesh->lpVtbl->UnlockAttributeBuffer(mesh);
6613 if (FAILED(hr))
6614 {
6615 skip("Couldn't unlock attributes buffer.\n");
6616 goto cleanup;
6617 }
6618
6619 hr = D3D_OK;
6620cleanup:
6621 return hr;
6622}
static HANDLE ACCESS_MASK ULONG attributes
Definition: om.c:94

Referenced by test_clone_mesh(), test_valid_mesh(), and test_weld_vertices().

◆ init_udec3_dword()

static DWORD init_udec3_dword ( UINT  x,
UINT  y,
UINT  z,
UINT  w 
)
static

Definition at line 6641 of file mesh.c.

6642{
6643 DWORD d = 0;
6644
6645 d |= x & 0x3ff;
6646 d |= (y << 10) & 0xffc00;
6647 d |= (z << 20) & 0x3ff00000;
6648 d |= (w << 30) & 0xc0000000;
6649
6650 return d;
6651}

Referenced by test_weld_vertices().

◆ is_direction_similar()

static BOOL is_direction_similar ( D3DXVECTOR2 *  dir1,
D3DXVECTOR2 *  dir2,
float  cos_theta 
)
inlinestatic

Definition at line 3814 of file mesh.c.

3815{
3816 /* dot product = cos(theta) */
3817 return D3DXVec2Dot(dir1, dir2) > cos_theta;
3818}

◆ load_frame_child_data()

static HRESULT STDMETHODCALLTYPE load_frame_child_data ( ID3DXLoadUserData *  iface,
D3DXFRAME *  frame,
ID3DXFileData *  filedata 
)
static

Definition at line 2097 of file mesh.c.

2099{
2101
2102 ok(!frame->pFrameSibling, "got %p.\n", frame->pFrameSibling);
2103 ok(!frame->pFrameFirstChild, "got %p.\n", frame->pFrameFirstChild);
2104
2105 user_data->data[user_data->data_count].mesh_container = !!frame->pMeshContainer;
2107 return S_OK;
2108}
static struct test_load_user_data * impl_from_ID3DXLoadUserData(ID3DXLoadUserData *iface)
Definition: mesh.c:2084
static void record_common_user_data(struct test_load_user_data *data, ID3DXFileData *filedata, enum user_data_type data_type)
Definition: mesh.c:2061
struct _D3DXFRAME * pFrameSibling
Definition: d3dx9anim.h:110
struct _D3DXFRAME * pFrameFirstChild
Definition: d3dx9anim.h:111
ID3DXLoadUserData iface
Definition: mesh.c:2054

◆ load_mesh_child_data()

static HRESULT STDMETHODCALLTYPE load_mesh_child_data ( ID3DXLoadUserData *  iface,
D3DXMESHCONTAINER *  mesh_container,
ID3DXFileData *  filedata 
)
static

Definition at line 2110 of file mesh.c.

2112{
2114
2115 user_data->data[user_data->data_count].num_materials = mesh_container->NumMaterials;
2116
2118 return S_OK;
2119}

◆ load_top_level_data()

static HRESULT STDMETHODCALLTYPE load_top_level_data ( ID3DXLoadUserData *  iface,
ID3DXFileData *  filedata 
)
static

Definition at line 2089 of file mesh.c.

◆ new_mesh()

static BOOL new_mesh ( struct mesh *  mesh,
DWORD  number_of_vertices,
DWORD  number_of_faces 
)
static

Definition at line 206 of file mesh.c.

207{
208 mesh->vertices = calloc(number_of_vertices, sizeof(*mesh->vertices));
209 if (!mesh->vertices)
210 {
211 return FALSE;
212 }
213 mesh->number_of_vertices = number_of_vertices;
214
215 mesh->faces = calloc(number_of_faces, sizeof(*mesh->faces));
216 if (!mesh->faces)
217 {
219 return FALSE;
220 }
221 mesh->number_of_faces = number_of_faces;
222
223 return TRUE;
224}

Referenced by compute_box(), compute_cylinder(), compute_polygon(), compute_sphere(), compute_text_mesh(), compute_torus(), D3DXCreateMeshFVFTest(), and D3DXCreateMeshTest().

◆ new_test_context()

static struct test_context * new_test_context ( void  )
static

Definition at line 112 of file mesh.c.

113{
114 HRESULT hr;
115 HWND hwnd = NULL;
116 IDirect3D9 *d3d = NULL;
118 D3DPRESENT_PARAMETERS d3dpp = {0};
120
121 if (!(hwnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
122 640, 480, NULL, NULL, NULL, NULL)))
123 {
124 skip("Couldn't create application window\n");
125 goto error;
126 }
127
129 if (!d3d)
130 {
131 skip("Couldn't create IDirect3D9 object\n");
132 goto error;
133 }
134
135 memset(&d3dpp, 0, sizeof(d3dpp));
136 d3dpp.Windowed = TRUE;
140 if (FAILED(hr))
141 {
142 skip("Couldn't create IDirect3DDevice9 object %#lx\n", hr);
143 goto error;
144 }
145
146 test_context = malloc(sizeof(*test_context));
147 if (!test_context)
148 {
149 skip("Couldn't allocate memory for test_context\n");
150 goto error;
151 }
155
156 return test_context;
157
158error:
159 if (device)
161
162 if (d3d)
164
165 if (hwnd)
167
168 return NULL;
169}
@ D3DSWAPEFFECT_DISCARD
Definition: d3d8types.h:851
@ D3DDEVTYPE_HAL
Definition: d3d8types.h:576
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
Definition: d3d9.h:224
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4469
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:53
#define D3D_SDK_VERSION
Definition: d3d8.h:52
#define D3DCREATE_SOFTWARE_VERTEXPROCESSING
Definition: d3d8.h:40
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by D3DXCreateBoxTest(), D3DXCreateCylinderTest(), D3DXCreateMeshFVFTest(), D3DXCreateMeshTest(), D3DXCreatePolygonTest(), D3DXCreateSphereTest(), D3DXCreateTextTest(), D3DXCreateTorusTest(), D3DXGenerateAdjacencyTest(), D3DXLoadMeshTest(), test_clone_mesh(), test_compute_normals(), test_convert_adjacency_to_point_reps(), test_convert_point_reps_to_adjacency(), test_mesh_optimize(), test_update_semantics(), test_valid_mesh(), and test_weld_vertices().

◆ print_elements()

static void print_elements ( const D3DVERTEXELEMENT9 *  elements)
static

Definition at line 585 of file mesh.c.

586{
588 const D3DVERTEXELEMENT9 *ptr = elements;
589 int count = 0;
590
591 while (memcmp(ptr, &last, sizeof(D3DVERTEXELEMENT9)))
592 {
593 trace(
594 "[Element %d] Stream = %d, Offset = %d, Type = %d, Method = %d, Usage = %d, UsageIndex = %d\n",
595 count, ptr->Stream, ptr->Offset, ptr->Type, ptr->Method, ptr->Usage, ptr->UsageIndex);
596 ptr++;
597 count++;
598 }
599}
static PVOID ptr
Definition: dispmode.c:27

Referenced by compare_elements().

◆ record_common_user_data()

static void record_common_user_data ( struct test_load_user_data *  data,
ID3DXFileData *  filedata,
enum user_data_type  data_type 
)
static

Definition at line 2061 of file mesh.c.

2063{
2064 struct test_user_data *d = &data->data[data->data_count];
2065 const void *ptr;
2066 HRESULT hr;
2067 SIZE_T sz;
2068
2069 assert(data->data_count < MAX_USER_DATA_COUNT);
2070
2071 d->data_type = data_type;
2072 hr = filedata->lpVtbl->GetType(filedata, &data->guids[data->data_count]);
2073 ok(hr == S_OK, "got %#lx.\n", hr);
2074 hr = filedata->lpVtbl->Lock(filedata, &sz, &ptr);
2075 ok(hr == S_OK, "got %#lx.\n", hr);
2076 d->size = sz;
2077 ok(sz >= sizeof(int), "got %Iu.\n", sz);
2078 d->value = *(unsigned int *)ptr;
2079 hr = filedata->lpVtbl->Unlock(filedata);
2080 ok(hr == S_OK, "got %#lx.\n", hr);
2081 ++data->data_count;
2082}
#define assert(_expr)
Definition: assert.h:32
enum wined3d_data_type data_type
Definition: glsl_shader.c:71
#define MAX_USER_DATA_COUNT
Definition: mesh.c:2034

Referenced by load_frame_child_data(), load_mesh_child_data(), and load_top_level_data().

◆ reserve()

static BOOL reserve ( struct dynamic_array *  array,
int  count,
int  itemsize 
)
static

Definition at line 3728 of file mesh.c.

3729{
3730 if (count > array->capacity) {
3731 void *new_buffer;
3732 int new_capacity;
3733 if (array->items && array->capacity) {
3734 new_capacity = max(array->capacity * 2, count);
3735 new_buffer = realloc(array->items, new_capacity * itemsize);
3736 } else {
3737 new_capacity = max(16, count);
3738 new_buffer = malloc(new_capacity * itemsize);
3739 }
3740 if (!new_buffer)
3741 return FALSE;
3742 array->items = new_buffer;
3743 array->capacity = new_capacity;
3744 }
3745 return TRUE;
3746}
#define realloc
Definition: debug_ros.c:6

◆ START_TEST()

START_TEST ( mesh  )

Definition at line 11832 of file mesh.c.

11833{
11867}
static void D3DXCreateMeshFVFTest(void)
Definition: mesh.c:1399
static void D3DXCreateSphereTest(void)
Definition: mesh.c:3253
static void D3DXCreatePolygonTest(void)
Definition: mesh.c:2976
static void D3DXCreateMeshTest(void)
Definition: mesh.c:1193
static void test_convert_point_reps_to_adjacency(void)
Definition: mesh.c:5978
static void D3DXGetFVFVertexSizeTest(void)
Definition: mesh.c:1002
static void D3DXCreateAnimationControllerTest(void)
Definition: mesh.c:11350
static void test_optimize_vertices(void)
Definition: mesh.c:10752
static void test_get_decl_length(void)
Definition: mesh.c:4622
static void test_compute_normals(void)
Definition: mesh.c:10921
static void D3DXGenerateAdjacencyTest(void)
Definition: mesh.c:4744
static void D3DXIntersectTriTest(void)
Definition: mesh.c:1106
static void test_convert_adjacency_to_point_reps(void)
Definition: mesh.c:5462
static void test_mesh_optimize(void)
Definition: mesh.c:11716
static void D3DXComputeBoundingSphereTest(void)
Definition: mesh.c:534
static void D3DXCreateBoxTest(void)
Definition: mesh.c:2851
static void D3DXCreateKeyframedAnimationSetTest(void)
Definition: mesh.c:11414
static void D3DXCreateCylinderTest(void)
Definition: mesh.c:3480
static void test_optimize_faces(void)
Definition: mesh.c:10602
static void D3DXCreateTorusTest(void)
Definition: mesh.c:3644
static void test_D3DXFrameFind(void)
Definition: mesh.c:11440
static void D3DXComputeBoundingBoxTest(void)
Definition: mesh.c:467
static void D3DXLoadMeshTest(void)
Definition: mesh.c:2161
static void D3DXCreateTextTest(void)
Definition: mesh.c:4524
static void test_update_semantics(void)
Definition: mesh.c:4860
static void test_clone_mesh(void)
Definition: mesh.c:8719
static void test_get_decl_vertex_size(void)
Definition: mesh.c:4672
static void D3DXBoundProbeTest(void)
Definition: mesh.c:373
static void test_fvf_decl_conversion(void)
Definition: mesh.c:664
static void test_weld_vertices(void)
Definition: mesh.c:6866
static void test_valid_mesh(void)
Definition: mesh.c:10479
static void test_create_skin_info(void)
Definition: mesh.c:5185
static void test_load_skin_mesh_from_xof(void)
Definition: mesh.c:11563

◆ test_box()

static void test_box ( IDirect3DDevice9 *  device,
float  width,
float  height,
float  depth 
)
static

Definition at line 2820 of file mesh.c.

2821{
2822 HRESULT hr;
2823 ID3DXMesh *box;
2824 struct mesh mesh;
2825 char name[256];
2826
2828 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
2829 if (hr != D3D_OK)
2830 {
2831 skip("Couldn't create box\n");
2832 return;
2833 }
2834
2835 if (!compute_box(&mesh, width, height, depth))
2836 {
2837 skip("Couldn't create mesh\n");
2838 box->lpVtbl->Release(box);
2839 return;
2840 }
2841
2843
2844 sprintf(name, "box (%g, %g, %g)", width, height, depth);
2846
2847 free_mesh(&mesh);
2848
2849 box->lpVtbl->Release(box);
2850}
static BOOL compute_box(struct mesh *mesh, float width, float height, float depth)
Definition: mesh.c:2772

Referenced by D3DXCreateBoxTest().

◆ test_clone_mesh()

static void test_clone_mesh ( void  )
static

Definition at line 8719 of file mesh.c.

8720{
8721 HRESULT hr;
8722 struct test_context *test_context = NULL;
8724 D3DVERTEXELEMENT9 declaration_pn[] =
8725 {
8728 D3DDECL_END()
8729 };
8730 D3DVERTEXELEMENT9 declaration_pntc[] =
8731 {
8735 D3DDECL_END()
8736 };
8737 D3DVERTEXELEMENT9 declaration_ptcn[] =
8738 {
8742 D3DDECL_END()
8743 };
8744 D3DVERTEXELEMENT9 declaration_ptc[] =
8745 {
8748 D3DDECL_END()
8749 };
8750 D3DVERTEXELEMENT9 declaration_ptc_float16_2[] =
8751 {
8754 D3DDECL_END()
8755 };
8756 D3DVERTEXELEMENT9 declaration_ptc_float16_4[] =
8757 {
8760 D3DDECL_END()
8761 };
8762 D3DVERTEXELEMENT9 declaration_ptc_float1[] =
8763 {
8766 D3DDECL_END()
8767 };
8768 D3DVERTEXELEMENT9 declaration_ptc_float3[] =
8769 {
8772 D3DDECL_END()
8773 };
8774 D3DVERTEXELEMENT9 declaration_ptc_float4[] =
8775 {
8778 D3DDECL_END()
8779 };
8780 D3DVERTEXELEMENT9 declaration_ptc_d3dcolor[] =
8781 {
8784 D3DDECL_END()
8785 };
8786 D3DVERTEXELEMENT9 declaration_ptc_ubyte4[] =
8787 {
8790 D3DDECL_END()
8791 };
8792 D3DVERTEXELEMENT9 declaration_ptc_ubyte4n[] =
8793 {
8796 D3DDECL_END()
8797 };
8798 D3DVERTEXELEMENT9 declaration_ptc_short2[] =
8799 {
8802 D3DDECL_END()
8803 };
8804 D3DVERTEXELEMENT9 declaration_ptc_short4[] =
8805 {
8808 D3DDECL_END()
8809 };
8810 D3DVERTEXELEMENT9 declaration_ptc_short2n[] =
8811 {
8814 D3DDECL_END()
8815 };
8816 D3DVERTEXELEMENT9 declaration_ptc_short4n[] =
8817 {
8820 D3DDECL_END()
8821 };
8822 D3DVERTEXELEMENT9 declaration_ptc_ushort2n[] =
8823 {
8826 D3DDECL_END()
8827 };
8828 D3DVERTEXELEMENT9 declaration_ptc_ushort4n[] =
8829 {
8832 D3DDECL_END()
8833 };
8834 D3DVERTEXELEMENT9 declaration_ptc_float16_2_partialu[] =
8835 {
8838 D3DDECL_END()
8839 };
8840 D3DVERTEXELEMENT9 declaration_pntc1[] =
8841 {
8845 D3DDECL_END()
8846 };
8847 const unsigned int VERTS_PER_FACE = 3;
8848 BYTE *vertices = NULL;
8849 INT i;
8850 struct vertex_pn
8851 {
8852 D3DXVECTOR3 position;
8854 };
8855 struct vertex_pntc
8856 {
8857 D3DXVECTOR3 position;
8859 D3DXVECTOR2 texcoords;
8860 };
8861 struct vertex_ptcn
8862 {
8863 D3DXVECTOR3 position;
8864 D3DXVECTOR2 texcoords;
8866 };
8867 struct vertex_ptc
8868 {
8869 D3DXVECTOR3 position;
8870 D3DXVECTOR2 texcoords;
8871 };
8872 struct vertex_ptc_float16_2
8873 {
8874 D3DXVECTOR3 position;
8875 WORD texcoords[2]; /* float16_2 */
8876 };
8877 struct vertex_ptc_float16_4
8878 {
8879 D3DXVECTOR3 position;
8880 WORD texcoords[4]; /* float16_4 */
8881 };
8882 struct vertex_ptc_float1
8883 {
8884 D3DXVECTOR3 position;
8885 FLOAT texcoords;
8886 };
8887 struct vertex_ptc_float3
8888 {
8889 D3DXVECTOR3 position;
8890 FLOAT texcoords[3];
8891 };
8892 struct vertex_ptc_float4
8893 {
8894 D3DXVECTOR3 position;
8895 FLOAT texcoords[4];
8896 };
8897 struct vertex_ptc_d3dcolor
8898 {
8899 D3DXVECTOR3 position;
8900 BYTE texcoords[4];
8901 };
8902 struct vertex_ptc_ubyte4
8903 {
8904 D3DXVECTOR3 position;
8905 BYTE texcoords[4];
8906 };
8907 struct vertex_ptc_ubyte4n
8908 {
8909 D3DXVECTOR3 position;
8910 BYTE texcoords[4];
8911 };
8912 struct vertex_ptc_short2
8913 {
8914 D3DXVECTOR3 position;
8915 SHORT texcoords[2];
8916 };
8917 struct vertex_ptc_short4
8918 {
8919 D3DXVECTOR3 position;
8920 SHORT texcoords[4];
8921 };
8922 struct vertex_ptc_ushort2n
8923 {
8924 D3DXVECTOR3 position;
8925 USHORT texcoords[2];
8926 };
8927 struct vertex_ptc_ushort4n
8928 {
8929 D3DXVECTOR3 position;
8930 USHORT texcoords[4];
8931 };
8932 struct vertex_ptc_udec3
8933 {
8934 D3DXVECTOR3 position;
8935 DWORD texcoords;
8936 };
8937 struct vertex_ptc_dec3n
8938 {
8939 D3DXVECTOR3 position;
8940 DWORD texcoords;
8941 };
8942 D3DXVECTOR3 up = {0.0f, 0.0f, 1.0f};
8943 D3DXVECTOR2 zero_vec2 = {0.0f, 0.0f};
8944 /* Test 0. Check that a mesh can be cloned if the new declaration is the
8945 * same as the one used to create the mesh.
8946 *
8947 * 0--1 3
8948 * | / /|
8949 * |/ / |
8950 * 2 5--4
8951 */
8952 const struct vertex_pn vertices0[] =
8953 {
8954 {{ 0.0f, 3.0f, 0.f}, up},
8955 {{ 2.0f, 3.0f, 0.f}, up},
8956 {{ 0.0f, 0.0f, 0.f}, up},
8957
8958 {{ 3.0f, 3.0f, 0.f}, up},
8959 {{ 3.0f, 0.0f, 0.f}, up},
8960 {{ 1.0f, 0.0f, 0.f}, up},
8961 };
8962 const UINT num_vertices0 = ARRAY_SIZE(vertices0);
8963 const UINT num_faces0 = ARRAY_SIZE(vertices0) / VERTS_PER_FACE;
8964 const UINT vertex_size0 = sizeof(*vertices0);
8965 /* Test 1. Check that 16-bit indices are handled. */
8966 const DWORD options_16bit = D3DXMESH_SYSTEMMEM;
8967 /* Test 2. Check that the size of each vertex is increased and the data
8968 * moved if the new declaration adds an element after the original elements.
8969 */
8970 const struct vertex_pntc exp_vertices2[] =
8971 {
8972 {{ 0.0f, 3.0f, 0.f}, up, zero_vec2},
8973 {{ 2.0f, 3.0f, 0.f}, up, zero_vec2},
8974 {{ 0.0f, 0.0f, 0.f}, up, zero_vec2},
8975
8976 {{ 3.0f, 3.0f, 0.f}, up, zero_vec2},
8977 {{ 3.0f, 0.0f, 0.f}, up, zero_vec2},
8978 {{ 1.0f, 0.0f, 0.f}, up, zero_vec2},
8979 };
8980 const UINT exp_vertex_size2 = sizeof(*exp_vertices2);
8981 /* Test 3. Check that the size of each vertex is increased and the data
8982 * moved if the new declaration adds an element between the original
8983 * elements.
8984 */
8985 const struct vertex_ptcn exp_vertices3[] =
8986 {
8987 {{ 0.0f, 3.0f, 0.f}, zero_vec2, up},
8988 {{ 2.0f, 3.0f, 0.f}, zero_vec2, up},
8989 {{ 0.0f, 0.0f, 0.f}, zero_vec2, up},
8990
8991 {{ 3.0f, 3.0f, 0.f}, zero_vec2, up},
8992 {{ 3.0f, 0.0f, 0.f}, zero_vec2, up},
8993 {{ 1.0f, 0.0f, 0.f}, zero_vec2, up},
8994 };
8995 const UINT exp_vertex_size3 = sizeof(*exp_vertices3);
8996 /* Test 4. Test that data types can be converted, e.g. FLOAT2 to FLOAT16_2. */
8997 const struct vertex_ptc vertices4[] =
8998 {
8999 {{ 0.0f, 3.0f, 0.f}, { 1.0f, 1.0f}},
9000 {{ 2.0f, 3.0f, 0.f}, { 0.5f, 0.7f}},
9001 {{ 0.0f, 0.0f, 0.f}, {-0.2f, -0.3f}},
9002
9003 {{ 3.0f, 3.0f, 0.f}, { 0.2f, 0.3f}},
9004 {{ 3.0f, 0.0f, 0.f}, { 1.0f, 1.0f}},
9005 {{ 1.0f, 0.0f, 0.f}, { 0.1f, 0.2f}},
9006 };
9007 const UINT num_vertices4 = ARRAY_SIZE(vertices4);
9008 const UINT num_faces4 = ARRAY_SIZE(vertices4) / VERTS_PER_FACE;
9009 const UINT vertex_size4 = sizeof(*vertices4);
9010 const struct vertex_ptc_float16_2 exp_vertices4[] =
9011 {
9012 {{ 0.0f, 3.0f, 0.f}, {0x3c00, 0x3c00}}, /* {1.0f, 1.0f} */
9013 {{ 2.0f, 3.0f, 0.f}, {0x3800, 0x399a}}, /* {0.5f, 0.7f} */
9014 {{ 0.0f, 0.0f, 0.f}, {0xb266, 0xb4cd}}, /* {-0.2f, -0.3f} */
9015
9016 {{ 3.0f, 3.0f, 0.f}, {0x3266, 0x34cd}}, /* {0.2f, 0.3f} */
9017 {{ 3.0f, 0.0f, 0.f}, {0x3c00, 0x3c00}}, /* {1.0f, 1.0f} */
9018 {{ 1.0f, 0.0f, 0.f}, {0x2e66, 0x3266}}, /* {0.1f, 0.2f} */
9019 };
9020 const UINT exp_vertex_size4 = sizeof(*exp_vertices4);
9021 /* Test 5. Convert FLOAT2 to FLOAT16_4. */
9022 const struct vertex_ptc vertices5[] =
9023 {
9024 {{ 0.0f, 3.0f, 0.f}, { 1.0f, 1.0f}},
9025 {{ 2.0f, 3.0f, 0.f}, { 0.5f, 0.7f}},
9026 {{ 0.0f, 0.0f, 0.f}, {-0.2f, -0.3f}},
9027
9028 {{ 3.0f, 3.0f, 0.f}, { 0.2f, 0.3f}},
9029 {{ 3.0f, 0.0f, 0.f}, { 1.0f, 1.0f}},
9030 {{ 1.0f, 0.0f, 0.f}, { 0.1f, 0.2f}},
9031 };
9032 const UINT num_vertices5 = ARRAY_SIZE(vertices5);
9033 const UINT num_faces5 = ARRAY_SIZE(vertices5) / VERTS_PER_FACE;
9034 const UINT vertex_size5 = sizeof(*vertices5);
9035 const struct vertex_ptc_float16_4 exp_vertices5[] =
9036 {
9037 {{ 0.0f, 3.0f, 0.f}, {0x3c00, 0x3c00, 0, 0x3c00}}, /* {1.0f, 1.0f, 0.0f, 1.0f} */
9038 {{ 2.0f, 3.0f, 0.f}, {0x3800, 0x399a, 0, 0x3c00}}, /* {0.5f, 0.7f, 0.0f, 1.0f} */
9039 {{ 0.0f, 0.0f, 0.f}, {0xb266, 0xb4cd, 0, 0x3c00}}, /* {-0.2f, -0.3f, 0.0f, 1.0f} */
9040
9041 {{ 3.0f, 3.0f, 0.f}, {0x3266, 0x34cd, 0, 0x3c00}}, /* {0.2f, 0.3f, 0.0f, 1.0f} */
9042 {{ 3.0f, 0.0f, 0.f}, {0x3c00, 0x3c00, 0, 0x3c00}}, /* {1.0f, 1.0f, 0.0f, 1.0f} */
9043 {{ 1.0f, 0.0f, 0.f}, {0x2e66, 0x3266, 0, 0x3c00}}, /* {0.1f, 0.2f, 0.0f, 1.0f} */
9044 };
9045 const UINT exp_vertex_size5 = sizeof(*exp_vertices5);
9046 /* Test 6. Convert FLOAT2 to FLOAT1. */
9047 const struct vertex_ptc vertices6[] =
9048 {
9049 {{ 0.0f, 3.0f, 0.f}, { 1.0f, 1.0f}},
9050 {{ 2.0f, 3.0f, 0.f}, { 0.5f, 0.7f}},
9051 {{ 0.0f, 0.0f, 0.f}, {-0.2f, -0.3f}},
9052
9053 {{ 3.0f, 3.0f, 0.f}, { 0.2f, 0.3f}},
9054 {{ 3.0f, 0.0f, 0.f}, { 1.0f, 1.0f}},
9055 {{ 1.0f, 0.0f, 0.f}, { 0.1f, 0.2f}},
9056 };
9057 const UINT num_vertices6 = ARRAY_SIZE(vertices6);
9058 const UINT num_faces6 = ARRAY_SIZE(vertices6) / VERTS_PER_FACE;
9059 const UINT vertex_size6 = sizeof(*vertices6);
9060 const struct vertex_ptc_float1 exp_vertices6[] =
9061 {
9062 {{ 0.0f, 3.0f, 0.f}, 1.0f},
9063 {{ 2.0f, 3.0f, 0.f}, 0.5f},
9064 {{ 0.0f, 0.0f, 0.f}, -0.2f},
9065
9066 {{ 3.0f, 3.0f, 0.f}, 0.2f},
9067 {{ 3.0f, 0.0f, 0.f}, 1.0f},
9068 {{ 1.0f, 0.0f, 0.f}, 0.1f},
9069 };
9070 const UINT exp_vertex_size6 = sizeof(*exp_vertices6);
9071 /* Test 7. Convert FLOAT2 to FLOAT3. */
9072 const struct vertex_ptc vertices7[] =
9073 {
9074 {{ 0.0f, 3.0f, 0.f}, { 1.0f, 1.0f}},
9075 {{ 2.0f, 3.0f, 0.f}, { 0.5f, 0.7f}},
9076 {{ 0.0f, 0.0f, 0.f}, {-0.2f, -0.3f}},
9077
9078 {{ 3.0f, 3.0f, 0.f}, { 0.2f, 0.3f}},
9079 {{ 3.0f, 0.0f, 0.f}, { 1.0f, 1.0f}},
9080 {{ 1.0f, 0.0f, 0.f}, { 0.1f, 0.2f}},
9081 };
9082 const UINT num_vertices7 = ARRAY_SIZE(vertices7);
9083 const UINT num_faces7 = ARRAY_SIZE(vertices7) / VERTS_PER_FACE;
9084 const UINT vertex_size7 = sizeof(*vertices7);
9085 const struct vertex_ptc_float3 exp_vertices7[] =
9086 {
9087 {{ 0.0f, 3.0f, 0.f}, { 1.0f, 1.0f, 0.0f}},
9088 {{ 2.0f, 3.0f, 0.f}, { 0.5f, 0.7f, 0.0f}},
9089 {{ 0.0f, 0.0f, 0.f}, {-0.2f, -0.3f, 0.0f}},
9090
9091 {{ 3.0f, 3.0f, 0.f}, { 0.2f, 0.3f, 0.0f}},
9092 {{ 3.0f, 0.0f, 0.f}, { 1.0f, 1.0f, 0.0f}},
9093 {{ 1.0f, 0.0f, 0.f}, { 0.1f, 0.2f, 0.0f}},
9094 };
9095 const UINT exp_vertex_size7 = sizeof(*exp_vertices7);
9096 /* Test 8. Convert FLOAT2 to FLOAT4. */
9097 const struct vertex_ptc vertices8[] =
9098 {
9099 {{ 0.0f, 3.0f, 0.f}, { 1.0f, 1.0f}},
9100 {{ 2.0f, 3.0f, 0.f}, { 0.5f, 0.7f}},
9101 {{ 0.0f, 0.0f, 0.f}, {-0.2f, -0.3f}},
9102
9103 {{ 3.0f, 3.0f, 0.f}, { 0.2f, 0.3f}},
9104 {{ 3.0f, 0.0f, 0.f}, { 1.0f, 1.0f}},
9105 {{ 1.0f, 0.0f, 0.f}, { 0.1f, 0.2f}},
9106 };
9107 const UINT num_vertices8 = ARRAY_SIZE(vertices8);
9108 const UINT num_faces8 = ARRAY_SIZE(vertices8) / VERTS_PER_FACE;
9109 const UINT vertex_size8 = sizeof(*vertices8);
9110 const struct vertex_ptc_float4 exp_vertices8[] =
9111 {
9112 {{ 0.0f, 3.0f, 0.f}, { 1.0f, 1.0f, 0.0f, 1.0f}},
9113 {{ 2.0f, 3.0f, 0.f}, { 0.5f, 0.7f, 0.0f, 1.0f}},
9114 {{ 0.0f, 0.0f, 0.f}, {-0.2f, -0.3f, 0.0f, 1.0f}},
9115
9116 {{ 3.0f, 3.0f, 0.f}, { 0.2f, 0.3f, 0.0f, 1.0f}},
9117 {{ 3.0f, 0.0f, 0.f}, { 1.0f, 1.0f, 0.0f, 1.0f}},
9118 {{ 1.0f, 0.0f, 0.f}, { 0.1f, 0.2f, 0.0f, 1.0f}},
9119 };
9120 const UINT exp_vertex_size8 = sizeof(*exp_vertices8);
9121 /* Test 9. Convert FLOAT2 to D3DCOLOR. */
9122 const struct vertex_ptc vertices9[] =
9123 {
9124 {{ 0.0f, 3.0f, 0.f}, { 1.0f, 1.0f}},
9125 {{ 2.0f, 3.0f, 0.f}, { 0.5f, 0.7f}},
9126 {{ 0.0f, 0.0f, 0.f}, {-0.4f, -0.6f}},
9127
9128 {{ 3.0f, 3.0f, 0.f}, { 0.2f, 0.3f}},
9129 {{ 3.0f, 0.0f, 0.f}, { 2.0f, 256.0f}},
9130 {{ 1.0f, 0.0f, 0.f}, { 0.11f, 0.2f}},
9131 };
9132 const UINT num_vertices9 = ARRAY_SIZE(vertices9);
9133 const UINT num_faces9 = ARRAY_SIZE(vertices9) / VERTS_PER_FACE;
9134 const UINT vertex_size9 = sizeof(*vertices9);
9135 const struct vertex_ptc_d3dcolor exp_vertices9[] =
9136 {
9137 {{ 0.0f, 3.0f, 0.f}, {0, 255, 255, 255}},
9138 {{ 2.0f, 3.0f, 0.f}, {0, 179, 128, 255}},
9139 {{ 0.0f, 0.0f, 0.f}, {0, 0, 0, 255}},
9140
9141 {{ 3.0f, 3.0f, 0.f}, {0, 77, 51, 255}},
9142 {{ 3.0f, 0.0f, 0.f}, {0, 255, 255, 255}},
9143 {{ 1.0f, 0.0f, 0.f}, {0, 51, 28, 255}},
9144 };
9145 const UINT exp_vertex_size9 = sizeof(*exp_vertices9);
9146 /* Test 10. Convert FLOAT2 to UBYTE4. */
9147 const struct vertex_ptc vertices10[] =
9148 {
9149 {{ 0.0f, 3.0f, 0.f}, { 0.0f, 1.0f}},
9150 {{ 2.0f, 3.0f, 0.f}, { 2.0f, 3.0f}},
9151 {{ 0.0f, 0.0f, 0.f}, { 254.0f, 255.0f}},
9152
9153 {{ 3.0f, 3.0f, 0.f}, { 256.0f, 257.0f}},
9154 {{ 3.0f, 0.0f, 0.f}, { 1.4f, 1.5f}},
9155 {{ 1.0f, 0.0f, 0.f}, {-4.0f, -5.0f}},
9156 };
9157 const UINT num_vertices10 = ARRAY_SIZE(vertices10);
9158 const UINT num_faces10 = ARRAY_SIZE(vertices10) / VERTS_PER_FACE;
9159 const UINT vertex_size10 = sizeof(*vertices10);
9160 const struct vertex_ptc_ubyte4 exp_vertices10[] =
9161 {
9162 {{ 0.0f, 3.0f, 0.f}, {0, 1, 0, 1}},
9163 {{ 2.0f, 3.0f, 0.f}, {2, 3, 0, 1}},
9164 {{ 0.0f, 0.0f, 0.f}, {254, 255, 0, 1}},
9165
9166 {{ 3.0f, 3.0f, 0.f}, {0, 1, 0, 1}},
9167 {{ 3.0f, 0.0f, 0.f}, {1, 2, 0, 1}},
9168 {{ 1.0f, 0.0f, 0.f}, {0, 0, 0, 1}},
9169 };
9170 const UINT exp_vertex_size10 = sizeof(*exp_vertices10);
9171 /* Test 11. Convert FLOAT2 to SHORT2. */
9172 const struct vertex_ptc vertices11[] =
9173 {
9174 {{ 0.0f, 3.0f, 0.f}, { 1.0f, -1.0f}},
9175 {{ 2.0f, 3.0f, 0.f}, { 0.4f, 0.5f}},
9176 {{ 0.0f, 0.0f, 0.f}, {-0.5f, -5.0f}},
9177
9178 {{ 3.0f, 3.0f, 0.f}, {SHRT_MAX, SHRT_MIN}},
9179 {{ 3.0f, 0.0f, 0.f}, {SHRT_MAX + 1.0f, SHRT_MIN - 1.0f}},
9180 {{ 1.0f, 0.0f, 0.f}, {SHRT_MAX + 2.0f, SHRT_MIN - 2.0f}},
9181
9182 {{ 4.0f, 3.0f, 0.f}, {2 * SHRT_MAX, 2 * SHRT_MIN}},
9183 {{ 6.0f, 0.0f, 0.f}, {3 * SHRT_MAX, 3 * SHRT_MIN}},
9184 {{ 4.0f, 0.0f, 0.f}, {4 * SHRT_MAX, 4 * SHRT_MIN}},
9185 };
9186 const UINT num_vertices11 = ARRAY_SIZE(vertices11);
9187 const UINT num_faces11 = ARRAY_SIZE(vertices11) / VERTS_PER_FACE;
9188 const UINT vertex_size11 = sizeof(*vertices11);
9189 const struct vertex_ptc_short2 exp_vertices11[] =
9190 {
9191 {{ 0.0f, 3.0f, 0.f}, {1, 0}},
9192 {{ 2.0f, 3.0f, 0.f}, {0, 1}},
9193 {{ 0.0f, 0.0f, 0.f}, {0, -4}},
9194
9195 {{ 3.0f, 3.0f, 0.f}, {SHRT_MAX, SHRT_MIN + 1}},
9196 {{ 3.0f, 0.0f, 0.f}, {SHRT_MIN, SHRT_MIN}},
9197 {{ 1.0f, 0.0f, 0.f}, {SHRT_MIN + 1, SHRT_MAX}},
9198
9199 {{ 4.0f, 3.0f, 0.f}, {-2, 1}},
9200 {{ 6.0f, 0.0f, 0.f}, {32765, -32767}},
9201 {{ 4.0f, 0.0f, 0.f}, {-4, 1}},
9202 };
9203 const UINT exp_vertex_size11 = sizeof(*exp_vertices11);
9204 /* Test 12. Convert FLOAT2 to SHORT4. */
9205 const struct vertex_ptc vertices12[] =
9206 {
9207 {{ 0.0f, 3.0f, 0.f}, { 1.0f, -1.0f}},
9208 {{ 2.0f, 3.0f, 0.f}, { 0.4f, 0.5f}},
9209 {{ 0.0f, 0.0f, 0.f}, {-0.5f, -5.0f}},
9210
9211 {{ 3.0f, 3.0f, 0.f}, {SHRT_MAX, SHRT_MIN}},
9212 {{ 3.0f, 0.0f, 0.f}, {SHRT_MAX + 1.0f, SHRT_MIN - 1.0f}},
9213 {{ 1.0f, 0.0f, 0.f}, {SHRT_MAX + 2.0f, SHRT_MIN - 2.0f}},
9214
9215 {{ 4.0f, 3.0f, 0.f}, {2 * SHRT_MAX, 2 * SHRT_MIN}},
9216 {{ 6.0f, 0.0f, 0.f}, {3 * SHRT_MAX, 3 * SHRT_MIN}},
9217 {{ 4.0f, 0.0f, 0.f}, {4 * SHRT_MAX, 4 * SHRT_MIN}},
9218 };
9219 const UINT num_vertices12 = ARRAY_SIZE(vertices12);
9220 const UINT num_faces12 = ARRAY_SIZE(vertices12) / VERTS_PER_FACE;
9221 const UINT vertex_size12 = sizeof(*vertices12);
9222 const struct vertex_ptc_short4 exp_vertices12[] =
9223 {
9224 {{ 0.0f, 3.0f, 0.f}, {1, 0, 0, 1}},
9225 {{ 2.0f, 3.0f, 0.f}, {0, 1, 0, 1}},
9226 {{ 0.0f, 0.0f, 0.f}, {0, -4, 0, 1}},
9227
9228 {{ 3.0f, 3.0f, 0.f}, {SHRT_MAX, SHRT_MIN + 1, 0, 1}},
9229 {{ 3.0f, 0.0f, 0.f}, {SHRT_MIN, SHRT_MIN, 0, 1}},
9230 {{ 1.0f, 0.0f, 0.f}, {SHRT_MIN + 1, SHRT_MAX, 0, 1}},
9231
9232 {{ 4.0f, 3.0f, 0.f}, {-2, 1, 0, 1}},
9233 {{ 6.0f, 0.0f, 0.f}, {32765, -32767, 0, 1}},
9234 {{ 4.0f, 0.0f, 0.f}, {-4, 1, 0, 1}},
9235 };
9236 const UINT exp_vertex_size12 = sizeof(*exp_vertices12);
9237 /* Test 13. Convert FLOAT2 to UBYTE4N. */
9238 const struct vertex_ptc vertices13[] =
9239 {
9240 {{ 0.0f, 3.0f, 0.f}, { 1.0f, 2.0f}},
9241 {{ 2.0f, 3.0f, 0.f}, { 0.5f, 0.7f}},
9242 {{ 0.0f, 0.0f, 0.f}, {-0.4f, -0.5f}},
9243
9244 {{ 3.0f, 3.0f, 0.f}, {-0.6f, -1.0f}},
9245 {{ 3.0f, 0.0f, 0.f}, {UCHAR_MAX, UCHAR_MAX + 1}},
9246 {{ 1.0f, 0.0f, 0.f}, {2 * UCHAR_MAX, -UCHAR_MAX}},
9247 };
9248 const UINT num_vertices13 = ARRAY_SIZE(vertices13);
9249 const UINT num_faces13 = ARRAY_SIZE(vertices13) / VERTS_PER_FACE;
9250 const UINT vertex_size13 = sizeof(*vertices13);
9251 const struct vertex_ptc_ubyte4n exp_vertices13[] =
9252 {
9253 {{ 0.0f, 3.0f, 0.f}, {255, 255, 0, 255}},
9254 {{ 2.0f, 3.0f, 0.f}, {128, 179, 0, 255}},
9255 {{ 0.0f, 0.0f, 0.f}, {0, 0, 0, 255}},
9256
9257 {{ 3.0f, 3.0f, 0.f}, {0, 0, 0, 255}},
9258 {{ 3.0f, 0.0f, 0.f}, {255, 255, 0, 255}},
9259 {{ 1.0f, 0.0f, 0.f}, {255, 0, 0, 255}},
9260 };
9261 const UINT exp_vertex_size13 = sizeof(*exp_vertices13);
9262 /* Test 14. Convert FLOAT2 to SHORT2N. */
9263 const struct vertex_ptc vertices14[] =
9264 {
9265 {{ 0.0f, 3.0f, 0.f}, {1.0f, 2.0f}},
9266 {{ 2.0f, 3.0f, 0.f}, {0.4f, 0.5f}},
9267 {{ 0.0f, 0.0f, 0.f}, {0.6f, -1.0f}},
9268
9269 {{ 3.0f, 3.0f, 0.f}, {-0.4f, -0.5f}},
9270 {{ 3.0f, 0.0f, 0.f}, {-0.9f, -0.99997}},
9271 {{ 1.0f, 0.0f, 0.f}, {SHRT_MAX, SHRT_MIN}},
9272 };
9273 const UINT num_vertices14 = ARRAY_SIZE(vertices14);
9274 const UINT num_faces14 = ARRAY_SIZE(vertices14) / VERTS_PER_FACE;
9275 const UINT vertex_size14 = sizeof(*vertices14);
9276 const struct vertex_ptc_short2 exp_vertices14[] =
9277 {
9278 {{ 0.0f, 3.0f, 0.f}, {SHRT_MAX, SHRT_MAX}},
9279 {{ 2.0f, 3.0f, 0.f}, {13107, 16384}},
9280 {{ 0.0f, 0.0f, 0.f}, {19660, SHRT_MIN + 2}},
9281
9282 {{ 3.0f, 3.0f, 0.f}, {-13106, -16383}},
9283 {{ 3.0f, 0.0f, 0.f}, {-29489, SHRT_MIN + 3}},
9284 {{ 1.0f, 0.0f, 0.f}, {SHRT_MAX, SHRT_MIN + 2}},
9285 };
9286 const UINT exp_vertex_size14 = sizeof(*exp_vertices14);
9287 /* Test 15. Convert FLOAT2 to SHORT4N. */
9288 const struct vertex_ptc vertices15[] =
9289 {
9290 {{ 0.0f, 3.0f, 0.f}, {1.0f, 2.0f}},
9291 {{ 2.0f, 3.0f, 0.f}, {0.4f, 0.5f}},
9292 {{ 0.0f, 0.0f, 0.f}, {0.6f, -1.0f}},
9293
9294 {{ 3.0f, 3.0f, 0.f}, {-0.4f, -0.5f}},
9295 {{ 3.0f, 0.0f, 0.f}, {-0.9f, -0.99997}},
9296 {{ 1.0f, 0.0f, 0.f}, {SHRT_MAX, SHRT_MIN}},
9297 };
9298 const UINT num_vertices15 = ARRAY_SIZE(vertices15);
9299 const UINT num_faces15 = ARRAY_SIZE(vertices15) / VERTS_PER_FACE;
9300 const UINT vertex_size15 = sizeof(*vertices15);
9301 const struct vertex_ptc_short4 exp_vertices15[] =
9302 {
9303 {{ 0.0f, 3.0f, 0.f}, {SHRT_MAX, SHRT_MAX, 0, SHRT_MAX}},
9304 {{ 2.0f, 3.0f, 0.f}, {13107, 16384, 0, SHRT_MAX}},
9305 {{ 0.0f, 0.0f, 0.f}, {19660, SHRT_MIN + 2, 0, SHRT_MAX}},
9306
9307 {{ 3.0f, 3.0f, 0.f}, {-13106, -16383, 0, SHRT_MAX}},
9308 {{ 3.0f, 0.0f, 0.f}, {-29489, SHRT_MIN + 3, 0, SHRT_MAX}},
9309 {{ 1.0f, 0.0f, 0.f}, {SHRT_MAX, SHRT_MIN + 2, 0, SHRT_MAX}},
9310 };
9311 const UINT exp_vertex_size15 = sizeof(*exp_vertices15);
9312 /* Test 16. Convert FLOAT2 to USHORT2N. */
9313 const struct vertex_ptc vertices16[] =
9314 {
9315 {{ 0.0f, 3.0f, 0.f}, {1.0f, 2.0f}},
9316 {{ 2.0f, 3.0f, 0.f}, {0.4f, 0.5f}},
9317 {{ 0.0f, 0.0f, 0.f}, {0.6f, -1.0f}},
9318
9319 {{ 3.0f, 3.0f, 0.f}, {-0.4f, -0.5f}},
9320 {{ 3.0f, 0.0f, 0.f}, {-0.9f, 0.99998f}},
9321 {{ 1.0f, 0.0f, 0.f}, {USHRT_MAX, 0.0f}},
9322 };
9323 const UINT num_vertices16 = ARRAY_SIZE(vertices16);
9324 const UINT num_faces16 = ARRAY_SIZE(vertices16) / VERTS_PER_FACE;
9325 const UINT vertex_size16 = sizeof(*vertices16);
9326 const struct vertex_ptc_ushort2n exp_vertices16[] =
9327 {
9328 {{ 0.0f, 3.0f, 0.f}, {USHRT_MAX, USHRT_MAX}},
9329 {{ 2.0f, 3.0f, 0.f}, {26214, 32768}},
9330 {{ 0.0f, 0.0f, 0.f}, {39321, 0}},
9331
9332 {{ 3.0f, 3.0f, 0.f}, {0, 0}},
9333 {{ 3.0f, 0.0f, 0.f}, {0, USHRT_MAX - 1}},
9334 {{ 1.0f, 0.0f, 0.f}, {USHRT_MAX, 0}},
9335 };
9336 const UINT exp_vertex_size16 = sizeof(*exp_vertices16);
9337 /* Test 17. Convert FLOAT2 to USHORT4N. */
9338 const struct vertex_ptc vertices17[] =
9339 {
9340 {{ 0.0f, 3.0f, 0.f}, {1.0f, 2.0f}},
9341 {{ 2.0f, 3.0f, 0.f}, {0.4f, 0.5f}},
9342 {{ 0.0f, 0.0f, 0.f}, {0.6f, -1.0f}},
9343
9344 {{ 3.0f, 3.0f, 0.f}, {-0.4f, -0.5f}},
9345 {{ 3.0f, 0.0f, 0.f}, {-0.9f, 0.99998f}},
9346 {{ 1.0f, 0.0f, 0.f}, {USHRT_MAX, 0.0f}},
9347 };
9348 const UINT num_vertices17 = ARRAY_SIZE(vertices17);
9349 const UINT num_faces17 = ARRAY_SIZE(vertices17) / VERTS_PER_FACE;
9350 const UINT vertex_size17 = sizeof(*vertices17);
9351 const struct vertex_ptc_ushort4n exp_vertices17[] =
9352 {
9353 {{ 0.0f, 3.0f, 0.f}, {USHRT_MAX, USHRT_MAX, 0, USHRT_MAX}},
9354 {{ 2.0f, 3.0f, 0.f}, {26214, 32768, 0, USHRT_MAX}},
9355 {{ 0.0f, 0.0f, 0.f}, {39321, 0, 0, USHRT_MAX}},
9356
9357 {{ 3.0f, 3.0f, 0.f}, {0, 0, 0, USHRT_MAX}},
9358 {{ 3.0f, 0.0f, 0.f}, {0, USHRT_MAX - 1, 0, USHRT_MAX}},
9359 {{ 1.0f, 0.0f, 0.f}, {USHRT_MAX, 0, 0, USHRT_MAX}},
9360 };
9361 const UINT exp_vertex_size17 = sizeof(*exp_vertices17);
9362 /* Test 18. Test that the method field is compared by converting a FLOAT2 to
9363 * FLOAT16_2. where the method field has been change from
9364 * D3DDECLMETHOD_DEFAULT to D3DDECLMETHOD_PARTIALU. */
9365 const struct vertex_ptc vertices18[] =
9366 {
9367 {{ 0.0f, 3.0f, 0.f}, { 1.0f, 1.0f}},
9368 {{ 2.0f, 3.0f, 0.f}, { 0.5f, 0.7f}},
9369 {{ 0.0f, 0.0f, 0.f}, {-0.2f, -0.3f}},
9370
9371 {{ 3.0f, 3.0f, 0.f}, { 0.2f, 0.3f}},
9372 {{ 3.0f, 0.0f, 0.f}, { 1.0f, 1.0f}},
9373 {{ 1.0f, 0.0f, 0.f}, { 0.1f, 0.2f}},
9374 };
9375 const UINT num_vertices18 = ARRAY_SIZE(vertices18);
9376 const UINT num_faces18 = ARRAY_SIZE(vertices18) / VERTS_PER_FACE;
9377 const UINT vertex_size18 = sizeof(*vertices18);
9378 const struct vertex_ptc_float16_2 exp_vertices18[] =
9379 {
9380 {{ 0.0f, 3.0f, 0.f}, {0x3c00, 0x3c00}}, /* {1.0f, 1.0f} */
9381 {{ 2.0f, 3.0f, 0.f}, {0x3800, 0x399a}}, /* {0.5f, 0.7f} */
9382 {{ 0.0f, 0.0f, 0.f}, {0xb266, 0xb4cd}}, /* {-0.2f, -0.3f} */
9383
9384 {{ 3.0f, 3.0f, 0.f}, {0x3266, 0x34cd}}, /* {0.2f, 0.3f} */
9385 {{ 3.0f, 0.0f, 0.f}, {0x3c00, 0x3c00}}, /* {1.0f, 1.0f} */
9386 {{ 1.0f, 0.0f, 0.f}, {0x2e66, 0x3266}}, /* {0.1f, 0.2f} */
9387 };
9388 const UINT exp_vertex_size18 = sizeof(*exp_vertices18);
9389 /* Test 19. Test that data is lost if usage index changes, e.g. TEXCOORD0
9390 * TEXCOORD1. */
9391 const struct vertex_pntc vertices19[] =
9392 {
9393 {{ 0.0f, 3.0f, 0.f}, up, { 1.0f, 1.0f}},
9394 {{ 2.0f, 3.0f, 0.f}, up, { 0.5f, 0.7f}},
9395 {{ 0.0f, 0.0f, 0.f}, up, {-0.2f, -0.3f}},
9396
9397 {{ 3.0f, 3.0f, 0.f}, up, { 0.2f, 0.3f}},
9398 {{ 3.0f, 0.0f, 0.f}, up, { 1.0f, 1.0f}},
9399 {{ 1.0f, 0.0f, 0.f}, up, { 0.1f, 0.2f}},
9400 };
9401 const UINT num_vertices19 = ARRAY_SIZE(vertices19);
9402 const UINT num_faces19 = ARRAY_SIZE(vertices19) / VERTS_PER_FACE;
9403 const UINT vertex_size19 = sizeof(*vertices19);
9404 const struct vertex_pntc exp_vertices19[] =
9405 {
9406 {{ 0.0f, 3.0f, 0.f}, up, zero_vec2},
9407 {{ 2.0f, 3.0f, 0.f}, up, zero_vec2},
9408 {{ 0.0f, 0.0f, 0.f}, up, zero_vec2},
9409
9410 {{ 3.0f, 3.0f, 0.f}, up, zero_vec2},
9411 {{ 3.0f, 0.0f, 0.f}, up, zero_vec2},
9412 {{ 1.0f, 0.0f, 0.f}, up, zero_vec2},
9413 };
9414 const UINT exp_vertex_size19 = sizeof(*exp_vertices19);
9415 /* Test 20. Another test that data is lost if usage index changes, e.g.
9416 * TEXCOORD1 to TEXCOORD0. */
9417 const struct vertex_pntc vertices20[] =
9418 {
9419 {{ 0.0f, 3.0f, 0.f}, up, { 1.0f, 1.0f}},
9420 {{ 2.0f, 3.0f, 0.f}, up, { 0.5f, 0.7f}},
9421 {{ 0.0f, 0.0f, 0.f}, up, {-0.2f, -0.3f}},
9422
9423 {{ 3.0f, 3.0f, 0.f}, up, { 0.2f, 0.3f}},
9424 {{ 3.0f, 0.0f, 0.f}, up, { 1.0f, 1.0f}},
9425 {{ 1.0f, 0.0f, 0.f}, up, { 0.1f, 0.2f}},
9426 };
9427 const UINT num_vertices20 = ARRAY_SIZE(vertices20);
9428 const UINT num_faces20 = ARRAY_SIZE(vertices20) / VERTS_PER_FACE;
9429 const UINT vertex_size20 = sizeof(*vertices20);
9430 const struct vertex_pntc exp_vertices20[] =
9431 {
9432 {{ 0.0f, 3.0f, 0.f}, up, zero_vec2},
9433 {{ 2.0f, 3.0f, 0.f}, up, zero_vec2},
9434 {{ 0.0f, 0.0f, 0.f}, up, zero_vec2},
9435
9436 {{ 3.0f, 3.0f, 0.f}, up, zero_vec2},
9437 {{ 3.0f, 0.0f, 0.f}, up, zero_vec2},
9438 {{ 1.0f, 0.0f, 0.f}, up, zero_vec2},
9439 };
9440 const UINT exp_vertex_size20 = sizeof(*exp_vertices20);
9441 /* Test 21. Convert FLOAT1 to FLOAT2. */
9442 const struct vertex_ptc_float1 vertices21[] =
9443 {
9444 {{ 0.0f, 3.0f, 0.f}, 1.0f},
9445 {{ 2.0f, 3.0f, 0.f}, 0.5f},
9446 {{ 0.0f, 0.0f, 0.f}, -0.2f},
9447
9448 {{ 3.0f, 3.0f, 0.f}, 0.2f},
9449 {{ 3.0f, 0.0f, 0.f}, 1.0f},
9450 {{ 1.0f, 0.0f, 0.f}, 0.1f},
9451 };
9452 const UINT num_vertices21 = ARRAY_SIZE(vertices21);
9453 const UINT num_faces21 = ARRAY_SIZE(vertices21) / VERTS_PER_FACE;
9454 const UINT vertex_size21 = sizeof(*vertices21);
9455 const struct vertex_ptc exp_vertices21[] =
9456 {
9457 {{ 0.0f, 3.0f, 0.f}, { 1.0f, 0.0f}},
9458 {{ 2.0f, 3.0f, 0.f}, { 0.5f, 0.0f}},
9459 {{ 0.0f, 0.0f, 0.f}, {-0.2f, 0.0f}},
9460
9461 {{ 3.0f, 3.0f, 0.f}, { 0.2f, 0.0f}},
9462 {{ 3.0f, 0.0f, 0.f}, { 1.0f, 0.0f}},
9463 {{ 1.0f, 0.0f, 0.f}, { 0.1f, 0.0f}},
9464 };
9465 const UINT exp_vertex_size21 = sizeof(*exp_vertices21);
9466 /* Test 22. Convert FLOAT1 to FLOAT3. */
9467 const struct vertex_ptc_float1 vertices22[] =
9468 {
9469 {{ 0.0f, 3.0f, 0.f}, 1.0f},
9470 {{ 2.0f, 3.0f, 0.f}, 0.5f},
9471 {{ 0.0f, 0.0f, 0.f}, -0.2f},
9472
9473 {{ 3.0f, 3.0f, 0.f}, 0.2f},
9474 {{ 3.0f, 0.0f, 0.f}, 1.0f},
9475 {{ 1.0f, 0.0f, 0.f}, 0.1f},
9476 };
9477 const UINT num_vertices22 = ARRAY_SIZE(vertices22);
9478 const UINT num_faces22 = ARRAY_SIZE(vertices22) / VERTS_PER_FACE;
9479 const UINT vertex_size22 = sizeof(*vertices22);
9480 const struct vertex_ptc_float3 exp_vertices22[] =
9481 {
9482 {{ 0.0f, 3.0f, 0.f}, { 1.0f, 0.0f, 0.0f}},
9483 {{ 2.0f, 3.0f, 0.f}, { 0.5f, 0.0f, 0.0f}},
9484 {{ 0.0f, 0.0f, 0.f}, {-0.2f, 0.0f, 0.0f}},
9485
9486 {{ 3.0f, 3.0f, 0.f}, { 0.2f, 0.0f, 0.0f}},
9487 {{ 3.0f, 0.0f, 0.f}, { 1.0f, 0.0f, 0.0f}},
9488 {{ 1.0f, 0.0f, 0.f}, { 0.1f, 0.0f, 0.0f}},
9489 };
9490 const UINT exp_vertex_size22 = sizeof(*exp_vertices22);
9491 /* Test 23. Convert FLOAT1 to FLOAT4. */
9492 const struct vertex_ptc_float1 vertices23[] =
9493 {
9494 {{ 0.0f, 3.0f, 0.f}, 1.0f},
9495 {{ 2.0f, 3.0f, 0.f}, 0.5f},
9496 {{ 0.0f, 0.0f, 0.f}, -0.2f},
9497
9498 {{ 3.0f, 3.0f, 0.f}, 0.2f},
9499 {{ 3.0f, 0.0f, 0.f}, 1.0f},
9500 {{ 1.0f, 0.0f, 0.f}, 0.1f},
9501 };
9502 const UINT num_vertices23 = ARRAY_SIZE(vertices23);
9503 const UINT num_faces23 = ARRAY_SIZE(vertices23) / VERTS_PER_FACE;
9504 const UINT vertex_size23 = sizeof(*vertices23);
9505 const struct vertex_ptc_float4 exp_vertices23[] =
9506 {
9507 {{ 0.0f, 3.0f, 0.f}, { 1.0f, 0.0f, 0.0f, 1.0f}},
9508 {{ 2.0f, 3.0f, 0.f}, { 0.5f, 0.0f, 0.0f, 1.0f}},
9509 {{ 0.0f, 0.0f, 0.f}, {-0.2f, 0.0f, 0.0f, 1.0f}},
9510
9511 {{ 3.0f, 3.0f, 0.f}, { 0.2f, 0.0f, 0.0f, 1.0f}},
9512 {{ 3.0f, 0.0f, 0.f}, { 1.0f, 0.0f, 0.0f, 1.0f}},
9513 {{ 1.0f, 0.0f, 0.f}, { 0.1f, 0.0f, 0.0f, 1.0f}},
9514 };
9515 const UINT exp_vertex_size23 = sizeof(*exp_vertices23);
9516 /* Test 24. Convert FLOAT1 to D3DCOLOR. */
9517 const struct vertex_ptc_float1 vertices24[] =
9518 {
9519 {{ 0.0f, 3.0f, 0.f}, 1.0f},
9520 {{ 2.0f, 3.0f, 0.f}, 0.5f},
9521 {{ 0.0f, 0.0f, 0.f}, -0.2f},
9522
9523 {{ 3.0f, 3.0f, 0.f}, 0.2f},
9524 {{ 3.0f, 0.0f, 0.f}, 1.0f},
9525 {{ 1.0f, 0.0f, 0.f}, 0.11f},
9526 };
9527 const UINT num_vertices24 = ARRAY_SIZE(vertices24);
9528 const UINT num_faces24 = ARRAY_SIZE(vertices24) / VERTS_PER_FACE;
9529 const UINT vertex_size24 = sizeof(*vertices24);
9530 const struct vertex_ptc_d3dcolor exp_vertices24[] =
9531 {
9532 {{ 0.0f, 3.0f, 0.f}, {0, 0, 255, 255}},
9533 {{ 2.0f, 3.0f, 0.f}, {0, 0, 128, 255}},
9534 {{ 0.0f, 0.0f, 0.f}, {0, 0, 0, 255}},
9535
9536 {{ 3.0f, 3.0f, 0.f}, {0, 0, 51, 255}},
9537 {{ 3.0f, 0.0f, 0.f}, {0, 0, 255, 255}},
9538 {{ 1.0f, 0.0f, 0.f}, {0, 0, 28, 255}},
9539 };
9540 const UINT exp_vertex_size24 = sizeof(*exp_vertices24);
9541 /* Test 25. Convert FLOAT1 to ubyte4. */
9542 const struct vertex_ptc_float1 vertices25[] =
9543 {
9544 {{ 0.0f, 3.0f, 0.f}, 0.0f},
9545 {{ 2.0f, 3.0f, 0.f}, 1.4f},
9546 {{ 0.0f, 0.0f, 0.f}, 1.5f},
9547
9548 {{ 3.0f, 3.0f, 0.f}, 255.0f},
9549 {{ 3.0f, 0.0f, 0.f}, 256.0f},
9550 {{ 1.0f, 0.0f, 0.f}, -1.0f},
9551 };
9552 const UINT num_vertices25 = ARRAY_SIZE(vertices25);
9553 const UINT num_faces25 = ARRAY_SIZE(vertices25) / VERTS_PER_FACE;
9554 const UINT vertex_size25 = sizeof(*vertices25);
9555 const struct vertex_ptc_ubyte4 exp_vertices25[] =
9556 {
9557 {{ 0.0f, 3.0f, 0.f}, {0, 0, 0, 1}},
9558 {{ 2.0f, 3.0f, 0.f}, {1, 0, 0, 1}},
9559 {{ 0.0f, 0.0f, 0.f}, {2, 0, 0, 1}},
9560
9561 {{ 3.0f, 3.0f, 0.f}, {255, 0, 0, 1}},
9562 {{ 3.0f, 0.0f, 0.f}, {0, 0, 0, 1}},
9563 {{ 1.0f, 0.0f, 0.f}, {0, 0, 0, 1}},
9564 };
9565 const UINT exp_vertex_size25 = sizeof(*exp_vertices25);
9566 /* Test 26. Convert FLOAT4 to D3DCOLOR. */
9567 const struct vertex_ptc_float4 vertices26[] =
9568 {
9569 {{ 0.0f, 3.0f, 0.f}, {0.0f, 1.0f, 0.4f, 0.5f}},
9570 {{ 2.0f, 3.0f, 0.f}, {-0.4f, -0.5f, -1.0f, -2.0f}},
9571 {{ 0.0f, 0.0f, 0.f}, {254.0f, 255.0f, 256.0f, 257.0f}},
9572
9573 {{ 3.0f, 3.0f, 0.f}, {0.1f, 0.2f, 0.3f, 0.4f}},
9574 {{ 3.0f, 0.0f, 0.f}, {0.5f, 0.6f, 0.7f, 0.8f}},
9575 {{ 1.0f, 0.0f, 0.f}, {0.9f, 0.99f, 0.995f, 0.999f}},
9576 };
9577 const UINT num_vertices26 = ARRAY_SIZE(vertices26);
9578 const UINT num_faces26 = ARRAY_SIZE(vertices26) / VERTS_PER_FACE;
9579 const UINT vertex_size26 = sizeof(*vertices26);
9580 const struct vertex_ptc_d3dcolor exp_vertices26[] =
9581 {
9582 {{ 0.0f, 3.0f, 0.f}, {102, 255, 0, 128}},
9583 {{ 2.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
9584 {{ 0.0f, 0.0f, 0.f}, {255, 255, 255, 255}},
9585
9586 {{ 3.0f, 3.0f, 0.f}, {77, 51, 26, 102}},
9587 {{ 3.0f, 0.0f, 0.f}, {179, 153, 128, 204}},
9588 {{ 1.0f, 0.0f, 0.f}, {254, 252, 230, 255}},
9589 };
9590 const UINT exp_vertex_size26 = sizeof(*exp_vertices26);
9591 /* Test 27. Convert D3DCOLOR to FLOAT4. */
9592 const struct vertex_ptc_d3dcolor vertices27[] =
9593 {
9594 {{ 0.0f, 3.0f, 0.f}, {102, 255, 0, 128}},
9595 {{ 2.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
9596 {{ 0.0f, 0.0f, 0.f}, {255, 255, 255, 255}},
9597
9598 {{ 3.0f, 3.0f, 0.f}, {77, 51, 26, 102}},
9599 {{ 3.0f, 0.0f, 0.f}, {179, 153, 128, 204}},
9600 {{ 1.0f, 0.0f, 0.f}, {254, 252, 230, 255}},
9601 };
9602 const UINT num_vertices27 = ARRAY_SIZE(vertices27);
9603 const UINT num_faces27 = ARRAY_SIZE(vertices27) / VERTS_PER_FACE;
9604 const UINT vertex_size27 = sizeof(*vertices27);
9605 const struct vertex_ptc_float4 exp_vertices27[] =
9606 {
9607 {{ 0.0f, 3.0f, 0.f}, {0.0f, 1.0f, 0.4f, 0.501961f}},
9608 {{ 2.0f, 3.0f, 0.f}, {0.0f, 0.0f, 0.0f, 0.0f}},
9609 {{ 0.0f, 0.0f, 0.f}, {1.0f, 1.0f, 1.0f, 1.0f}},
9610
9611 {{ 3.0f, 3.0f, 0.f}, {0.101961f, 0.2f, 0.301961f, 0.4f}},
9612 {{ 3.0f, 0.0f, 0.f}, {0.501961f, 0.6f, 0.701961f, 0.8f}},
9613 {{ 1.0f, 0.0f, 0.f}, {0.901961f, 0.988235f, 0.996078f, 1.0f}},
9614 };
9615 const UINT exp_vertex_size27 = sizeof(*exp_vertices27);
9616 /* Test 28. Convert UBYTE4 to FLOAT4. */
9617 const struct vertex_ptc_ubyte4 vertices28[] =
9618 {
9619 {{ 0.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
9620 {{ 2.0f, 3.0f, 0.f}, {1, 1, 1, 1}},
9621 {{ 0.0f, 0.0f, 0.f}, {1, 0, 1, 0}},
9622
9623 {{ 3.0f, 3.0f, 0.f}, {0, 1, 0, 1}},
9624 {{ 3.0f, 0.0f, 0.f}, {10, 20, 30, 40}},
9625 {{ 1.0f, 0.0f, 0.f}, {50, 60, 127, 255}},
9626 };
9627 const UINT num_vertices28 = ARRAY_SIZE(vertices28);
9628 const UINT num_faces28 = ARRAY_SIZE(vertices28) / VERTS_PER_FACE;
9629 const UINT vertex_size28 = sizeof(*vertices28);
9630 const struct vertex_ptc_float4 exp_vertices28[] =
9631 {
9632 {{ 0.0f, 3.0f, 0.f}, {0.0f, 0.0f, 0.0f, 0.0f}},
9633 {{ 2.0f, 3.0f, 0.f}, {1.0f, 1.0f, 1.0f, 1.0f}},
9634 {{ 0.0f, 0.0f, 0.f}, {1.0f, 0.0f, 1.0f, 0.0f}},
9635
9636 {{ 3.0f, 3.0f, 0.f}, {0.0f, 1.0f, 0.0f, 1.0f}},
9637 {{ 3.0f, 0.0f, 0.f}, {10.0f, 20.0f, 30.0f, 40.0f}},
9638 {{ 1.0f, 0.0f, 0.f}, {50.0f, 60.0f, 127.0f, 255.0f}},
9639 };
9640 const UINT exp_vertex_size28 = sizeof(*exp_vertices28);
9641 /* Test 29. Convert SHORT2 to FLOAT4. */
9642 const struct vertex_ptc_short2 vertices29[] =
9643 {
9644 {{ 0.0f, 3.0f, 0.f}, {0, 0}},
9645 {{ 2.0f, 3.0f, 0.f}, {0, 1}},
9646 {{ 0.0f, 0.0f, 0.f}, {1, 0}},
9647
9648 {{ 3.0f, 3.0f, 0.f}, {1, 1}},
9649 {{ 3.0f, 0.0f, 0.f}, {SHRT_MIN, SHRT_MAX}},
9650 {{ 1.0f, 0.0f, 0.f}, {-42, 42}},
9651 };
9652 const UINT num_vertices29 = ARRAY_SIZE(vertices29);
9653 const UINT num_faces29 = ARRAY_SIZE(vertices29) / VERTS_PER_FACE;
9654 const UINT vertex_size29 = sizeof(*vertices29);
9655 const struct vertex_ptc_float4 exp_vertices29[] =
9656 {
9657 {{ 0.0f, 3.0f, 0.f}, {0.0f, 0.0f, 0.0f, 1.0f}},
9658 {{ 2.0f, 3.0f, 0.f}, {0.0f, 1.0f, 0.0f, 1.0f }},
9659 {{ 0.0f, 0.0f, 0.f}, {1.0f, 0.0f, 0.0f, 1.0f}},
9660
9661 {{ 3.0f, 3.0f, 0.f}, {1.0f, 1.0f, 0.0f, 1.0f}},
9662 {{ 3.0f, 0.0f, 0.f}, {SHRT_MIN, SHRT_MAX, 0.0f, 1.0f}},
9663 {{ 1.0f, 0.0f, 0.f}, {-42.0f, 42.0f, 0.0f, 1.0f}},
9664 };
9665 const UINT exp_vertex_size29 = sizeof(*exp_vertices29);
9666 /* Test 29. Convert SHORT4 to FLOAT4. */
9667 const struct vertex_ptc_short4 vertices30[] =
9668 {
9669 {{ 0.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
9670 {{ 2.0f, 3.0f, 0.f}, {0, 1, 0, 1}},
9671 {{ 0.0f, 0.0f, 0.f}, {1, 0, 1, 0}},
9672
9673 {{ 3.0f, 3.0f, 0.f}, {1, 1, 1, 1}},
9674 {{ 3.0f, 0.0f, 0.f}, {SHRT_MIN, SHRT_MAX, 1, 0}},
9675 {{ 1.0f, 0.0f, 0.f}, {-42, 42, SHRT_MAX, SHRT_MIN}},
9676 };
9677 const UINT num_vertices30 = ARRAY_SIZE(vertices30);
9678 const UINT num_faces30 = ARRAY_SIZE(vertices30) / VERTS_PER_FACE;
9679 const UINT vertex_size30 = sizeof(*vertices30);
9680 const struct vertex_ptc_float4 exp_vertices30[] =
9681 {
9682 {{ 0.0f, 3.0f, 0.f}, {0.0f, 0.0f, 0.0f, 0.0f}},
9683 {{ 2.0f, 3.0f, 0.f}, {0.0f, 1.0f, 0.0f, 1.0f }},
9684 {{ 0.0f, 0.0f, 0.f}, {1.0f, 0.0f, 1.0f, 0.0f}},
9685
9686 {{ 3.0f, 3.0f, 0.f}, {1.0f, 1.0f, 1.0f, 1.0f}},
9687 {{ 3.0f, 0.0f, 0.f}, {SHRT_MIN, SHRT_MAX, 1.0f, 0.0f}},
9688 {{ 1.0f, 0.0f, 0.f}, {-42.0f, 42.0f, SHRT_MAX, SHRT_MIN}},
9689 };
9690 const UINT exp_vertex_size30 = sizeof(*exp_vertices30);
9691 /* Test 31. Convert UBYTE4N to FLOAT4. */
9692 const struct vertex_ptc_ubyte4n vertices31[] =
9693 {
9694 {{ 0.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
9695 {{ 2.0f, 3.0f, 0.f}, {1, 1, 1, 1}},
9696 {{ 0.0f, 0.0f, 0.f}, {1, 0, 1, 0}},
9697
9698 {{ 3.0f, 3.0f, 0.f}, {0, 1, 0, 1}},
9699 {{ 3.0f, 0.0f, 0.f}, {10, 20, 30, 40}},
9700 {{ 1.0f, 0.0f, 0.f}, {50, 60, 70, UCHAR_MAX}},
9701 };
9702 const UINT num_vertices31 = ARRAY_SIZE(vertices31);
9703 const UINT num_faces31 = ARRAY_SIZE(vertices31) / VERTS_PER_FACE;
9704 const UINT vertex_size31 = sizeof(*vertices31);
9705 const struct vertex_ptc_float4 exp_vertices31[] =
9706 {
9707 {{ 0.0f, 3.0f, 0.f}, {0.0f, 0.0f, 0.0f, 0.0f}},
9708 {{ 2.0f, 3.0f, 0.f}, {(FLOAT)1/UCHAR_MAX, (FLOAT)1/UCHAR_MAX, (FLOAT)1/UCHAR_MAX, (FLOAT)1/UCHAR_MAX}},
9709 {{ 0.0f, 0.0f, 0.f}, {(FLOAT)1/UCHAR_MAX, 0.0f, (FLOAT)1/UCHAR_MAX, 0.0f}},
9710
9711 {{ 3.0f, 3.0f, 0.f}, {0.0f, (FLOAT)1/UCHAR_MAX, 0.0f, (FLOAT)1/UCHAR_MAX}},
9712 {{ 3.0f, 0.0f, 0.f}, {(FLOAT)10/UCHAR_MAX, (FLOAT)20/UCHAR_MAX, (FLOAT)30/UCHAR_MAX, (FLOAT)40/UCHAR_MAX}},
9713 {{ 1.0f, 0.0f, 0.f}, {(FLOAT)50/UCHAR_MAX, (FLOAT)60/UCHAR_MAX, (FLOAT)70/UCHAR_MAX, 1.0f}},
9714 };
9715 const UINT exp_vertex_size31 = sizeof(*exp_vertices31);
9716 /* Test 32. Convert SHORT2N to FLOAT4. */
9717 const struct vertex_ptc_short2 vertices32[] =
9718 {
9719 {{ 0.0f, 3.0f, 0.f}, {0, 0}},
9720 {{ 2.0f, 3.0f, 0.f}, {0, 1}},
9721 {{ 0.0f, 0.0f, 0.f}, {1, 0}},
9722
9723 {{ 3.0f, 3.0f, 0.f}, {1, 1}},
9724 {{ 3.0f, 0.0f, 0.f}, {SHRT_MIN + 1, SHRT_MAX}},
9725 {{ 1.0f, 0.0f, 0.f}, {-42, 42}},
9726 };
9727 const UINT num_vertices32 = ARRAY_SIZE(vertices32);
9728 const UINT num_faces32 = ARRAY_SIZE(vertices32) / VERTS_PER_FACE;
9729 const UINT vertex_size32 = sizeof(*vertices32);
9730 const struct vertex_ptc_float4 exp_vertices32[] =
9731 {
9732 {{ 0.0f, 3.0f, 0.f}, {0.0f, 0.0f, 0.0f, 1.0f}},
9733 {{ 2.0f, 3.0f, 0.f}, {0.0f, 1.0f/SHRT_MAX, 0.0f, 1.0f}},
9734 {{ 0.0f, 0.0f, 0.f}, {1.0f/SHRT_MAX, 0.0f, 0.0f, 1.0f}},
9735
9736 {{ 3.0f, 3.0f, 0.f}, {1.0f/SHRT_MAX, 1.0f/SHRT_MAX, 0.0f, 1.0f}},
9737 {{ 3.0f, 0.0f, 0.f}, {-1.0f, 1.0f, 0.0f, 1.0f}},
9738 {{ 1.0f, 0.0f, 0.f}, {-42.0f/SHRT_MAX, 42.0f/SHRT_MAX, 0.0f, 1.0f}},
9739 };
9740 const UINT exp_vertex_size32 = sizeof(*exp_vertices32);
9741 /* Test 33. Convert SHORT4N to FLOAT4. */
9742 const struct vertex_ptc_short4 vertices33[] =
9743 {
9744 {{ 0.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
9745 {{ 2.0f, 3.0f, 0.f}, {0, 1, 0, 1}},
9746 {{ 0.0f, 0.0f, 0.f}, {1, 0, 1, 0}},
9747
9748 {{ 3.0f, 3.0f, 0.f}, {1, 1, 1, 1}},
9749 {{ 3.0f, 0.0f, 0.f}, {SHRT_MIN + 1, SHRT_MAX, SHRT_MIN + 1, SHRT_MAX}},
9750 {{ 1.0f, 0.0f, 0.f}, {-42, 42, 1, 1}},
9751 };
9752 const UINT num_vertices33 = ARRAY_SIZE(vertices33);
9753 const UINT num_faces33 = ARRAY_SIZE(vertices33) / VERTS_PER_FACE;
9754 const UINT vertex_size33 = sizeof(*vertices33);
9755 const struct vertex_ptc_float4 exp_vertices33[] =
9756 {
9757 {{ 0.0f, 3.0f, 0.f}, {0.0f, 0.0f, 0.0f, 0.0f}},
9758 {{ 2.0f, 3.0f, 0.f}, {0.0f, 1.0f/SHRT_MAX, 0.0f, 1.0f/SHRT_MAX}},
9759 {{ 0.0f, 0.0f, 0.f}, {1.0f/SHRT_MAX, 0.0f, 1.0f/SHRT_MAX, 0.0f}},
9760
9761 {{ 3.0f, 3.0f, 0.f}, {1.0f/SHRT_MAX, 1.0f/SHRT_MAX, 1.0f/SHRT_MAX, 1.0f/SHRT_MAX}},
9762 {{ 3.0f, 0.0f, 0.f}, {-1.0f, 1.0f, -1.0f, 1.0f}},
9763 {{ 1.0f, 0.0f, 0.f}, {-42.0f/SHRT_MAX, 42.0f/SHRT_MAX, 1.0f/SHRT_MAX, 1.0f/SHRT_MAX}},
9764 };
9765 const UINT exp_vertex_size33 = sizeof(*exp_vertices33);
9766 /* Test 34. Convert FLOAT16_2 to FLOAT4. */
9767 const struct vertex_ptc_float16_2 vertices34[] =
9768 {
9769 {{ 0.0f, 3.0f, 0.f}, {0x3c00, 0x3c00}}, /* {1.0f, 1.0f} */
9770 {{ 2.0f, 3.0f, 0.f}, {0x3800, 0x399a}}, /* {0.5f, 0.7f} */
9771 {{ 0.0f, 0.0f, 0.f}, {0xb266, 0xb4cd}}, /* {-0.2f, -0.3f} */
9772
9773 {{ 3.0f, 3.0f, 0.f}, {0x3266, 0x34cd}}, /* {0.2f, 0.3f} */
9774 {{ 3.0f, 0.0f, 0.f}, {0x3c00, 0x3c00}}, /* {1.0f, 1.0f} */
9775 {{ 1.0f, 0.0f, 0.f}, {0x2e66, 0x3266}}, /* {0.1f, 0.2f} */
9776 };
9777 const UINT num_vertices34 = ARRAY_SIZE(vertices34);
9778 const UINT num_faces34 = ARRAY_SIZE(vertices34) / VERTS_PER_FACE;
9779 const UINT vertex_size34 = sizeof(*vertices34);
9780 const struct vertex_ptc_float4 exp_vertices34[] =
9781 {
9782 {{ 0.0f, 3.0f, 0.f}, {1.0f, 1.0f, 0.0f, 1.0f}},
9783 {{ 2.0f, 3.0f, 0.f}, {0.5f, 0.700195f, 0.0f, 1.0f}},
9784 {{ 0.0f, 0.0f, 0.f}, {-0.199951f, -0.300049f, 0.0f, 1.0f}},
9785
9786 {{ 3.0f, 3.0f, 0.f}, {0.199951f, 0.300049f, 0.0f, 1.0f}},
9787 {{ 3.0f, 0.0f, 0.f}, {1.0f, 1.0f, 0.0f, 1.0f}},
9788 {{ 1.0f, 0.0f, 0.f}, {0.099976f, 0.199951f, 0.0f, 1.0f}},
9789 };
9790 const UINT exp_vertex_size34 = sizeof(*exp_vertices34);
9791 /* Test 35. Convert FLOAT16_4 to FLOAT4. */
9792 const struct vertex_ptc_float16_4 vertices35[] =
9793 {
9794 {{ 0.0f, 3.0f, 0.f}, {0x0000, 0x0000, 0x0000, 0x0000}},
9795 {{ 2.0f, 3.0f, 0.f}, {0x3c00, 0x3c00, 0x3c00, 0x3c00}},
9796 {{ 0.0f, 0.0f, 0.f}, {0x3c00, 0x0000, 0x3c00, 0x0000}},
9797
9798 {{ 3.0f, 3.0f, 0.f}, {0x0000, 0x3c00, 0x0000, 0x3c00}},
9799 {{ 3.0f, 0.0f, 0.f}, {0x3800, 0x399a, 0xb266, 0xb4cd}},
9800 {{ 1.0f, 0.0f, 0.f}, {0x2e66, 0x3266, 0x2e66, 0x3266}},
9801 };
9802 const UINT num_vertices35 = ARRAY_SIZE(vertices35);
9803 const UINT num_faces35 = ARRAY_SIZE(vertices35) / VERTS_PER_FACE;
9804 const UINT vertex_size35 = sizeof(*vertices35);
9805 const struct vertex_ptc_float4 exp_vertices35[] =
9806 {
9807 {{ 0.0f, 3.0f, 0.f}, {0.0f, 0.0f, 0.0f, 0.0f}},
9808 {{ 2.0f, 3.0f, 0.f}, {1.0f, 1.0f, 1.0f, 1.0f}},
9809 {{ 0.0f, 0.0f, 0.f}, {1.0f, 0.0f, 1.0f, 0.0f}},
9810
9811 {{ 3.0f, 3.0f, 0.f}, {0.0f, 1.0f, 0.0f, 1.0f}},
9812 {{ 3.0f, 0.0f, 0.f}, {0.5f, 0.700195f, -0.199951f, -0.300049f}},
9813 {{ 1.0f, 0.0f, 0.f}, {0.099976f, 0.199951f, 0.099976f, 0.199951f}},
9814 };
9815 const UINT exp_vertex_size35 = sizeof(*exp_vertices35);
9816 /* Test 36. Check that vertex buffer sharing is ok. */
9817 const struct vertex_pn vertices36[] =
9818 {
9819 {{ 0.0f, 3.0f, 0.f}, up},
9820 {{ 2.0f, 3.0f, 0.f}, up},
9821 {{ 0.0f, 0.0f, 0.f}, up},
9822 };
9823 const UINT num_vertices36 = ARRAY_SIZE(vertices36);
9824 const UINT num_faces36 = ARRAY_SIZE(vertices36) / VERTS_PER_FACE;
9825 const UINT vertex_size36 = sizeof(*vertices36);
9826 const DWORD clone_options36 = options | D3DXMESH_VB_SHARE;
9827 /* Common mesh data */
9828 ID3DXMesh *mesh = NULL;
9829 ID3DXMesh *mesh_clone = NULL;
9830 struct
9831 {
9832 const BYTE *vertices;
9833 const DWORD *indices;
9834 const DWORD *attributes;
9835 const UINT num_vertices;
9836 const UINT num_faces;
9837 const UINT vertex_size;
9838 const DWORD create_options;
9839 const DWORD clone_options;
9841 D3DVERTEXELEMENT9 *new_declaration;
9842 const BYTE *exp_vertices;
9843 const UINT exp_vertex_size;
9844 }
9845 tc[] =
9846 {
9847 {
9848 (BYTE*)vertices0,
9849 NULL,
9850 NULL,
9851 num_vertices0,
9852 num_faces0,
9853 vertex_size0,
9854 options,
9855 options,
9856 declaration_pn,
9857 declaration_pn,
9858 (BYTE*)vertices0,
9859 vertex_size0
9860 },
9861 {
9862 (BYTE*)vertices0,
9863 NULL,
9864 NULL,
9865 num_vertices0,
9866 num_faces0,
9867 vertex_size0,
9868 options_16bit,
9869 options_16bit,
9870 declaration_pn,
9871 declaration_pn,
9872 (BYTE*)vertices0,
9873 vertex_size0
9874 },
9875 {
9876 (BYTE*)vertices0,
9877 NULL,
9878 NULL,
9879 num_vertices0,
9880 num_faces0,
9881 vertex_size0,
9882 options,
9883 options,
9884 declaration_pn,
9885 declaration_pntc,
9886 (BYTE*)exp_vertices2,
9887 exp_vertex_size2
9888 },
9889 {
9890 (BYTE*)vertices0,
9891 NULL,
9892 NULL,
9893 num_vertices0,
9894 num_faces0,
9895 vertex_size0,
9896 options,
9897 options,
9898 declaration_pn,
9899 declaration_ptcn,
9900 (BYTE*)exp_vertices3,
9901 exp_vertex_size3
9902 },
9903 {
9904 (BYTE*)vertices4,
9905 NULL,
9906 NULL,
9907 num_vertices4,
9908 num_faces4,
9909 vertex_size4,
9910 options,
9911 options,
9912 declaration_ptc,
9913 declaration_ptc_float16_2,
9914 (BYTE*)exp_vertices4,
9915 exp_vertex_size4
9916 },
9917 {
9918 (BYTE*)vertices5,
9919 NULL,
9920 NULL,
9921 num_vertices5,
9922 num_faces5,
9923 vertex_size5,
9924 options,
9925 options,
9926 declaration_ptc,
9927 declaration_ptc_float16_4,
9928 (BYTE*)exp_vertices5,
9929 exp_vertex_size5
9930 },
9931 {
9932 (BYTE*)vertices6,
9933 NULL,
9934 NULL,
9935 num_vertices6,
9936 num_faces6,
9937 vertex_size6,
9938 options,
9939 options,
9940 declaration_ptc,
9941 declaration_ptc_float1,
9942 (BYTE*)exp_vertices6,
9943 exp_vertex_size6
9944 },
9945 {
9946 (BYTE*)vertices7,
9947 NULL,
9948 NULL,
9949 num_vertices7,
9950 num_faces7,
9951 vertex_size7,
9952 options,
9953 options,
9954 declaration_ptc,
9955 declaration_ptc_float3,
9956 (BYTE*)exp_vertices7,
9957 exp_vertex_size7
9958 },
9959 {
9960 (BYTE*)vertices8,
9961 NULL,
9962 NULL,
9963 num_vertices8,
9964 num_faces8,
9965 vertex_size8,
9966 options,
9967 options,
9968 declaration_ptc,
9969 declaration_ptc_float4,
9970 (BYTE*)exp_vertices8,
9971 exp_vertex_size8
9972 },
9973 {
9974 (BYTE*)vertices9,
9975 NULL,
9976 NULL,
9977 num_vertices9,
9978 num_faces9,
9979 vertex_size9,
9980 options,
9981 options,
9982 declaration_ptc,
9983 declaration_ptc_d3dcolor,
9984 (BYTE*)exp_vertices9,
9985 exp_vertex_size9
9986 },
9987 {
9988 (BYTE*)vertices10,
9989 NULL,
9990 NULL,
9991 num_vertices10,
9992 num_faces10,
9993 vertex_size10,
9994 options,
9995 options,
9996 declaration_ptc,
9997 declaration_ptc_ubyte4,
9998 (BYTE*)exp_vertices10,
9999 exp_vertex_size10
10000 },
10001 {
10002 (BYTE*)vertices11,
10003 NULL,
10004 NULL,
10005 num_vertices11,
10006 num_faces11,
10007 vertex_size11,
10008 options,
10009 options,
10010 declaration_ptc,
10011 declaration_ptc_short2,
10012 (BYTE*)exp_vertices11,
10013 exp_vertex_size11
10014 },
10015 {
10016 (BYTE*)vertices12,
10017 NULL,
10018 NULL,
10019 num_vertices12,
10020 num_faces12,
10021 vertex_size12,
10022 options,
10023 options,
10024 declaration_ptc,
10025 declaration_ptc_short4,
10026 (BYTE*)exp_vertices12,
10027 exp_vertex_size12
10028 },
10029 {
10030 (BYTE*)vertices13,
10031 NULL,
10032 NULL,
10033 num_vertices13,
10034 num_faces13,
10035 vertex_size13,
10036 options,
10037 options,
10038 declaration_ptc,
10039 declaration_ptc_ubyte4n,
10040 (BYTE*)exp_vertices13,
10041 exp_vertex_size13
10042 },
10043 {
10044 (BYTE*)vertices14,
10045 NULL,
10046 NULL,
10047 num_vertices14,
10048 num_faces14,
10049 vertex_size14,
10050 options,
10051 options,
10052 declaration_ptc,
10053 declaration_ptc_short2n,
10054 (BYTE*)exp_vertices14,
10055 exp_vertex_size14
10056 },
10057 {
10058 (BYTE*)vertices15,
10059 NULL,
10060 NULL,
10061 num_vertices15,
10062 num_faces15,
10063 vertex_size15,
10064 options,
10065 options,
10066 declaration_ptc,
10067 declaration_ptc_short4n,
10068 (BYTE*)exp_vertices15,
10069 exp_vertex_size15
10070 },
10071 {
10072 (BYTE*)vertices16,
10073 NULL,
10074 NULL,
10075 num_vertices16,
10076 num_faces16,
10077 vertex_size16,
10078 options,
10079 options,
10080 declaration_ptc,
10081 declaration_ptc_ushort2n,
10082 (BYTE*)exp_vertices16,
10083 exp_vertex_size16
10084 },
10085 {
10086 (BYTE*)vertices17,
10087 NULL,
10088 NULL,
10089 num_vertices17,
10090 num_faces17,
10091 vertex_size17,
10092 options,
10093 options,
10094 declaration_ptc,
10095 declaration_ptc_ushort4n,
10096 (BYTE*)exp_vertices17,
10097 exp_vertex_size17
10098 },
10099 {
10100 (BYTE*)vertices18,
10101 NULL,
10102 NULL,
10103 num_vertices18,
10104 num_faces18,
10105 vertex_size18,
10106 options,
10107 options,
10108 declaration_ptc,
10109 declaration_ptc_float16_2_partialu,
10110 (BYTE*)exp_vertices18,
10111 exp_vertex_size18
10112 },
10113 {
10114 (BYTE*)vertices19,
10115 NULL,
10116 NULL,
10117 num_vertices19,
10118 num_faces19,
10119 vertex_size19,
10120 options,
10121 options,
10122 declaration_pntc,
10123 declaration_pntc1,
10124 (BYTE*)exp_vertices19,
10125 exp_vertex_size19
10126 },
10127 {
10128 (BYTE*)vertices20,
10129 NULL,
10130 NULL,
10131 num_vertices20,
10132 num_faces20,
10133 vertex_size20,
10134 options,
10135 options,
10136 declaration_pntc1,
10137 declaration_pntc,
10138 (BYTE*)exp_vertices20,
10139 exp_vertex_size20
10140 },
10141 {
10142 (BYTE*)vertices21,
10143 NULL,
10144 NULL,
10145 num_vertices21,
10146 num_faces21,
10147 vertex_size21,
10148 options,
10149 options,
10150 declaration_ptc_float1,
10151 declaration_ptc,
10152 (BYTE*)exp_vertices21,
10153 exp_vertex_size21
10154 },
10155 {
10156 (BYTE*)vertices22,
10157 NULL,
10158 NULL,
10159 num_vertices22,
10160 num_faces22,
10161 vertex_size22,
10162 options,
10163 options,
10164 declaration_ptc_float1,
10165 declaration_ptc_float3,
10166 (BYTE*)exp_vertices22,
10167 exp_vertex_size22
10168 },
10169 {
10170 (BYTE*)vertices23,
10171 NULL,
10172 NULL,
10173 num_vertices23,
10174 num_faces23,
10175 vertex_size23,
10176 options,
10177 options,
10178 declaration_ptc_float1,
10179 declaration_ptc_float4,
10180 (BYTE*)exp_vertices23,
10181 exp_vertex_size23
10182 },
10183 {
10184 (BYTE*)vertices24,
10185 NULL,
10186 NULL,
10187 num_vertices24,
10188 num_faces24,
10189 vertex_size24,
10190 options,
10191 options,
10192 declaration_ptc_float1,
10193 declaration_ptc_d3dcolor,
10194 (BYTE*)exp_vertices24,
10195 exp_vertex_size24
10196 },
10197 {
10198 (BYTE*)vertices25,
10199 NULL,
10200 NULL,
10201 num_vertices25,
10202 num_faces25,
10203 vertex_size25,
10204 options,
10205 options,
10206 declaration_ptc_float1,
10207 declaration_ptc_ubyte4,
10208 (BYTE*)exp_vertices25,
10209 exp_vertex_size25
10210 },
10211 {
10212 (BYTE*)vertices26,
10213 NULL,
10214 NULL,
10215 num_vertices26,
10216 num_faces26,
10217 vertex_size26,
10218 options,
10219 options,
10220 declaration_ptc_float4,
10221 declaration_ptc_d3dcolor,
10222 (BYTE*)exp_vertices26,
10223 exp_vertex_size26
10224 },
10225 {
10226 (BYTE*)vertices27,
10227 NULL,
10228 NULL,
10229 num_vertices27,
10230 num_faces27,
10231 vertex_size27,
10232 options,
10233 options,
10234 declaration_ptc_d3dcolor,
10235 declaration_ptc_float4,
10236 (BYTE*)exp_vertices27,
10237 exp_vertex_size27
10238 },
10239 {
10240 (BYTE*)vertices28,
10241 NULL,
10242 NULL,
10243 num_vertices28,
10244 num_faces28,
10245 vertex_size28,
10246 options,
10247 options,
10248 declaration_ptc_ubyte4,
10249 declaration_ptc_float4,
10250 (BYTE*)exp_vertices28,
10251 exp_vertex_size28
10252 },
10253 {
10254 (BYTE*)vertices29,
10255 NULL,
10256 NULL,
10257 num_vertices29,
10258 num_faces29,
10259 vertex_size29,
10260 options,
10261 options,
10262 declaration_ptc_short2,
10263 declaration_ptc_float4,
10264 (BYTE*)exp_vertices29,
10265 exp_vertex_size29
10266 },
10267 {
10268 (BYTE*)vertices30,
10269 NULL,
10270 NULL,
10271 num_vertices30,
10272 num_faces30,
10273 vertex_size30,
10274 options,
10275 options,
10276 declaration_ptc_short4,
10277 declaration_ptc_float4,
10278 (BYTE*)exp_vertices30,
10279 exp_vertex_size30
10280 },
10281 {
10282 (BYTE*)vertices31,
10283 NULL,
10284 NULL,
10285 num_vertices31,
10286 num_faces31,
10287 vertex_size31,
10288 options,
10289 options,
10290 declaration_ptc_ubyte4n,
10291 declaration_ptc_float4,
10292 (BYTE*)exp_vertices31,
10293 exp_vertex_size31
10294 },
10295 {
10296 (BYTE*)vertices32,
10297 NULL,
10298 NULL,
10299 num_vertices32,
10300 num_faces32,
10301 vertex_size32,
10302 options,
10303 options,
10304 declaration_ptc_short2n,
10305 declaration_ptc_float4,
10306 (BYTE*)exp_vertices32,
10307 exp_vertex_size32
10308 },
10309 {
10310 (BYTE*)vertices33,
10311 NULL,
10312 NULL,
10313 num_vertices33,
10314 num_faces33,
10315 vertex_size33,
10316 options,
10317 options,
10318 declaration_ptc_short4n,
10319 declaration_ptc_float4,
10320 (BYTE*)exp_vertices33,
10321 exp_vertex_size33
10322 },
10323 {
10324 (BYTE*)vertices34,
10325 NULL,
10326 NULL,
10327 num_vertices34,
10328 num_faces34,
10329 vertex_size34,
10330 options,
10331 options,
10332 declaration_ptc_float16_2,
10333 declaration_ptc_float4,
10334 (BYTE*)exp_vertices34,
10335 exp_vertex_size34
10336 },
10337 {
10338 (BYTE*)vertices35,
10339 NULL,
10340 NULL,
10341 num_vertices35,
10342 num_faces35,
10343 vertex_size35,
10344 options,
10345 options,
10346 declaration_ptc_float16_4,
10347 declaration_ptc_float4,
10348 (BYTE*)exp_vertices35,
10349 exp_vertex_size35
10350 },
10351 {
10352 (BYTE*)vertices36,
10353 NULL,
10354 NULL,
10355 num_vertices36,
10356 num_faces36,
10357 vertex_size36,
10358 options,
10359 clone_options36,
10360 declaration_pn,
10361 declaration_pn,
10362 (BYTE*)vertices36,
10363 vertex_size36
10364 },
10365 };
10366
10368 if (!test_context)
10369 {
10370 skip("Couldn't create test context\n");
10371 goto cleanup;
10372 }
10373
10374 for (i = 0; i < ARRAY_SIZE(tc); i++)
10375 {
10376 UINT j;
10377 D3DVERTEXELEMENT9 new_declaration[MAX_FVF_DECL_SIZE];
10378 UINT exp_new_decl_length, new_decl_length;
10379 UINT exp_new_decl_size, new_decl_size;
10380
10381 hr = init_test_mesh(tc[i].num_faces, tc[i].num_vertices,
10382 tc[i].create_options,
10383 tc[i].declaration,
10385 tc[i].vertices, tc[i].vertex_size,
10386 tc[i].indices, tc[i].attributes);
10387 if (FAILED(hr))
10388 {
10389 skip("Couldn't initialize test mesh %d. Got %lx expected D3D_OK\n", i, hr);
10390 goto cleanup;
10391 }
10392
10393 hr = mesh->lpVtbl->CloneMesh(mesh, tc[i].clone_options, tc[i].new_declaration,
10394 test_context->device, &mesh_clone);
10395 ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
10396
10397 hr = mesh_clone->lpVtbl->GetDeclaration(mesh_clone, new_declaration);
10398 ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
10399 /* Check declaration elements */
10400 for (j = 0; tc[i].new_declaration[j].Stream != 0xFF; j++)
10401 {
10402 ok(memcmp(&tc[i].new_declaration[j], &new_declaration[j], sizeof(*new_declaration)) == 0,
10403 "Test case %d failed. Declaration element %d did not match.\n", i, j);
10404 }
10405
10406 /* Check declaration length */
10407 exp_new_decl_length = D3DXGetDeclLength(tc[i].new_declaration);
10408 new_decl_length = D3DXGetDeclLength(new_declaration);
10409 ok(new_decl_length == exp_new_decl_length,
10410 "Test case %d failed. Got new declaration length %d, expected %d\n",
10411 i, new_decl_length, exp_new_decl_length);
10412
10413 /* Check declaration size */
10414 exp_new_decl_size = D3DXGetDeclVertexSize(tc[i].new_declaration, 0);
10415 new_decl_size = D3DXGetDeclVertexSize(new_declaration, 0);
10416 ok(new_decl_size == exp_new_decl_size,
10417 "Test case %d failed. Got new declaration size %d, expected %d\n",
10418 i, new_decl_size, exp_new_decl_size);
10419
10420 /* Check vertex data in cloned mesh */
10421 hr = mesh_clone->lpVtbl->LockVertexBuffer(mesh_clone, 0, (void**)&vertices);
10422 if (FAILED(hr))
10423 {
10424 skip("Couldn't lock cloned vertex buffer.\n");
10425 goto cleanup;
10426 }
10427 for (j = 0; j < tc[i].num_vertices; j++)
10428 {
10429 UINT index = tc[i].exp_vertex_size * j;
10430 check_vertex_components(__LINE__, i, j, &vertices[index], &tc[i].exp_vertices[index], tc[i].new_declaration);
10431 }
10432 hr = mesh_clone->lpVtbl->UnlockVertexBuffer(mesh_clone);
10433 if (FAILED(hr))
10434 {
10435 skip("Couldn't unlock vertex buffer.\n");
10436 goto cleanup;
10437 }
10438 vertices = NULL;
10439 mesh->lpVtbl->Release(mesh);
10440 mesh = NULL;
10441 mesh_clone->lpVtbl->Release(mesh_clone);
10442 mesh_clone = NULL;
10443 }
10444
10445 /* The following test shows that it is not possible to share a vertex buffer
10446 * with D3DXMESH_VB_SHARE and change the vertex declaration at the same
10447 * time. It reuses the test data from test 2.
10448 */
10449 hr = init_test_mesh(tc[2].num_faces, tc[2].num_vertices,
10450 tc[2].create_options,
10451 tc[2].declaration,
10453 tc[2].vertices, tc[2].vertex_size,
10454 tc[2].indices, tc[2].attributes);
10455 if (FAILED(hr))
10456 {
10457 skip("Couldn't initialize test mesh for D3DXMESH_VB_SHARE case."
10458 " Got %lx expected D3D_OK\n", hr);
10459 goto cleanup;
10460 }
10461
10462 hr = mesh->lpVtbl->CloneMesh(mesh, tc[2].create_options | D3DXMESH_VB_SHARE,
10463 tc[2].new_declaration, test_context->device,
10464 &mesh_clone);
10465 ok(hr == D3DERR_INVALIDCALL, "CloneMesh D3DXMESH_VB_SHARE with new"
10466 " declaration. Got %lx, expected D3DERR_INVALIDCALL\n",
10467 hr);
10468 mesh->lpVtbl->Release(mesh);
10469 mesh = NULL;
10470 mesh_clone = NULL;
10471
10472cleanup:
10473 if (vertices) mesh->lpVtbl->UnlockVertexBuffer(mesh);
10474 if (mesh) mesh->lpVtbl->Release(mesh);
10475 if (mesh_clone) mesh_clone->lpVtbl->Release(mesh_clone);
10477}
@ D3DDECLMETHOD_PARTIALU
Definition: d3d9types.h:259
UINT WINAPI D3DXGetDeclLength(const D3DVERTEXELEMENT9 *decl)
Definition: mesh.c:2352
UINT WINAPI D3DXGetDeclVertexSize(const D3DVERTEXELEMENT9 *decl, DWORD stream_idx)
Definition: mesh.c:2321
#define SHRT_MAX
Definition: limits.h:22
#define UCHAR_MAX
Definition: limits.h:11
#define USHRT_MAX
Definition: limits.h:23
#define SHRT_MIN
Definition: limits.h:21
@ D3DXMESH_SYSTEMMEM
Definition: d3dx9mesh.h:63
@ D3DXMESH_VB_SHARE
Definition: d3dx9mesh.h:61
const GLfloat * tc
Definition: glext.h:8925
GLuint index
Definition: glext.h:6031
#define up(mutex)
Definition: glue.h:30
#define FLOAT
Definition: i386-dis.c:525
static void check_vertex_components(int line, int mesh_number, int vertex_number, BYTE *got_ptr, const BYTE *exp_ptr, D3DVERTEXELEMENT9 *declaration)
Definition: mesh.c:6689
static HRESULT init_test_mesh(const DWORD num_faces, const DWORD num_vertices, const DWORD options, const D3DVERTEXELEMENT9 *declaration, IDirect3DDevice9 *device, ID3DXMesh **mesh_ptr, const void *vertices, const DWORD vertex_size, const DWORD *indices, const DWORD *attributes)
Definition: mesh.c:6527
int32_t INT
Definition: typedefs.h:58

Referenced by START_TEST().

◆ test_compute_normals()

static void test_compute_normals ( void  )
static

Definition at line 10921 of file mesh.c.

10922{
10923 HRESULT hr;
10924 ULONG refcount;
10925 ID3DXMesh *mesh, *cloned_mesh;
10926 ID3DXBuffer *adjacency;
10928 struct test_context *test_context;
10929 unsigned int i;
10930
10931 static const struct compute_normals_func
10932 {
10933 const char *name;
10934 HRESULT (*apply)(ID3DXMesh *mesh, const DWORD *adjacency);
10935 }
10936 compute_normals_funcs[] =
10937 {
10938 {"D3DXComputeNormals", compute_normals_D3DXComputeNormals },
10939 {"D3DXComputeTangentFrameEx", compute_normals_D3DXComputeTangentFrameEx}
10940 };
10941
10942 static const D3DXVECTOR3 box_normals[24] =
10943 {
10944 {-1.0f, 0.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}, {-1.0f, 0.0f, 0.0f},
10945 { 0.0f, 1.0f, 0.0f}, { 0.0f, 1.0f, 0.0f}, { 0.0f, 1.0f, 0.0f}, { 0.0f, 1.0f, 0.0f},
10946 { 1.0f, 0.0f, 0.0f}, { 1.0f, 0.0f, 0.0f}, { 1.0f, 0.0f, 0.0f}, { 1.0f, 0.0f, 0.0f},
10947 { 0.0f,-1.0f, 0.0f}, { 0.0f,-1.0f, 0.0f}, { 0.0f,-1.0f, 0.0f}, { 0.0f,-1.0f, 0.0f},
10948 { 0.0f, 0.0f, 1.0f}, { 0.0f, 0.0f, 1.0f}, { 0.0f, 0.0f, 1.0f}, { 0.0f, 0.0f, 1.0f},
10949 { 0.0f, 0.0f,-1.0f}, { 0.0f, 0.0f,-1.0f}, { 0.0f, 0.0f,-1.0f}, { 0.0f, 0.0f,-1.0f}
10950 };
10951 const float box_normal_component = 1.0f / sqrtf(3.0f);
10952 const D3DXVECTOR3 box_normals_adjacency[24] =
10953 {
10954 {-box_normal_component, -box_normal_component, -box_normal_component},
10955 {-box_normal_component, -box_normal_component, box_normal_component},
10956 {-box_normal_component, box_normal_component, box_normal_component},
10957 {-box_normal_component, box_normal_component, -box_normal_component},
10958 {-box_normal_component, box_normal_component, -box_normal_component},
10959 {-box_normal_component, box_normal_component, box_normal_component},
10960 { box_normal_component, box_normal_component, box_normal_component},
10961 { box_normal_component, box_normal_component, -box_normal_component},
10962 { box_normal_component, box_normal_component, -box_normal_component},
10963 { box_normal_component, box_normal_component, box_normal_component},
10964 { box_normal_component, -box_normal_component, box_normal_component},
10965 { box_normal_component, -box_normal_component, -box_normal_component},
10966 {-box_normal_component, -box_normal_component, box_normal_component},
10967 {-box_normal_component, -box_normal_component, -box_normal_component},
10968 { box_normal_component, -box_normal_component, -box_normal_component},
10969 { box_normal_component, -box_normal_component, box_normal_component},
10970 {-box_normal_component, -box_normal_component, box_normal_component},
10971 { box_normal_component, -box_normal_component, box_normal_component},
10972 { box_normal_component, box_normal_component, box_normal_component},
10973 {-box_normal_component, box_normal_component, box_normal_component},
10974 {-box_normal_component, -box_normal_component, -box_normal_component},
10975 {-box_normal_component, box_normal_component, -box_normal_component},
10976 { box_normal_component, box_normal_component, -box_normal_component},
10977 { box_normal_component, -box_normal_component, -box_normal_component}
10978 };
10979 static const D3DXVECTOR3 box_normals_adjacency_area[24] =
10980 {
10981 {-0.666667f, -0.333333f, -0.666667f}, {-0.333333f, -0.666667f, 0.666667f},
10982 {-0.816496f, 0.408248f, 0.408248f}, {-0.408248f, 0.816496f, -0.408248f},
10983 {-0.408248f, 0.816496f, -0.408248f}, {-0.816496f, 0.408248f, 0.408248f},
10984 { 0.333333f, 0.666667f, 0.666667f}, { 0.666667f, 0.333333f, -0.666667f},
10985 { 0.666667f, 0.333333f, -0.666667f}, { 0.333333f, 0.666667f, 0.666667f},
10986 { 0.816496f, -0.408248f, 0.408248f}, { 0.408248f, -0.816496f, -0.408248f},
10987 {-0.333333f, -0.666667f, 0.666667f}, {-0.666667f, -0.333333f, -0.666667f},
10988 { 0.408248f, -0.816496f, -0.408248f}, { 0.816496f, -0.408248f, 0.408248f},
10989 {-0.333333f, -0.666667f, 0.666667f}, { 0.816497f, -0.408248f, 0.408248f},
10990 { 0.333333f, 0.666667f, 0.666667f}, {-0.816497f, 0.408248f, 0.408248f},
10991 {-0.666667f, -0.333333f, -0.666667f}, {-0.408248f, 0.816497f, -0.408248f},
10992 { 0.666667f, 0.333333f, -0.666667f}, { 0.408248f, -0.816496f, -0.408248f}
10993 };
10994 static const D3DXVECTOR3 box_normals_position1f[24] = {{0}};
10995 static const D3DXVECTOR3 box_normals_position2f[24] =
10996 {
10997 {0.0f, 0.0f, -1.0f}, {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 1.0f},
10998 {0.0f, 0.0f, -1.0f}, {0.0f, 0.0f, -1.0f}, {0.0f, 0.0f, 1.0f},
10999 {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, -1.0f}, {0.0f, 0.0f, -1.0f},
11000 {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, -1.0f},
11001 {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, -1.0f}, {0.0f, 0.0f, -1.0f},
11002 {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 1.0f},
11003 {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, -1.0f},
11004 {0.0f, 0.0f, -1.0f}, {0.0f, 0.0f, -1.0f}, {0.0f, 0.0f, -1.0f}
11005 };
11006
11007 static const D3DXVECTOR3 sphere_normals[22] =
11008 {
11009 { 0.000000f, -0.000000f, 1.000000f}, { 0.000000f, 0.582244f, 0.813014f},
11010 { 0.582244f, -0.000000f, 0.813014f}, {-0.000000f, -0.582244f, 0.813014f},
11011 {-0.582244f, 0.000000f, 0.813014f}, {-0.000000f, 0.890608f, 0.454772f},
11012 { 0.890608f, 0.000000f, 0.454772f}, { 0.000000f, -0.890608f, 0.454772f},
11013 {-0.890608f, -0.000000f, 0.454772f}, { 0.000000f, 1.000000f, -0.000000f},
11014 { 1.000000f, -0.000000f, -0.000000f}, {-0.000000f, -1.000000f, -0.000000f},
11015 {-1.000000f, 0.000000f, -0.000000f}, { 0.000000f, 0.890608f, -0.454773f},
11016 { 0.890608f, -0.000000f, -0.454772f}, {-0.000000f, -0.890608f, -0.454773f},
11017 {-0.890608f, 0.000000f, -0.454773f}, { 0.000000f, 0.582244f, -0.813015f},
11018 { 0.582244f, -0.000000f, -0.813015f}, { 0.000000f, -0.582244f, -0.813015f},
11019 {-0.582243f, 0.000000f, -0.813015f}, { 0.000000f, 0.000000f, -1.000000f}
11020 };
11021 static const D3DXVECTOR3 sphere_normals_area[22] =
11022 {
11023 { 0.000000f, -0.000000f, 1.000000f}, {-0.215311f, 0.554931f, 0.803550f},
11024 { 0.554931f, 0.215311f, 0.803550f}, { 0.215311f, -0.554931f, 0.803550f},
11025 {-0.554931f, -0.215311f, 0.803550f}, {-0.126638f, 0.872121f, 0.472618f},
11026 { 0.872121f, 0.126638f, 0.472618f}, { 0.126638f, -0.872121f, 0.472618f},
11027 {-0.872121f, -0.126637f, 0.472618f}, { 0.000000f, 1.000000f, -0.000000f},
11028 { 1.000000f, -0.000000f, -0.000000f}, {-0.000000f, -1.000000f, -0.000000f},
11029 {-1.000000f, 0.000000f, -0.000000f}, { 0.126638f, 0.872121f, -0.472618f},
11030 { 0.872121f, -0.126638f, -0.472618f}, {-0.126638f, -0.872121f, -0.472618f},
11031 {-0.872121f, 0.126638f, -0.472618f}, { 0.215311f, 0.554931f, -0.803550f},
11032 { 0.554931f, -0.215311f, -0.803550f}, {-0.215311f, -0.554931f, -0.803550f},
11033 {-0.554931f, 0.215311f, -0.803550f}, { 0.000000f, 0.000000f, -1.000000f}
11034 };
11035 static const D3DXVECTOR3 sphere_normals_equal[22] =
11036 {
11037 { 0.000000f, -0.000000f, 1.000000f}, {-0.134974f, 0.522078f, 0.842150f},
11038 { 0.522078f, 0.134974f, 0.842150f}, { 0.134974f, -0.522078f, 0.842150f},
11039 {-0.522078f, -0.134974f, 0.842150f}, {-0.026367f, 0.857121f, 0.514440f},
11040 { 0.857121f, 0.026367f, 0.514440f}, { 0.026367f, -0.857121f, 0.514440f},
11041 {-0.857121f, -0.026367f, 0.514440f}, { 0.000000f, 1.000000f, -0.000000f},
11042 { 1.000000f, -0.000000f, -0.000000f}, {-0.000000f, -1.000000f, -0.000000f},
11043 {-1.000000f, 0.000000f, -0.000000f}, { 0.026367f, 0.857121f, -0.514440f},
11044 { 0.857121f, -0.026367f, -0.514440f}, {-0.026367f, -0.857121f, -0.514440f},
11045 {-0.857121f, 0.026367f, -0.514440f}, { 0.134975f, 0.522078f, -0.842150f},
11046 { 0.522078f, -0.134975f, -0.842150f}, {-0.134974f, -0.522078f, -0.842150f},
11047 {-0.522078f, 0.134974f, -0.842150f}, { 0.000000f, 0.000000f, -1.000000f}
11048 };
11049
11050 static const D3DVERTEXELEMENT9 position3f_normal1f_declaration[] =
11051 {
11054 D3DDECL_END()
11055 };
11056 static const D3DVERTEXELEMENT9 position3f_normal2f_declaration[] =
11057 {
11060 D3DDECL_END()
11061 };
11062 static const D3DVERTEXELEMENT9 normal4f_position3f_declaration[] =
11063 {
11066 D3DDECL_END()
11067 };
11068 static const D3DVERTEXELEMENT9 position1f_normal3f_declaration[] =
11069 {
11072 D3DDECL_END()
11073 };
11074 static const D3DVERTEXELEMENT9 position2f_normal3f_declaration[] =
11075 {
11078 D3DDECL_END()
11079 };
11080 static const D3DVERTEXELEMENT9 position4f_normal3f_declaration[] =
11081 {
11084 D3DDECL_END()
11085 };
11086
11087 for (i = 0; i < ARRAY_SIZE(compute_normals_funcs); i++)
11088 {
11089 hr = compute_normals_funcs[i].apply(NULL, NULL);
11090 ok(hr == D3DERR_INVALIDCALL, "%s returned %#lx, expected D3DERR_INVALIDCALL\n", compute_normals_funcs[i].name, hr);
11091 }
11092
11093 if (!(test_context = new_test_context()))
11094 {
11095 skip("Couldn't create test context\n");
11096 return;
11097 }
11099
11100 hr = D3DXCreateBox(device, 1.0f, 1.0f, 1.0f, &mesh, &adjacency);
11101 ok(SUCCEEDED(hr), "D3DXCreateBox failed %#lx\n", hr);
11102
11103 /* Check wrong input */
11105 D3DDECLUSAGE_NORMAL, 0, D3DXTANGENT_GENERATE_IN_PLACE, NULL, -1.01f, -0.01f, -1.01f, NULL, NULL);
11106 todo_wine ok(hr == D3DERR_INVALIDCALL, "D3DXComputeTangentFrameEx returned %#lx, expected D3DERR_INVALIDCALL\n", hr);
11107
11110 NULL, -1.01f, -0.01f, -1.01f, NULL, NULL);
11111 ok(hr == D3DERR_INVALIDCALL, "D3DXComputeTangentFrameEx returned %#lx, expected D3DERR_INVALIDCALL\n", hr);
11112
11114 D3DDECLUSAGE_NORMAL, 0, 0, NULL, -1.01f, -0.01f, -1.01f, NULL, NULL);
11115 todo_wine ok(hr == D3DERR_INVALIDCALL, "D3DXComputeTangentFrameEx returned %#lx, expected D3DERR_INVALIDCALL\n", hr);
11116
11119 NULL, -1.01f, -0.01f, -1.01f, NULL, NULL);
11120 ok(hr == D3DERR_INVALIDCALL, "D3DXComputeTangentFrameEx returned %#lx, expected D3DERR_INVALIDCALL\n", hr);
11121
11124 NULL, -1.01f, -0.01f, -1.01f, NULL, NULL);
11125 ok(hr == D3DERR_INVALIDCALL, "D3DXComputeTangentFrameEx returned %#lx, expected D3DERR_INVALIDCALL\n", hr);
11126
11129 NULL, -1.01f, -0.01f, -1.01f, NULL, NULL);
11130 todo_wine ok(hr == D3DERR_INVALIDCALL, "D3DXComputeTangentFrameEx returned %#lx, expected D3DERR_INVALIDCALL\n", hr);
11131
11132 for (i = 0; i < ARRAY_SIZE(compute_normals_funcs); i++)
11133 {
11134 const struct compute_normals_func *func = &compute_normals_funcs[i];
11135
11136 /* Mesh without normals */
11137 hr = mesh->lpVtbl->CloneMeshFVF(mesh, 0, D3DFVF_XYZ, device, &cloned_mesh);
11138 ok(SUCCEEDED(hr), "CloneMeshFVF failed %#lx\n", hr);
11139
11140 hr = func->apply(cloned_mesh, NULL);
11141 ok(hr == D3DERR_INVALIDCALL, "%s returned %#lx, expected D3DERR_INVALIDCALL\n", func->name, hr);
11142
11143 refcount = cloned_mesh->lpVtbl->Release(cloned_mesh);
11144 ok(!refcount, "Mesh has %lu references left\n", refcount);
11145
11146 /* Mesh without positions */
11147 hr = mesh->lpVtbl->CloneMeshFVF(mesh, 0, D3DFVF_NORMAL, device, &cloned_mesh);
11148 ok(SUCCEEDED(hr), "CloneMeshFVF failed %#lx\n", hr);
11149
11150 hr = func->apply(cloned_mesh, NULL);
11151 ok(hr == D3DERR_INVALIDCALL, "%s returned %#lx, expected D3DERR_INVALIDCALL\n", func->name, hr);
11152
11153 refcount = cloned_mesh->lpVtbl->Release(cloned_mesh);
11154 ok(!refcount, "Mesh has %lu references left\n", refcount);
11155
11156 /* Mesh with D3DDECLTYPE_FLOAT1 normals */
11157 hr = mesh->lpVtbl->CloneMesh(mesh, 0, position3f_normal1f_declaration, device, &cloned_mesh);
11158 ok(SUCCEEDED(hr), "CloneMesh failed %#lx\n", hr);
11159
11160 hr = func->apply(cloned_mesh, NULL);
11161 ok(hr == D3DERR_INVALIDCALL, "%s returned %#lx, expected D3DERR_INVALIDCALL\n", func->name, hr);
11162
11163 refcount = cloned_mesh->lpVtbl->Release(cloned_mesh);
11164 ok(!refcount, "Mesh has %lu references left\n", refcount);
11165
11166 /* Mesh with D3DDECLTYPE_FLOAT2 normals */
11167 hr = mesh->lpVtbl->CloneMesh(mesh, 0, position3f_normal2f_declaration, device, &cloned_mesh);
11168 ok(SUCCEEDED(hr), "CloneMesh failed %#lx\n", hr);
11169
11170 hr = func->apply(cloned_mesh, NULL);
11171 ok(hr == D3DERR_INVALIDCALL, "%s returned %#lx, expected D3DERR_INVALIDCALL\n", func->name, hr);
11172
11173 refcount = cloned_mesh->lpVtbl->Release(cloned_mesh);
11174 ok(!refcount, "Mesh has %lu references left\n", refcount);
11175
11176 /* Mesh without adjacency data */
11178 ok(SUCCEEDED(hr), "Failed to clear normals, returned %#lx\n", hr);
11179
11180 hr = func->apply(mesh, NULL);
11181 ok(hr == D3D_OK, "%s returned %#lx, expected D3D_OK\n", func->name, hr);
11182
11183 compare_normals(__LINE__, func->name, mesh, box_normals, ARRAY_SIZE(box_normals));
11184
11185 /* Mesh with adjacency data */
11187 ok(SUCCEEDED(hr), "Failed to clear normals, returned %#lx\n", hr);
11188
11189 hr = func->apply(mesh, ID3DXBuffer_GetBufferPointer(adjacency));
11190 ok(hr == D3D_OK, "%s returned %#lx, expected D3D_OK\n", func->name, hr);
11191
11192 compare_normals(__LINE__, func->name, mesh, box_normals_adjacency, ARRAY_SIZE(box_normals_adjacency));
11193
11194 /* Mesh with custom vertex format, D3DDECLTYPE_FLOAT4 normals and adjacency */
11195 hr = mesh->lpVtbl->CloneMesh(mesh, 0, normal4f_position3f_declaration, device, &cloned_mesh);
11196 ok(SUCCEEDED(hr), "CloneMesh failed %#lx\n", hr);
11197
11198 hr = clear_normals(cloned_mesh);
11199 ok(SUCCEEDED(hr), "Failed to clear normals, returned %#lx\n", hr);
11200
11201 hr = func->apply(cloned_mesh, ID3DXBuffer_GetBufferPointer(adjacency));
11202 ok(hr == D3D_OK, "%s returned %#lx, expected D3D_OK\n", func->name, hr);
11203
11204 compare_normals(__LINE__, func->name, cloned_mesh, box_normals_adjacency, ARRAY_SIZE(box_normals_adjacency));
11205
11206 refcount = cloned_mesh->lpVtbl->Release(cloned_mesh);
11207 ok(!refcount, "Mesh has %lu references left\n", refcount);
11208
11209 /* Mesh with D3DDECLTYPE_FLOAT1 positions and D3DDECLTYPE_FLOAT3 normals */
11210 hr = mesh->lpVtbl->CloneMesh(mesh, 0, position1f_normal3f_declaration, device, &cloned_mesh);
11211 ok(SUCCEEDED(hr), "CloneMesh failed %#lx\n", hr);
11212
11213 hr = clear_normals(cloned_mesh);
11214 ok(SUCCEEDED(hr), "Failed to clear normals, returned %#lx\n", hr);
11215
11216 hr = func->apply(cloned_mesh, ID3DXBuffer_GetBufferPointer(adjacency));
11217 ok(hr == D3D_OK, "%s returned %#lx, expected D3D_OK\n", func->name, hr);
11218
11219 compare_normals(__LINE__, func->name, cloned_mesh, box_normals_position1f, ARRAY_SIZE(box_normals_position1f));
11220
11221 refcount = cloned_mesh->lpVtbl->Release(cloned_mesh);
11222 ok(!refcount, "Mesh has %lu references left\n", refcount);
11223
11224 /* Mesh with D3DDECLTYPE_FLOAT2 positions and D3DDECLTYPE_FLOAT3 normals */
11225 hr = mesh->lpVtbl->CloneMesh(mesh, 0, position2f_normal3f_declaration, device, &cloned_mesh);
11226 ok(SUCCEEDED(hr), "CloneMesh failed %#lx\n", hr);
11227
11228 hr = clear_normals(cloned_mesh);
11229 ok(SUCCEEDED(hr), "Failed to clear normals, returned %#lx\n", hr);
11230
11231 hr = func->apply(cloned_mesh, ID3DXBuffer_GetBufferPointer(adjacency));
11232 ok(hr == D3D_OK, "%s returned %#lx, expected D3D_OK\n", func->name, hr);
11233
11234 compare_normals(__LINE__, func->name, cloned_mesh, box_normals_position2f, ARRAY_SIZE(box_normals_position2f));
11235
11236 refcount = cloned_mesh->lpVtbl->Release(cloned_mesh);
11237 ok(!refcount, "Mesh has %lu references left\n", refcount);
11238
11239 /* Mesh with D3DDECLTYPE_FLOAT4 positions and D3DDECLTYPE_FLOAT3 normals */
11240 hr = mesh->lpVtbl->CloneMesh(mesh, 0, position4f_normal3f_declaration, device, &cloned_mesh);
11241 ok(SUCCEEDED(hr), "CloneMesh failed %#lx\n", hr);
11242
11243 hr = clear_normals(cloned_mesh);
11244 ok(SUCCEEDED(hr), "Failed to clear normals, returned %#lx\n", hr);
11245
11246 hr = func->apply(cloned_mesh, ID3DXBuffer_GetBufferPointer(adjacency));
11247 ok(hr == D3D_OK, "%s returned %#lx, expected D3D_OK\n", func->name, hr);
11248
11249 compare_normals(__LINE__, func->name, cloned_mesh, box_normals_adjacency, ARRAY_SIZE(box_normals_adjacency));
11250
11251 refcount = cloned_mesh->lpVtbl->Release(cloned_mesh);
11252 ok(!refcount, "Mesh has %lu references left\n", refcount);
11253 }
11254
11257 NULL, -1.01f, -0.01f, -1.01f, NULL, NULL);
11258 ok(hr == D3D_OK, "D3DXComputeTangentFrameEx returned %#lx, expected D3D_OK\n", hr);
11259
11260 compare_normals(__LINE__, "D3DXComputeTangentFrameEx", mesh, box_normals, ARRAY_SIZE(box_normals));
11261
11264 ID3DXBuffer_GetBufferPointer(adjacency), -1.01f, -0.01f, -1.01f, NULL, NULL);
11265 ok(hr == D3D_OK, "D3DXComputeTangentFrameEx returned %#lx, expected D3D_OK\n", hr);
11266
11267 compare_normals(__LINE__, "D3DXComputeTangentFrameEx", mesh, box_normals_adjacency_area, ARRAY_SIZE(box_normals_adjacency_area));
11268
11271 NULL, -1.01f, -0.01f, -1.01f, NULL, NULL);
11272 ok(hr == D3D_OK, "D3DXComputeTangentFrameEx returned %#lx, expected D3D_OK\n", hr);
11273
11274 compare_normals(__LINE__, "D3DXComputeTangentFrameEx", mesh, box_normals, ARRAY_SIZE(box_normals));
11275
11278 ID3DXBuffer_GetBufferPointer(adjacency), -1.01f, -0.01f, -1.01f, NULL, NULL);
11279 ok(hr == D3D_OK, "D3DXComputeTangentFrameEx returned %#lx, expected D3D_OK\n", hr);
11280
11281 compare_normals(__LINE__, "D3DXComputeTangentFrameEx", mesh, box_normals_adjacency_area, ARRAY_SIZE(box_normals_adjacency_area));
11282
11283 refcount = mesh->lpVtbl->Release(mesh);
11284 ok(!refcount, "Mesh has %lu references left\n", refcount);
11285 refcount = ID3DXBuffer_Release(adjacency);
11286 ok(!refcount, "Buffer has %lu references left\n", refcount);
11287
11288 hr = D3DXCreateSphere(device, 1.0f, 4, 6, &mesh, &adjacency);
11289 ok(SUCCEEDED(hr), "D3DXCreateSphere failed %#lx\n", hr);
11290
11291 for (i = 0; i < ARRAY_SIZE(compute_normals_funcs); i++)
11292 {
11293 const struct compute_normals_func *func = &compute_normals_funcs[i];
11294
11295 /* Sphere without adjacency data */
11297 ok(SUCCEEDED(hr), "Failed to clear normals, returned %#lx\n", hr);
11298
11299 hr = func->apply(mesh, NULL);
11300 ok(hr == D3D_OK, "%s returned %#lx, expected D3D_OK\n", func->name, hr);
11301
11302 compare_normals(__LINE__, func->name, mesh, sphere_normals, ARRAY_SIZE(sphere_normals));
11303
11304 /* Sphere with adjacency data */
11306 ok(SUCCEEDED(hr), "Failed to clear normals, returned %#lx\n", hr);
11307
11308 hr = func->apply(mesh, ID3DXBuffer_GetBufferPointer(adjacency));
11309 ok(hr == D3D_OK, "%s returned %#lx, expected D3D_OK\n", func->name, hr);
11310
11311 compare_normals(__LINE__, func->name, mesh, sphere_normals, ARRAY_SIZE(sphere_normals));
11312 }
11313
11316 NULL, -1.01f, -0.01f, -1.01f, NULL, NULL);
11317 ok(hr == D3D_OK, "D3DXComputeTangentFrameEx returned %#lx, expected D3D_OK\n", hr);
11318
11319 compare_normals(__LINE__, "D3DXComputeTangentFrameEx", mesh, sphere_normals_area, ARRAY_SIZE(sphere_normals_area));
11320
11323 ID3DXBuffer_GetBufferPointer(adjacency), -1.01f, -0.01f, -1.01f, NULL, NULL);
11324 ok(hr == D3D_OK, "D3DXComputeTangentFrameEx returned %#lx, expected D3D_OK\n", hr);
11325
11326 compare_normals(__LINE__, "D3DXComputeTangentFrameEx", mesh, sphere_normals_area, ARRAY_SIZE(sphere_normals_area));
11327
11330 NULL, -1.01f, -0.01f, -1.01f, NULL, NULL);
11331 ok(hr == D3D_OK, "D3DXComputeTangentFrameEx returned %#lx, expected D3D_OK\n", hr);
11332
11333 compare_normals(__LINE__, "D3DXComputeTangentFrameEx", mesh, sphere_normals_equal, ARRAY_SIZE(sphere_normals_equal));
11334
11337 ID3DXBuffer_GetBufferPointer(adjacency), -1.01f, -0.01f, -1.01f, NULL, NULL);
11338 ok(hr == D3D_OK, "D3DXComputeTangentFrameEx returned %#lx, expected D3D_OK\n", hr);
11339
11340 compare_normals(__LINE__, "D3DXComputeTangentFrameEx", mesh, sphere_normals_equal, ARRAY_SIZE(sphere_normals_equal));
11341
11342 refcount = mesh->lpVtbl->Release(mesh);
11343 ok(!refcount, "Mesh has %lu references left\n", refcount);
11344 refcount = ID3DXBuffer_Release(adjacency);
11345 ok(!refcount, "Buffer has %lu references left\n", refcount);
11346
11348}
@ D3DXTANGENT_WEIGHT_BY_AREA
Definition: d3dx9mesh.h:118
@ D3DXTANGENT_WEIGHT_EQUAL
Definition: d3dx9mesh.h:119
GLenum func
Definition: glext.h:6028
static HRESULT clear_normals(ID3DXMesh *mesh)
Definition: mesh.c:10783
static void compare_normals(unsigned int line, const char *test_name, ID3DXMesh *mesh, const D3DXVECTOR3 *normals, unsigned int num_normals)
Definition: mesh.c:10836
static HRESULT compute_normals_D3DXComputeTangentFrameEx(ID3DXMesh *mesh, const DWORD *adjacency)
Definition: mesh.c:10914
static HRESULT compute_normals_D3DXComputeNormals(ID3DXMesh *mesh, const DWORD *adjacency)
Definition: mesh.c:10909
#define sqrtf(x)
Definition: mymath.h:59
char * name
Definition: wpp.c:52
uint32_t ULONG
Definition: typedefs.h:59
#define HRESULT
Definition: msvc.h:7

Referenced by START_TEST().

◆ test_convert_adjacency_to_point_reps()

static void test_convert_adjacency_to_point_reps ( void  )
static

Definition at line 5462 of file mesh.c.

5463{
5464 HRESULT hr;
5465 struct test_context *test_context = NULL;
5467 const DWORD options_16bit = D3DXMESH_SYSTEMMEM;
5469 {
5473 D3DDECL_END()
5474 };
5475 const unsigned int VERTS_PER_FACE = 3;
5476 void *vertex_buffer;
5477 void *index_buffer;
5478 DWORD *attributes_buffer;
5479 int i, j;
5480 enum color { RED = 0xffff0000, GREEN = 0xff00ff00, BLUE = 0xff0000ff};
5481 struct vertex_pnc
5482 {
5483 D3DXVECTOR3 position;
5485 enum color color; /* In case of manual visual inspection */
5486 };
5487 D3DXVECTOR3 up = {0.0f, 0.0f, 1.0f};
5488 /* mesh0 (one face)
5489 *
5490 * 0--1
5491 * | /
5492 * |/
5493 * 2
5494 */
5495 const struct vertex_pnc vertices0[] =
5496 {
5497 {{ 0.0f, 3.0f, 0.f}, up, RED},
5498 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
5499 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
5500 };
5501 const DWORD indices0[] = {0, 1, 2};
5502 const unsigned int num_vertices0 = ARRAY_SIZE(vertices0);
5503 const unsigned int num_faces0 = ARRAY_SIZE(indices0) / VERTS_PER_FACE;
5504 const DWORD adjacency0[] = {-1, -1, -1};
5505 const DWORD exp_point_rep0[] = {0, 1, 2};
5506 /* mesh1 (right)
5507 *
5508 * 0--1 3
5509 * | / /|
5510 * |/ / |
5511 * 2 5--4
5512 */
5513 const struct vertex_pnc vertices1[] =
5514 {
5515 {{ 0.0f, 3.0f, 0.f}, up, RED},
5516 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
5517 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
5518
5519 {{ 3.0f, 3.0f, 0.f}, up, GREEN},
5520 {{ 3.0f, 0.0f, 0.f}, up, RED},
5521 {{ 1.0f, 0.0f, 0.f}, up, BLUE},
5522 };
5523 const DWORD indices1[] = {0, 1, 2, 3, 4, 5};
5524 const unsigned int num_vertices1 = ARRAY_SIZE(vertices1);
5525 const unsigned int num_faces1 = ARRAY_SIZE(indices1) / VERTS_PER_FACE;
5526 const DWORD adjacency1[] = {-1, 1, -1, -1, -1, 0};
5527 const DWORD exp_point_rep1[] = {0, 1, 2, 1, 4, 2};
5528 /* mesh2 (left)
5529 *
5530 * 3 0--1
5531 * /| | /
5532 * / | |/
5533 * 5--4 2
5534 */
5535 const struct vertex_pnc vertices2[] =
5536 {
5537 {{ 0.0f, 3.0f, 0.f}, up, RED},
5538 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
5539 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
5540
5541 {{-1.0f, 3.0f, 0.f}, up, RED},
5542 {{-1.0f, 0.0f, 0.f}, up, GREEN},
5543 {{-3.0f, 0.0f, 0.f}, up, BLUE},
5544 };
5545 const DWORD indices2[] = {0, 1, 2, 3, 4, 5};
5546 const unsigned int num_vertices2 = ARRAY_SIZE(vertices2);
5547 const unsigned int num_faces2 = ARRAY_SIZE(indices2) / VERTS_PER_FACE;
5548 const DWORD adjacency2[] = {-1, -1, 1, 0, -1, -1};
5549 const DWORD exp_point_rep2[] = {0, 1, 2, 0, 2, 5};
5550 /* mesh3 (above)
5551 *
5552 * 3
5553 * /|
5554 * / |
5555 * 5--4
5556 * 0--1
5557 * | /
5558 * |/
5559 * 2
5560 */
5561 struct vertex_pnc vertices3[] =
5562 {
5563 {{ 0.0f, 3.0f, 0.f}, up, RED},
5564 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
5565 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
5566
5567 {{ 2.0f, 7.0f, 0.f}, up, BLUE},
5568 {{ 2.0f, 4.0f, 0.f}, up, GREEN},
5569 {{ 0.0f, 4.0f, 0.f}, up, RED},
5570 };
5571 const DWORD indices3[] = {0, 1, 2, 3, 4, 5};
5572 const unsigned int num_vertices3 = ARRAY_SIZE(vertices3);
5573 const unsigned int num_faces3 = ARRAY_SIZE(indices3) / VERTS_PER_FACE;
5574 const DWORD adjacency3[] = {1, -1, -1, -1, 0, -1};
5575 const DWORD exp_point_rep3[] = {0, 1, 2, 3, 1, 0};
5576 /* mesh4 (below, tip against tip)
5577 *
5578 * 0--1
5579 * | /
5580 * |/
5581 * 2
5582 * 3
5583 * |\
5584 * | \
5585 * 5--4
5586 */
5587 struct vertex_pnc vertices4[] =
5588 {
5589 {{ 0.0f, 3.0f, 0.f}, up, RED},
5590 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
5591 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
5592
5593 {{ 0.0f, -4.0f, 0.f}, up, BLUE},
5594 {{ 2.0f, -7.0f, 0.f}, up, GREEN},
5595 {{ 0.0f, -7.0f, 0.f}, up, RED},
5596 };
5597 const DWORD indices4[] = {0, 1, 2, 3, 4, 5};
5598 const unsigned int num_vertices4 = ARRAY_SIZE(vertices4);
5599 const unsigned int num_faces4 = ARRAY_SIZE(indices4) / VERTS_PER_FACE;
5600 const DWORD adjacency4[] = {-1, -1, -1, -1, -1, -1};
5601 const DWORD exp_point_rep4[] = {0, 1, 2, 3, 4, 5};
5602 /* mesh5 (gap in mesh)
5603 *
5604 * 0 3-----4 15
5605 * / \ \ / / \
5606 * / \ \ / / \
5607 * 2-----1 5 17-----16
5608 * 6-----7 9 12-----13
5609 * \ / / \ \ /
5610 * \ / / \ \ /
5611 * 8 10-----11 14
5612 *
5613 */
5614 const struct vertex_pnc vertices5[] =
5615 {
5616 {{ 0.0f, 1.0f, 0.f}, up, RED},
5617 {{ 1.0f, -1.0f, 0.f}, up, GREEN},
5618 {{-1.0f, -1.0f, 0.f}, up, BLUE},
5619
5620 {{ 0.1f, 1.0f, 0.f}, up, RED},
5621 {{ 2.1f, 1.0f, 0.f}, up, BLUE},
5622 {{ 1.1f, -1.0f, 0.f}, up, GREEN},
5623
5624 {{-1.0f, -1.1f, 0.f}, up, BLUE},
5625 {{ 1.0f, -1.1f, 0.f}, up, GREEN},
5626 {{ 0.0f, -3.1f, 0.f}, up, RED},
5627
5628 {{ 1.1f, -1.1f, 0.f}, up, GREEN},
5629 {{ 2.1f, -3.1f, 0.f}, up, BLUE},
5630 {{ 0.1f, -3.1f, 0.f}, up, RED},
5631
5632 {{ 1.2f, -1.1f, 0.f}, up, GREEN},
5633 {{ 3.2f, -1.1f, 0.f}, up, RED},
5634 {{ 2.2f, -3.1f, 0.f}, up, BLUE},
5635
5636 {{ 2.2f, 1.0f, 0.f}, up, BLUE},
5637 {{ 3.2f, -1.0f, 0.f}, up, RED},
5638 {{ 1.2f, -1.0f, 0.f}, up, GREEN},
5639 };
5640 const DWORD indices5[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
5641 const unsigned int num_vertices5 = ARRAY_SIZE(vertices5);
5642 const unsigned int num_faces5 = ARRAY_SIZE(indices5) / VERTS_PER_FACE;
5643 const DWORD adjacency5[] = {-1, 2, -1, -1, 5, -1, 0, -1, -1, 4, -1, -1, 5, -1, 3, -1, 4, 1};
5644 const DWORD exp_point_rep5[] = {0, 1, 2, 3, 4, 5, 2, 1, 8, 5, 10, 11, 5, 13, 10, 4, 13, 5};
5645 const WORD indices5_16bit[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
5646 /* mesh6 (indices re-ordering)
5647 *
5648 * 0--1 6 3
5649 * | / /| |\
5650 * |/ / | | \
5651 * 2 8--7 5--4
5652 */
5653 const struct vertex_pnc vertices6[] =
5654 {
5655 {{ 0.0f, 3.0f, 0.f}, up, RED},
5656 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
5657 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
5658
5659 {{ 3.0f, 3.0f, 0.f}, up, GREEN},
5660 {{ 3.0f, 0.0f, 0.f}, up, RED},
5661 {{ 1.0f, 0.0f, 0.f}, up, BLUE},
5662
5663 {{ 4.0f, 3.0f, 0.f}, up, GREEN},
5664 {{ 6.0f, 0.0f, 0.f}, up, BLUE},
5665 {{ 4.0f, 0.0f, 0.f}, up, RED},
5666 };
5667 const DWORD indices6[] = {0, 1, 2, 6, 7, 8, 3, 4, 5};
5668 const unsigned int num_vertices6 = ARRAY_SIZE(vertices6);
5669 const unsigned int num_faces6 = ARRAY_SIZE(indices6) / VERTS_PER_FACE;
5670 const DWORD adjacency6[] = {-1, 1, -1, 2, -1, 0, -1, -1, 1};
5671 const DWORD exp_point_rep6[] = {0, 1, 2, 1, 4, 5, 1, 5, 2};
5672 /* mesh7 (expands collapsed triangle)
5673 *
5674 * 0--1 3
5675 * | / /|
5676 * |/ / |
5677 * 2 5--4
5678 */
5679 const struct vertex_pnc vertices7[] =
5680 {
5681 {{ 0.0f, 3.0f, 0.f}, up, RED},
5682 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
5683 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
5684
5685 {{ 3.0f, 3.0f, 0.f}, up, GREEN},
5686 {{ 3.0f, 0.0f, 0.f}, up, RED},
5687 {{ 1.0f, 0.0f, 0.f}, up, BLUE},
5688 };
5689 const DWORD indices7[] = {0, 1, 2, 3, 3, 3}; /* Face 1 is collapsed*/
5690 const unsigned int num_vertices7 = ARRAY_SIZE(vertices7);
5691 const unsigned int num_faces7 = ARRAY_SIZE(indices7) / VERTS_PER_FACE;
5692 const DWORD adjacency7[] = {-1, -1, -1, -1, -1, -1};
5693 const DWORD exp_point_rep7[] = {0, 1, 2, 3, 4, 5};
5694 /* mesh8 (indices re-ordering and double replacement)
5695 *
5696 * 0--1 9 6
5697 * | / /| |\
5698 * |/ / | | \
5699 * 2 11-10 8--7
5700 * 3--4
5701 * | /
5702 * |/
5703 * 5
5704 */
5705 const struct vertex_pnc vertices8[] =
5706 {
5707 {{ 0.0f, 3.0f, 0.f}, up, RED},
5708 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
5709 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
5710
5711 {{ 4.0, -4.0, 0.f}, up, RED},
5712 {{ 6.0, -4.0, 0.f}, up, BLUE},
5713 {{ 4.0, -7.0, 0.f}, up, GREEN},
5714
5715 {{ 4.0f, 3.0f, 0.f}, up, GREEN},
5716 {{ 6.0f, 0.0f, 0.f}, up, BLUE},
5717 {{ 4.0f, 0.0f, 0.f}, up, RED},
5718
5719 {{ 3.0f, 3.0f, 0.f}, up, GREEN},
5720 {{ 3.0f, 0.0f, 0.f}, up, RED},
5721 {{ 1.0f, 0.0f, 0.f}, up, BLUE},
5722 };
5723 const DWORD indices8[] = {0, 1, 2, 9, 10, 11, 6, 7, 8, 3, 4, 5};
5724 const unsigned int num_vertices8 = ARRAY_SIZE(vertices8);
5725 const unsigned int num_faces8 = ARRAY_SIZE(indices8) / VERTS_PER_FACE;
5726 const DWORD adjacency8[] = {-1, 1, -1, 2, -1, 0, -1, 3, 1, 2, -1, -1};
5727 const DWORD exp_point_rep8[] = {0, 1, 2, 3, 4, 5, 1, 4, 3, 1, 3, 2};
5728 /* mesh9 (right, shared vertices)
5729 *
5730 * 0--1
5731 * | /|
5732 * |/ |
5733 * 2--3
5734 */
5735 const struct vertex_pnc vertices9[] =
5736 {
5737 {{ 0.0f, 3.0f, 0.f}, up, RED},
5738 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
5739 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
5740
5741 {{ 2.0f, 0.0f, 0.f}, up, RED},
5742 };
5743 const DWORD indices9[] = {0, 1, 2, 1, 3, 2};
5744 const unsigned int num_vertices9 = ARRAY_SIZE(vertices9);
5745 const unsigned int num_faces9 = ARRAY_SIZE(indices9) / VERTS_PER_FACE;
5746 const DWORD adjacency9[] = {-1, 1, -1, -1, -1, 0};
5747 const DWORD exp_point_rep9[] = {0, 1, 2, 3};
5748 /* All mesh data */
5749 ID3DXMesh *mesh = NULL;
5750 ID3DXMesh *mesh_null_check = NULL;
5751 unsigned int attributes[] = {0};
5752 struct
5753 {
5754 const struct vertex_pnc *vertices;
5755 const DWORD *indices;
5756 const DWORD num_vertices;
5757 const DWORD num_faces;
5758 const DWORD *adjacency;
5759 const DWORD *exp_point_reps;
5760 const DWORD options;
5761 }
5762 tc[] =
5763 {
5764 {
5765 vertices0,
5766 indices0,
5767 num_vertices0,
5768 num_faces0,
5769 adjacency0,
5770 exp_point_rep0,
5771 options
5772 },
5773 {
5774 vertices1,
5775 indices1,
5776 num_vertices1,
5777 num_faces1,
5778 adjacency1,
5779 exp_point_rep1,
5780 options
5781 },
5782 {
5783 vertices2,
5784 indices2,
5785 num_vertices2,
5786 num_faces2,
5787 adjacency2,
5788 exp_point_rep2,
5789 options
5790 },
5791 {
5792 vertices3,
5793 indices3,
5794 num_vertices3,
5795 num_faces3,
5796 adjacency3,
5797 exp_point_rep3,
5798 options
5799 },
5800 {
5801 vertices4,
5802 indices4,
5803 num_vertices4,
5804 num_faces4,
5805 adjacency4,
5806 exp_point_rep4,
5807 options
5808 },
5809 {
5810 vertices5,
5811 indices5,
5812 num_vertices5,
5813 num_faces5,
5814 adjacency5,
5815 exp_point_rep5,
5816 options
5817 },
5818 {
5819 vertices6,
5820 indices6,
5821 num_vertices6,
5822 num_faces6,
5823 adjacency6,
5824 exp_point_rep6,
5825 options
5826 },
5827 {
5828 vertices7,
5829 indices7,
5830 num_vertices7,
5831 num_faces7,
5832 adjacency7,
5833 exp_point_rep7,
5834 options
5835 },
5836 {
5837 vertices8,
5838 indices8,
5839 num_vertices8,
5840 num_faces8,
5841 adjacency8,
5842 exp_point_rep8,
5843 options
5844 },
5845 {
5846 vertices9,
5847 indices9,
5848 num_vertices9,
5849 num_faces9,
5850 adjacency9,
5851 exp_point_rep9,
5852 options
5853 },
5854 {
5855 vertices5,
5856 (DWORD*)indices5_16bit,
5857 num_vertices5,
5858 num_faces5,
5859 adjacency5,
5860 exp_point_rep5,
5861 options_16bit
5862 },
5863 };
5864 DWORD *point_reps = NULL;
5865
5867 if (!test_context)
5868 {
5869 skip("Couldn't create test context\n");
5870 goto cleanup;
5871 }
5872
5873 for (i = 0; i < ARRAY_SIZE(tc); i++)
5874 {
5875 hr = D3DXCreateMesh(tc[i].num_faces, tc[i].num_vertices, tc[i].options, declaration,
5877 if (FAILED(hr))
5878 {
5879 skip("Couldn't create mesh %d. Got %lx expected D3D_OK\n", i, hr);
5880 goto cleanup;
5881 }
5882
5883 if (i == 0) /* Save first mesh for later NULL checks */
5884 mesh_null_check = mesh;
5885
5886 point_reps = malloc(tc[i].num_vertices * sizeof(*point_reps));
5887 if (!point_reps)
5888 {
5889 skip("Couldn't allocate point reps array.\n");
5890 goto cleanup;
5891 }
5892
5893 hr = mesh->lpVtbl->LockVertexBuffer(mesh, 0, &vertex_buffer);
5894 if (FAILED(hr))
5895 {
5896 skip("Couldn't lock vertex buffer.\n");
5897 goto cleanup;
5898 }
5899 memcpy(vertex_buffer, tc[i].vertices, tc[i].num_vertices * sizeof(*tc[i].vertices));
5900 hr = mesh->lpVtbl->UnlockVertexBuffer(mesh);
5901 if (FAILED(hr))
5902 {
5903 skip("Couldn't unlock vertex buffer.\n");
5904 goto cleanup;
5905 }
5906
5907 hr = mesh->lpVtbl->LockIndexBuffer(mesh, 0, &index_buffer);
5908 if (FAILED(hr))
5909 {
5910 skip("Couldn't lock index buffer.\n");
5911 goto cleanup;
5912 }
5913 if (tc[i].options & D3DXMESH_32BIT)
5914 {
5915 memcpy(index_buffer, tc[i].indices, VERTS_PER_FACE * tc[i].num_faces * sizeof(DWORD));
5916 }
5917 else
5918 {
5919 memcpy(index_buffer, tc[i].indices, VERTS_PER_FACE * tc[i].num_faces * sizeof(WORD));
5920 }
5921 hr = mesh->lpVtbl->UnlockIndexBuffer(mesh);
5922 if (FAILED(hr)) {
5923 skip("Couldn't unlock index buffer.\n");
5924 goto cleanup;
5925 }
5926
5927 hr = mesh->lpVtbl->LockAttributeBuffer(mesh, 0, &attributes_buffer);
5928 if (FAILED(hr))
5929 {
5930 skip("Couldn't lock attributes buffer.\n");
5931 goto cleanup;
5932 }
5933 memcpy(attributes_buffer, attributes, sizeof(attributes));
5934 hr = mesh->lpVtbl->UnlockAttributeBuffer(mesh);
5935 if (FAILED(hr))
5936 {
5937 skip("Couldn't unlock attributes buffer.\n");
5938 goto cleanup;
5939 }
5940
5941 /* Convert adjacency to point representation */
5942 for (j = 0; j < tc[i].num_vertices; j++) point_reps[j] = -1;
5943 hr = mesh->lpVtbl->ConvertAdjacencyToPointReps(mesh, tc[i].adjacency, point_reps);
5944 ok(hr == D3D_OK, "ConvertAdjacencyToPointReps failed case %d. "
5945 "Got %lx expected D3D_OK\n", i, hr);
5946
5947 /* Check point representation */
5948 for (j = 0; j < tc[i].num_vertices; j++)
5949 {
5950 ok(point_reps[j] == tc[i].exp_point_reps[j],
5951 "Unexpected point representation at (%d, %d)."
5952 " Got %ld expected %ld\n",
5953 i, j, point_reps[j], tc[i].exp_point_reps[j]);
5954 }
5955
5956 free(point_reps);
5957 point_reps = NULL;
5958
5959 if (i != 0) /* First mesh will be freed during cleanup */
5960 mesh->lpVtbl->Release(mesh);
5961 }
5962
5963 /* NULL checks */
5964 hr = mesh_null_check->lpVtbl->ConvertAdjacencyToPointReps(mesh_null_check, tc[0].adjacency, NULL);
5965 ok(hr == D3DERR_INVALIDCALL, "ConvertAdjacencyToPointReps point_reps NULL. "
5966 "Got %lx expected D3DERR_INVALIDCALL\n", hr);
5967 hr = mesh_null_check->lpVtbl->ConvertAdjacencyToPointReps(mesh_null_check, NULL, NULL);
5968 ok(hr == D3DERR_INVALIDCALL, "ConvertAdjacencyToPointReps adjacency and point_reps NULL. "
5969 "Got %lx expected D3DERR_INVALIDCALL\n", hr);
5970
5971cleanup:
5972 if (mesh_null_check)
5973 mesh_null_check->lpVtbl->Release(mesh_null_check);
5974 free(point_reps);
5976}
@ GREEN
Definition: ansiprsr.h:4
GLuint color
Definition: glext.h:6243
#define RED
Definition: graph.h:18
#define BLUE
Definition: seh0053.c:10

Referenced by START_TEST().

◆ test_convert_point_reps_to_adjacency()

static void test_convert_point_reps_to_adjacency ( void  )
static

Definition at line 5978 of file mesh.c.

5979{
5980 HRESULT hr;
5981 struct test_context *test_context = NULL;
5983 const DWORD options_16bit = D3DXMESH_SYSTEMMEM;
5985 {
5989 D3DDECL_END()
5990 };
5991 const unsigned int VERTS_PER_FACE = 3;
5992 void *vertex_buffer;
5993 void *index_buffer;
5994 DWORD *attributes_buffer;
5995 int i, j;
5996 enum color { RED = 0xffff0000, GREEN = 0xff00ff00, BLUE = 0xff0000ff};
5997 struct vertex_pnc
5998 {
5999 D3DXVECTOR3 position;
6001 enum color color; /* In case of manual visual inspection */
6002 };
6003 D3DXVECTOR3 up = {0.0f, 0.0f, 1.0f};
6004 /* mesh0 (one face)
6005 *
6006 * 0--1
6007 * | /
6008 * |/
6009 * 2
6010 */
6011 const struct vertex_pnc vertices0[] =
6012 {
6013 {{ 0.0f, 3.0f, 0.f}, up, RED},
6014 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
6015 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
6016 };
6017 const DWORD indices0[] = {0, 1, 2};
6018 const unsigned int num_vertices0 = ARRAY_SIZE(vertices0);
6019 const unsigned int num_faces0 = num_vertices0 / VERTS_PER_FACE;
6020 const DWORD exp_adjacency0[] = {-1, -1, -1};
6021 const DWORD exp_id_adjacency0[] = {-1, -1, -1};
6022 const DWORD point_rep0[] = {0, 1, 2};
6023 /* mesh1 (right)
6024 *
6025 * 0--1 3
6026 * | / /|
6027 * |/ / |
6028 * 2 5--4
6029 */
6030 const struct vertex_pnc vertices1[] =
6031 {
6032 {{ 0.0f, 3.0f, 0.f}, up, RED},
6033 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
6034 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
6035
6036 {{ 3.0f, 3.0f, 0.f}, up, GREEN},
6037 {{ 3.0f, 0.0f, 0.f}, up, RED},
6038 {{ 1.0f, 0.0f, 0.f}, up, BLUE},
6039 };
6040 const DWORD indices1[] = {0, 1, 2, 3, 4, 5};
6041 const unsigned int num_vertices1 = ARRAY_SIZE(vertices1);
6042 const unsigned int num_faces1 = num_vertices1 / VERTS_PER_FACE;
6043 const DWORD exp_adjacency1[] = {-1, 1, -1, -1, -1, 0};
6044 const DWORD exp_id_adjacency1[] = {-1, -1, -1, -1, -1, -1};
6045 const DWORD point_rep1[] = {0, 1, 2, 1, 4, 2};
6046 /* mesh2 (left)
6047 *
6048 * 3 0--1
6049 * /| | /
6050 * / | |/
6051 * 5--4 2
6052 */
6053 const struct vertex_pnc vertices2[] =
6054 {
6055 {{ 0.0f, 3.0f, 0.f}, up, RED},
6056 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
6057 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
6058
6059 {{-1.0f, 3.0f, 0.f}, up, RED},
6060 {{-1.0f, 0.0f, 0.f}, up, GREEN},
6061 {{-3.0f, 0.0f, 0.f}, up, BLUE},
6062 };
6063 const DWORD indices2[] = {0, 1, 2, 3, 4, 5};
6064 const unsigned int num_vertices2 = ARRAY_SIZE(vertices2);
6065 const unsigned int num_faces2 = num_vertices2 / VERTS_PER_FACE;
6066 const DWORD exp_adjacency2[] = {-1, -1, 1, 0, -1, -1};
6067 const DWORD exp_id_adjacency2[] = {-1, -1, -1, -1, -1, -1};
6068 const DWORD point_rep2[] = {0, 1, 2, 0, 2, 5};
6069 /* mesh3 (above)
6070 *
6071 * 3
6072 * /|
6073 * / |
6074 * 5--4
6075 * 0--1
6076 * | /
6077 * |/
6078 * 2
6079 */
6080 struct vertex_pnc vertices3[] =
6081 {
6082 {{ 0.0f, 3.0f, 0.f}, up, RED},
6083 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
6084 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
6085
6086 {{ 2.0f, 7.0f, 0.f}, up, BLUE},
6087 {{ 2.0f, 4.0f, 0.f}, up, GREEN},
6088 {{ 0.0f, 4.0f, 0.f}, up, RED},
6089 };
6090 const DWORD indices3[] = {0, 1, 2, 3, 4, 5};
6091 const unsigned int num_vertices3 = ARRAY_SIZE(vertices3);
6092 const unsigned int num_faces3 = num_vertices3 / VERTS_PER_FACE;
6093 const DWORD exp_adjacency3[] = {1, -1, -1, -1, 0, -1};
6094 const DWORD exp_id_adjacency3[] = {-1, -1, -1, -1, -1, -1};
6095 const DWORD point_rep3[] = {0, 1, 2, 3, 1, 0};
6096 /* mesh4 (below, tip against tip)
6097 *
6098 * 0--1
6099 * | /
6100 * |/
6101 * 2
6102 * 3
6103 * |\
6104 * | \
6105 * 5--4
6106 */
6107 struct vertex_pnc vertices4[] =
6108 {
6109 {{ 0.0f, 3.0f, 0.f}, up, RED},
6110 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
6111 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
6112
6113 {{ 0.0f, -4.0f, 0.f}, up, BLUE},
6114 {{ 2.0f, -7.0f, 0.f}, up, GREEN},
6115 {{ 0.0f, -7.0f, 0.f}, up, RED},
6116 };
6117 const DWORD indices4[] = {0, 1, 2, 3, 4, 5};
6118 const unsigned int num_vertices4 = ARRAY_SIZE(vertices4);
6119 const unsigned int num_faces4 = num_vertices4 / VERTS_PER_FACE;
6120 const DWORD exp_adjacency4[] = {-1, -1, -1, -1, -1, -1};
6121 const DWORD exp_id_adjacency4[] = {-1, -1, -1, -1, -1, -1};
6122 const DWORD point_rep4[] = {0, 1, 2, 3, 4, 5};
6123 /* mesh5 (gap in mesh)
6124 *
6125 * 0 3-----4 15
6126 * / \ \ / / \
6127 * / \ \ / / \
6128 * 2-----1 5 17-----16
6129 * 6-----7 9 12-----13
6130 * \ / / \ \ /
6131 * \ / / \ \ /
6132 * 8 10-----11 14
6133 *
6134 */
6135 const struct vertex_pnc vertices5[] =
6136 {
6137 {{ 0.0f, 1.0f, 0.f}, up, RED},
6138 {{ 1.0f, -1.0f, 0.f}, up, GREEN},
6139 {{-1.0f, -1.0f, 0.f}, up, BLUE},
6140
6141 {{ 0.1f, 1.0f, 0.f}, up, RED},
6142 {{ 2.1f, 1.0f, 0.f}, up, BLUE},
6143 {{ 1.1f, -1.0f, 0.f}, up, GREEN},
6144
6145 {{-1.0f, -1.1f, 0.f}, up, BLUE},
6146 {{ 1.0f, -1.1f, 0.f}, up, GREEN},
6147 {{ 0.0f, -3.1f, 0.f}, up, RED},
6148
6149 {{ 1.1f, -1.1f, 0.f}, up, GREEN},
6150 {{ 2.1f, -3.1f, 0.f}, up, BLUE},
6151 {{ 0.1f, -3.1f, 0.f}, up, RED},
6152
6153 {{ 1.2f, -1.1f, 0.f}, up, GREEN},
6154 {{ 3.2f, -1.1f, 0.f}, up, RED},
6155 {{ 2.2f, -3.1f, 0.f}, up, BLUE},
6156
6157 {{ 2.2f, 1.0f, 0.f}, up, BLUE},
6158 {{ 3.2f, -1.0f, 0.f}, up, RED},
6159 {{ 1.2f, -1.0f, 0.f}, up, GREEN},
6160 };
6161 const DWORD indices5[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
6162 const unsigned int num_vertices5 = ARRAY_SIZE(vertices5);
6163 const unsigned int num_faces5 = num_vertices5 / VERTS_PER_FACE;
6164 const DWORD exp_adjacency5[] = {-1, 2, -1, -1, 5, -1, 0, -1, -1, 4, -1, -1, 5, -1, 3, -1, 4, 1};
6165 const DWORD exp_id_adjacency5[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
6166 const DWORD point_rep5[] = {0, 1, 2, 3, 4, 5, 2, 1, 8, 5, 10, 11, 5, 13, 10, 4, 13, 5};
6167 /* mesh6 (indices re-ordering)
6168 *
6169 * 0--1 6 3
6170 * | / /| |\
6171 * |/ / | | \
6172 * 2 8--7 5--4
6173 */
6174 const struct vertex_pnc vertices6[] =
6175 {
6176 {{ 0.0f, 3.0f, 0.f}, up, RED},
6177 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
6178 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
6179
6180 {{ 3.0f, 3.0f, 0.f}, up, GREEN},
6181 {{ 3.0f, 0.0f, 0.f}, up, RED},
6182 {{ 1.0f, 0.0f, 0.f}, up, BLUE},
6183
6184 {{ 4.0f, 3.0f, 0.f}, up, GREEN},
6185 {{ 6.0f, 0.0f, 0.f}, up, BLUE},
6186 {{ 4.0f, 0.0f, 0.f}, up, RED},
6187 };
6188 const DWORD indices6[] = {0, 1, 2, 6, 7, 8, 3, 4, 5};
6189 const unsigned int num_vertices6 = ARRAY_SIZE(vertices6);
6190 const unsigned int num_faces6 = num_vertices6 / VERTS_PER_FACE;
6191 const DWORD exp_adjacency6[] = {-1, 1, -1, 2, -1, 0, -1, -1, 1};
6192 const DWORD exp_id_adjacency6[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1};
6193 const DWORD point_rep6[] = {0, 1, 2, 1, 4, 5, 1, 5, 2};
6194 /* mesh7 (expands collapsed triangle)
6195 *
6196 * 0--1 3
6197 * | / /|
6198 * |/ / |
6199 * 2 5--4
6200 */
6201 const struct vertex_pnc vertices7[] =
6202 {
6203 {{ 0.0f, 3.0f, 0.f}, up, RED},
6204 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
6205 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
6206
6207 {{ 3.0f, 3.0f, 0.f}, up, GREEN},
6208 {{ 3.0f, 0.0f, 0.f}, up, RED},
6209 {{ 1.0f, 0.0f, 0.f}, up, BLUE},
6210 };
6211 const DWORD indices7[] = {0, 1, 2, 3, 3, 3}; /* Face 1 is collapsed*/
6212 const unsigned int num_vertices7 = ARRAY_SIZE(vertices7);
6213 const unsigned int num_faces7 = num_vertices7 / VERTS_PER_FACE;
6214 const DWORD exp_adjacency7[] = {-1, -1, -1, -1, -1, -1};
6215 const DWORD exp_id_adjacency7[] = {-1, -1, -1, -1, -1, -1};
6216 const DWORD point_rep7[] = {0, 1, 2, 3, 4, 5};
6217 /* mesh8 (indices re-ordering and double replacement)
6218 *
6219 * 0--1 9 6
6220 * | / /| |\
6221 * |/ / | | \
6222 * 2 11-10 8--7
6223 * 3--4
6224 * | /
6225 * |/
6226 * 5
6227 */
6228 const struct vertex_pnc vertices8[] =
6229 {
6230 {{ 0.0f, 3.0f, 0.f}, up, RED},
6231 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
6232 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
6233
6234 {{ 4.0, -4.0, 0.f}, up, RED},
6235 {{ 6.0, -4.0, 0.f}, up, BLUE},
6236 {{ 4.0, -7.0, 0.f}, up, GREEN},
6237
6238 {{ 4.0f, 3.0f, 0.f}, up, GREEN},
6239 {{ 6.0f, 0.0f, 0.f}, up, BLUE},
6240 {{ 4.0f, 0.0f, 0.f}, up, RED},
6241
6242 {{ 3.0f, 3.0f, 0.f}, up, GREEN},
6243 {{ 3.0f, 0.0f, 0.f}, up, RED},
6244 {{ 1.0f, 0.0f, 0.f}, up, BLUE},
6245 };
6246 const DWORD indices8[] = {0, 1, 2, 9, 10, 11, 6, 7, 8, 3, 4, 5};
6247 const WORD indices8_16bit[] = {0, 1, 2, 9, 10, 11, 6, 7, 8, 3, 4, 5};
6248 const unsigned int num_vertices8 = ARRAY_SIZE(vertices8);
6249 const unsigned int num_faces8 = num_vertices8 / VERTS_PER_FACE;
6250 const DWORD exp_adjacency8[] = {-1, 1, -1, 2, -1, 0, -1, 3, 1, 2, -1, -1};
6251 const DWORD exp_id_adjacency8[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
6252 const DWORD point_rep8[] = {0, 1, 2, 3, 4, 5, 1, 4, 3, 1, 3, 2};
6253 /* mesh9 (right, shared vertices)
6254 *
6255 * 0--1
6256 * | /|
6257 * |/ |
6258 * 2--3
6259 */
6260 const struct vertex_pnc vertices9[] =
6261 {
6262 {{ 0.0f, 3.0f, 0.f}, up, RED},
6263 {{ 2.0f, 3.0f, 0.f}, up, GREEN},
6264 {{ 0.0f, 0.0f, 0.f}, up, BLUE},
6265
6266 {{ 2.0f, 0.0f, 0.f}, up, RED},
6267 };
6268 const DWORD indices9[] = {0, 1, 2, 1, 3, 2};
6269 const unsigned int num_vertices9 = ARRAY_SIZE(vertices9);
6270 const unsigned int num_faces9 = 2;
6271 const DWORD exp_adjacency9[] = {-1, 1, -1, -1, -1, 0};
6272 const DWORD exp_id_adjacency9[] = {-1, 1, -1, -1, -1, 0};
6273 const DWORD point_rep9[] = {0, 1, 2, 3};
6274 /* All mesh data */
6275 ID3DXMesh *mesh = NULL;
6276 ID3DXMesh *mesh_null_check = NULL;
6277 unsigned int attributes[] = {0};
6278 struct
6279 {
6280 const struct vertex_pnc *vertices;
6281 const DWORD *indices;
6282 const DWORD num_vertices;
6283 const DWORD num_faces;
6284 const DWORD *point_reps;
6285 const DWORD *exp_adjacency;
6286 const DWORD *exp_id_adjacency;
6287 const DWORD options;
6288 }
6289 tc[] =
6290 {
6291 {
6292 vertices0,
6293 indices0,
6294 num_vertices0,
6295 num_faces0,
6296 point_rep0,
6297 exp_adjacency0,
6298 exp_id_adjacency0,
6299 options
6300 },
6301 {
6302 vertices1,
6303 indices1,
6304 num_vertices1,
6305 num_faces1,
6306 point_rep1,
6307 exp_adjacency1,
6308 exp_id_adjacency1,
6309 options
6310 },
6311 {
6312 vertices2,
6313 indices2,
6314 num_vertices2,
6315 num_faces2,
6316 point_rep2,
6317 exp_adjacency2,
6318 exp_id_adjacency2,
6319 options
6320 },
6321 {
6322 vertices3,
6323 indices3,
6324 num_vertices3,
6325 num_faces3,
6326 point_rep3,
6327 exp_adjacency3,
6328 exp_id_adjacency3,
6329 options
6330 },
6331 {
6332 vertices4,
6333 indices4,
6334 num_vertices4,
6335 num_faces4,
6336 point_rep4,
6337 exp_adjacency4,
6338 exp_id_adjacency4,
6339 options
6340 },
6341 {
6342 vertices5,
6343 indices5,
6344 num_vertices5,
6345 num_faces5,
6346 point_rep5,
6347 exp_adjacency5,
6348 exp_id_adjacency5,
6349 options
6350 },
6351 {
6352 vertices6,
6353 indices6,
6354 num_vertices6,
6355 num_faces6,
6356 point_rep6,
6357 exp_adjacency6,
6358 exp_id_adjacency6,
6359 options
6360 },
6361 {
6362 vertices7,
6363 indices7,
6364 num_vertices7,
6365 num_faces7,
6366 point_rep7,
6367 exp_adjacency7,
6368 exp_id_adjacency7,
6369 options
6370 },
6371 {
6372 vertices8,
6373 indices8,
6374 num_vertices8,
6375 num_faces8,
6376 point_rep8,
6377 exp_adjacency8,
6378 exp_id_adjacency8,
6379 options
6380 },
6381 {
6382 vertices9,
6383 indices9,
6384 num_vertices9,
6385 num_faces9,
6386 point_rep9,
6387 exp_adjacency9,
6388 exp_id_adjacency9,
6389 options
6390 },
6391 {
6392 vertices8,
6393 (DWORD*)indices8_16bit,
6394 num_vertices8,
6395 num_faces8,
6396 point_rep8,
6397 exp_adjacency8,
6398 exp_id_adjacency8,
6399 options_16bit
6400 },
6401 };
6402 DWORD *adjacency = NULL;
6403
6405 if (!test_context)
6406 {
6407 skip("Couldn't create test context\n");
6408 goto cleanup;
6409 }
6410
6411 for (i = 0; i < ARRAY_SIZE(tc); i++)
6412 {
6413 hr = D3DXCreateMesh(tc[i].num_faces, tc[i].num_vertices, tc[i].options,
6415 if (FAILED(hr))
6416 {
6417 skip("Couldn't create mesh %d. Got %lx expected D3D_OK\n", i, hr);
6418 goto cleanup;
6419 }
6420
6421 if (i == 0) /* Save first mesh for later NULL checks */
6422 mesh_null_check = mesh;
6423
6424 adjacency = malloc(VERTS_PER_FACE * tc[i].num_faces * sizeof(*adjacency));
6425 if (!adjacency)
6426 {
6427 skip("Couldn't allocate adjacency array.\n");
6428 goto cleanup;
6429 }
6430
6431 hr = mesh->lpVtbl->LockVertexBuffer(mesh, 0, &vertex_buffer);
6432 if (FAILED(hr))
6433 {
6434 skip("Couldn't lock vertex buffer.\n");
6435 goto cleanup;
6436 }
6437 memcpy(vertex_buffer, tc[i].vertices, tc[i].num_vertices * sizeof(*tc[i].vertices));
6438 hr = mesh->lpVtbl->UnlockVertexBuffer(mesh);
6439 if (FAILED(hr))
6440 {
6441 skip("Couldn't unlock vertex buffer.\n");
6442 goto cleanup;
6443 }
6444 hr = mesh->lpVtbl->LockIndexBuffer(mesh, 0, &index_buffer);
6445 if (FAILED(hr))
6446 {
6447 skip("Couldn't lock index buffer.\n");
6448 goto cleanup;
6449 }
6450 if (tc[i].options & D3DXMESH_32BIT)
6451 {
6452 memcpy(index_buffer, tc[i].indices, VERTS_PER_FACE * tc[i].num_faces * sizeof(DWORD));
6453 }
6454 else
6455 {
6456 memcpy(index_buffer, tc[i].indices, VERTS_PER_FACE * tc[i].num_faces * sizeof(WORD));
6457 }
6458 hr = mesh->lpVtbl->UnlockIndexBuffer(mesh);
6459 if (FAILED(hr)) {
6460 skip("Couldn't unlock index buffer.\n");
6461 goto cleanup;
6462 }
6463
6464 hr = mesh->lpVtbl->LockAttributeBuffer(mesh, 0, &attributes_buffer);
6465 if (FAILED(hr))
6466 {
6467 skip("Couldn't lock attributes buffer.\n");
6468 goto cleanup;
6469 }
6470 memcpy(attributes_buffer, attributes, sizeof(attributes));
6471 hr = mesh->lpVtbl->UnlockAttributeBuffer(mesh);
6472 if (FAILED(hr))
6473 {
6474 skip("Couldn't unlock attributes buffer.\n");
6475 goto cleanup;
6476 }
6477
6478 /* Convert point representation to adjacency*/
6479 for (j = 0; j < VERTS_PER_FACE * tc[i].num_faces; j++) adjacency[j] = -2;
6480
6481 hr = mesh->lpVtbl->ConvertPointRepsToAdjacency(mesh, tc[i].point_reps, adjacency);
6482 ok(hr == D3D_OK, "ConvertPointRepsToAdjacency failed case %d. "
6483 "Got %lx expected D3D_OK\n", i, hr);
6484 /* Check adjacency */
6485 for (j = 0; j < VERTS_PER_FACE * tc[i].num_faces; j++)
6486 {
6487 ok(adjacency[j] == tc[i].exp_adjacency[j],
6488 "Unexpected adjacency information at (%d, %d)."
6489 " Got %ld expected %ld\n",
6490 i, j, adjacency[j], tc[i].exp_adjacency[j]);
6491 }
6492
6493 /* NULL point representation is considered identity. */
6494 for (j = 0; j < VERTS_PER_FACE * tc[i].num_faces; j++) adjacency[j] = -2;
6495 hr = mesh_null_check->lpVtbl->ConvertPointRepsToAdjacency(mesh, NULL, adjacency);
6496 ok(hr == D3D_OK, "ConvertPointRepsToAdjacency NULL point_reps. "
6497 "Got %lx expected D3D_OK\n", hr);
6498 for (j = 0; j < VERTS_PER_FACE * tc[i].num_faces; j++)
6499 {
6500 ok(adjacency[j] == tc[i].exp_id_adjacency[j],
6501 "Unexpected adjacency information (id) at (%d, %d)."
6502 " Got %ld expected %ld\n",
6503 i, j, adjacency[j], tc[i].exp_id_adjacency[j]);
6504 }
6505
6506 free(adjacency);
6507 adjacency = NULL;
6508 if (i != 0) /* First mesh will be freed during cleanup */
6509 mesh->lpVtbl->Release(mesh);
6510 }
6511
6512 /* NULL checks */
6513 hr = mesh_null_check->lpVtbl->ConvertPointRepsToAdjacency(mesh_null_check, tc[0].point_reps, NULL);
6514 ok(hr == D3DERR_INVALIDCALL, "ConvertPointRepsToAdjacency NULL adjacency. "
6515 "Got %lx expected D3DERR_INVALIDCALL\n", hr);
6516 hr = mesh_null_check->lpVtbl->ConvertPointRepsToAdjacency(mesh_null_check, NULL, NULL);
6517 ok(hr == D3DERR_INVALIDCALL, "ConvertPointRepsToAdjacency NULL point_reps and adjacency. "
6518 "Got %lx expected D3DERR_INVALIDCALL\n", hr);
6519
6520cleanup:
6521 if (mesh_null_check)
6522 mesh_null_check->lpVtbl->Release(mesh_null_check);
6523 free(adjacency);
6525}

Referenced by START_TEST().

◆ test_create_skin_info()

static void test_create_skin_info ( void  )
static

Definition at line 5185 of file mesh.c.

5186{
5187 D3DVERTEXELEMENT9 empty_declaration[] = { D3DDECL_END() };
5188 D3DVERTEXELEMENT9 declaration_out[MAX_FVF_DECL_SIZE];
5189 const D3DVERTEXELEMENT9 declaration_with_nonzero_stream[] = {
5191 D3DDECL_END()
5192 };
5194 DWORD exp_vertices[2], vertices[2];
5195 float exp_weights[2], weights[2];
5196 const char *exp_string, *string;
5197 ID3DXSkinInfo *skininfo = NULL;
5198 DWORD exp_fvf, fvf;
5199 unsigned int i;
5200 HRESULT hr;
5201
5202 hr = D3DXCreateSkinInfo(0, empty_declaration, 0, &skininfo);
5203 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5204 if (skininfo) IUnknown_Release(skininfo);
5205 skininfo = NULL;
5206
5207 hr = D3DXCreateSkinInfo(1, NULL, 1, &skininfo);
5208 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5209
5210 hr = D3DXCreateSkinInfo(1, declaration_with_nonzero_stream, 1, &skininfo);
5211 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5212
5213 hr = D3DXCreateSkinInfoFVF(1, 0, 1, &skininfo);
5214 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5215 if (skininfo)
5216 {
5217 ID3DXSkinInfo *clone = NULL;
5218 DWORD dword_result;
5219 float flt_result;
5220 const char *string_result;
5222 D3DXMATRIX identity_matrix;
5223
5224 /* test initial values */
5225 hr = skininfo->lpVtbl->GetDeclaration(skininfo, declaration_out);
5226 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5227 if (SUCCEEDED(hr))
5228 compare_elements(declaration_out, empty_declaration, __LINE__, 0);
5229
5230 dword_result = skininfo->lpVtbl->GetNumBones(skininfo);
5231 ok(dword_result == 1, "Expected 1, got %lu\n", dword_result);
5232
5233 flt_result = skininfo->lpVtbl->GetMinBoneInfluence(skininfo);
5234 ok(flt_result == 0.0f, "Expected 0.0, got %g\n", flt_result);
5235
5236 string_result = skininfo->lpVtbl->GetBoneName(skininfo, 0);
5237 ok(string_result == NULL, "Expected NULL, got %p\n", string_result);
5238
5239 dword_result = skininfo->lpVtbl->GetFVF(skininfo);
5240 ok(dword_result == 0, "Expected 0, got %lu\n", dword_result);
5241
5242 dword_result = skininfo->lpVtbl->GetNumBoneInfluences(skininfo, 0);
5243 ok(dword_result == 0, "Expected 0, got %lu\n", dword_result);
5244
5245 dword_result = skininfo->lpVtbl->GetNumBoneInfluences(skininfo, 1);
5246 ok(dword_result == 0, "Expected 0, got %lu\n", dword_result);
5247
5248 transform = skininfo->lpVtbl->GetBoneOffsetMatrix(skininfo, -1);
5249 ok(transform == NULL, "Expected NULL, got %p\n", transform);
5250
5251 hr = skininfo->lpVtbl->Clone(skininfo, &clone);
5252 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5253 IUnknown_Release(clone);
5254
5255 {
5256 /* test [GS]etBoneOffsetMatrix */
5257 hr = skininfo->lpVtbl->SetBoneOffsetMatrix(skininfo, 1, &identity_matrix);
5258 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5259
5260 hr = skininfo->lpVtbl->SetBoneOffsetMatrix(skininfo, 0, NULL);
5261 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5262
5263 D3DXMatrixIdentity(&identity_matrix);
5264 hr = skininfo->lpVtbl->SetBoneOffsetMatrix(skininfo, 0, &identity_matrix);
5265 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5266
5267 transform = skininfo->lpVtbl->GetBoneOffsetMatrix(skininfo, 0);
5268 check_matrix(transform, &identity_matrix);
5269 }
5270
5271 {
5272 /* test [GS]etBoneName */
5273 const char *name_in = "testBoneName";
5274 const char *string_result2;
5275
5276 hr = skininfo->lpVtbl->SetBoneName(skininfo, 1, name_in);
5277 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5278
5279 hr = skininfo->lpVtbl->SetBoneName(skininfo, 0, NULL);
5280 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5281
5282 hr = skininfo->lpVtbl->SetBoneName(skininfo, 0, name_in);
5283 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5284
5285 string_result = skininfo->lpVtbl->GetBoneName(skininfo, 0);
5286 ok(string_result != NULL, "Expected non-NULL string, got %p\n", string_result);
5287 ok(!strcmp(string_result, name_in), "Expected '%s', got '%s'\n", name_in, string_result);
5288
5289 string_result2 = skininfo->lpVtbl->GetBoneName(skininfo, 0);
5290 ok(string_result == string_result2, "Expected %p, got %p\n", string_result, string_result2);
5291
5292 string_result = skininfo->lpVtbl->GetBoneName(skininfo, 1);
5293 ok(string_result == NULL, "Expected NULL, got %p\n", string_result);
5294 }
5295
5296 {
5297 /* test [GS]etBoneInfluence */
5298 DWORD num_influences;
5299
5300 /* vertex and weight arrays untouched when num_influences is 0 */
5301 vertices[0] = 0xdeadbeef;
5302 weights[0] = FLT_MAX;
5303 hr = skininfo->lpVtbl->GetBoneInfluence(skininfo, 0, vertices, weights);
5304 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5305 ok(vertices[0] == 0xdeadbeef, "expected 0xdeadbeef, got %#lx\n", vertices[0]);
5306 ok(weights[0] == FLT_MAX, "expected %g, got %g\n", FLT_MAX, weights[0]);
5307
5308 hr = skininfo->lpVtbl->GetBoneInfluence(skininfo, 1, vertices, weights);
5309 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5310
5311 hr = skininfo->lpVtbl->GetBoneInfluence(skininfo, 0, NULL, NULL);
5312 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5313
5314 hr = skininfo->lpVtbl->GetBoneInfluence(skininfo, 0, vertices, NULL);
5315 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5316
5317 hr = skininfo->lpVtbl->GetBoneInfluence(skininfo, 0, NULL, weights);
5318 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5319
5320
5321 /* no vertex or weight value checking */
5322 exp_vertices[0] = 0;
5323 exp_vertices[1] = 0x87654321;
5324 exp_weights[0] = 0.5;
5325 exp_weights[1] = NAN;
5326 num_influences = 2;
5327
5328 hr = skininfo->lpVtbl->SetBoneInfluence(skininfo, 1, num_influences, vertices, weights);
5329 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5330
5331 hr = skininfo->lpVtbl->SetBoneInfluence(skininfo, 0, num_influences, NULL, weights);
5332 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5333
5334 hr = skininfo->lpVtbl->SetBoneInfluence(skininfo, 0, num_influences, vertices, NULL);
5335 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5336
5337 hr = skininfo->lpVtbl->SetBoneInfluence(skininfo, 0, num_influences, NULL, NULL);
5338 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5339
5340 hr = skininfo->lpVtbl->SetBoneInfluence(skininfo, 0, num_influences, exp_vertices, exp_weights);
5341 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5342
5343 memset(vertices, 0, sizeof(vertices));
5344 memset(weights, 0, sizeof(weights));
5345 hr = skininfo->lpVtbl->GetBoneInfluence(skininfo, 0, vertices, weights);
5346 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5347 for (i = 0; i < num_influences; i++) {
5348 ok(exp_vertices[i] == vertices[i],
5349 "influence[%d]: expected vertex %lu, got %lu\n", i, exp_vertices[i], vertices[i]);
5350 ok((isnan(exp_weights[i]) && isnan(weights[i])) || exp_weights[i] == weights[i],
5351 "influence[%d]: expected weights %g, got %g\n", i, exp_weights[i], weights[i]);
5352 }
5353
5354 /* vertices and weights aren't returned after setting num_influences to 0 */
5355 memset(vertices, 0, sizeof(vertices));
5356 memset(weights, 0, sizeof(weights));
5357 hr = skininfo->lpVtbl->SetBoneInfluence(skininfo, 0, 0, vertices, weights);
5358 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5359
5360 vertices[0] = 0xdeadbeef;
5361 weights[0] = FLT_MAX;
5362 hr = skininfo->lpVtbl->GetBoneInfluence(skininfo, 0, vertices, weights);
5363 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5364 ok(vertices[0] == 0xdeadbeef, "expected vertex 0xdeadbeef, got %lu\n", vertices[0]);
5365 ok(weights[0] == FLT_MAX, "expected weight %g, got %g\n", FLT_MAX, weights[0]);
5366
5367 hr = skininfo->lpVtbl->SetBoneInfluence(skininfo, 0, num_influences, exp_vertices, exp_weights);
5368 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5369 }
5370
5371 {
5372 /* test [GS]etFVF and [GS]etDeclaration */
5373 D3DVERTEXELEMENT9 declaration_in[MAX_FVF_DECL_SIZE];
5374 DWORD got_fvf;
5375
5376 fvf = D3DFVF_XYZ;
5377 hr = skininfo->lpVtbl->SetDeclaration(skininfo, NULL);
5378 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5379
5380 hr = skininfo->lpVtbl->SetDeclaration(skininfo, declaration_with_nonzero_stream);
5381 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5382
5383 hr = skininfo->lpVtbl->SetFVF(skininfo, 0);
5384 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5385
5386 hr = D3DXDeclaratorFromFVF(fvf, declaration_in);
5387 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5388 hr = skininfo->lpVtbl->SetDeclaration(skininfo, declaration_in);
5389 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5390 got_fvf = skininfo->lpVtbl->GetFVF(skininfo);
5391 ok(fvf == got_fvf, "Expected %#lx, got %#lx\n", fvf, got_fvf);
5392 hr = skininfo->lpVtbl->GetDeclaration(skininfo, declaration_out);
5393 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5394 compare_elements(declaration_out, declaration_in, __LINE__, 0);
5395
5396 hr = skininfo->lpVtbl->SetDeclaration(skininfo, empty_declaration);
5397 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5398 got_fvf = skininfo->lpVtbl->GetFVF(skininfo);
5399 ok(got_fvf == 0, "Expected 0, got %#lx\n", got_fvf);
5400 hr = skininfo->lpVtbl->GetDeclaration(skininfo, declaration_out);
5401 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5402 compare_elements(declaration_out, empty_declaration, __LINE__, 0);
5403
5404 hr = skininfo->lpVtbl->SetFVF(skininfo, fvf);
5405 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5406 got_fvf = skininfo->lpVtbl->GetFVF(skininfo);
5407 ok(fvf == got_fvf, "Expected %#lx, got %#lx\n", fvf, got_fvf);
5408 hr = skininfo->lpVtbl->GetDeclaration(skininfo, declaration_out);
5409 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
5410 compare_elements(declaration_out, declaration_in, __LINE__, 0);
5411 }
5412
5413 /* Test Clone() */
5414 hr = skininfo->lpVtbl->Clone(skininfo, NULL);
5415 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
5416
5417 clone = NULL;
5418 hr = skininfo->lpVtbl->Clone(skininfo, &clone);
5419 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
5420
5421 hr = clone->lpVtbl->GetDeclaration(clone, declaration);
5422 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
5423 compare_elements(declaration, declaration_out, __LINE__, 0);
5424
5425 hr = D3DXFVFFromDeclarator(declaration_out, &exp_fvf);
5426 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
5427 fvf = clone->lpVtbl->GetFVF(clone);
5428 ok(fvf == exp_fvf, "Got unexpected fvf %#lx.\n", fvf);
5429
5430 exp_string = skininfo->lpVtbl->GetBoneName(skininfo, 0);
5431 string = clone->lpVtbl->GetBoneName(clone, 0);
5432 ok(!strcmp(string, exp_string), "Got unexpected bone 0 name %s.\n", debugstr_a(string));
5433
5434 transform = clone->lpVtbl->GetBoneOffsetMatrix(clone, 0);
5435 check_matrix(transform, &identity_matrix);
5436
5437 hr = skininfo->lpVtbl->GetBoneInfluence(skininfo, 0, exp_vertices, exp_weights);
5438 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
5439 hr = clone->lpVtbl->GetBoneInfluence(clone, 0, vertices, weights);
5440 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
5441
5442 for (i = 0; i < ARRAY_SIZE(vertices); ++i)
5443 {
5444 ok(vertices[i] == exp_vertices[i], "influence[%u]: got unexpected vertex %lu, expected %lu.\n",
5445 i, vertices[i], exp_vertices[i]);
5446 ok(((DWORD *)weights)[i] == ((DWORD *)exp_weights)[i],
5447 "influence[%u]: got unexpected weight %.8e, expected %.8e.\n", i, weights[i], exp_weights[i]);
5448 }
5449
5450 IUnknown_Release(clone);
5451 }
5452 if (skininfo) IUnknown_Release(skininfo);
5453 skininfo = NULL;
5454
5456 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5457
5458 hr = D3DXCreateSkinInfo(1, NULL, 1, &skininfo);
5459 ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#lx\n", hr);
5460}
HRESULT WINAPI D3DXDeclaratorFromFVF(DWORD fvf, D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE])
Definition: mesh.c:2034
HRESULT WINAPI D3DXFVFFromDeclarator(const D3DVERTEXELEMENT9 *declaration, DWORD *fvf)
Definition: mesh.c:2132
const GLbyte * weights
Definition: glext.h:6523
char string[160]
Definition: util.h:11
static void compare_elements(const D3DVERTEXELEMENT9 *elements, const D3DVERTEXELEMENT9 *expected_elements, unsigned int line, unsigned int test_id)
Definition: mesh.c:601
HRESULT WINAPI D3DXCreateSkinInfo(DWORD vertex_count, const D3DVERTEXELEMENT9 *declaration, DWORD bone_count, ID3DXSkinInfo **skin_info)
Definition: skin.c:463
HRESULT WINAPI D3DXCreateSkinInfoFVF(DWORD vertex_count, DWORD fvf, DWORD bone_count, ID3DXSkinInfo **skin_info)
Definition: skin.c:505

Referenced by START_TEST().

◆ test_createtext()

static void test_createtext ( IDirect3DDevice9 *  device,
HDC  hdc,
const char *  text,
float  deviation,
float  extrusion 
)
static

Definition at line 4440 of file mesh.c.

4441{
4442 static const MAT2 identity = {{0, 1}, {0, 0}, {0, 0}, {0, 1}};
4443 HRESULT hr;
4444 ID3DXMesh *d3dxmesh = NULL;
4445 struct mesh mesh = {0};
4446 char name[256];
4448 GLYPHMETRICS gm;
4449 struct glyphinfo *glyphs;
4450 GLYPHMETRICSFLOAT *glyphmetrics_float = malloc(sizeof(GLYPHMETRICSFLOAT) * strlen(text));
4451 int i;
4452 LOGFONTA lf;
4453 float offset_x;
4454 size_t textlen;
4455 HFONT font = NULL, oldfont = NULL;
4456 char *raw_outline;
4457
4458 sprintf(name, "text ('%s', %f, %f)", text, deviation, extrusion);
4459
4460 hr = D3DXCreateTextA(device, hdc, text, deviation, extrusion, &d3dxmesh, NULL, glyphmetrics_float);
4461 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
4462
4463 /* must select a modified font having lfHeight = otm.otmEMSquare before
4464 * calling GetGlyphOutline to get the expected values */
4465 ok(GetObjectA(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), &lf), "Failed to get current DC font.\n");
4466 ok(GetOutlineTextMetricsA(hdc, sizeof(otm), &otm), "Failed to get DC font outline.\n");
4467 lf.lfHeight = otm.otmEMSquare;
4468 lf.lfWidth = 0;
4469 ok(!!(font = CreateFontIndirectA(&lf)), "Failed to create font.\n");
4470
4471 textlen = strlen(text);
4472 glyphs = calloc(textlen, sizeof(*glyphs));
4473 oldfont = SelectObject(hdc, font);
4474
4475 for (i = 0; i < textlen; i++)
4476 {
4478 compare_float(glyphmetrics_float[i].gmfBlackBoxX, gm.gmBlackBoxX / (float)otm.otmEMSquare);
4479 compare_float(glyphmetrics_float[i].gmfBlackBoxY, gm.gmBlackBoxY / (float)otm.otmEMSquare);
4480 compare_float(glyphmetrics_float[i].gmfptGlyphOrigin.x, gm.gmptGlyphOrigin.x / (float)otm.otmEMSquare);
4481 compare_float(glyphmetrics_float[i].gmfptGlyphOrigin.y, gm.gmptGlyphOrigin.y / (float)otm.otmEMSquare);
4482 compare_float(glyphmetrics_float[i].gmfCellIncX, gm.gmCellIncX / (float)otm.otmEMSquare);
4483 compare_float(glyphmetrics_float[i].gmfCellIncY, gm.gmCellIncY / (float)otm.otmEMSquare);
4484 }
4485
4486 if (deviation == 0.0f)
4487 deviation = 1.0f / otm.otmEMSquare;
4488
4489 offset_x = 0.0f;
4490 for (i = 0; i < textlen; i++)
4491 {
4493
4494 glyphs[i].offset_x = offset_x;
4495
4497 ok(datasize != GDI_ERROR, "Failed to retrieve GDI glyph outline size.\n");
4498 raw_outline = malloc(datasize);
4499 datasize = GetGlyphOutlineA(hdc, text[i], GGO_NATIVE, &gm, datasize, raw_outline, &identity);
4500 ok(datasize != GDI_ERROR, "Failed to retrieve GDI glyph outline.\n");
4501 create_outline(&glyphs[i], raw_outline, datasize, deviation, otm.otmEMSquare);
4502 free(raw_outline);
4503
4504 offset_x += gm.gmCellIncX / (float)otm.otmEMSquare;
4505 }
4506
4507 SelectObject(hdc, oldfont);
4508
4509 compute_text_mesh(&mesh, text, deviation, extrusion, otm.otmEMSquare, glyphs);
4511
4512 compare_text_outline_mesh(name, d3dxmesh, &mesh, textlen, extrusion, glyphs);
4513
4514 free_mesh(&mesh);
4515 d3dxmesh->lpVtbl->Release(d3dxmesh);
4517 free(glyphmetrics_float);
4518
4519 for (i = 0; i < textlen; i++)
4520 free_glyphinfo(&glyphs[i]);
4521 free(glyphs);
4522}
static HRESULT create_outline(struct glyphinfo *glyph, void *raw_outline, int datasize, float max_deviation_sq, unsigned int emsquare, const struct cos_table *cos_table)
Definition: mesh.c:5671
static void free_glyphinfo(struct glyphinfo *glyph)
Definition: mesh.c:4022
#define compare_float(got, exp)
Definition: mesh.c:43
static void compute_text_mesh(struct mesh *mesh, const char *text, float deviation, float extrusion, float otmEMSquare, const struct glyphinfo *glyphs)
Definition: mesh.c:4031
static void compare_text_outline_mesh(const char *name, ID3DXMesh *d3dxmesh, struct mesh *mesh, size_t textlen, float extrusion, const struct glyphinfo *glyphs)
Definition: mesh.c:4175
Definition: mk_font.cpp:20
#define OBJ_FONT
Definition: objidl.idl:1019
LONG lfHeight
Definition: dimm.idl:42
LONG lfWidth
Definition: dimm.idl:43
long y
Definition: dcommon.idl:24
long x
Definition: dcommon.idl:24
short gmCellIncX
Definition: wingdi.h:2891
UINT gmBlackBoxY
Definition: wingdi.h:2889
UINT gmBlackBoxX
Definition: wingdi.h:2888
short gmCellIncY
Definition: wingdi.h:2892
POINT gmptGlyphOrigin
Definition: wingdi.h:2890
Definition: wingdi.h:2918
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:428
#define GDI_ERROR
Definition: wingdi.h:1309
#define GGO_NATIVE
Definition: wingdi.h:850
DWORD WINAPI GetGlyphOutlineA(_In_ HDC hdc, _In_ UINT uChar, _In_ UINT fuFormat, _Out_ LPGLYPHMETRICS lpgm, _In_ DWORD cjBuffer, _Out_writes_bytes_opt_(cjBuffer) LPVOID pvBuffer, _In_ CONST MAT2 *lpmat2)

Referenced by D3DXCreateTextTest().

◆ test_cylinder()

static void test_cylinder ( IDirect3DDevice9 *  device,
FLOAT  radius1,
FLOAT  radius2,
FLOAT  length,
UINT  slices,
UINT  stacks 
)
static

Definition at line 3448 of file mesh.c.

3449{
3450 HRESULT hr;
3451 ID3DXMesh *cylinder;
3452 struct mesh mesh;
3453 char name[256];
3454
3455 hr = D3DXCreateCylinder(device, radius1, radius2, length, slices, stacks, &cylinder, NULL);
3456 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
3457 if (hr != D3D_OK)
3458 {
3459 skip("Couldn't create cylinder\n");
3460 return;
3461 }
3462
3463 if (!compute_cylinder(&mesh, radius1, radius2, length, slices, stacks))
3464 {
3465 skip("Couldn't create mesh\n");
3466 cylinder->lpVtbl->Release(cylinder);
3467 return;
3468 }
3469
3471
3472 sprintf(name, "cylinder (%g, %g, %g, %u, %u)", radius1, radius2, length, slices, stacks);
3474
3475 free_mesh(&mesh);
3476
3477 cylinder->lpVtbl->Release(cylinder);
3478}
static BOOL compute_cylinder(struct mesh *mesh, FLOAT radius1, FLOAT radius2, FLOAT length, UINT slices, UINT stacks)
Definition: mesh.c:3302

Referenced by D3DXCreateCylinderTest().

◆ test_D3DXFrameFind()

static void test_D3DXFrameFind ( void  )
static

Definition at line 11440 of file mesh.c.

11441{
11442 static char n1[] = "name1";
11443 static char n2[] = "name2";
11444 static char n3[] = "name3";
11445 static char n4[] = "name4";
11446 static char n5[] = "name5";
11447 static char n6[] = "name6";
11448 static char N1[] = "Name1";
11449 D3DXFRAME root, sibling, sibling2, child, *ret;
11450 D3DXFRAME child2, child3;
11451
11453 ok(ret == NULL, "Unexpected frame, %p.\n", ret);
11454
11455 ret = D3DXFrameFind(NULL, "test");
11456 ok(ret == NULL, "Unexpected frame, %p.\n", ret);
11457
11458 memset(&root, 0, sizeof(root));
11459
11461 ok(ret == &root, "Unexpected frame, %p.\n", ret);
11462
11463 root.Name = n1;
11465 ok(ret == NULL, "Unexpected frame, %p.\n", ret);
11466
11467 ret = D3DXFrameFind(&root, n1);
11468 ok(ret == &root, "Unexpected frame, %p.\n", ret);
11469
11470 ret = D3DXFrameFind(&root, N1);
11471 ok(ret == NULL, "Unexpected frame, %p.\n", ret);
11472
11473 /* Test siblings order traversal. */
11474 memset(&sibling, 0, sizeof(sibling));
11475 sibling.Name = n2;
11476 root.pFrameSibling = &sibling;
11477 ret = D3DXFrameFind(&root, n2);
11478 ok(ret == &sibling, "Unexpected frame, %p.\n", ret);
11479
11480 memset(&sibling2, 0, sizeof(sibling2));
11481 sibling2.Name = n2;
11482 sibling.pFrameSibling = &sibling2;
11483 ret = D3DXFrameFind(&root, n2);
11484 ok(ret == &sibling, "Unexpected frame, %p.\n", ret);
11485
11486 sibling2.Name = n3;
11487 ret = D3DXFrameFind(&root, n3);
11488 ok(ret == &sibling2, "Unexpected frame, %p.\n", ret);
11489
11490 /* Siblings first. */
11491 memset(&child, 0, sizeof(child));
11492 child.Name = n2;
11493 root.pFrameFirstChild = &child;
11494 ret = D3DXFrameFind(&root, n2);
11495 ok(ret == &sibling, "Unexpected frame, %p.\n", ret);
11496
11497 child.Name = n4;
11498 ret = D3DXFrameFind(&root, n4);
11499 ok(ret == &child, "Unexpected frame, %p.\n", ret);
11500
11501 /* Link a grandchild and another one for sibling. */
11502 memset(&child2, 0, sizeof(child2));
11503 memset(&child3, 0, sizeof(child3));
11504 child2.Name = child3.Name = n5;
11505 sibling.pFrameFirstChild = &child2;
11506 child.pFrameFirstChild = &child3;
11507 ret = D3DXFrameFind(&root, n5);
11508 ok(ret == &child2, "Unexpected frame, %p.\n", ret);
11509
11510 child3.Name = n6;
11511 ret = D3DXFrameFind(&root, n6);
11512 ok(ret == &child3, "Unexpected frame, %p.\n", ret);
11513}
struct _root root
D3DXFRAME *WINAPI D3DXFrameFind(const D3DXFRAME *root, const char *name)
Definition: mesh.c:7716
static HWND child
Definition: cursoricon.c:298
int n4
Definition: dwarfget.c:147
int n5
Definition: dwarfget.c:147
int n2
Definition: dwarfget.c:147
int n1
Definition: dwarfget.c:147
int n3
Definition: dwarfget.c:147

Referenced by START_TEST().

◆ test_decl_to_fvf()

static void test_decl_to_fvf ( const D3DVERTEXELEMENT9 *  decl,
DWORD  expected_fvf,
HRESULT  expected_hr,
unsigned int  line,
unsigned int  test_id 
)
static

Definition at line 647 of file mesh.c.

649{
650 HRESULT hr;
651 DWORD result_fvf = 0xdeadbeef;
652
653 hr = D3DXFVFFromDeclarator(decl, &result_fvf);
654 ok(hr == expected_hr,
655 "Line %u, test %u: D3DXFVFFromDeclarator returned %#lx, expected %#lx.\n",
656 line, test_id, hr, expected_hr);
657 if (SUCCEEDED(hr))
658 {
659 ok(expected_fvf == result_fvf, "Line %u, test %u: Got FVF %#lx, expected %#lx.\n",
660 line, test_id, result_fvf, expected_fvf);
661 }
662}
HRESULT expected_hr

Referenced by test_fvf_decl_conversion().

◆ test_fvf_decl_conversion()

static void test_fvf_decl_conversion ( void  )
static

Definition at line 664 of file mesh.c.

665{
666 static const struct
667 {
669 DWORD fvf;
670 }
671 test_data[] =
672 {
673 {{
674 D3DDECL_END(),
675 }, 0},
676 {{
678 D3DDECL_END(),
679 }, D3DFVF_XYZ},
680 {{
682 D3DDECL_END(),
683 }, D3DFVF_XYZRHW},
684 {{
686 D3DDECL_END(),
687 }, D3DFVF_XYZRHW},
688 {{
691 D3DDECL_END(),
692 }, D3DFVF_XYZB1},
693 {{
696 D3DDECL_END(),
698 {{
701 D3DDECL_END(),
703 {{
706 D3DDECL_END(),
707 }, D3DFVF_XYZB2},
708 {{
712 D3DDECL_END(),
714 {{
718 D3DDECL_END(),
720 {{
723 D3DDECL_END(),
724 }, D3DFVF_XYZB3},
725 {{
729 D3DDECL_END(),
731 {{
735 D3DDECL_END(),
737 {{
740 D3DDECL_END(),
741 }, D3DFVF_XYZB4},
742 {{
746 D3DDECL_END(),
748 {{
752 D3DDECL_END(),
754 {{
758 D3DDECL_END(),
760 {{
764 D3DDECL_END(),
766 {{
768 D3DDECL_END(),
769 }, D3DFVF_NORMAL},
770 {{
773 D3DDECL_END(),
775 {{
777 D3DDECL_END(),
778 }, D3DFVF_PSIZE},
779 {{
781 D3DDECL_END(),
782 }, D3DFVF_DIFFUSE},
783 {{
785 D3DDECL_END(),
786 }, D3DFVF_SPECULAR},
787 /* Make sure textures of different sizes work. */
788 {{
790 D3DDECL_END(),
792 {{
794 D3DDECL_END(),
796 {{
798 D3DDECL_END(),
800 {{
802 D3DDECL_END(),
804 /* Make sure the TEXCOORD index works correctly - try several textures. */
805 {{
810 D3DDECL_END(),
813 /* Now try some combination tests. */
814 {{
821 D3DDECL_END(),
824 {{
831 D3DDECL_END(),
834 };
835 unsigned int i;
836
837 for (i = 0; i < ARRAY_SIZE(test_data); ++i)
838 {
839 test_decl_to_fvf(test_data[i].decl, test_data[i].fvf, D3D_OK, __LINE__, i);
840 test_fvf_to_decl(test_data[i].fvf, test_data[i].decl, D3D_OK, __LINE__, i);
841 }
842
843 /* Usage indices for position and normal are apparently ignored. */
844 {
845 const D3DVERTEXELEMENT9 decl[] =
846 {
848 D3DDECL_END(),
849 };
850 test_decl_to_fvf(decl, D3DFVF_XYZ, D3D_OK, __LINE__, 0);
851 }
852 {
853 const D3DVERTEXELEMENT9 decl[] =
854 {
856 D3DDECL_END(),
857 };
858 test_decl_to_fvf(decl, D3DFVF_NORMAL, D3D_OK, __LINE__, 0);
859 }
860 /* D3DFVF_LASTBETA_UBYTE4 and D3DFVF_LASTBETA_D3DCOLOR are ignored if
861 * there are no blend matrices. */
862 {
863 const D3DVERTEXELEMENT9 decl[] =
864 {
866 D3DDECL_END(),
867 };
869 }
870 {
871 const D3DVERTEXELEMENT9 decl[] =
872 {
874 D3DDECL_END(),
875 };
877 }
878 /* D3DFVF_LASTBETA_UBYTE4 takes precedence over D3DFVF_LASTBETA_D3DCOLOR. */
879 {
880 const D3DVERTEXELEMENT9 decl[] =
881 {
885 D3DDECL_END(),
886 };
888 decl, D3D_OK, __LINE__, 0);
889 }
890 /* These are supposed to fail, both ways. */
891 {
892 const D3DVERTEXELEMENT9 decl[] =
893 {
895 D3DDECL_END(),
896 };
899 }
900 {
901 const D3DVERTEXELEMENT9 decl[] =
902 {
905 D3DDECL_END(),
906 };
909 }
910 {
911 const D3DVERTEXELEMENT9 decl[] =
912 {
916 D3DDECL_END(),
917 };
920 }
921 /* Test a declaration that can't be converted to an FVF. */
922 {
923 const D3DVERTEXELEMENT9 decl[] =
924 {
930 /* 8 bytes padding */
932 D3DDECL_END(),
933 };
934 test_decl_to_fvf(decl, 0, D3DERR_INVALIDCALL, __LINE__, 0);
935 }
936 /* Elements must be ordered by offset. */
937 {
938 const D3DVERTEXELEMENT9 decl[] =
939 {
942 D3DDECL_END(),
943 };
944 test_decl_to_fvf(decl, 0, D3DERR_INVALIDCALL, __LINE__, 0);
945 }
946 /* Basic tests for element order. */
947 {
948 const D3DVERTEXELEMENT9 decl[] =
949 {
953 D3DDECL_END(),
954 };
955 test_decl_to_fvf(decl, 0, D3DERR_INVALIDCALL, __LINE__, 0);
956 }
957 {
958 const D3DVERTEXELEMENT9 decl[] =
959 {
962 D3DDECL_END(),
963 };
964 test_decl_to_fvf(decl, 0, D3DERR_INVALIDCALL, __LINE__, 0);
965 }
966 {
967 const D3DVERTEXELEMENT9 decl[] =
968 {
971 D3DDECL_END(),
972 };
973 test_decl_to_fvf(decl, 0, D3DERR_INVALIDCALL, __LINE__, 0);
974 }
975 /* Textures must be ordered by texcoords. */
976 {
977 const D3DVERTEXELEMENT9 decl[] =
978 {
983 D3DDECL_END(),
984 };
985 test_decl_to_fvf(decl, 0, D3DERR_INVALIDCALL, __LINE__, 0);
986 }
987 /* Duplicate elements are not allowed. */
988 {
989 const D3DVERTEXELEMENT9 decl[] =
990 {
994 D3DDECL_END(),
995 };
996 test_decl_to_fvf(decl, 0, D3DERR_INVALIDCALL, __LINE__, 0);
997 }
998 /* Invalid FVFs cannot be converted to a declarator. */
999 test_fvf_to_decl(0xdeadbeef, NULL, D3DERR_INVALIDCALL, __LINE__, 0);
1000}
@ D3DDECLUSAGE_BLENDWEIGHT
Definition: d3d9types.h:237
@ D3DDECLUSAGE_BLENDINDICES
Definition: d3d9types.h:238
@ D3DDECLUSAGE_POSITIONT
Definition: d3d9types.h:245
#define MAXD3DDECLLENGTH
Definition: d3d9types.h:195
static void test_fvf_to_decl(DWORD test_fvf, const D3DVERTEXELEMENT9 expected_elements[], HRESULT expected_hr, unsigned int line, unsigned int test_id)
Definition: mesh.c:634
static void test_decl_to_fvf(const D3DVERTEXELEMENT9 *decl, DWORD expected_fvf, HRESULT expected_hr, unsigned int line, unsigned int test_id)
Definition: mesh.c:647

Referenced by START_TEST().

◆ test_fvf_to_decl()

static void test_fvf_to_decl ( DWORD  test_fvf,
const D3DVERTEXELEMENT9  expected_elements[],
HRESULT  expected_hr,
unsigned int  line,
unsigned int  test_id 
)
static

Definition at line 634 of file mesh.c.

636{
637 HRESULT hr;
639
640 hr = D3DXDeclaratorFromFVF(test_fvf, decl);
641 ok(hr == expected_hr,
642 "Line %u, test %u: D3DXDeclaratorFromFVF returned %#lx, expected %#lx.\n",
643 line, test_id, hr, expected_hr);
644 if (SUCCEEDED(hr)) compare_elements(decl, expected_elements, line, test_id);
645}

Referenced by test_fvf_decl_conversion().

◆ test_get_decl_length()

static void test_get_decl_length ( void  )
static

Definition at line 4622 of file mesh.c.

4623{
4624 static const D3DVERTEXELEMENT9 declaration1[] =
4625 {
4641 D3DDECL_END(),
4642 };
4643 static const D3DVERTEXELEMENT9 declaration2[] =
4644 {
4661 D3DDECL_END(),
4662 };
4663 UINT size;
4664
4665 size = D3DXGetDeclLength(declaration1);
4666 ok(size == 15, "Got size %u, expected 15.\n", size);
4667
4668 size = D3DXGetDeclLength(declaration2);
4669 ok(size == 16, "Got size %u, expected 16.\n", size);
4670}

Referenced by START_TEST().

◆ test_get_decl_vertex_size()

static void test_get_decl_vertex_size ( void  )
static

Definition at line 4672 of file mesh.c.

4673{
4674 static const D3DVERTEXELEMENT9 declaration1[] =
4675 {
4691 D3DDECL_END(),
4692 };
4693 static const D3DVERTEXELEMENT9 declaration2[] =
4694 {
4711 D3DDECL_END(),
4712 };
4713 static const UINT sizes1[] =
4714 {
4715 4, 8, 12, 16,
4716 4, 4, 4, 8,
4717 4, 4, 8, 4,
4718 4, 4, 8, 0,
4719 };
4720 static const UINT sizes2[] =
4721 {
4722 12, 16, 20, 24,
4723 12, 12, 16, 16,
4724 };
4725 unsigned int i;
4726 UINT size;
4727
4729 ok(size == 0, "Got size %#x, expected 0.\n", size);
4730
4731 for (i = 0; i < 16; ++i)
4732 {
4733 size = D3DXGetDeclVertexSize(declaration1, i);
4734 ok(size == sizes1[i], "Got size %u for stream %u, expected %u.\n", size, i, sizes1[i]);
4735 }
4736
4737 for (i = 0; i < 8; ++i)
4738 {
4739 size = D3DXGetDeclVertexSize(declaration2, i);
4740 ok(size == sizes2[i], "Got size %u for stream %u, expected %u.\n", size, i, sizes2[i]);
4741 }
4742}

Referenced by START_TEST().

◆ test_load_skin_mesh_from_xof()

static void test_load_skin_mesh_from_xof ( void  )
static

Definition at line 11563 of file mesh.c.

11564{
11565 static const char simple_xfile[] =
11566 "xof 0303txt 0032"
11567 "Mesh {"
11568 "3;"
11569 "0.0; 0.0; 0.0;,"
11570 "0.0; 1.0; 0.0;,"
11571 "1.0; 1.0; 0.0;;"
11572 "1;"
11573 "3; 0, 1, 2;;"
11574 "}";
11575 static const char simple_xfile_empty[] =
11576 "xof 0303txt 0032"
11577 "Mesh { 0;; 0;; }";
11578 static const D3DVERTEXELEMENT9 expected_declaration[] =
11579 {
11581 D3DDECL_END(),
11582 };
11584 ID3DXBuffer *adjacency, *materials, *effects;
11585 DWORD max_influences[3], count, fvf;
11588 ID3DXSkinInfo *skin_info;
11589 ID3DXFileData *file_data;
11590 const char *bone_name;
11592 float influence;
11593 ID3DXMesh *mesh;
11594 IDirect3D9 *d3d;
11595 ULONG refcount;
11596 HRESULT hr;
11597 HWND hwnd;
11598
11599 if (!(hwnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
11600 640, 480, NULL, NULL, NULL, NULL)))
11601 {
11602 skip("Failed to create application window.\n");
11603 return;
11604 }
11605
11607 if (!d3d)
11608 {
11609 skip("Failed to create d3d object.\n");
11611 return;
11612 }
11613
11614 memset(&d3dpp, 0, sizeof(d3dpp));
11615 d3dpp.Windowed = TRUE;
11617
11620 IDirect3D9_Release(d3d);
11621 if (FAILED(hr))
11622 {
11623 skip("Failed to create device, hr %#lx.\n", hr);
11625 return;
11626 }
11627
11628 file_data = get_mesh_data(simple_xfile, sizeof(simple_xfile) - 1);
11629 ok(!!file_data, "Failed to load mesh data.\n");
11630
11631 adjacency = materials = effects = (void *)0xdeadbeef;
11632 count = ~0u;
11633 skin_info = (void *)0xdeadbeef;
11634 mesh = (void *)0xdeadbeef;
11635
11636 hr = D3DXLoadSkinMeshFromXof(file_data, 0, device, &adjacency, &materials, &effects, &count,
11637 &skin_info, &mesh);
11638 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
11639 ok(!!adjacency, "Got unexpected value %p.\n", adjacency);
11640 ok(!materials, "Got unexpected value %p.\n", materials);
11641 ok(!effects, "Got unexpected value %p.\n", effects);
11642 ok(!count, "Got unexpected value %lu.\n", count);
11643 ok(!!skin_info, "Got unexpected value %p.\n", skin_info);
11644 ok(!!mesh, "Got unexpected value %p.\n", mesh);
11645 count = mesh->lpVtbl->GetNumVertices(mesh);
11646 ok(count == 3, "Got unexpected value %lu.\n", count);
11647 count = mesh->lpVtbl->GetNumFaces(mesh);
11648 ok(count == 1, "Got unexpected value %lu.\n", count);
11649
11650 hr = skin_info->lpVtbl->GetDeclaration(skin_info, declaration);
11651 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
11652 compare_elements(declaration, expected_declaration, __LINE__, 0);
11653
11654 fvf = skin_info->lpVtbl->GetFVF(skin_info);
11655 ok(fvf == D3DFVF_XYZ, "Got unexpected value %lu.\n", fvf);
11656
11657 count = skin_info->lpVtbl->GetNumBones(skin_info);
11658 ok(!count, "Got unexpected value %lu.\n", count);
11659
11660 influence = skin_info->lpVtbl->GetMinBoneInfluence(skin_info);
11661 ok(!influence, "Got unexpected value %.8e.\n", influence);
11662
11663 memset(max_influences, 0x55, sizeof(max_influences));
11664 hr = skin_info->lpVtbl->GetMaxVertexInfluences(skin_info, max_influences);
11665 todo_wine ok(hr == D3D_OK, "Got unexpected value %#lx.\n", hr);
11666 todo_wine ok(!max_influences[0], "Got unexpected value %lu.\n", max_influences[0]);
11667 ok(max_influences[1] == 0x55555555, "Got unexpected value %lu.\n", max_influences[1]);
11668 ok(max_influences[2] == 0x55555555, "Got unexpected value %lu.\n", max_influences[2]);
11669
11670 bone_name = skin_info->lpVtbl->GetBoneName(skin_info, 0);
11671 ok(!bone_name, "Got unexpected value %p.\n", bone_name);
11672
11673 count = skin_info->lpVtbl->GetNumBoneInfluences(skin_info, 0);
11674 ok(!count, "Got unexpected value %lu.\n", count);
11675
11676 count = skin_info->lpVtbl->GetNumBoneInfluences(skin_info, 1);
11677 ok(!count, "Got unexpected value %lu.\n", count);
11678
11679 matrix = skin_info->lpVtbl->GetBoneOffsetMatrix(skin_info, -1);
11680 ok(!matrix, "Got unexpected value %p.\n", matrix);
11681
11682 matrix = skin_info->lpVtbl->GetBoneOffsetMatrix(skin_info, 0);
11683 ok(!matrix, "Got unexpected value %p.\n", matrix);
11684
11685 skin_info->lpVtbl->Release(skin_info);
11686 mesh->lpVtbl->Release(mesh);
11687 adjacency->lpVtbl->Release(adjacency);
11688 file_data->lpVtbl->Release(file_data);
11689
11690 /* Empty Mesh Test */
11691 file_data = get_mesh_data(simple_xfile_empty, sizeof(simple_xfile_empty) - 1);
11692 ok(!!file_data, "Failed to load mesh data.\n");
11693
11694 adjacency = materials = effects = (void *)0xdeadbeef;
11695 count = 0xdeadbeefu;
11696 skin_info = (void *)0xdeadbeef;
11697 mesh = (void *)0xdeadbeef;
11698
11699 hr = D3DXLoadSkinMeshFromXof(file_data, 0, device, &adjacency, &materials, &effects, &count,
11700 &skin_info, &mesh);
11701 todo_wine ok(hr == D3DXERR_LOADEDMESHASNODATA, "Unexpected hr %#lx.\n", hr);
11702 ok(!adjacency, "Unexpected adjacency %p.\n", adjacency);
11703 ok(!materials, "Unexpected materials %p.\n", materials);
11704 ok(!effects, "Unexpected effects %p.\n", effects);
11705 ok(count == 0xdeadbeefu, "Unexpected count %lu.\n", count);
11706 ok(skin_info == (void *)0xdeadbeef, "Unexpected skin_info %p.\n", skin_info);
11707 ok(!mesh, "Unexpected mesh %p.\n", mesh);
11708
11709 file_data->lpVtbl->Release(file_data);
11710
11711 refcount = IDirect3DDevice9_Release(device);
11712 ok(!refcount, "Device has %lu references left.\n", refcount);
11714}
HRESULT WINAPI D3DXLoadSkinMeshFromXof(struct ID3DXFileData *filedata, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXBuffer **adjacency_out, struct ID3DXBuffer **materials_out, struct ID3DXBuffer **effects_out, DWORD *num_materials_out, struct ID3DXSkinInfo **skin_info_out, struct ID3DXMesh **mesh_out)
Definition: mesh.c:3487
@ D3DXERR_LOADEDMESHASNODATA
Definition: d3dx9.h:51
GLuint GLenum matrix
Definition: glext.h:9407
static ID3DXFileData * get_mesh_data(const void *memory, SIZE_T length)
Definition: mesh.c:11515

Referenced by START_TEST().

◆ test_LoadMeshFromX_()

static void test_LoadMeshFromX_ ( int  line,
IDirect3DDevice9 *  device,
const char *  xfile_str,
size_t  xfile_strlen,
const void *  vertices,
DWORD  num_vertices,
DWORD  fvf,
const void *  indices,
DWORD  num_indices,
size_t  index_size,
const D3DXMATERIAL *  expected_materials,
DWORD  expected_num_materials,
BOOL  check_adjacency 
)
static

Definition at line 1997 of file mesh.c.

2000{
2001 HRESULT hr;
2002 ID3DXBuffer *materials = NULL;
2003 ID3DXBuffer *effects = NULL;
2004 ID3DXBuffer *adjacency = NULL;
2005 ID3DXMesh *mesh = NULL;
2006 DWORD num_materials = 0;
2007
2008 /* Adjacency is not checked when the X file contains multiple meshes,
2009 * since calling GenerateAdjacency on the merged mesh is not equivalent
2010 * to calling GenerateAdjacency on the individual meshes and then merging
2011 * the adjacency data. */
2012 hr = D3DXLoadMeshFromXInMemory(xfile_str, xfile_strlen, D3DXMESH_MANAGED, device,
2013 check_adjacency ? &adjacency : NULL, &materials, &effects, &num_materials, &mesh);
2014 ok_(__FILE__,line)(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
2015 if (SUCCEEDED(hr)) {
2016 D3DXMATERIAL *materials_ptr = materials ? ID3DXBuffer_GetBufferPointer(materials) : NULL;
2017 D3DXEFFECTINSTANCE *effects_ptr = effects ? ID3DXBuffer_GetBufferPointer(effects) : NULL;
2018 DWORD *adjacency_ptr = check_adjacency ? ID3DXBuffer_GetBufferPointer(adjacency) : NULL;
2019
2020 check_vertex_buffer_(line, mesh, vertices, num_vertices, fvf);
2021 check_index_buffer_(line, mesh, indices, num_indices, index_size);
2022 check_materials_(line, materials_ptr, num_materials, expected_materials, expected_num_materials);
2023 check_generated_effects_(line, materials_ptr, num_materials, effects_ptr);
2024 if (check_adjacency)
2025 check_generated_adjacency_(line, mesh, adjacency_ptr, 0.0f);
2026
2027 if (materials) ID3DXBuffer_Release(materials);
2028 if (effects) ID3DXBuffer_Release(effects);
2029 if (adjacency) ID3DXBuffer_Release(adjacency);
2030 IUnknown_Release(mesh);
2031 }
2032}
static void check_generated_effects_(int line, const D3DXMATERIAL *materials, DWORD num_materials, const D3DXEFFECTINSTANCE *effects)
Definition: mesh.c:1735
static void check_generated_adjacency_(int line, ID3DXMesh *mesh, const DWORD *got, FLOAT epsilon)
Definition: mesh.c:1704
static void check_index_buffer_(int line, ID3DXMesh *mesh, const void *indices, DWORD num_indices, DWORD index_size)
Definition: mesh.c:1622
static void check_materials_(int line, const D3DXMATERIAL *got, DWORD got_count, const D3DXMATERIAL *expected, DWORD expected_count)
Definition: mesh.c:1678
static void check_vertex_buffer_(int line, ID3DXMesh *mesh, const void *vertices, DWORD num_vertices, DWORD fvf)
Definition: mesh.c:1520

◆ test_mesh_optimize()

static void test_mesh_optimize ( void  )
static

Definition at line 11716 of file mesh.c.

11717{
11718/*
11719 * . _ .
11720 * / \ / \
11721 * . _ . _ .
11722 * \ / \ /
11723 * . _ .
11724 */
11725 static const struct
11726 {
11727 float c[3];
11728 float n[3];
11729 float t[2];
11730 }
11731 vertices[] =
11732 {
11733 { {-0.5f, -1.0f, 0.0f,}, {0.0f, 0.0f, 1.0f}, {-0.5f, -1.0f} },
11734 { { 0.5f, -1.0f, 0.0f,}, {0.0f, 0.0f, 1.0f}, { 0.5f, -1.0f} },
11735
11736 { {-1.0f, 0.0f, 0.0f,}, {0.0f, 0.0f, 1.0f}, {-1.0f, 0.0f} },
11737 { { 0.0f, 0.0f, 0.0f,}, {0.0f, 0.0f, 1.0f}, { 0.0f, 0.0f} },
11738 { { 1.0f, 0.0f, 0.0f,}, {0.0f, 0.0f, 1.0f}, { 1.0f, 0.0f} },
11739
11740 { {-0.5f, 1.0f, 0.0f,}, {0.0f, 0.0f, 1.0f}, {-0.5f, 1.0f} },
11741 { { 0.5f, 1.0f, 0.0f,}, {0.0f, 0.0f, 1.0f}, { 0.5f, 1.0f} },
11742 };
11743 static const unsigned short indices[] =
11744 {
11745 3, 0, 2,
11746 3, 2, 5,
11747 3, 5, 6,
11748 3, 6, 4,
11749 3, 4, 1,
11750 3, 1, 0,
11751 };
11752 static const DWORD attrs[] = { 1, 2, 1, 2, 1, 2 };
11753 static const DWORD expected_adjacency[] =
11754 {
11755 5, 0xffffffff, 1,
11756 0, 0xffffffff, 2,
11757 1, 0xffffffff, 3,
11758 2, 0xffffffff, 4,
11759 3, 0xffffffff, 5,
11760 4, 0xffffffff, 0,
11761 };
11762 static const DWORD expected_adjacency_out[] =
11763 {
11764 5, 0xffffffff, 3,
11765 3, 0xffffffff, 4,
11766 4, 0xffffffff, 5,
11767 0, 0xffffffff, 1,
11768 1, 0xffffffff, 2,
11769 2, 0xffffffff, 0,
11770 };
11771
11772 DWORD adjacency[6 * 3], adjacency_out[6 * 3];
11773 struct test_context *test_context;
11776 ID3DXMesh *mesh;
11777 unsigned int i;
11778 DWORD size;
11779 HRESULT hr;
11780 void *data;
11781
11783 if (!test_context)
11784 {
11785 skip("Couldn't create test context\n");
11786 return;
11787 }
11789
11792 ok(hr == S_OK, "got %#lx.\n", hr);
11793
11794 hr = mesh->lpVtbl->LockVertexBuffer(mesh, 0, &data);
11795 ok(hr == S_OK, "got %#lx.\n", hr);
11796 memcpy(data, vertices, sizeof(vertices));
11797 hr = mesh->lpVtbl->UnlockVertexBuffer(mesh);
11798 ok(hr == S_OK, "got %#lx.\n", hr);
11799
11800 hr = mesh->lpVtbl->LockIndexBuffer(mesh, 0, &data);
11801 ok(hr == S_OK, "got %#lx.\n", hr);
11802 memcpy(data, indices, sizeof(indices));
11803 hr = mesh->lpVtbl->UnlockIndexBuffer(mesh);
11804 ok(hr == S_OK, "got %#lx.\n", hr);
11805
11806 hr = mesh->lpVtbl->LockAttributeBuffer(mesh, 0, (DWORD **)&data);
11807 ok(hr == S_OK, "got %#lx.\n", hr);
11808 memcpy(data, attrs, sizeof(attrs));
11809 hr = mesh->lpVtbl->UnlockAttributeBuffer(mesh);
11810 ok(hr == S_OK, "got %#lx.\n", hr);
11811
11812 hr = mesh->lpVtbl->GenerateAdjacency(mesh, 0.0f, adjacency);
11813 ok(hr == S_OK, "got %#lx.\n", hr);
11814 ok(!memcmp(adjacency, expected_adjacency, sizeof(adjacency)), "data mismatch.\n");
11815
11817 adjacency, adjacency_out, NULL, &buffer);
11818 ok(hr == S_OK, "got %#lx.\n", hr);
11819
11820 size = buffer->lpVtbl->GetBufferSize(buffer);
11821 ok(size == sizeof(DWORD) * ARRAY_SIZE(vertices), "got %lu.\n", size);
11822 data = buffer->lpVtbl->GetBufferPointer(buffer);
11823 for (i = 0; i < ARRAY_SIZE(vertices); ++i)
11824 ok(((DWORD *)data)[i] == i, "i %u, got %lu.\n", i, ((DWORD *)data)[i]);
11825 ok(!memcmp(adjacency_out, expected_adjacency_out, sizeof(adjacency)), "data mismatch.\n");
11826
11827 buffer->lpVtbl->Release(buffer);
11828 mesh->lpVtbl->Release(mesh);
11830}
@ D3DXMESHOPT_DONOTSPLIT
Definition: d3dx9mesh.h:78
@ D3DXMESHOPT_IGNOREVERTS
Definition: d3dx9mesh.h:77
@ D3DXMESHOPT_ATTRSORT
Definition: d3dx9mesh.h:74
@ D3DXMESH_VB_MANAGED
Definition: d3dx9mesh.h:52
@ D3DXMESH_IB_MANAGED
Definition: d3dx9mesh.h:57
GLdouble GLdouble t
Definition: gl.h:2047
const GLubyte * c
Definition: glext.h:8905

Referenced by START_TEST().

◆ test_optimize_faces()

static void test_optimize_faces ( void  )
static

Definition at line 10602 of file mesh.c.

10603{
10604 HRESULT hr;
10605 UINT i;
10606 DWORD smallest_face_remap;
10607 /* mesh0
10608 *
10609 * 0--1
10610 * | /
10611 * |/
10612 * 2
10613 */
10614 const DWORD indices0[] = {0, 1, 2};
10615 const UINT num_faces0 = 1;
10616 const UINT num_vertices0 = 3;
10617 const DWORD exp_face_remap0[] = {0};
10618 /* mesh1
10619 *
10620 * 0--1 3
10621 * | / /|
10622 * |/ / |
10623 * 2 5--4
10624 */
10625 const DWORD indices1[] = {0, 1, 2, 3, 4, 5};
10626 const UINT num_faces1 = 2;
10627 const UINT num_vertices1 = 6;
10628 const DWORD exp_face_remap1[] = {1, 0};
10629 /* mesh2
10630 *
10631 * 0--1
10632 * | /|
10633 * |/ |
10634 * 2--3
10635 */
10636 const DWORD indices2[] = {0, 1, 2, 1, 3, 2};
10637 const UINT num_faces2 = 2;
10638 const UINT num_vertices2 = 4;
10639 const DWORD exp_face_remap2[] = {1, 0};
10640 /* mesh3
10641 *
10642 * 0--1
10643 * | /|
10644 * |/ |
10645 * 2--3
10646 * | /|
10647 * |/ |
10648 * 4--5
10649 */
10650 const DWORD indices3[] = {0, 1, 2, 1, 3, 2, 2, 3, 4, 3, 4, 5};
10651 const UINT num_faces3 = 4;
10652 const UINT num_vertices3 = 6;
10653 const DWORD exp_face_remap3[] = {3, 2, 1, 0};
10654 /* mesh4
10655 *
10656 * 0--1
10657 * | /|
10658 * |/ |
10659 * 2--3
10660 * | /|
10661 * |/ |
10662 * 4--5
10663 */
10664 const WORD indices4[] = {0, 1, 2, 1, 3, 2, 2, 3, 4, 3, 4, 5};
10665 const UINT num_faces4 = 4;
10666 const UINT num_vertices4 = 6;
10667 const DWORD exp_face_remap4[] = {3, 2, 1, 0};
10668 /* Test cases are stored in the tc array */
10669 struct
10670 {
10671 const VOID *indices;
10672 const UINT num_faces;
10673 const UINT num_vertices;
10674 const BOOL indices_are_32bit;
10675 const DWORD *exp_face_remap;
10676 }
10677 tc[] =
10678 {
10679 {
10680 indices0,
10681 num_faces0,
10682 num_vertices0,
10683 TRUE,
10684 exp_face_remap0
10685 },
10686 {
10687 indices1,
10688 num_faces1,
10689 num_vertices1,
10690 TRUE,
10691 exp_face_remap1
10692 },
10693 {
10694 indices2,
10695 num_faces2,
10696 num_vertices2,
10697 TRUE,
10698 exp_face_remap2
10699 },
10700 {
10701 indices3,
10702 num_faces3,
10703 num_vertices3,
10704 TRUE,
10705 exp_face_remap3
10706 },
10707 {
10708 indices4,
10709 num_faces4,
10710 num_vertices4,
10711 FALSE,
10712 exp_face_remap4
10713 },
10714 };
10715
10716 /* Go through all test cases */
10717 for (i = 0; i < ARRAY_SIZE(tc); i++)
10718 {
10719 DWORD j;
10720 DWORD *face_remap;
10721 face_remap = calloc(tc[i].num_faces, sizeof(*face_remap));
10722
10723 hr = D3DXOptimizeFaces(tc[i].indices, tc[i].num_faces,
10724 tc[i].num_vertices, tc[i].indices_are_32bit,
10725 face_remap);
10726 ok(hr == D3D_OK, "Test %u, got unexpected hr %#lx.\n", i, hr);
10727
10728 /* Compare face remap with expected face remap */
10729 for (j = 0; j < tc[i].num_faces; j++)
10730 {
10731 ok(tc[i].exp_face_remap[j] == face_remap[j],
10732 "Test case %d: Got face %ld at %ld, expected %ld\n", i,
10733 face_remap[j], j, tc[i].exp_face_remap[j]);
10734 }
10735
10736 free(face_remap);
10737 }
10738
10739 /* face_remap must not be NULL */
10740 hr = D3DXOptimizeFaces(tc[0].indices, tc[0].num_faces,
10741 tc[0].num_vertices, tc[0].indices_are_32bit,
10742 NULL);
10743 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
10744
10745 /* Number of faces must be smaller than 2^15 */
10746 hr = D3DXOptimizeFaces(tc[0].indices, 2 << 15,
10747 tc[0].num_vertices, FALSE,
10748 &smallest_face_remap);
10749 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
10750}
HRESULT WINAPI D3DXOptimizeFaces(const void *indices, UINT num_faces, UINT num_vertices, BOOL indices_are_32bit, DWORD *face_remap)
Definition: mesh.c:7311

Referenced by START_TEST().

◆ test_optimize_vertices()

static void test_optimize_vertices ( void  )
static

Definition at line 10752 of file mesh.c.

10753{
10754 static const WORD indices_16bit[] = {0, 1, 2};
10755 static const DWORD indices[] = {0, 1, 2};
10756 DWORD vertex_remap[3];
10757 unsigned int i;
10758 HRESULT hr;
10759
10760 hr = D3DXOptimizeVertices(indices, 1, 3, TRUE, vertex_remap);
10761 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
10762 for (i = 0; i < 3; ++i)
10763 ok(vertex_remap[i] == i, "Unexpected vertex remap %u -> %lu.\n", i, vertex_remap[i]);
10764
10765 hr = D3DXOptimizeVertices(indices_16bit, 1, 3, FALSE, vertex_remap);
10766 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
10767 for (i = 0; i < 3; ++i)
10768 ok(vertex_remap[i] == i, "Unexpected vertex remap %u -> %lu.\n", i, vertex_remap[i]);
10769
10770 hr = D3DXOptimizeVertices(indices, 0, 3, TRUE, vertex_remap);
10771 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
10772
10773 hr = D3DXOptimizeVertices(indices, 1, 0, TRUE, vertex_remap);
10774 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
10775
10776 hr = D3DXOptimizeVertices(NULL, 1, 3, TRUE, vertex_remap);
10777 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
10778
10780 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
10781}
HRESULT WINAPI D3DXOptimizeVertices(const void *indices, UINT face_count, UINT vertex_count, BOOL indices_are_32bit, DWORD *vertex_remap)
Definition: mesh.c:7356

Referenced by START_TEST().

◆ test_polygon()

static void test_polygon ( IDirect3DDevice9 *  device,
float  length,
unsigned int  sides 
)
static

Definition at line 2944 of file mesh.c.

2945{
2946 HRESULT hr;
2947 ID3DXMesh *polygon;
2948 struct mesh mesh;
2949 char name[64];
2950
2951 hr = D3DXCreatePolygon(device, length, sides, &polygon, NULL);
2952 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
2953 if (hr != D3D_OK)
2954 {
2955 skip("Couldn't create polygon\n");
2956 return;
2957 }
2958
2959 if (!compute_polygon(&mesh, length, sides))
2960 {
2961 skip("Couldn't create mesh\n");
2962 polygon->lpVtbl->Release(polygon);
2963 return;
2964 }
2965
2967
2968 sprintf(name, "polygon (%g, %u)", length, sides);
2969 compare_mesh(name, polygon, &mesh);
2970
2971 free_mesh(&mesh);
2972
2973 polygon->lpVtbl->Release(polygon);
2974}
static BOOL compute_polygon(struct mesh *mesh, float length, unsigned int sides)
Definition: mesh.c:2906

◆ test_sphere()

static void test_sphere ( IDirect3DDevice9 *  device,
FLOAT  radius,
UINT  slices,
UINT  stacks 
)
static

Definition at line 3221 of file mesh.c.

3222{
3223 HRESULT hr;
3224 ID3DXMesh *sphere;
3225 struct mesh mesh;
3226 char name[256];
3227
3228 hr = D3DXCreateSphere(device, radius, slices, stacks, &sphere, NULL);
3229 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
3230 if (hr != D3D_OK)
3231 {
3232 skip("Couldn't create sphere\n");
3233 return;
3234 }
3235
3236 if (!compute_sphere(&mesh, radius, slices, stacks))
3237 {
3238 skip("Couldn't create mesh\n");
3239 sphere->lpVtbl->Release(sphere);
3240 return;
3241 }
3242
3244
3245 sprintf(name, "sphere (%g, %u, %u)", radius, slices, stacks);
3246 compare_mesh(name, sphere, &mesh);
3247
3248 free_mesh(&mesh);
3249
3250 sphere->lpVtbl->Release(sphere);
3251}
static BOOL compute_sphere(struct mesh *mesh, FLOAT radius, UINT slices, UINT stacks)
Definition: mesh.c:3087

Referenced by D3DXCreateSphereTest().

◆ test_torus()

static void test_torus ( IDirect3DDevice9 *  device,
float  innerradius,
float  outerradius,
UINT  sides,
UINT  rings 
)
static

Definition at line 3612 of file mesh.c.

3613{
3614 HRESULT hr;
3615 ID3DXMesh *torus;
3616 struct mesh mesh;
3617 char name[256];
3618
3619 hr = D3DXCreateTorus(device, innerradius, outerradius, sides, rings, &torus, NULL);
3620 ok(hr == D3D_OK, "Got result %#lx, expected 0 (D3D_OK)\n", hr);
3621 if (hr != D3D_OK)
3622 {
3623 skip("Couldn't create torus\n");
3624 return;
3625 }
3626
3627 if (!compute_torus(&mesh, innerradius, outerradius, sides, rings))
3628 {
3629 skip("Couldn't create mesh\n");
3630 torus->lpVtbl->Release(torus);
3631 return;
3632 }
3633
3635
3636 sprintf(name, "torus (%g, %g, %u, %u)", innerradius, outerradius, sides, rings);
3637 compare_mesh(name, torus, &mesh);
3638
3639 free_mesh(&mesh);
3640
3641 torus->lpVtbl->Release(torus);
3642}
static BOOL compute_torus(struct mesh *mesh, float innerradius, float outerradius, UINT sides, UINT rings)
Definition: mesh.c:3553

Referenced by D3DXCreateTorusTest().

◆ test_update_semantics()

static void test_update_semantics ( void  )
static

Definition at line 4860 of file mesh.c.

4861{
4862 HRESULT hr;
4863 struct test_context *test_context = NULL;
4864 ID3DXMesh *mesh = NULL;
4865 D3DVERTEXELEMENT9 declaration0[] =
4866 {
4870 D3DDECL_END()
4871 };
4872 D3DVERTEXELEMENT9 declaration_pos_type_color[] =
4873 {
4877 D3DDECL_END()
4878 };
4879 D3DVERTEXELEMENT9 declaration_smaller[] =
4880 {
4883 D3DDECL_END()
4884 };
4885 D3DVERTEXELEMENT9 declaration_larger[] =
4886 {
4891 D3DDECL_END()
4892 };
4893 D3DVERTEXELEMENT9 declaration_multiple_streams[] =
4894 {
4899
4900 D3DDECL_END()
4901 };
4902 D3DVERTEXELEMENT9 declaration_double_usage[] =
4903 {
4908 D3DDECL_END()
4909 };
4910 D3DVERTEXELEMENT9 declaration_undefined_type[] =
4911 {
4915 D3DDECL_END()
4916 };
4917 D3DVERTEXELEMENT9 declaration_not_4_byte_aligned_offset[] =
4918 {
4922 D3DDECL_END()
4923 };
4924 static const struct
4925 {
4926 D3DXVECTOR3 position0;
4927 D3DXVECTOR3 position1;
4929 DWORD color;
4930 }
4931 vertices[] =
4932 {
4933 { { 0.0f, 1.0f, 0.f}, { 1.0f, 0.0f, 0.f}, {0.0f, 0.0f, 1.0f}, 0xffff0000 },
4934 { { 1.0f, -1.0f, 0.f}, {-1.0f, -1.0f, 0.f}, {0.0f, 0.0f, 1.0f}, 0xff00ff00 },
4935 { {-1.0f, -1.0f, 0.f}, {-1.0f, 1.0f, 0.f}, {0.0f, 0.0f, 1.0f}, 0xff0000ff },
4936 };
4937 unsigned int faces[] = {0, 1, 2};
4938 unsigned int attributes[] = {0};
4939 unsigned int num_faces = ARRAY_SIZE(faces) / 3;
4940 unsigned int num_vertices = ARRAY_SIZE(vertices);
4941 int offset = sizeof(D3DXVECTOR3);
4943 void *vertex_buffer;
4944 void *index_buffer;
4945 DWORD *attributes_buffer;
4947 D3DVERTEXELEMENT9 *decl_ptr;
4948 DWORD exp_vertex_size = sizeof(*vertices);
4949 DWORD vertex_size = 0;
4950 BYTE *decl_mem;
4951 int equal;
4952 int i = 0;
4953
4955 if (!test_context)
4956 {
4957 skip("Couldn't create a test_context\n");
4958 goto cleanup;
4959 }
4960
4961 hr = D3DXCreateMesh(num_faces, num_vertices, options, declaration0,
4963 if (FAILED(hr))
4964 {
4965 skip("Couldn't create test mesh %#lx\n", hr);
4966 goto cleanup;
4967 }
4968
4969 mesh->lpVtbl->LockVertexBuffer(mesh, 0, &vertex_buffer);
4970 memcpy(vertex_buffer, vertices, sizeof(vertices));
4971 mesh->lpVtbl->UnlockVertexBuffer(mesh);
4972
4973 mesh->lpVtbl->LockIndexBuffer(mesh, 0, &index_buffer);
4974 memcpy(index_buffer, faces, sizeof(faces));
4975 mesh->lpVtbl->UnlockIndexBuffer(mesh);
4976
4977 mesh->lpVtbl->LockAttributeBuffer(mesh, 0, &attributes_buffer);
4978 memcpy(attributes_buffer, attributes, sizeof(attributes));
4979 mesh->lpVtbl->UnlockAttributeBuffer(mesh);
4980
4981 /* Get the declaration and try to change it */
4982 hr = mesh->lpVtbl->GetDeclaration(mesh, declaration);
4983 if (FAILED(hr))
4984 {
4985 skip("Couldn't get vertex declaration %#lx\n", hr);
4986 goto cleanup;
4987 }
4988 equal = memcmp(declaration, declaration0, sizeof(declaration0));
4989 ok(equal == 0, "Vertex declarations were not equal\n");
4990
4991 for (decl_ptr = declaration; decl_ptr->Stream != 0xFF; decl_ptr++)
4992 {
4993 if (decl_ptr->Usage == D3DDECLUSAGE_POSITION)
4994 {
4995 /* Use second vertex position instead of first */
4996 decl_ptr->Offset = offset;
4997 }
4998 }
4999
5000 hr = mesh->lpVtbl->UpdateSemantics(mesh, declaration);
5001 ok(hr == D3D_OK, "Test UpdateSemantics, got %#lx expected %#lx\n", hr, D3D_OK);
5002
5003 /* Check that declaration was written by getting it again */
5004 memset(declaration, 0, sizeof(declaration));
5005 hr = mesh->lpVtbl->GetDeclaration(mesh, declaration);
5006 if (FAILED(hr))
5007 {
5008 skip("Couldn't get vertex declaration %#lx\n", hr);
5009 goto cleanup;
5010 }
5011
5012 for (decl_ptr = declaration; decl_ptr->Stream != 0xFF; decl_ptr++)
5013 {
5014 if (decl_ptr->Usage == D3DDECLUSAGE_POSITION)
5015 {
5016 ok(decl_ptr->Offset == offset, "Test UpdateSemantics, got offset %d expected %d\n",
5017 decl_ptr->Offset, offset);
5018 }
5019 }
5020
5021 /* Check that GetDeclaration only writes up to the D3DDECL_END() marker and
5022 * not the full MAX_FVF_DECL_SIZE elements.
5023 */
5024 memset(declaration, 0xaa, sizeof(declaration));
5025 memcpy(declaration, declaration0, sizeof(declaration0));
5026 hr = mesh->lpVtbl->UpdateSemantics(mesh, declaration);
5027 ok(hr == D3D_OK, "Test UpdateSemantics, "
5028 "got %#lx expected D3D_OK\n", hr);
5029 memset(declaration, 0xbb, sizeof(declaration));
5030 hr = mesh->lpVtbl->GetDeclaration(mesh, declaration);
5031 ok(hr == D3D_OK, "Couldn't get vertex declaration. Got %#lx, expected D3D_OK\n", hr);
5032 decl_mem = (BYTE *)declaration;
5033 for (i = sizeof(declaration0); i < sizeof(declaration); ++i)
5034 {
5035 ok(decl_mem[i] == 0xbb, "Unexpected %#x.\n", decl_mem[i]);
5036 if (equal != 0)
5037 break;
5038 }
5039
5040 /* UpdateSemantics does not check for overlapping fields */
5041 memset(declaration, 0, sizeof(declaration));
5042 hr = mesh->lpVtbl->GetDeclaration(mesh, declaration);
5043 if (FAILED(hr))
5044 {
5045 skip("Couldn't get vertex declaration %#lx\n", hr);
5046 goto cleanup;
5047 }
5048
5049 for (decl_ptr = declaration; decl_ptr->Stream != 0xFF; decl_ptr++)
5050 {
5051 if (decl_ptr->Type == D3DDECLTYPE_FLOAT3)
5052 {
5053 decl_ptr->Type = D3DDECLTYPE_FLOAT4;
5054 }
5055 }
5056
5057 hr = mesh->lpVtbl->UpdateSemantics(mesh, declaration);
5058 ok(hr == D3D_OK, "Test UpdateSemantics for overlapping fields, "
5059 "got %#lx expected D3D_OK\n", hr);
5060
5061 /* Set the position type to color instead of float3 */
5062 hr = mesh->lpVtbl->UpdateSemantics(mesh, declaration_pos_type_color);
5063 ok(hr == D3D_OK, "Test UpdateSemantics position type color, "
5064 "got %#lx expected D3D_OK\n", hr);
5065
5066 /* The following test cases show that NULL, smaller or larger declarations,
5067 * and declarations with non-zero Stream values are not accepted.
5068 * UpdateSemantics returns D3DERR_INVALIDCALL and the previously set
5069 * declaration will be used by DrawSubset, GetNumBytesPerVertex, and
5070 * GetDeclaration.
5071 */
5072
5073 /* Null declaration (invalid declaration) */
5074 mesh->lpVtbl->UpdateSemantics(mesh, declaration0); /* Set a valid declaration */
5075 hr = mesh->lpVtbl->UpdateSemantics(mesh, NULL);
5076 ok(hr == D3DERR_INVALIDCALL, "Test UpdateSemantics null pointer declaration, "
5077 "got %#lx expected D3DERR_INVALIDCALL\n", hr);
5078 vertex_size = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
5079 ok(vertex_size == exp_vertex_size, "Got vertex declaration size %lu, expected %lu\n",
5080 vertex_size, exp_vertex_size);
5081 memset(declaration, 0, sizeof(declaration));
5082 hr = mesh->lpVtbl->GetDeclaration(mesh, declaration);
5083 ok(hr == D3D_OK, "Couldn't get vertex declaration. Got %#lx, expected D3D_OK\n", hr);
5084 equal = memcmp(declaration, declaration0, sizeof(declaration0));
5085 ok(equal == 0, "Vertex declarations were not equal\n");
5086
5087 /* Smaller vertex declaration (invalid declaration) */
5088 mesh->lpVtbl->UpdateSemantics(mesh, declaration0); /* Set a valid declaration */
5089 hr = mesh->lpVtbl->UpdateSemantics(mesh, declaration_smaller);
5090 ok(hr == D3DERR_INVALIDCALL, "Test UpdateSemantics for smaller vertex declaration, "
5091 "got %#lx expected D3DERR_INVALIDCALL\n", hr);
5092 vertex_size = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
5093 ok(vertex_size == exp_vertex_size, "Got vertex declaration size %lu, expected %lu\n",
5094 vertex_size, exp_vertex_size);
5095 memset(declaration, 0, sizeof(declaration));
5096 hr = mesh->lpVtbl->GetDeclaration(mesh, declaration);
5097 ok(hr == D3D_OK, "Couldn't get vertex declaration. Got %#lx, expected D3D_OK\n", hr);
5098 equal = memcmp(declaration, declaration0, sizeof(declaration0));
5099 ok(equal == 0, "Vertex declarations were not equal\n");
5100
5101 /* Larger vertex declaration (invalid declaration) */
5102 mesh->lpVtbl->UpdateSemantics(mesh, declaration0); /* Set a valid declaration */
5103 hr = mesh->lpVtbl->UpdateSemantics(mesh, declaration_larger);
5104 ok(hr == D3DERR_INVALIDCALL, "Test UpdateSemantics for larger vertex declaration, "
5105 "got %#lx expected D3DERR_INVALIDCALL\n", hr);
5106 vertex_size = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
5107 ok(vertex_size == exp_vertex_size, "Got vertex declaration size %lu, expected %lu\n",
5108 vertex_size, exp_vertex_size);
5109 memset(declaration, 0, sizeof(declaration));
5110 hr = mesh->lpVtbl->GetDeclaration(mesh, declaration);
5111 ok(hr == D3D_OK, "Couldn't get vertex declaration. Got %#lx, expected D3D_OK\n", hr);
5112 equal = memcmp(declaration, declaration0, sizeof(declaration0));
5113 ok(equal == 0, "Vertex declarations were not equal\n");
5114
5115 /* Use multiple streams and keep the same vertex size (invalid declaration) */
5116 mesh->lpVtbl->UpdateSemantics(mesh, declaration0); /* Set a valid declaration */
5117 hr = mesh->lpVtbl->UpdateSemantics(mesh, declaration_multiple_streams);
5118 ok(hr == D3DERR_INVALIDCALL, "Test UpdateSemantics using multiple streams, "
5119 "got %#lx expected D3DERR_INVALIDCALL\n", hr);
5120 vertex_size = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
5121 ok(vertex_size == exp_vertex_size, "Got vertex declaration size %lu, expected %lu\n",
5122 vertex_size, exp_vertex_size);
5123 memset(declaration, 0, sizeof(declaration));
5124 hr = mesh->lpVtbl->GetDeclaration(mesh, declaration);
5125 ok(hr == D3D_OK, "Couldn't get vertex declaration. Got %#lx, expected D3D_OK\n", hr);
5126 equal = memcmp(declaration, declaration0, sizeof(declaration0));
5127 ok(equal == 0, "Vertex declarations were not equal\n");
5128
5129 /* The next following test cases show that some invalid declarations are
5130 * accepted with a D3D_OK. An access violation is thrown on Windows if
5131 * DrawSubset is called. The methods GetNumBytesPerVertex and GetDeclaration
5132 * are not affected, which indicates that the declaration is cached.
5133 */
5134
5135 /* Double usage (invalid declaration) */
5136 mesh->lpVtbl->UpdateSemantics(mesh, declaration0); /* Set a valid declaration */
5137 hr = mesh->lpVtbl->UpdateSemantics(mesh, declaration_double_usage);
5138 ok(hr == D3D_OK, "Test UpdateSemantics double usage, "
5139 "got %#lx expected D3D_OK\n", hr);
5140 vertex_size = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
5141 ok(vertex_size == exp_vertex_size, "Got vertex declaration size %lu, expected %lu\n",
5142 vertex_size, exp_vertex_size);
5143 memset(declaration, 0, sizeof(declaration));
5144 hr = mesh->lpVtbl->GetDeclaration(mesh, declaration);
5145 ok(hr == D3D_OK, "Couldn't get vertex declaration. Got %#lx, expected D3D_OK\n", hr);
5146 equal = memcmp(declaration, declaration_double_usage, sizeof(declaration_double_usage));
5147 ok(equal == 0, "Vertex declarations were not equal\n");
5148
5149 /* Set the position to an undefined type (invalid declaration) */
5150 mesh->lpVtbl->UpdateSemantics(mesh, declaration0); /* Set a valid declaration */
5151 hr = mesh->lpVtbl->UpdateSemantics(mesh, declaration_undefined_type);
5152 ok(hr == D3D_OK, "Test UpdateSemantics undefined type, "
5153 "got %#lx expected D3D_OK\n", hr);
5154 vertex_size = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
5155 ok(vertex_size == exp_vertex_size, "Got vertex declaration size %lu, expected %lu\n",
5156 vertex_size, exp_vertex_size);
5157 memset(declaration, 0, sizeof(declaration));
5158 hr = mesh->lpVtbl->GetDeclaration(mesh, declaration);
5159 ok(hr == D3D_OK, "Couldn't get vertex declaration. Got %#lx, expected D3D_OK\n", hr);
5160 equal = memcmp(declaration, declaration_undefined_type, sizeof(declaration_undefined_type));
5161 ok(equal == 0, "Vertex declarations were not equal\n");
5162
5163 /* Use a not 4 byte aligned offset (invalid declaration) */
5164 mesh->lpVtbl->UpdateSemantics(mesh, declaration0); /* Set a valid declaration */
5165 hr = mesh->lpVtbl->UpdateSemantics(mesh, declaration_not_4_byte_aligned_offset);
5166 ok(hr == D3D_OK, "Test UpdateSemantics not 4 byte aligned offset, "
5167 "got %#lx expected D3D_OK\n", hr);
5168 vertex_size = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
5169 ok(vertex_size == exp_vertex_size, "Got vertex declaration size %lu, expected %lu\n",
5170 vertex_size, exp_vertex_size);
5171 memset(declaration, 0, sizeof(declaration));
5172 hr = mesh->lpVtbl->GetDeclaration(mesh, declaration);
5173 ok(hr == D3D_OK, "Couldn't get vertex declaration. Got %#lx, expected D3D_OK\n", hr);
5174 equal = memcmp(declaration, declaration_not_4_byte_aligned_offset,
5175 sizeof(declaration_not_4_byte_aligned_offset));
5176 ok(equal == 0, "Vertex declarations were not equal\n");
5177
5178cleanup:
5179 if (mesh)
5180 mesh->lpVtbl->Release(mesh);
5181
5183}
@ D3DDECLUSAGE_TANGENT
Definition: d3d9types.h:242
@ D3DDECLTYPE_UNUSED
Definition: d3d9types.h:289
GLintptr offset
Definition: glext.h:5920

Referenced by START_TEST().

◆ test_valid_mesh()

static void test_valid_mesh ( void  )
static

Definition at line 10479 of file mesh.c.

10480{
10481 HRESULT hr;
10482 struct test_context *test_context = NULL;
10483 UINT i;
10486 {
10488 D3DDECL_END()
10489 };
10490 const unsigned int VERTS_PER_FACE = 3;
10491 /* mesh0 (one face)
10492 *
10493 * 0--1
10494 * | /
10495 * |/
10496 * 2
10497 */
10498 const D3DXVECTOR3 vertices0[] =
10499 {
10500 { 0.0f, 3.0f, 0.f},
10501 { 2.0f, 3.0f, 0.f},
10502 { 0.0f, 0.0f, 0.f},
10503 };
10504 const DWORD indices0[] = {0, 1, 2};
10505 const unsigned int num_vertices0 = ARRAY_SIZE(vertices0);
10506 const unsigned int num_faces0 = ARRAY_SIZE(indices0) / VERTS_PER_FACE;
10507 const DWORD adjacency0[] = {-1, -1, -1};
10508 const HRESULT exp_hr0 = D3D_OK;
10509 /* mesh1 (Simple bow-tie)
10510 *
10511 * 0--1 1--3
10512 * | / \ |
10513 * |/ \|
10514 * 2 4
10515 */
10516 const D3DXVECTOR3 vertices1[] =
10517 {
10518 { 0.0f, 3.0f, 0.f},
10519 { 2.0f, 3.0f, 0.f},
10520 { 0.0f, 0.0f, 0.f},
10521
10522 { 4.0f, 3.0f, 0.f},
10523 { 4.0f, 0.0f, 0.f},
10524 };
10525 const DWORD indices1[] = {0, 1, 2, 1, 3, 4};
10526 const unsigned int num_vertices1 = ARRAY_SIZE(vertices1);
10527 const unsigned int num_faces1 = ARRAY_SIZE(indices1) / VERTS_PER_FACE;
10528 const DWORD adjacency1[] = {-1, -1, -1, -1, -1, -1};
10529 const HRESULT exp_hr1 = D3DXERR_INVALIDMESH;
10530 /* Common mesh data */
10531 ID3DXMesh *mesh = NULL;
10532 UINT vertex_size = sizeof(D3DXVECTOR3);
10533 ID3DXBuffer *errors_and_warnings = NULL;
10534 struct
10535 {
10536 const D3DXVECTOR3 *vertices;
10537 const DWORD *indices;
10538 const UINT num_vertices;
10539 const UINT num_faces;
10540 const DWORD *adjacency;
10541 const HRESULT exp_hr;
10542 }
10543 tc[] =
10544 {
10545 {
10546 vertices0,
10547 indices0,
10548 num_vertices0,
10549 num_faces0,
10550 adjacency0,
10551 exp_hr0,
10552 },
10553 {
10554 vertices1,
10555 indices1,
10556 num_vertices1,
10557 num_faces1,
10558 adjacency1,
10559 exp_hr1,
10560 },
10561 };
10562
10564 if (!test_context)
10565 {
10566 skip("Couldn't create test context\n");
10567 goto cleanup;
10568 }
10569
10570 for (i = 0; i < ARRAY_SIZE(tc); i++)
10571 {
10572 hr = init_test_mesh(tc[i].num_faces, tc[i].num_vertices,
10575 tc[i].vertices, vertex_size,
10576 tc[i].indices, NULL);
10577 if (FAILED(hr))
10578 {
10579 skip("Couldn't initialize test mesh %d. Got %lx expected D3D_OK\n", i, hr);
10580 goto cleanup;
10581 }
10582
10583 hr = D3DXValidMesh(mesh, tc[i].adjacency, &errors_and_warnings);
10584 todo_wine ok(hr == tc[i].exp_hr, "Test %u, got unexpected hr %#lx, expected %#lx.\n", i, hr, tc[i].exp_hr);
10585
10586 /* Note errors_and_warnings is deliberately not checked because that
10587 * would require copying wast amounts of the text output. */
10588 if (errors_and_warnings)
10589 {
10590 ID3DXBuffer_Release(errors_and_warnings);
10591 errors_and_warnings = NULL;
10592 }
10593 mesh->lpVtbl->Release(mesh);
10594 mesh = NULL;
10595 }
10596
10597cleanup:
10598 if (mesh) mesh->lpVtbl->Release(mesh);
10600}
#define D3DXERR_INVALIDMESH
Definition: d3dx8core.h:42
HRESULT WINAPI D3DXValidMesh(ID3DXMesh *mesh, const DWORD *adjacency, ID3DXBuffer **errors_and_warnings)
Definition: mesh.c:6531

Referenced by START_TEST().

◆ test_weld_vertices()

static void test_weld_vertices ( void  )
static

Definition at line 6866 of file mesh.c.

6867{
6868 HRESULT hr;
6869 struct test_context *test_context = NULL;
6870 DWORD i;
6872 const DWORD options_16bit = D3DXMESH_SYSTEMMEM;
6873 BYTE *vertices = NULL;
6874 DWORD *indices = NULL;
6875 WORD *indices_16bit = NULL;
6876 const UINT VERTS_PER_FACE = 3;
6877 const D3DXVECTOR3 up = {0.0f, 0.0f, 1.0f};
6878 struct vertex_normal
6879 {
6880 D3DXVECTOR3 position;
6882 };
6883 struct vertex_blendweight
6884 {
6885 D3DXVECTOR3 position;
6886 FLOAT blendweight;
6887 };
6888 struct vertex_texcoord
6889 {
6890 D3DXVECTOR3 position;
6891 D3DXVECTOR2 texcoord;
6892 };
6893 struct vertex_color
6894 {
6895 D3DXVECTOR3 position;
6896 DWORD color;
6897 };
6898 struct vertex_color_ubyte4
6899 {
6900 D3DXVECTOR3 position;
6901 BYTE color[4];
6902 };
6903 struct vertex_texcoord_short2
6904 {
6905 D3DXVECTOR3 position;
6906 SHORT texcoord[2];
6907 };
6908 struct vertex_texcoord_ushort2n
6909 {
6910 D3DXVECTOR3 position;
6911 USHORT texcoord[2];
6912 };
6913 struct vertex_normal_short4
6914 {
6915 D3DXVECTOR3 position;
6916 SHORT normal[4];
6917 };
6918 struct vertex_texcoord_float16_2
6919 {
6920 D3DXVECTOR3 position;
6921 WORD texcoord[2];
6922 };
6923 struct vertex_texcoord_float16_4
6924 {
6925 D3DXVECTOR3 position;
6926 WORD texcoord[4];
6927 };
6928 struct vertex_normal_udec3
6929 {
6930 D3DXVECTOR3 position;
6931 DWORD normal;
6932 };
6933 struct vertex_normal_dec3n
6934 {
6935 D3DXVECTOR3 position;
6936 DWORD normal;
6937 };
6938 UINT vertex_size_normal = sizeof(struct vertex_normal);
6939 UINT vertex_size_blendweight = sizeof(struct vertex_blendweight);
6940 UINT vertex_size_texcoord = sizeof(struct vertex_texcoord);
6941 UINT vertex_size_color = sizeof(struct vertex_color);
6942 UINT vertex_size_color_ubyte4 = sizeof(struct vertex_color_ubyte4);
6943 UINT vertex_size_texcoord_short2 = sizeof(struct vertex_texcoord_short2);
6944 UINT vertex_size_normal_short4 = sizeof(struct vertex_normal_short4);
6945 UINT vertex_size_texcoord_float16_2 = sizeof(struct vertex_texcoord_float16_2);
6946 UINT vertex_size_texcoord_float16_4 = sizeof(struct vertex_texcoord_float16_4);
6947 UINT vertex_size_normal_udec3 = sizeof(struct vertex_normal_udec3);
6948 UINT vertex_size_normal_dec3n = sizeof(struct vertex_normal_dec3n);
6949 D3DVERTEXELEMENT9 declaration_normal[] =
6950 {
6953 D3DDECL_END()
6954 };
6955 D3DVERTEXELEMENT9 declaration_normal3[] =
6956 {
6959 D3DDECL_END()
6960 };
6961 D3DVERTEXELEMENT9 declaration_blendweight[] =
6962 {
6965 D3DDECL_END()
6966 };
6967 D3DVERTEXELEMENT9 declaration_texcoord[] =
6968 {
6971 D3DDECL_END()
6972 };
6973 D3DVERTEXELEMENT9 declaration_color[] =
6974 {
6977 D3DDECL_END()
6978 };
6979 D3DVERTEXELEMENT9 declaration_color_ubyte4n[] =
6980 {
6983 D3DDECL_END()
6984 };
6985 D3DVERTEXELEMENT9 declaration_color_ubyte4[] =
6986 {
6989 D3DDECL_END()
6990 };
6991 D3DVERTEXELEMENT9 declaration_texcoord_short2[] =
6992 {
6995 D3DDECL_END()
6996 };
6997 D3DVERTEXELEMENT9 declaration_texcoord_short2n[] =
6998 {
7001 D3DDECL_END()
7002 };
7003 D3DVERTEXELEMENT9 declaration_texcoord_ushort2n[] =
7004 {
7007 D3DDECL_END()
7008 };
7009 D3DVERTEXELEMENT9 declaration_normal_short4[] =
7010 {
7013 D3DDECL_END()
7014 };
7015 D3DVERTEXELEMENT9 declaration_normal_short4n[] =
7016 {
7019 D3DDECL_END()
7020 };
7021 D3DVERTEXELEMENT9 declaration_normal_ushort4n[] =
7022 {
7025 D3DDECL_END()
7026 };
7027 D3DVERTEXELEMENT9 declaration_texcoord10[] =
7028 {
7031 D3DDECL_END()
7032 };
7033 D3DVERTEXELEMENT9 declaration_color2[] =
7034 {
7037 D3DDECL_END()
7038 };
7039 D3DVERTEXELEMENT9 declaration_color1[] =
7040 {
7043 D3DDECL_END()
7044 };
7045 D3DVERTEXELEMENT9 declaration_texcoord_float16_2[] =
7046 {
7049 D3DDECL_END()
7050 };
7051 D3DVERTEXELEMENT9 declaration_texcoord_float16_4[] =
7052 {
7055 D3DDECL_END()
7056 };
7057 D3DVERTEXELEMENT9 declaration_normal_udec3[] =
7058 {
7061 D3DDECL_END()
7062 };
7063 D3DVERTEXELEMENT9 declaration_normal_dec3n[] =
7064 {
7067 D3DDECL_END()
7068 };
7069 /* Test 0. One face and no welding.
7070 *
7071 * 0--1
7072 * | /
7073 * |/
7074 * 2
7075 */
7076 const struct vertex vertices0[] =
7077 {
7078 {{ 0.0f, 3.0f, 0.f}, up},
7079 {{ 2.0f, 3.0f, 0.f}, up},
7080 {{ 0.0f, 0.0f, 0.f}, up},
7081 };
7082 const DWORD indices0[] = {0, 1, 2};
7083 const DWORD attributes0[] = {0};
7084 const DWORD exp_indices0[] = {0, 1, 2};
7085 const UINT num_vertices0 = ARRAY_SIZE(vertices0);
7086 const UINT num_faces0 = ARRAY_SIZE(indices0) / VERTS_PER_FACE;
7087 const DWORD flags0 = D3DXWELDEPSILONS_WELDALL;
7088 /* epsilons0 is NULL */
7089 const DWORD adjacency0[] = {-1, -1, -1};
7090 const struct vertex exp_vertices0[] =
7091 {
7092 {{ 0.0f, 3.0f, 0.f}, up},
7093 {{ 2.0f, 3.0f, 0.f}, up},
7094 {{ 0.0f, 0.0f, 0.f}, up},
7095 };
7096 const DWORD exp_face_remap0[] = {0};
7097 const DWORD exp_vertex_remap0[] = {0, 1, 2};
7098 const DWORD exp_new_num_vertices0 = ARRAY_SIZE(exp_vertices0);
7099 /* Test 1. Two vertices should be removed without regard to epsilon.
7100 *
7101 * 0--1 3
7102 * | / /|
7103 * |/ / |
7104 * 2 5--4
7105 */
7106 const struct vertex_normal vertices1[] =
7107 {
7108 {{ 0.0f, 3.0f, 0.f}, up},
7109 {{ 2.0f, 3.0f, 0.f}, up},
7110 {{ 0.0f, 0.0f, 0.f}, up},
7111
7112 {{ 3.0f, 3.0f, 0.f}, up},
7113 {{ 3.0f, 0.0f, 0.f}, up},
7114 {{ 1.0f, 0.0f, 0.f}, up},
7115 };
7116 const DWORD indices1[] = {0, 1, 2, 3, 4, 5};
7117 const DWORD attributes1[] = {0, 0};
7118 const UINT num_vertices1 = ARRAY_SIZE(vertices1);
7119 const UINT num_faces1 = ARRAY_SIZE(indices1) / VERTS_PER_FACE;
7120 const DWORD flags1 = D3DXWELDEPSILONS_WELDALL;
7121 /* epsilons1 is NULL */
7122 const DWORD adjacency1[] = {-1, 1, -1, -1, -1, 0};
7123 const struct vertex_normal exp_vertices1[] =
7124 {
7125 {{ 0.0f, 3.0f, 0.f}, up},
7126 {{ 2.0f, 3.0f, 0.f}, up},
7127 {{ 0.0f, 0.0f, 0.f}, up},
7128
7129 {{ 3.0f, 0.0f, 0.f}, up}
7130 };
7131 const DWORD exp_indices1[] = {0, 1, 2, 1, 3, 2};
7132 const DWORD exp_face_remap1[] = {0, 1};
7133 const DWORD exp_vertex_remap1[] = {0, 1, 2, 4, -1, -1};
7134 const DWORD exp_new_num_vertices1 = ARRAY_SIZE(exp_vertices1);
7135 /* Test 2. Two faces. No vertices should be removed because of normal
7136 * epsilon, but the positions should be replaced. */
7137 const struct vertex_normal vertices2[] =
7138 {
7139 {{ 0.0f, 3.0f, 0.f}, up},
7140 {{ 2.0f, 3.0f, 0.f}, up},
7141 {{ 0.0f, 0.0f, 0.f}, up},
7142
7143 {{ 3.0f, 3.0f, 0.f}, {0.0f, 0.5f, 0.5f}},
7144 {{ 3.0f, 0.0f, 0.f}, up},
7145 {{ 1.0f, 0.0f, 0.f}, {0.2f, 0.4f, 0.4f}},
7146 };
7147 const DWORD indices2[] = {0, 1, 2, 3, 4, 5};
7148 const DWORD attributes2[] = {0, 0};
7149 const UINT num_vertices2 = ARRAY_SIZE(vertices2);
7150 const UINT num_faces2 = ARRAY_SIZE(indices2) / VERTS_PER_FACE;
7152 const D3DXWELDEPSILONS epsilons2 = {1.0f, 0.0f, 0.499999f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7153 const DWORD adjacency2[] = {-1, 1, -1, -1, -1, 0};
7154 const struct vertex_normal exp_vertices2[] =
7155 {
7156 {{ 0.0f, 3.0f, 0.f}, up},
7157 {{ 2.0f, 3.0f, 0.f}, up},
7158 {{ 0.0f, 0.0f, 0.f}, up},
7159
7160 {{ 2.0f, 3.0f, 0.f}, {0.0f, 0.5f, 0.5f}},
7161 {{ 3.0f, 0.0f, 0.f}, up},
7162 {{ 0.0f, 0.0f, 0.f}, {0.2f, 0.4f, 0.4f}},
7163 };
7164 const DWORD exp_indices2[] = {0, 1, 2, 3, 4, 5};
7165 const DWORD exp_face_remap2[] = {0, 1};
7166 const DWORD exp_vertex_remap2[] = {0, 1, 2, 3, 4, 5};
7167 const DWORD exp_new_num_vertices2 = ARRAY_SIZE(exp_vertices2);
7168 /* Test 3. Two faces. One vertex should be removed because of normal epsilon. */
7169 const struct vertex_normal vertices3[] =
7170 {
7171 {{ 0.0f, 3.0f, 0.f}, up},
7172 {{ 2.0f, 3.0f, 0.f}, up},
7173 {{ 0.0f, 0.0f, 0.f}, up},
7174
7175 {{ 3.0f, 3.0f, 0.f}, {0.0f, 0.5f, 0.5f}},
7176 {{ 3.0f, 0.0f, 0.f}, up},
7177 {{ 1.0f, 0.0f, 0.f}, {0.2f, 0.4f, 0.4f}},
7178 };
7179 const DWORD indices3[] = {0, 1, 2, 3, 4, 5};
7180 const DWORD attributes3[] = {0, 0};
7181 const UINT num_vertices3 = ARRAY_SIZE(vertices3);
7182 const UINT num_faces3 = ARRAY_SIZE(indices3) / VERTS_PER_FACE;
7184 const D3DXWELDEPSILONS epsilons3 = {1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7185 const DWORD adjacency3[] = {-1, 1, -1, -1, -1, 0};
7186 const struct vertex_normal exp_vertices3[] =
7187 {
7188 {{ 0.0f, 3.0f, 0.f}, up},
7189 {{ 2.0f, 3.0f, 0.f}, up},
7190 {{ 0.0f, 0.0f, 0.f}, up},
7191
7192 {{ 3.0f, 0.0f, 0.f}, up},
7193 {{ 0.0f, 0.0f, 0.f}, {0.2f, 0.4f, 0.4f}},
7194 };
7195 const DWORD exp_indices3[] = {0, 1, 2, 1, 3, 4};
7196 const DWORD exp_face_remap3[] = {0, 1};
7197 const DWORD exp_vertex_remap3[] = {0, 1, 2, 4, 5, -1};
7198 const DWORD exp_new_num_vertices3 = ARRAY_SIZE(exp_vertices3);
7199 /* Test 4 Two faces. Two vertices should be removed. */
7200 const struct vertex_normal vertices4[] =
7201 {
7202 {{ 0.0f, 3.0f, 0.f}, up},
7203 {{ 2.0f, 3.0f, 0.f}, up},
7204 {{ 0.0f, 0.0f, 0.f}, up},
7205
7206 {{ 3.0f, 3.0f, 0.f}, {0.0f, 0.5f, 0.5f}},
7207 {{ 3.0f, 0.0f, 0.f}, up},
7208 {{ 1.0f, 0.0f, 0.f}, {0.2f, 0.4f, 0.4f}},
7209 };
7210 const DWORD indices4[] = {0, 1, 2, 3, 4, 5};
7211 const DWORD attributes4[] = {0, 0};
7212 const UINT num_vertices4 = ARRAY_SIZE(vertices4);
7213 const UINT num_faces4 = ARRAY_SIZE(indices4) / VERTS_PER_FACE;
7215 const D3DXWELDEPSILONS epsilons4 = {1.0f, 0.0f, 0.6f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7216 const DWORD adjacency4[] = {-1, 1, -1, -1, -1, 0};
7217 const struct vertex_normal exp_vertices4[] =
7218 {
7219 {{ 0.0f, 3.0f, 0.f}, up},
7220 {{ 2.0f, 3.0f, 0.f}, up},
7221 {{ 0.0f, 0.0f, 0.f}, up},
7222
7223 {{ 3.0f, 0.0f, 0.f}, up},
7224 };
7225 const DWORD exp_indices4[] = {0, 1, 2, 1, 3, 2};
7226 const DWORD exp_face_remap4[] = {0, 1};
7227 const DWORD exp_vertex_remap4[] = {0, 1, 2, 4, -1, -1};
7228 const DWORD exp_new_num_vertices4 = ARRAY_SIZE(exp_vertices4);
7229 /* Test 5. Odd face ordering.
7230 *
7231 * 0--1 6 3
7232 * | / /| |\
7233 * |/ / | | \
7234 * 2 8--7 5--4
7235 */
7236 const struct vertex_normal vertices5[] =
7237 {
7238 {{ 0.0f, 3.0f, 0.f}, up},
7239 {{ 2.0f, 3.0f, 0.f}, up},
7240 {{ 0.0f, 0.0f, 0.f}, up},
7241
7242 {{ 3.0f, 3.0f, 0.f}, up},
7243 {{ 3.0f, 0.0f, 0.f}, up},
7244 {{ 1.0f, 0.0f, 0.f}, up},
7245
7246 {{ 4.0f, 3.0f, 0.f}, up},
7247 {{ 6.0f, 0.0f, 0.f}, up},
7248 {{ 4.0f, 0.0f, 0.f}, up},
7249 };
7250 const DWORD indices5[] = {0, 1, 2, 6, 7, 8, 3, 4, 5};
7251 const DWORD exp_indices5[] = {0, 1, 2, 1, 4, 2, 1, 3, 4};
7252 const DWORD attributes5[] = {0, 0, 0};
7253 const UINT num_vertices5 = ARRAY_SIZE(vertices5);
7254 const UINT num_faces5 = ARRAY_SIZE(indices5) / VERTS_PER_FACE;
7256 const DWORD adjacency5[] = {-1, 1, -1, 2, -1, 0, -1, -1, 1};
7257 const struct vertex_normal exp_vertices5[] =
7258 {
7259 {{ 0.0f, 3.0f, 0.f}, up},
7260 {{ 2.0f, 3.0f, 0.f}, up},
7261 {{ 0.0f, 0.0f, 0.f}, up},
7262
7263 {{ 3.0f, 0.0f, 0.f}, up},
7264 {{ 1.0f, 0.0f, 0.f}, up},
7265 };
7266 const DWORD exp_face_remap5[] = {0, 1, 2};
7267 const DWORD exp_vertex_remap5[] = {0, 1, 2, 4, 5, -1, -1, -1, -1};
7268 const DWORD exp_new_num_vertices5 = ARRAY_SIZE(exp_vertices5);
7269 /* Test 6. Two faces. Do not remove flag is used, so no vertices should be
7270 * removed. */
7271 const struct vertex_normal vertices6[] =
7272 {
7273 {{ 0.0f, 3.0f, 0.f}, up},
7274 {{ 2.0f, 3.0f, 0.f}, up},
7275 {{ 0.0f, 0.0f, 0.f}, up},
7276
7277 {{ 3.0f, 3.0f, 0.f}, {0.0f, 0.5f, 0.5f}},
7278 {{ 3.0f, 0.0f, 0.f}, up},
7279 {{ 1.0f, 0.0f, 0.f}, {0.2f, 0.4f, 0.4f}},
7280 };
7281 const DWORD indices6[] = {0, 1, 2, 3, 4, 5};
7282 const DWORD attributes6[] = {0, 0};
7283 const UINT num_vertices6 = ARRAY_SIZE(vertices6);
7284 const UINT num_faces6 = ARRAY_SIZE(indices6) / VERTS_PER_FACE;
7286 const D3DXWELDEPSILONS epsilons6 = {1.0f, 0.0f, 0.6f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7287 const DWORD adjacency6[] = {-1, 1, -1, -1, -1, 0};
7288 const struct vertex_normal exp_vertices6[] =
7289 {
7290 {{ 0.0f, 3.0f, 0.f}, up},
7291 {{ 2.0f, 3.0f, 0.f}, up},
7292 {{ 0.0f, 0.0f, 0.f}, up},
7293
7294 {{ 2.0f, 3.0f, 0.f}, up},
7295 {{ 3.0f, 0.0f, 0.f}, up},
7296 {{ 0.0f, 0.0f, 0.f}, up},
7297
7298 };
7299 const DWORD exp_indices6[] = {0, 1, 2, 3, 4, 5};
7300 const DWORD exp_face_remap6[] = {0, 1};
7301 const DWORD exp_vertex_remap6[] = {0, 1, 2, 3, 4, 5};
7302 const DWORD exp_new_num_vertices6 = ARRAY_SIZE(exp_vertices6);
7303 /* Test 7. Same as test 6 but with 16 bit indices. */
7304 const WORD indices6_16bit[] = {0, 1, 2, 3, 4, 5};
7305 /* Test 8. No flags. Same result as D3DXWELDEPSILONS_WELDPARTIALMATCHES. */
7306 const struct vertex_normal vertices8[] =
7307 {
7308 {{ 0.0f, 3.0f, 0.f}, up},
7309 {{ 2.0f, 3.0f, 0.f}, up},
7310 {{ 0.0f, 0.0f, 0.f}, up},
7311
7312 {{ 3.0f, 3.0f, 0.f}, {0.0f, 0.5f, 0.5f}},
7313 {{ 3.0f, 0.0f, 0.f}, up},
7314 {{ 1.0f, 0.0f, 0.f}, {0.2f, 0.4f, 0.4f}},
7315 };
7316 const DWORD indices8[] = {0, 1, 2, 1, 3, 4};
7317 const DWORD attributes8[] = {0, 0};
7318 const UINT num_vertices8 = ARRAY_SIZE(vertices8);
7319 const UINT num_faces8 = ARRAY_SIZE(indices8) / VERTS_PER_FACE;
7320 DWORD flags8 = 0;
7321 const D3DXWELDEPSILONS epsilons8 = {1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7322 const DWORD adjacency8[] = {-1, 1, -1, -1, -1, 0};
7323 const struct vertex_normal exp_vertices8[] =
7324 {
7325 {{ 0.0f, 3.0f, 0.f}, up},
7326 {{ 2.0f, 3.0f, 0.f}, up},
7327 {{ 0.0f, 0.0f, 0.f}, up},
7328
7329 {{ 3.0f, 3.0f, 0.f}, {0.0f, 0.5f, 0.5f}},
7330 {{ 3.0f, 0.0f, 0.f}, up},
7331 };
7332 const DWORD exp_indices8[] = {0, 1, 2, 1, 3, 4};
7333 const DWORD exp_face_remap8[] = {0, 1};
7334 const DWORD exp_vertex_remap8[] = {0, 1, 2, 3, 4, -1};
7335 const DWORD exp_new_num_vertices8 = ARRAY_SIZE(exp_vertices8);
7336 /* Test 9. Vertices are removed even though they belong to separate
7337 * attribute groups if D3DXWELDEPSILONS_DONOTSPLIT is set. */
7338 const struct vertex_normal vertices9[] =
7339 {
7340 {{ 0.0f, 3.0f, 0.f}, up},
7341 {{ 2.0f, 3.0f, 0.f}, up},
7342 {{ 0.0f, 0.0f, 0.f}, up},
7343
7344 {{ 3.0f, 3.0f, 0.f}, {0.0f, 0.5f, 0.5f}},
7345 {{ 3.0f, 0.0f, 0.f}, up},
7346 {{ 1.0f, 0.0f, 0.f}, {0.2f, 0.4f, 0.4f}},
7347 };
7348 const DWORD indices9[] = {0, 1, 2, 3, 4, 5};
7349 const DWORD attributes9[] = {0, 1};
7350 const UINT num_vertices9 = ARRAY_SIZE(vertices9);
7351 const UINT num_faces9 = ARRAY_SIZE(indices9) / VERTS_PER_FACE;
7353 const D3DXWELDEPSILONS epsilons9 = {1.0f, 0.0f, 0.6f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7354 const DWORD adjacency9[] = {-1, 1, -1, -1, -1, 0};
7355 const struct vertex_normal exp_vertices9[] =
7356 {
7357 {{ 0.0f, 3.0f, 0.f}, up},
7358 {{ 2.0f, 3.0f, 0.f}, up},
7359 {{ 0.0f, 0.0f, 0.f}, up},
7360
7361 {{ 3.0f, 0.0f, 0.f}, up},
7362 };
7363 const DWORD exp_indices9[] = {0, 1, 2, 1, 3, 2};
7364 const DWORD exp_face_remap9[] = {0, 1};
7365 const DWORD exp_vertex_remap9[] = {0, 1, 2, 4, -1, -1};
7366 const DWORD exp_new_num_vertices9 = ARRAY_SIZE(exp_vertices9);
7367 /* Test 10. Weld blendweight (FLOAT1). */
7368 const struct vertex_blendweight vertices10[] =
7369 {
7370 {{ 0.0f, 3.0f, 0.f}, 1.0f},
7371 {{ 2.0f, 3.0f, 0.f}, 1.0f},
7372 {{ 0.0f, 0.0f, 0.f}, 1.0f},
7373
7374 {{ 3.0f, 3.0f, 0.f}, 0.9},
7375 {{ 3.0f, 0.0f, 0.f}, 1.0},
7376 {{ 1.0f, 0.0f, 0.f}, 0.4},
7377 };
7378 const DWORD indices10[] = {0, 1, 2, 3, 4, 5};
7379 const DWORD attributes10[] = {0, 0};
7380 const UINT num_vertices10 = ARRAY_SIZE(vertices10);
7381 const UINT num_faces10 = ARRAY_SIZE(indices10) / VERTS_PER_FACE;
7383 const D3DXWELDEPSILONS epsilons10 = {1.0f, 0.1f + FLT_EPSILON, 0.0f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7384 const DWORD adjacency10[] = {-1, 1, -1, -1, -1, 0};
7385 const struct vertex_blendweight exp_vertices10[] =
7386 {
7387 {{ 0.0f, 3.0f, 0.f}, 1.0f},
7388 {{ 2.0f, 3.0f, 0.f}, 1.0f},
7389 {{ 0.0f, 0.0f, 0.f}, 1.0f},
7390
7391 {{ 3.0f, 0.0f, 0.f}, 1.0},
7392 {{ 0.0f, 0.0f, 0.f}, 0.4},
7393 };
7394 const DWORD exp_indices10[] = {0, 1, 2, 1, 3, 4};
7395 const DWORD exp_face_remap10[] = {0, 1};
7396 const DWORD exp_vertex_remap10[] = {0, 1, 2, 4, 5, -1};
7397 const DWORD exp_new_num_vertices10 = ARRAY_SIZE(exp_vertices10);
7398 /* Test 11. Weld texture coordinates. */
7399 const struct vertex_texcoord vertices11[] =
7400 {
7401 {{ 0.0f, 3.0f, 0.f}, {1.0f, 1.0f}},
7402 {{ 2.0f, 3.0f, 0.f}, {0.5f, 0.7f}},
7403 {{ 0.0f, 0.0f, 0.f}, {-0.2f, -0.3f}},
7404
7405 {{ 3.0f, 3.0f, 0.f}, {0.2f, 0.3f}},
7406 {{ 3.0f, 0.0f, 0.f}, {1.0f, 1.0f}},
7407 {{ 1.0f, 0.0f, 0.f}, {0.1f, 0.2f}}
7408 };
7409 const DWORD indices11[] = {0, 1, 2, 3, 4, 5};
7410 const DWORD attributes11[] = {0, 0};
7411 const UINT num_vertices11 = ARRAY_SIZE(vertices11);
7412 const UINT num_faces11 = ARRAY_SIZE(indices11) / VERTS_PER_FACE;
7414 const D3DXWELDEPSILONS epsilons11 = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, {0.4f + FLT_EPSILON, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7415 const DWORD adjacency11[] = {-1, 1, -1, -1, -1, 0};
7416 const struct vertex_texcoord exp_vertices11[] =
7417 {
7418 {{ 0.0f, 3.0f, 0.f}, {1.0f, 1.0f}},
7419 {{ 2.0f, 3.0f, 0.f}, {0.5f, 0.7f}},
7420 {{ 0.0f, 0.0f, 0.f}, {-0.2f, -0.3f}},
7421
7422 {{ 3.0f, 0.0f, 0.f}, {1.0f, 1.0f}},
7423 {{ 0.0f, 0.0f, 0.f}, {0.1f, 0.2f}},
7424 };
7425 const DWORD exp_indices11[] = {0, 1, 2, 1, 3, 4};
7426 const DWORD exp_face_remap11[] = {0, 1};
7427 const DWORD exp_vertex_remap11[] = {0, 1, 2, 4, 5, -1};
7428 const DWORD exp_new_num_vertices11 = ARRAY_SIZE(exp_vertices11);
7429 /* Test 12. Weld with color. */
7430 const struct vertex_color vertices12[] =
7431 {
7432 {{ 0.0f, 3.0f, 0.f}, 0xFFFFFFFF},
7433 {{ 2.0f, 3.0f, 0.f}, 0xFFFFFFFF},
7434 {{ 0.0f, 0.0f, 0.f}, 0xFFFFFFFF},
7435
7436 {{ 3.0f, 3.0f, 0.f}, 0x00000000},
7437 {{ 3.0f, 0.0f, 0.f}, 0xFFFFFFFF},
7438 {{ 1.0f, 0.0f, 0.f}, 0x88888888},
7439 };
7440 const DWORD indices12[] = {0, 1, 2, 3, 4, 5};
7441 const DWORD attributes12[] = {0, 0};
7442 const UINT num_vertices12 = ARRAY_SIZE(vertices12);
7443 const UINT num_faces12 = ARRAY_SIZE(indices12) / VERTS_PER_FACE;
7445 const D3DXWELDEPSILONS epsilons12 = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7446 const DWORD adjacency12[] = {-1, 1, -1, -1, -1, 0};
7447 const struct vertex_color exp_vertices12[] =
7448 {
7449 {{ 0.0f, 3.0f, 0.f}, 0xFFFFFFFF},
7450 {{ 2.0f, 3.0f, 0.f}, 0xFFFFFFFF},
7451 {{ 0.0f, 0.0f, 0.f}, 0xFFFFFFFF},
7452
7453 {{ 2.0f, 3.0f, 0.f}, 0x00000000},
7454 {{ 3.0f, 0.0f, 0.f}, 0xFFFFFFFF},
7455 };
7456 const DWORD exp_indices12[] = {0, 1, 2, 3, 4, 2};
7457 const DWORD exp_face_remap12[] = {0, 1};
7458 const DWORD exp_vertex_remap12[] = {0, 1, 2, 3, 4, -1};
7459 const DWORD exp_new_num_vertices12 = ARRAY_SIZE(exp_vertices12);
7460 /* Test 13. Two faces. One vertex should be removed because of normal epsilon.
7461 * This is similar to test 3, but the declaration has been changed to NORMAL3.
7462 */
7463 const struct vertex_normal vertices13[] =
7464 {
7465 {{ 0.0f, 3.0f, 0.f}, up},
7466 {{ 2.0f, 3.0f, 0.f}, up},
7467 {{ 0.0f, 0.0f, 0.f}, up},
7468
7469 {{ 3.0f, 3.0f, 0.f}, {0.0f, 0.5f, 0.5f}},
7470 {{ 3.0f, 0.0f, 0.f}, up},
7471 {{ 1.0f, 0.0f, 0.f}, {0.2f, 0.4f, 0.4f}},
7472 };
7473 const DWORD indices13[] = {0, 1, 2, 3, 4, 5};
7474 const DWORD attributes13[] = {0, 0};
7475 const UINT num_vertices13 = ARRAY_SIZE(vertices3);
7476 const UINT num_faces13 = ARRAY_SIZE(indices3) / VERTS_PER_FACE;
7478 const D3DXWELDEPSILONS epsilons13 = {1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7479 const DWORD adjacency13[] = {-1, 1, -1, -1, -1, 0};
7480 const struct vertex_normal exp_vertices13[] =
7481 {
7482 {{ 0.0f, 3.0f, 0.f}, up},
7483 {{ 2.0f, 3.0f, 0.f}, up},
7484 {{ 0.0f, 0.0f, 0.f}, up},
7485
7486 {{ 3.0f, 0.0f, 0.f}, up},
7487 {{ 0.0f, 0.0f, 0.f}, {0.2f, 0.4f, 0.4f}},
7488 };
7489 const DWORD exp_indices13[] = {0, 1, 2, 1, 3, 4};
7490 const DWORD exp_face_remap13[] = {0, 1};
7491 const DWORD exp_vertex_remap13[] = {0, 1, 2, 4, 5, -1};
7492 const DWORD exp_new_num_vertices13 = ARRAY_SIZE(exp_vertices13);
7493 /* Test 14. Another test for welding with color. */
7494 const struct vertex_color vertices14[] =
7495 {
7496 {{ 0.0f, 3.0f, 0.f}, 0xFFFFFFFF},
7497 {{ 2.0f, 3.0f, 0.f}, 0xFFFFFFFF},
7498 {{ 0.0f, 0.0f, 0.f}, 0xFFFFFFFF},
7499
7500 {{ 3.0f, 3.0f, 0.f}, 0x00000000},
7501 {{ 3.0f, 0.0f, 0.f}, 0xFFFFFFFF},
7502 {{ 1.0f, 0.0f, 0.f}, 0x01010101},
7503 };
7504 const DWORD indices14[] = {0, 1, 2, 3, 4, 5};
7505 const DWORD attributes14[] = {0, 0};
7506 const UINT num_vertices14 = ARRAY_SIZE(vertices14);
7507 const UINT num_faces14 = ARRAY_SIZE(indices14) / VERTS_PER_FACE;
7509 const D3DXWELDEPSILONS epsilons14 = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 254.0f/255.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7510 const DWORD adjacency14[] = {-1, 1, -1, -1, -1, 0};
7511 const struct vertex_color exp_vertices14[] =
7512 {
7513 {{ 0.0f, 3.0f, 0.f}, 0xFFFFFFFF},
7514 {{ 2.0f, 3.0f, 0.f}, 0xFFFFFFFF},
7515 {{ 0.0f, 0.0f, 0.f}, 0xFFFFFFFF},
7516
7517 {{ 2.0f, 3.0f, 0.f}, 0x00000000},
7518 {{ 3.0f, 0.0f, 0.f}, 0xFFFFFFFF},
7519 };
7520 const DWORD exp_indices14[] = {0, 1, 2, 3, 4, 2};
7521 const DWORD exp_face_remap14[] = {0, 1};
7522 const DWORD exp_vertex_remap14[] = {0, 1, 2, 3, 4, -1};
7523 const DWORD exp_new_num_vertices14 = ARRAY_SIZE(exp_vertices14);
7524 /* Test 15. Weld with color, but as UBYTE4N instead of D3DCOLOR. It shows
7525 * that UBYTE4N and D3DCOLOR are compared the same way.
7526 */
7527 const struct vertex_color_ubyte4 vertices15[] =
7528 {
7529 {{ 0.0f, 3.0f, 0.f}, {255, 255, 255, 255}},
7530 {{ 2.0f, 3.0f, 0.f}, {255, 255, 255, 255}},
7531 {{ 0.0f, 0.0f, 0.f}, {255, 255, 255, 255}},
7532
7533 {{ 3.0f, 3.0f, 0.f}, { 0, 0, 0, 0}},
7534 {{ 3.0f, 0.0f, 0.f}, {255, 255, 255, 255}},
7535 {{ 1.0f, 0.0f, 0.f}, { 1, 1, 1, 1}},
7536 };
7537 const DWORD indices15[] = {0, 1, 2, 3, 4, 5};
7538 const DWORD attributes15[] = {0, 0};
7539 const UINT num_vertices15 = ARRAY_SIZE(vertices15);
7540 const UINT num_faces15 = ARRAY_SIZE(indices15) / VERTS_PER_FACE;
7542 const D3DXWELDEPSILONS epsilons15 = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 254.0f/255.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7543 const DWORD adjacency15[] = {-1, 1, -1, -1, -1, 0};
7544 const struct vertex_color_ubyte4 exp_vertices15[] =
7545 {
7546 {{ 0.0f, 3.0f, 0.f}, {255, 255, 255, 255}},
7547 {{ 2.0f, 3.0f, 0.f}, {255, 255, 255, 255}},
7548 {{ 0.0f, 0.0f, 0.f}, {255, 255, 255, 255}},
7549
7550 {{ 2.0f, 3.0f, 0.f}, { 0, 0, 0, 0}},
7551 {{ 3.0f, 0.0f, 0.f}, {255, 255, 255, 255}},
7552 };
7553 const DWORD exp_indices15[] = {0, 1, 2, 3, 4, 2};
7554 const DWORD exp_face_remap15[] = {0, 1};
7555 const DWORD exp_vertex_remap15[] = {0, 1, 2, 3, 4, -1};
7556 const DWORD exp_new_num_vertices15 = ARRAY_SIZE(exp_vertices15);
7557 /* Test 16. Weld with color, but as UBYTE4 instead of D3DCOLOR. It shows
7558 * that UBYTE4 is not normalized and that epsilon is truncated and compared
7559 * directly to each of the four bytes.
7560 */
7561 const struct vertex_color_ubyte4 vertices16[] =
7562 {
7563 {{ 0.0f, 3.0f, 0.f}, {255, 255, 255, 255}},
7564 {{ 2.0f, 3.0f, 0.f}, {255, 255, 255, 255}},
7565 {{ 0.0f, 0.0f, 0.f}, {255, 255, 255, 255}},
7566
7567 {{ 3.0f, 3.0f, 0.f}, { 0, 0, 0, 0}},
7568 {{ 3.0f, 0.0f, 0.f}, {255, 255, 255, 255}},
7569 {{ 1.0f, 0.0f, 0.f}, { 1, 1, 1, 1}},
7570 };
7571 const DWORD indices16[] = {0, 1, 2, 3, 4, 5};
7572 const DWORD attributes16[] = {0, 0};
7573 const UINT num_vertices16 = ARRAY_SIZE(vertices16);
7574 const UINT num_faces16 = ARRAY_SIZE(indices16) / VERTS_PER_FACE;
7576 const D3DXWELDEPSILONS epsilons16 = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 254.9f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7577 const DWORD adjacency16[] = {-1, 1, -1, -1, -1, 0};
7578 const struct vertex_color_ubyte4 exp_vertices16[] =
7579 {
7580 {{ 0.0f, 3.0f, 0.f}, {255, 255, 255, 255}},
7581 {{ 2.0f, 3.0f, 0.f}, {255, 255, 255, 255}},
7582 {{ 0.0f, 0.0f, 0.f}, {255, 255, 255, 255}},
7583
7584 {{ 2.0f, 3.0f, 0.f}, { 0, 0, 0, 0}},
7585 {{ 3.0f, 0.0f, 0.f}, {255, 255, 255, 255}},
7586 };
7587 const DWORD exp_indices16[] = {0, 1, 2, 3, 4, 2};
7588 const DWORD exp_face_remap16[] = {0, 1};
7589 const DWORD exp_vertex_remap16[] = {0, 1, 2, 3, 4, -1};
7590 const DWORD exp_new_num_vertices16 = ARRAY_SIZE(exp_vertices16);
7591 /* Test 17. Weld texture coordinates but as SHORT2 instead of D3DXVECTOR2.*/
7592 const struct vertex_texcoord_short2 vertices17[] =
7593 {
7594 {{ 0.0f, 3.0f, 0.f}, { 0, 0}},
7595 {{ 2.0f, 3.0f, 0.f}, { 0, 0}},
7596 {{ 0.0f, 0.0f, 0.f}, { 0, 0}},
7597
7598 {{ 3.0f, 3.0f, 0.f}, {32767, 32767}},
7599 {{ 3.0f, 0.0f, 0.f}, {0, 0}},
7600 {{ 1.0f, 0.0f, 0.f}, {32766, 32766}},
7601 };
7602 const DWORD indices17[] = {0, 1, 2, 3, 4, 5};
7603 const DWORD attributes17[] = {0, 0};
7604 const UINT num_vertices17 = ARRAY_SIZE(vertices17);
7605 const UINT num_faces17 = ARRAY_SIZE(indices17) / VERTS_PER_FACE;
7607 const D3DXWELDEPSILONS epsilons17 = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, {32766.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7608 const DWORD adjacency17[] = {-1, 1, -1, -1, -1, 0};
7609 const struct vertex_texcoord_short2 exp_vertices17[] =
7610 {
7611 {{ 0.0f, 3.0f, 0.f}, { 0, 0}},
7612 {{ 2.0f, 3.0f, 0.f}, { 0, 0}},
7613 {{ 0.0f, 0.0f, 0.f}, { 0, 0}},
7614
7615 {{ 2.0f, 3.0f, 0.f}, {32767, 32767}},
7616 {{ 3.0f, 0.0f, 0.f}, {0, 0}},
7617 };
7618 const DWORD exp_indices17[] = {0, 1, 2, 3, 4, 2};
7619 const DWORD exp_face_remap17[] = {0, 1};
7620 const DWORD exp_vertex_remap17[] = {0, 1, 2, 3, 4, -1};
7621 const DWORD exp_new_num_vertices17 = ARRAY_SIZE(exp_vertices17);
7622 /* Test 18. Weld texture coordinates but as SHORT2N instead of D3DXVECTOR2. */
7623 const struct vertex_texcoord_short2 vertices18[] =
7624 {
7625 {{ 0.0f, 3.0f, 0.f}, { 0, 0}},
7626 {{ 2.0f, 3.0f, 0.f}, { 0, 0}},
7627 {{ 0.0f, 0.0f, 0.f}, { 0, 0}},
7628
7629 {{ 3.0f, 3.0f, 0.f}, {32767, 32767}},
7630 {{ 3.0f, 0.0f, 0.f}, {0, 0}},
7631 {{ 1.0f, 0.0f, 0.f}, {32766, 32766}},
7632 };
7633 const DWORD indices18[] = {0, 1, 2, 3, 4, 5};
7634 const DWORD attributes18[] = {0, 0};
7635 const UINT num_vertices18 = ARRAY_SIZE(vertices18);
7636 const UINT num_faces18 = ARRAY_SIZE(indices18) / VERTS_PER_FACE;
7638 const D3DXWELDEPSILONS epsilons18 = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, {32766.0f/32767.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7639 const DWORD adjacency18[] = {-1, 1, -1, -1, -1, 0};
7640 const struct vertex_texcoord_short2 exp_vertices18[] =
7641 {
7642 {{ 0.0f, 3.0f, 0.f}, { 0, 0}},
7643 {{ 2.0f, 3.0f, 0.f}, { 0, 0}},
7644 {{ 0.0f, 0.0f, 0.f}, { 0, 0}},
7645
7646 {{ 2.0f, 3.0f, 0.f}, {32767, 32767}},
7647 {{ 3.0f, 0.0f, 0.f}, {0, 0}},
7648 };
7649 const DWORD exp_indices18[] = {0, 1, 2, 3, 4, 2};
7650 const DWORD exp_face_remap18[] = {0, 1};
7651 const DWORD exp_vertex_remap18[] = {0, 1, 2, 3, 4, -1};
7652 const DWORD exp_new_num_vertices18 = ARRAY_SIZE(exp_vertices18);
7653 /* Test 19. Weld texture coordinates but as USHORT2N instead of D3DXVECTOR2. */
7654 const struct vertex_texcoord_ushort2n vertices19[] =
7655 {
7656 {{ 0.0f, 3.0f, 0.f}, { 0, 0}},
7657 {{ 2.0f, 3.0f, 0.f}, { 0, 0}},
7658 {{ 0.0f, 0.0f, 0.f}, { 0, 0}},
7659
7660 {{ 3.0f, 3.0f, 0.f}, {65535, 65535}},
7661 {{ 3.0f, 0.0f, 0.f}, {0, 0}},
7662 {{ 1.0f, 0.0f, 0.f}, {65534, 65534}},
7663 };
7664 const DWORD indices19[] = {0, 1, 2, 3, 4, 5};
7665 const DWORD attributes19[] = {0, 0};
7666 const UINT num_vertices19 = ARRAY_SIZE(vertices19);
7667 const UINT num_faces19 = ARRAY_SIZE(indices19) / VERTS_PER_FACE;
7669 const D3DXWELDEPSILONS epsilons19 = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, {65534.0f/65535.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7670 const DWORD adjacency19[] = {-1, 1, -1, -1, -1, 0};
7671 const struct vertex_texcoord_ushort2n exp_vertices19[] =
7672 {
7673 {{ 0.0f, 3.0f, 0.f}, { 0, 0}},
7674 {{ 2.0f, 3.0f, 0.f}, { 0, 0}},
7675 {{ 0.0f, 0.0f, 0.f}, { 0, 0}},
7676
7677 {{ 2.0f, 3.0f, 0.f}, {65535, 65535}},
7678 {{ 3.0f, 0.0f, 0.f}, {0, 0}},
7679 };
7680 const DWORD exp_indices19[] = {0, 1, 2, 3, 4, 2};
7681 const DWORD exp_face_remap19[] = {0, 1};
7682 const DWORD exp_vertex_remap19[] = {0, 1, 2, 3, 4, -1};
7683 const DWORD exp_new_num_vertices19 = ARRAY_SIZE(exp_vertices19);
7684 /* Test 20. Weld normal as SHORT4 instead of D3DXVECTOR3. */
7685 const struct vertex_normal_short4 vertices20[] =
7686 {
7687 {{ 0.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
7688 {{ 2.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
7689 {{ 0.0f, 0.0f, 0.f}, {0, 0, 0, 0}},
7690
7691 {{ 3.0f, 3.0f, 0.f}, {32767, 32767, 32767, 32767}},
7692 {{ 3.0f, 0.0f, 0.f}, {0, 0, 0, 0}},
7693 {{ 1.0f, 0.0f, 0.f}, {32766, 32766, 32766, 32766}},
7694 };
7695 const DWORD indices20[] = {0, 1, 2, 3, 4, 5};
7696 const DWORD attributes20[] = {0, 0};
7697 const UINT num_vertices20 = ARRAY_SIZE(vertices20);
7698 const UINT num_faces20 = ARRAY_SIZE(indices20) / VERTS_PER_FACE;
7700 const D3DXWELDEPSILONS epsilons20 = {1.0f, 0.0f, 32766.0f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7701 const DWORD adjacency20[] = {-1, 1, -1, -1, -1, 0};
7702 const struct vertex_normal_short4 exp_vertices20[] =
7703 {
7704 {{ 0.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
7705 {{ 2.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
7706 {{ 0.0f, 0.0f, 0.f}, {0, 0, 0, 0}},
7707
7708 {{ 2.0f, 3.0f, 0.f}, {32767, 32767, 32767, 32767}},
7709 {{ 3.0f, 0.0f, 0.f}, {0, 0, 0, 0}},
7710 };
7711 const DWORD exp_indices20[] = {0, 1, 2, 3, 4, 2};
7712 const DWORD exp_face_remap20[] = {0, 1};
7713 const DWORD exp_vertex_remap20[] = {0, 1, 2, 3, 4, -1};
7714 const DWORD exp_new_num_vertices20 = ARRAY_SIZE(exp_vertices20);
7715 /* Test 21. Weld normal as SHORT4N instead of D3DXVECTOR3. */
7716 const struct vertex_normal_short4 vertices21[] =
7717 {
7718 {{ 0.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
7719 {{ 2.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
7720 {{ 0.0f, 0.0f, 0.f}, {0, 0, 0, 0}},
7721
7722 {{ 3.0f, 3.0f, 0.f}, {32767, 32767, 32767, 32767}},
7723 {{ 3.0f, 0.0f, 0.f}, {0, 0, 0, 0}},
7724 {{ 1.0f, 0.0f, 0.f}, {32766, 32766, 32766, 32766}},
7725 };
7726 const DWORD indices21[] = {0, 1, 2, 3, 4, 5};
7727 const DWORD attributes21[] = {0, 0};
7728 const UINT num_vertices21 = ARRAY_SIZE(vertices21);
7729 const UINT num_faces21 = ARRAY_SIZE(indices21) / VERTS_PER_FACE;
7731 const D3DXWELDEPSILONS epsilons21 = {1.0f, 0.0f, 32766.0f/32767.0f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7732 const DWORD adjacency21[] = {-1, 1, -1, -1, -1, 0};
7733 const struct vertex_normal_short4 exp_vertices21[] =
7734 {
7735 {{ 0.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
7736 {{ 2.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
7737 {{ 0.0f, 0.0f, 0.f}, {0, 0, 0, 0}},
7738
7739 {{ 2.0f, 3.0f, 0.f}, {32767, 32767, 32767, 32767}},
7740 {{ 3.0f, 0.0f, 0.f}, {0, 0, 0, 0}},
7741 };
7742 const DWORD exp_indices21[] = {0, 1, 2, 3, 4, 2};
7743 const DWORD exp_face_remap21[] = {0, 1};
7744 const DWORD exp_vertex_remap21[] = {0, 1, 2, 3, 4, -1};
7745 const DWORD exp_new_num_vertices21 = ARRAY_SIZE(exp_vertices21);
7746 /* Test 22. Weld normal as USHORT4N instead of D3DXVECTOR3. */
7747 const struct vertex_normal_short4 vertices22[] =
7748 {
7749 {{ 0.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
7750 {{ 2.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
7751 {{ 0.0f, 0.0f, 0.f}, {0, 0, 0, 0}},
7752
7753 {{ 3.0f, 3.0f, 0.f}, {-1, -1, -1, -1}},
7754 {{ 3.0f, 0.0f, 0.f}, {0, 0, 0, 0}},
7755 {{ 1.0f, 0.0f, 0.f}, {-2, -2, -2, -2}},
7756 };
7757 const DWORD indices22[] = {0, 1, 2, 3, 4, 5};
7758 const DWORD attributes22[] = {0, 0};
7759 const UINT num_vertices22 = ARRAY_SIZE(vertices22);
7760 const UINT num_faces22 = ARRAY_SIZE(indices22) / VERTS_PER_FACE;
7762 const D3DXWELDEPSILONS epsilons22 = {1.0f, 0.0f, 65534.0f/65535.0f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7763 const DWORD adjacency22[] = {-1, 1, -1, -1, -1, 0};
7764 const struct vertex_normal_short4 exp_vertices22[] =
7765 {
7766 {{ 0.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
7767 {{ 2.0f, 3.0f, 0.f}, {0, 0, 0, 0}},
7768 {{ 0.0f, 0.0f, 0.f}, {0, 0, 0, 0}},
7769
7770 {{ 2.0f, 3.0f, 0.f}, {-1, -1, -1, -1}},
7771 {{ 3.0f, 0.0f, 0.f}, {0, 0, 0, 0}},
7772 };
7773 const DWORD exp_indices22[] = {0, 1, 2, 3, 4, 2};
7774 const DWORD exp_face_remap22[] = {0, 1};
7775 const DWORD exp_vertex_remap22[] = {0, 1, 2, 3, 4, -1};
7776 const DWORD exp_new_num_vertices22 = ARRAY_SIZE(exp_vertices22);
7777 /* Test 23. Weld texture coordinates as FLOAT16_2. Similar to test 11, but
7778 * with texture coordinates converted to float16 in hex. */
7779 const struct vertex_texcoord_float16_2 vertices23[] =
7780 {
7781 {{ 0.0f, 3.0f, 0.f}, {0x3c00, 0x3c00}}, /* {1.0f, 1.0f} */
7782 {{ 2.0f, 3.0f, 0.f}, {0x3800, 0x399a}}, /* {0.5f, 0.7f} */
7783 {{ 0.0f, 0.0f, 0.f}, {0xb266, 0xb4cd}}, /* {-0.2f, -0.3f} */
7784
7785 {{ 3.0f, 3.0f, 0.f}, {0x3266, 0x34cd}}, /* {0.2f, 0.3f} */
7786 {{ 3.0f, 0.0f, 0.f}, {0x3c00, 0x3c00}}, /* {1.0f, 1.0f} */
7787 {{ 1.0f, 0.0f, 0.f}, {0x2e66, 0x3266}}, /* {0.1f, 0.2f} */
7788 };
7789 const DWORD indices23[] = {0, 1, 2, 3, 4, 5};
7790 const DWORD attributes23[] = {0, 0};
7791 const UINT num_vertices23 = ARRAY_SIZE(vertices23);
7792 const UINT num_faces23 = ARRAY_SIZE(indices23) / VERTS_PER_FACE;
7794 const D3DXWELDEPSILONS epsilons23 = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, {0.41f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7795 const DWORD adjacency23[] = {-1, 1, -1, -1, -1, 0};
7796 const struct vertex_texcoord_float16_2 exp_vertices23[] =
7797 {
7798 {{ 0.0f, 3.0f, 0.f}, {0x3c00, 0x3c00}}, /* {1.0f, 1.0f} */
7799 {{ 2.0f, 3.0f, 0.f}, {0x3800, 0x399a}}, /* {0.5f, 0.7f} */
7800 {{ 0.0f, 0.0f, 0.f}, {0xb266, 0xb4cd}}, /* {-0.2f, -0.3f} */
7801
7802 {{ 3.0f, 0.0f, 0.f}, {0x3c00, 0x3c00}}, /* {1.0f, 1.0f} */
7803 {{ 0.0f, 0.0f, 0.f}, {0x2e66, 0x3266}}, /* {0.1f, 0.2f} */
7804 };
7805 const DWORD exp_indices23[] = {0, 1, 2, 1, 3, 4};
7806 const DWORD exp_face_remap23[] = {0, 1};
7807 const DWORD exp_vertex_remap23[] = {0, 1, 2, 4, 5, -1};
7808 const DWORD exp_new_num_vertices23 = ARRAY_SIZE(exp_vertices23);
7809 /* Test 24. Weld texture coordinates as FLOAT16_4. Similar to test 24. */
7810 const struct vertex_texcoord_float16_4 vertices24[] =
7811 {
7812 {{ 0.0f, 3.0f, 0.f}, {0x3c00, 0x3c00, 0x3c00, 0x3c00}},
7813 {{ 2.0f, 3.0f, 0.f}, {0x3800, 0x399a, 0x3800, 0x399a}},
7814 {{ 0.0f, 0.0f, 0.f}, {0xb266, 0xb4cd, 0xb266, 0xb4cd}},
7815
7816 {{ 3.0f, 3.0f, 0.f}, {0x3266, 0x34cd, 0x3266, 0x34cd}},
7817 {{ 3.0f, 0.0f, 0.f}, {0x3c00, 0x3c00, 0x3c00, 0x3c00}},
7818 {{ 1.0f, 0.0f, 0.f}, {0x2e66, 0x3266, 0x2e66, 0x3266}},
7819 };
7820 const DWORD indices24[] = {0, 1, 2, 3, 4, 5};
7821 const DWORD attributes24[] = {0, 0};
7822 const UINT num_vertices24 = ARRAY_SIZE(vertices24);
7823 const UINT num_faces24 = ARRAY_SIZE(indices24) / VERTS_PER_FACE;
7825 const D3DXWELDEPSILONS epsilons24 = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, {0.41f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7826 const DWORD adjacency24[] = {-1, 1, -1, -1, -1, 0};
7827 const struct vertex_texcoord_float16_4 exp_vertices24[] =
7828 {
7829 {{ 0.0f, 3.0f, 0.f}, {0x3c00, 0x3c00, 0x3c00, 0x3c00}},
7830 {{ 2.0f, 3.0f, 0.f}, {0x3800, 0x399a, 0x3800, 0x399a}},
7831 {{ 0.0f, 0.0f, 0.f}, {0xb266, 0xb4cd, 0xb266, 0xb4cd}},
7832
7833 {{ 3.0f, 0.0f, 0.f}, {0x3c00, 0x3c00, 0x3c00, 0x3c00}},
7834 {{ 0.0f, 0.0f, 0.f}, {0x2e66, 0x3266, 0x2e66, 0x3266}},
7835 };
7836 const DWORD exp_indices24[] = {0, 1, 2, 1, 3, 4};
7837 const DWORD exp_face_remap24[] = {0, 1};
7838 const DWORD exp_vertex_remap24[] = {0, 1, 2, 4, 5, -1};
7839 const DWORD exp_new_num_vertices24 = ARRAY_SIZE(exp_vertices24);
7840 /* Test 25. Weld texture coordinates with usage index 10 (TEXCOORD10). The
7841 * usage index is capped at 7, so the epsilon for TEXCOORD7 is used instead.
7842 */
7843 const struct vertex_texcoord vertices25[] =
7844 {
7845 {{ 0.0f, 3.0f, 0.f}, {1.0f, 1.0f}},
7846 {{ 2.0f, 3.0f, 0.f}, {0.5f, 0.7f}},
7847 {{ 0.0f, 0.0f, 0.f}, {-0.2f, -0.3f}},
7848
7849 {{ 3.0f, 3.0f, 0.f}, {0.2f, 0.3f}},
7850 {{ 3.0f, 0.0f, 0.f}, {1.0f, 1.0f}},
7851 {{ 1.0f, 0.0f, 0.f}, {0.1f, 0.2f}}
7852 };
7853 const DWORD indices25[] = {0, 1, 2, 3, 4, 5};
7854 const DWORD attributes25[] = {0, 0};
7855 const UINT num_vertices25 = ARRAY_SIZE(vertices25);
7856 const UINT num_faces25 = ARRAY_SIZE(indices25) / VERTS_PER_FACE;
7858 const D3DXWELDEPSILONS epsilons25 = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f + FLT_EPSILON}, 0.0f, 0.0f, 0.0f};
7859 const DWORD adjacency25[] = {-1, 1, -1, -1, -1, 0};
7860 const struct vertex_texcoord exp_vertices25[] =
7861 {
7862 {{ 0.0f, 3.0f, 0.f}, {1.0f, 1.0f}},
7863 {{ 2.0f, 3.0f, 0.f}, {0.5f, 0.7f}},
7864 {{ 0.0f, 0.0f, 0.f}, {-0.2f, -0.3f}},
7865
7866 {{ 3.0f, 0.0f, 0.f}, {1.0f, 1.0f}},
7867 {{ 0.0f, 0.0f, 0.f}, {0.1f, 0.2f}},
7868 };
7869 const DWORD exp_indices25[] = {0, 1, 2, 1, 3, 4};
7870 const DWORD exp_face_remap25[] = {0, 1};
7871 const DWORD exp_vertex_remap25[] = {0, 1, 2, 4, 5, -1};
7872 const DWORD exp_new_num_vertices25 = ARRAY_SIZE(exp_vertices25);
7873 /* Test 26. Weld color with usage index larger than 1. Shows that none of
7874 * the epsilon values are used. */
7875 const struct vertex_color vertices26[] =
7876 {
7877 {{ 0.0f, 3.0f, 0.f}, 0xFFFFFFFF},
7878 {{ 2.0f, 3.0f, 0.f}, 0xFFFFFFFF},
7879 {{ 0.0f, 0.0f, 0.f}, 0xFFFFFFFF},
7880
7881 {{ 3.0f, 3.0f, 0.f}, 0x00000000},
7882 {{ 3.0f, 0.0f, 0.f}, 0xFFFFFFFF},
7883 {{ 1.0f, 0.0f, 0.f}, 0x01010101},
7884 };
7885 const DWORD indices26[] = {0, 1, 2, 3, 4, 5};
7886 const DWORD attributes26[] = {0, 0};
7887 const UINT num_vertices26 = ARRAY_SIZE(vertices26);
7888 const UINT num_faces26 = ARRAY_SIZE(indices26) / VERTS_PER_FACE;
7890 const D3DXWELDEPSILONS epsilons26 = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}, 1.0f, 1.0f, 1.0f};
7891 const DWORD adjacency26[] = {-1, 1, -1, -1, -1, 0};
7892 const struct vertex_color exp_vertices26[] =
7893 {
7894 {{ 0.0f, 3.0f, 0.f}, 0xFFFFFFFF},
7895 {{ 2.0f, 3.0f, 0.f}, 0xFFFFFFFF},
7896 {{ 0.0f, 0.0f, 0.f}, 0xFFFFFFFF},
7897
7898 {{ 2.0f, 3.0f, 0.f}, 0x00000000},
7899 {{ 3.0f, 0.0f, 0.f}, 0xFFFFFFFF},
7900 {{ 0.0f, 0.0f, 0.f}, 0x01010101},
7901 };
7902 const DWORD exp_indices26[] = {0, 1, 2, 3, 4, 5};
7903 const DWORD exp_face_remap26[] = {0, 1};
7904 const DWORD exp_vertex_remap26[] = {0, 1, 2, 3, 4, 5};
7905 const DWORD exp_new_num_vertices26 = ARRAY_SIZE(exp_vertices26);
7906 /* Test 27. Weld color with usage index 1 (specular). */
7907 /* Previously this test used float color values and index > 1 but that case
7908 * appears to be effectively unhandled in native so the test gave
7909 * inconsistent results. */
7910 const struct vertex_color vertices27[] =
7911 {
7912 {{ 0.0f, 3.0f, 0.0f}, 0x00000000},
7913 {{ 2.0f, 3.0f, 0.0f}, 0x10203040},
7914 {{ 0.0f, 0.0f, 0.0f}, 0x50607080},
7915
7916 {{ 3.0f, 3.0f, 0.0f}, 0x11213141},
7917 {{ 3.0f, 0.0f, 0.0f}, 0xffffffff},
7918 {{ 1.0f, 0.0f, 0.0f}, 0x51617181},
7919 };
7920 const DWORD indices27[] = {0, 1, 2, 3, 4, 5};
7921 const DWORD attributes27[] = {0, 0};
7922 const UINT num_vertices27 = ARRAY_SIZE(vertices27);
7923 const UINT num_faces27 = ARRAY_SIZE(indices27) / VERTS_PER_FACE;
7925 const D3DXWELDEPSILONS epsilons27 =
7926 {
7927 1.1f, 0.0f, 0.0f, 0.0f, 2.0f / 255.0f, 0.0f,
7928 {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f
7929 };
7930 const DWORD adjacency27[] = {-1, 1, -1, -1, -1, 0};
7931 const struct vertex_color exp_vertices27[] =
7932 {
7933 {{ 0.0f, 3.0f, 0.0f}, 0x00000000},
7934 {{ 2.0f, 3.0f, 0.0f}, 0x10203040},
7935 {{ 0.0f, 0.0f, 0.0f}, 0x50607080},
7936
7937 {{ 3.0f, 0.0f, 0.0f}, 0xffffffff},
7938 };
7939 const DWORD exp_indices27[] = {0, 1, 2, 1, 3, 2};
7940 const DWORD exp_face_remap27[] = {0, 1};
7941 const DWORD exp_vertex_remap27[] = {0, 1, 2, 4, -1, -1};
7942 const DWORD exp_new_num_vertices27 = ARRAY_SIZE(exp_vertices27);
7943 /* Test 28. Weld one normal with UDEC3. */
7944 const DWORD dword_udec3_zero = init_udec3_dword(0, 0, 0, 1);
7945 const DWORD dword_udec3_1023 = init_udec3_dword(1023, 1023, 1023, 1);
7946 const DWORD dword_udec3_1022 = init_udec3_dword(1022, 1022, 1022, 1);
7947 const struct vertex_normal_udec3 vertices28[] =
7948 {
7949 {{ 0.0f, 3.0f, 0.f}, dword_udec3_zero},
7950 {{ 2.0f, 3.0f, 0.f}, dword_udec3_zero},
7951 {{ 0.0f, 0.0f, 0.f}, dword_udec3_zero},
7952
7953 {{ 3.0f, 3.0f, 0.f}, dword_udec3_1023},
7954 {{ 3.0f, 0.0f, 0.f}, dword_udec3_zero},
7955 {{ 1.0f, 0.0f, 0.f}, dword_udec3_1022},
7956 };
7957 const DWORD indices28[] = {0, 1, 2, 3, 4, 5};
7958 const DWORD attributes28[] = {0, 0};
7959 const UINT num_vertices28 = ARRAY_SIZE(vertices28);
7960 const UINT num_faces28 = ARRAY_SIZE(indices28) / VERTS_PER_FACE;
7962 const D3DXWELDEPSILONS epsilons28 = {1.0f, 0.0f, 1022.0f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, 0.0f};
7963 const DWORD adjacency28[] = {-1, 1, -1, -1, -1, 0};
7964 const struct vertex_normal_udec3 exp_vertices28[] =
7965 {
7966 {{ 0.0f, 3.0f, 0.f}, dword_udec3_zero},
7967 {{ 2.0f, 3.0f, 0.f}, dword_udec3_zero},
7968 {{ 0.0f, 0.0f, 0.f}, dword_udec3_zero},
7969
7970 {{ 2.0f, 3.0f, 0.f}, dword_udec3_1023},
7971 {{ 3.0f, 0.0f, 0.f}, dword_udec3_zero},
7972 };
7973 const DWORD exp_indices28[] = {0, 1, 2, 3, 4, 2};
7974 const DWORD exp_face_remap28[] = {0, 1};
7975 const DWORD exp_vertex_remap28[] = {0, 1, 2, 3, 4, -1};
7976 const DWORD exp_new_num_vertices28 = ARRAY_SIZE(exp_vertices28);
7977 /* Test 29. Weld one normal with DEC3N. */
7978 const DWORD dword_dec3n_zero = init_dec3n_dword(0, 0, 0, 1);
7979 const DWORD dword_dec3n_511 = init_dec3n_dword(511, 511, 511, 1);
7980 const DWORD dword_dec3n_510 = init_dec3n_dword(510, 510, 510, 1);
7981 const struct vertex_normal_dec3n vertices29[] =
7982 {
7983 {{ 0.0f, 3.0f, 0.f}, dword_dec3n_zero},
7984 {{ 2.0f, 3.0f, 0.f}, dword_dec3n_zero},
7985 {{ 0.0f, 0.0f, 0.f}, dword_dec3n_zero},
7986
7987 {{ 3.0f, 3.0f, 0.f}, dword_dec3n_511},
7988 {{ 3.0f, 0.0f, 0.f}, dword_dec3n_zero},
7989 {{ 1.0f, 0.0f, 0.f}, dword_dec3n_510},
7990 };
7991 const DWORD indices29[] = {0, 1, 2, 3, 4, 5};
7992 const DWORD attributes29[] = {0, 0};
7993 const UINT num_vertices29 = ARRAY_SIZE(vertices29);
7994 const UINT num_faces29 = ARRAY_SIZE(indices29) / VERTS_PER_FACE;
7996 const D3DXWELDEPSILONS epsilons29 = {1.0f, 0.0f, 510.0f/511.0f, 0.0f, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, .0f}, 0.0f, 0.0f, 0.0f};
7997 const DWORD adjacency29[] = {-1, 1, -1, -1, -1, 0};
7998 const struct vertex_normal_dec3n exp_vertices29[] =
7999 {
8000 {{ 0.0f, 3.0f, 0.f}, dword_dec3n_zero},
8001 {{ 2.0f, 3.0f, 0.f}, dword_dec3n_zero},
8002 {{ 0.0f, 0.0f, 0.f}, dword_dec3n_zero},
8003
8004 {{ 2.0f, 3.0f, 0.f}, dword_dec3n_511},
8005 {{ 3.0f, 0.0f, 0.f}, dword_dec3n_zero},
8006 };
8007 const DWORD exp_indices29[] = {0, 1, 2, 3, 4, 2};
8008 const DWORD exp_face_remap29[] = {0, 1};
8009 const DWORD exp_vertex_remap29[] = {0, 1, 2, 3, 4, -1};
8010 const DWORD exp_new_num_vertices29 = ARRAY_SIZE(exp_vertices29);
8011 /* All mesh data */
8012 DWORD *adjacency_out = NULL;
8013 DWORD *face_remap = NULL;
8014 ID3DXMesh *mesh = NULL;
8015 ID3DXBuffer *vertex_remap = NULL;
8016 struct
8017 {
8018 const BYTE *vertices;
8019 const DWORD *indices;
8020 const DWORD *attributes;
8021 const DWORD num_vertices;
8022 const DWORD num_faces;
8023 const DWORD options;
8025 const UINT vertex_size;
8026 const DWORD flags;
8027 const D3DXWELDEPSILONS *epsilons;
8028 const DWORD *adjacency;
8029 const BYTE *exp_vertices;
8030 const DWORD *exp_indices;
8031 const DWORD *exp_face_remap;
8032 const DWORD *exp_vertex_remap;
8033 const DWORD exp_new_num_vertices;
8034 }
8035 tc[] =
8036 {
8037 {
8038 (BYTE*)vertices0,
8039 indices0,
8040 attributes0,
8041 num_vertices0,
8042 num_faces0,
8043 options,
8044 declaration_normal,
8045 vertex_size_normal,
8046 flags0,
8047 NULL,
8048 adjacency0,
8049 (BYTE*)exp_vertices0,
8050 exp_indices0,
8051 exp_face_remap0,
8052 exp_vertex_remap0,
8053 exp_new_num_vertices0
8054 },
8055 {
8056 (BYTE*)vertices1,
8057 indices1,
8058 attributes1,
8059 num_vertices1,
8060 num_faces1,
8061 options,
8062 declaration_normal,
8063 vertex_size_normal,
8064 flags1,
8065 NULL,
8066 adjacency1,
8067 (BYTE*)exp_vertices1,
8068 exp_indices1,
8069 exp_face_remap1,
8070 exp_vertex_remap1,
8071 exp_new_num_vertices1
8072 },
8073 {
8074 (BYTE*)vertices2,
8075 indices2,
8076 attributes2,
8077 num_vertices2,
8078 num_faces2,
8079 options,
8080 declaration_normal,
8081 vertex_size_normal,
8082 flags2,
8083 &epsilons2,
8084 adjacency2,
8085 (BYTE*)exp_vertices2,
8086 exp_indices2,
8087 exp_face_remap2,
8088 exp_vertex_remap2,
8089 exp_new_num_vertices2
8090 },
8091 {
8092 (BYTE*)vertices3,
8093 indices3,
8094 attributes3,
8095 num_vertices3,
8096 num_faces3,
8097 options,
8098 declaration_normal,
8099 vertex_size_normal,
8100 flags3,
8101 &epsilons3,
8102 adjacency3,
8103 (BYTE*)exp_vertices3,
8104 exp_indices3,
8105 exp_face_remap3,
8106 exp_vertex_remap3,
8107 exp_new_num_vertices3
8108 },
8109 {
8110 (BYTE*)vertices4,
8111 indices4,
8112 attributes4,
8113 num_vertices4,
8114 num_faces4,
8115 options,
8116 declaration_normal,
8117 vertex_size_normal,
8118 flags4,
8119 &epsilons4,
8120 adjacency4,
8121 (BYTE*)exp_vertices4,
8122 exp_indices4,
8123 exp_face_remap4,
8124 exp_vertex_remap4,
8125 exp_new_num_vertices4
8126 },
8127 /* Unusual ordering. */
8128 {
8129 (BYTE*)vertices5,
8130 indices5,
8131 attributes5,
8132 num_vertices5,
8133 num_faces5,
8134 options,
8135 declaration_normal,
8136 vertex_size_normal,
8137 flags5,
8138 NULL,
8139 adjacency5,
8140 (BYTE*)exp_vertices5,
8141 exp_indices5,
8142 exp_face_remap5,
8143 exp_vertex_remap5,
8144 exp_new_num_vertices5
8145 },
8146 {
8147 (BYTE*)vertices6,
8148 indices6,
8149 attributes6,
8150 num_vertices6,
8151 num_faces6,
8152 options,
8153 declaration_normal,
8154 vertex_size_normal,
8155 flags6,
8156 &epsilons6,
8157 adjacency6,
8158 (BYTE*)exp_vertices6,
8159 exp_indices6,
8160 exp_face_remap6,
8161 exp_vertex_remap6,
8162 exp_new_num_vertices6
8163 },
8164 {
8165 (BYTE*)vertices6,
8166 (DWORD*)indices6_16bit,
8167 attributes6,
8168 num_vertices6,
8169 num_faces6,
8170 options_16bit,
8171 declaration_normal,
8172 vertex_size_normal,
8173 flags6,
8174 &epsilons6,
8175 adjacency6,
8176 (BYTE*)exp_vertices6,
8177 exp_indices6,
8178 exp_face_remap6,
8179 exp_vertex_remap6,
8180 exp_new_num_vertices6
8181 },
8182 {
8183 (BYTE*)vertices8,
8184 indices8,
8185 attributes8,
8186 num_vertices8,
8187 num_faces8,
8188 options,
8189 declaration_normal,
8190 vertex_size_normal,
8191 flags8,
8192 &epsilons8,
8193 adjacency8,
8194 (BYTE*)exp_vertices8,
8195 exp_indices8,
8196 exp_face_remap8,
8197 exp_vertex_remap8,
8198 exp_new_num_vertices8
8199 },
8200 {
8201 (BYTE*)vertices9,
8202 indices9,
8203 attributes9,
8204 num_vertices9,
8205 num_faces9,
8206 options,
8207 declaration_normal,
8208 vertex_size_normal,
8209 flags9,
8210 &epsilons9,
8211 adjacency9,
8212 (BYTE*)exp_vertices9,
8213 exp_indices9,
8214 exp_face_remap9,
8215 exp_vertex_remap9,
8216 exp_new_num_vertices9
8217 },
8218 {
8219 (BYTE*)vertices10,
8220 indices10,
8221 attributes10,
8222 num_vertices10,
8223 num_faces10,
8224 options,
8225 declaration_blendweight,
8226 vertex_size_blendweight,
8227 flags10,
8228 &epsilons10,
8229 adjacency10,
8230 (BYTE*)exp_vertices10,
8231 exp_indices10,
8232 exp_face_remap10,
8233 exp_vertex_remap10,
8234 exp_new_num_vertices10
8235 },
8236 {
8237 (BYTE*)vertices11,
8238 indices11,
8239 attributes11,
8240 num_vertices11,
8241 num_faces11,
8242 options,
8243 declaration_texcoord,
8244 vertex_size_texcoord,
8245 flags11,
8246 &epsilons11,
8247 adjacency11,
8248 (BYTE*)exp_vertices11,
8249 exp_indices11,
8250 exp_face_remap11,
8251 exp_vertex_remap11,
8252 exp_new_num_vertices11
8253 },
8254 {
8255 (BYTE*)vertices12,
8256 indices12,
8257 attributes12,
8258 num_vertices12,
8259 num_faces12,
8260 options,
8261 declaration_color,
8262 vertex_size_color,
8263 flags12,
8264 &epsilons12,
8265 adjacency12,
8266 (BYTE*)exp_vertices12,
8267 exp_indices12,
8268 exp_face_remap12,
8269 exp_vertex_remap12,
8270 exp_new_num_vertices12
8271 },
8272 {
8273 (BYTE*)vertices13,
8274 indices13,
8275 attributes13,
8276 num_vertices13,
8277 num_faces13,
8278 options,
8279 declaration_normal3,
8280 vertex_size_normal,
8281 flags13,
8282 &epsilons13,
8283 adjacency13,
8284 (BYTE*)exp_vertices13,
8285 exp_indices13,
8286 exp_face_remap13,
8287 exp_vertex_remap13,
8288 exp_new_num_vertices13
8289 },
8290 {
8291 (BYTE*)vertices14,
8292 indices14,
8293 attributes14,
8294 num_vertices14,
8295 num_faces14,
8296 options,
8297 declaration_color,
8298 vertex_size_color,
8299 flags14,
8300 &epsilons14,
8301 adjacency14,
8302 (BYTE*)exp_vertices14,
8303 exp_indices14,
8304 exp_face_remap14,
8305 exp_vertex_remap14,
8306 exp_new_num_vertices14
8307 },
8308 {
8309 (BYTE*)vertices15,
8310 indices15,
8311 attributes15,
8312 num_vertices15,
8313 num_faces15,
8314 options,
8315 declaration_color_ubyte4n,
8316 vertex_size_color_ubyte4, /* UBYTE4 same size as UBYTE4N */
8317 flags15,
8318 &epsilons15,
8319 adjacency15,
8320 (BYTE*)exp_vertices15,
8321 exp_indices15,
8322 exp_face_remap15,
8323 exp_vertex_remap15,
8324 exp_new_num_vertices15
8325 },
8326 {
8327 (BYTE*)vertices16,
8328 indices16,
8329 attributes16,
8330 num_vertices16,
8331 num_faces16,
8332 options,
8333 declaration_color_ubyte4,
8334 vertex_size_color_ubyte4,
8335 flags16,
8336 &epsilons16,
8337 adjacency16,
8338 (BYTE*)exp_vertices16,
8339 exp_indices16,
8340 exp_face_remap16,
8341 exp_vertex_remap16,
8342 exp_new_num_vertices16
8343 },
8344 {
8345 (BYTE*)vertices17,
8346 indices17,
8347 attributes17,
8348 num_vertices17,
8349 num_faces17,
8350 options,
8351 declaration_texcoord_short2,
8352 vertex_size_texcoord_short2,
8353 flags17,
8354 &epsilons17,
8355 adjacency17,
8356 (BYTE*)exp_vertices17,
8357 exp_indices17,
8358 exp_face_remap17,
8359 exp_vertex_remap17,
8360 exp_new_num_vertices17
8361 },
8362 {
8363 (BYTE*)vertices18,
8364 indices18,
8365 attributes18,
8366 num_vertices18,
8367 num_faces18,
8368 options,
8369 declaration_texcoord_short2n,
8370 vertex_size_texcoord_short2, /* SHORT2 same size as SHORT2N */
8371 flags18,
8372 &epsilons18,
8373 adjacency18,
8374 (BYTE*)exp_vertices18,
8375 exp_indices18,
8376 exp_face_remap18,
8377 exp_vertex_remap18,
8378 exp_new_num_vertices18
8379 },
8380 {
8381 (BYTE*)vertices19,
8382 indices19,
8383 attributes19,
8384 num_vertices19,
8385 num_faces19,
8386 options,
8387 declaration_texcoord_ushort2n,
8388 vertex_size_texcoord_short2, /* SHORT2 same size as USHORT2N */
8389 flags19,
8390 &epsilons19,
8391 adjacency19,
8392 (BYTE*)exp_vertices19,
8393 exp_indices19,
8394 exp_face_remap19,
8395 exp_vertex_remap19,
8396 exp_new_num_vertices19
8397 },
8398 {
8399 (BYTE*)vertices20,
8400 indices20,
8401 attributes20,
8402 num_vertices20,
8403 num_faces20,
8404 options,
8405 declaration_normal_short4,
8406 vertex_size_normal_short4,
8407 flags20,
8408 &epsilons20,
8409 adjacency20,
8410 (BYTE*)exp_vertices20,
8411 exp_indices20,
8412 exp_face_remap20,
8413 exp_vertex_remap20,
8414 exp_new_num_vertices20
8415 },
8416 {
8417 (BYTE*)vertices21,
8418 indices21,
8419 attributes21,
8420 num_vertices21,
8421 num_faces21,
8422 options,
8423 declaration_normal_short4n,
8424 vertex_size_normal_short4, /* SHORT4 same size as SHORT4N */
8425 flags21,
8426 &epsilons21,
8427 adjacency21,
8428 (BYTE*)exp_vertices21,
8429 exp_indices21,
8430 exp_face_remap21,
8431 exp_vertex_remap21,
8432 exp_new_num_vertices21
8433 },
8434 {
8435 (BYTE*)vertices22,
8436 indices22,
8437 attributes22,
8438 num_vertices22,
8439 num_faces22,
8440 options,
8441 declaration_normal_ushort4n,
8442 vertex_size_normal_short4, /* SHORT4 same size as USHORT4N */
8443 flags22,
8444 &epsilons22,
8445 adjacency22,
8446 (BYTE*)exp_vertices22,
8447 exp_indices22,
8448 exp_face_remap22,
8449 exp_vertex_remap22,
8450 exp_new_num_vertices22
8451 },
8452 {
8453 (BYTE*)vertices23,
8454 indices23,
8455 attributes23,
8456 num_vertices23,
8457 num_faces23,
8458 options,
8459 declaration_texcoord_float16_2,
8460 vertex_size_texcoord_float16_2,
8461 flags23,
8462 &epsilons23,
8463 adjacency23,
8464 (BYTE*)exp_vertices23,
8465 exp_indices23,
8466 exp_face_remap23,
8467 exp_vertex_remap23,
8468 exp_new_num_vertices23
8469 },
8470 {
8471 (BYTE*)vertices24,
8472 indices24,
8473 attributes24,
8474 num_vertices24,
8475 num_faces24,
8476 options,
8477 declaration_texcoord_float16_4,
8478 vertex_size_texcoord_float16_4,
8479 flags24,
8480 &epsilons24,
8481 adjacency24,
8482 (BYTE*)exp_vertices24,
8483 exp_indices24,
8484 exp_face_remap24,
8485 exp_vertex_remap24,
8486 exp_new_num_vertices24
8487 },
8488 {
8489 (BYTE*)vertices25,
8490 indices25,
8491 attributes25,
8492 num_vertices25,
8493 num_faces25,
8494 options,
8495 declaration_texcoord10,
8496 vertex_size_texcoord,
8497 flags25,
8498 &epsilons25,
8499 adjacency25,
8500 (BYTE*)exp_vertices25,
8501 exp_indices25,
8502 exp_face_remap25,
8503 exp_vertex_remap25,
8504 exp_new_num_vertices25
8505 },
8506 {
8507 (BYTE*)vertices26,
8508 indices26,
8509 attributes26,
8510 num_vertices26,
8511 num_faces26,
8512 options,
8513 declaration_color2,
8514 vertex_size_color,
8515 flags26,
8516 &epsilons26,
8517 adjacency26,
8518 (BYTE*)exp_vertices26,
8519 exp_indices26,
8520 exp_face_remap26,
8521 exp_vertex_remap26,
8522 exp_new_num_vertices26
8523 },
8524 {
8525 (BYTE*)vertices27,
8526 indices27,
8527 attributes27,
8528 num_vertices27,
8529 num_faces27,
8530 options,
8531 declaration_color1,
8532 vertex_size_color,
8533 flags27,
8534 &epsilons27,
8535 adjacency27,
8536 (BYTE*)exp_vertices27,
8537 exp_indices27,
8538 exp_face_remap27,
8539 exp_vertex_remap27,
8540 exp_new_num_vertices27
8541 },
8542 {
8543 (BYTE*)vertices28,
8544 indices28,
8545 attributes28,
8546 num_vertices28,
8547 num_faces28,
8548 options,
8549 declaration_normal_udec3,
8550 vertex_size_normal_udec3,
8551 flags28,
8552 &epsilons28,
8553 adjacency28,
8554 (BYTE*)exp_vertices28,
8555 exp_indices28,
8556 exp_face_remap28,
8557 exp_vertex_remap28,
8558 exp_new_num_vertices28
8559 },
8560 {
8561 (BYTE*)vertices29,
8562 indices29,
8563 attributes29,
8564 num_vertices29,
8565 num_faces29,
8566 options,
8567 declaration_normal_dec3n,
8568 vertex_size_normal_dec3n,
8569 flags29,
8570 &epsilons29,
8571 adjacency29,
8572 (BYTE*)exp_vertices29,
8573 exp_indices29,
8574 exp_face_remap29,
8575 exp_vertex_remap29,
8576 exp_new_num_vertices29
8577 }
8578 };
8579
8581 if (!test_context)
8582 {
8583 skip("Couldn't create test context\n");
8584 goto cleanup;
8585 }
8586
8587 for (i = 0; i < ARRAY_SIZE(tc); i++)
8588 {
8589 DWORD j;
8590 DWORD *vertex_remap_ptr;
8591 DWORD new_num_vertices;
8592
8593 hr = init_test_mesh(tc[i].num_faces, tc[i].num_vertices, tc[i].options,
8595 tc[i].vertices, tc[i].vertex_size,
8596 tc[i].indices, tc[i].attributes);
8597 if (FAILED(hr))
8598 {
8599 skip("Couldn't initialize test mesh %ld.\n", i);
8600 goto cleanup;
8601 }
8602
8603 /* Allocate out parameters */
8604 adjacency_out = malloc(VERTS_PER_FACE * tc[i].num_faces * sizeof(*adjacency_out));
8605 if (!adjacency_out)
8606 {
8607 skip("Couldn't allocate adjacency_out array.\n");
8608 goto cleanup;
8609 }
8610 face_remap = malloc(tc[i].num_faces * sizeof(*face_remap));
8611 if (!face_remap)
8612 {
8613 skip("Couldn't allocate face_remap array.\n");
8614 goto cleanup;
8615 }
8616
8617 hr = D3DXWeldVertices(mesh, tc[i].flags, tc[i].epsilons, tc[i].adjacency,
8618 adjacency_out, face_remap, &vertex_remap);
8619 ok(hr == D3D_OK, "Expected D3D_OK, got %#lx\n", hr);
8620 /* Check number of vertices*/
8621 new_num_vertices = mesh->lpVtbl->GetNumVertices(mesh);
8622 ok(new_num_vertices == tc[i].exp_new_num_vertices,
8623 "Mesh %ld: new_num_vertices == %ld, expected %ld.\n",
8624 i, new_num_vertices, tc[i].exp_new_num_vertices);
8625 /* Check index buffer */
8626 if (tc[i].options & D3DXMESH_32BIT)
8627 {
8628 hr = mesh->lpVtbl->LockIndexBuffer(mesh, 0, (void**)&indices);
8629 if (FAILED(hr))
8630 {
8631 skip("Couldn't lock index buffer.\n");
8632 goto cleanup;
8633 }
8634 for (j = 0; j < VERTS_PER_FACE * tc[i].num_faces; j++)
8635 {
8636 ok(indices[j] == tc[i].exp_indices[j],
8637 "Mesh %ld: indices[%ld] == %ld, expected %ld\n",
8638 i, j, indices[j], tc[i].exp_indices[j]);
8639 }
8640 }
8641 else
8642 {
8643 hr = mesh->lpVtbl->LockIndexBuffer(mesh, 0, (void**)&indices_16bit);
8644 if (FAILED(hr))
8645 {
8646 skip("Couldn't lock index buffer.\n");
8647 goto cleanup;
8648 }
8649 for (j = 0; j < VERTS_PER_FACE * tc[i].num_faces; j++)
8650 {
8651 ok(indices_16bit[j] == tc[i].exp_indices[j],
8652 "Mesh %ld: indices_16bit[%ld] == %d, expected %ld\n",
8653 i, j, indices_16bit[j], tc[i].exp_indices[j]);
8654 }
8655 }
8656 mesh->lpVtbl->UnlockIndexBuffer(mesh);
8657 indices = NULL;
8658 indices_16bit = NULL;
8659 /* Check adjacency_out */
8660 for (j = 0; j < VERTS_PER_FACE * tc[i].num_faces; j++)
8661 {
8662 ok(adjacency_out[j] == tc[i].adjacency[j],
8663 "Mesh %ld: adjacency_out[%ld] == %ld, expected %ld\n",
8664 i, j, adjacency_out[j], tc[i].adjacency[j]);
8665 }
8666 /* Check face_remap */
8667 for (j = 0; j < tc[i].num_faces; j++)
8668 {
8669 ok(face_remap[j] == tc[i].exp_face_remap[j],
8670 "Mesh %ld: face_remap[%ld] == %ld, expected %ld\n",
8671 i, j, face_remap[j], tc[i].exp_face_remap[j]);
8672 }
8673 /* Check vertex_remap */
8674 vertex_remap_ptr = vertex_remap->lpVtbl->GetBufferPointer(vertex_remap);
8675 for (j = 0; j < VERTS_PER_FACE * tc[i].num_faces; j++)
8676 {
8677 ok(vertex_remap_ptr[j] == tc[i].exp_vertex_remap[j],
8678 "Mesh %ld: vertex_remap_ptr[%ld] == %ld, expected %ld\n",
8679 i, j, vertex_remap_ptr[j], tc[i].exp_vertex_remap[j]);
8680 }
8681 /* Check vertex buffer */
8682 hr = mesh->lpVtbl->LockVertexBuffer(mesh, 0, (void*)&vertices);
8683 if (FAILED(hr))
8684 {
8685 skip("Couldn't lock vertex buffer.\n");
8686 goto cleanup;
8687 }
8688 /* Check contents of re-ordered vertex buffer */
8689 for (j = 0; j < tc[i].exp_new_num_vertices; j++)
8690 {
8691 int index = tc[i].vertex_size*j;
8692 check_vertex_components(__LINE__, i, j, &vertices[index], &tc[i].exp_vertices[index], tc[i].declaration);
8693 }
8694 mesh->lpVtbl->UnlockVertexBuffer(mesh);
8695 vertices = NULL;
8696
8697 /* Free mesh and output data */
8698 free(adjacency_out);
8699 adjacency_out = NULL;
8700 free(face_remap);
8701 face_remap = NULL;
8702 vertex_remap->lpVtbl->Release(vertex_remap);
8703 vertex_remap = NULL;
8704 mesh->lpVtbl->Release(mesh);
8705 mesh = NULL;
8706 }
8707
8708cleanup:
8709 free(adjacency_out);
8710 free(face_remap);
8711 if (indices) mesh->lpVtbl->UnlockIndexBuffer(mesh);
8712 if (indices_16bit) mesh->lpVtbl->UnlockIndexBuffer(mesh);
8713 if (mesh) mesh->lpVtbl->Release(mesh);
8714 if (vertex_remap) vertex_remap->lpVtbl->Release(vertex_remap);
8715 if (vertices) mesh->lpVtbl->UnlockVertexBuffer(mesh);
8717}
HRESULT WINAPI D3DXWeldVertices(ID3DXMesh *mesh, DWORD flags, const D3DXWELDEPSILONS *epsilons, const DWORD *adjacency, DWORD *adjacency_out, DWORD *face_remap_out, ID3DXBuffer **vertex_remap_out)
Definition: mesh.c:7104
#define FLT_EPSILON
Definition: float.h:35
@ D3DXWELDEPSILONS_DONOTREMOVEVERTICES
Definition: d3dx9mesh.h:151
@ D3DXWELDEPSILONS_DONOTSPLIT
Definition: d3dx9mesh.h:152
@ D3DXWELDEPSILONS_WELDALL
Definition: d3dx9mesh.h:149
@ D3DXWELDEPSILONS_WELDPARTIALMATCHES
Definition: d3dx9mesh.h:150
GLbitfield flags
Definition: glext.h:7161
static DWORD init_dec3n_dword(INT x, INT y, INT z, INT w)
Definition: mesh.c:6653
static DWORD init_udec3_dword(UINT x, UINT y, UINT z, UINT w)
Definition: mesh.c:6641

Referenced by START_TEST().

◆ unit_vec2()

static D3DXVECTOR2 * unit_vec2 ( D3DXVECTOR2 *  dir,
const D3DXVECTOR2 *  pt1,
const D3DXVECTOR2 *  pt2 
)
inlinestatic

Definition at line 3820 of file mesh.c.

3821{
3822 return D3DXVec2Normalize(dir, D3DXVec2Subtract(dir, pt2, pt1));
3823}
unsigned int dir
Definition: maze.c:112

◆ vertex_index()

static WORD vertex_index ( UINT  slices,
int  slice,
int  stack 
)
static

Definition at line 3081 of file mesh.c.

3082{
3083 return stack*slices+slice+1;
3084}

Variable Documentation

◆ alloc_hier

◆ ID3DXAllocateHierarchyImpl_Vtbl

ID3DXAllocateHierarchyVtbl ID3DXAllocateHierarchyImpl_Vtbl
static
Initial value:
= {
}
static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_CreateMeshContainer(ID3DXAllocateHierarchy *iface, const char *name, const D3DXMESHDATA *mesh_data, const D3DXMATERIAL *materials, const D3DXEFFECTINSTANCE *effects, DWORD num_materials, const DWORD *adjacency, ID3DXSkinInfo *skin_info, D3DXMESHCONTAINER **new_mesh_container)
Definition: mesh.c:1880
static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_DestroyFrame(ID3DXAllocateHierarchy *iface, LPD3DXFRAME frame)
Definition: mesh.c:1809
static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_DestroyMeshContainer(ID3DXAllocateHierarchy *iface, LPD3DXMESHCONTAINER mesh_container)
Definition: mesh.c:1874
static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_CreateFrame(ID3DXAllocateHierarchy *iface, const char *name, D3DXFRAME **new_frame)
Definition: mesh.c:1819

Definition at line 1985 of file mesh.c.

◆ load_user_data_vtbl

const struct ID3DXLoadUserDataVtbl load_user_data_vtbl
static
Initial value:
=
{
}
static HRESULT STDMETHODCALLTYPE load_mesh_child_data(ID3DXLoadUserData *iface, D3DXMESHCONTAINER *mesh_container, ID3DXFileData *filedata)
Definition: mesh.c:2110
static HRESULT STDMETHODCALLTYPE load_top_level_data(ID3DXLoadUserData *iface, ID3DXFileData *filedata)
Definition: mesh.c:2089
static HRESULT STDMETHODCALLTYPE load_frame_child_data(ID3DXLoadUserData *iface, D3DXFRAME *frame, ID3DXFileData *filedata)
Definition: mesh.c:2097

Definition at line 2121 of file mesh.c.

Referenced by init_load_user_data().