ReactOS 0.4.16-dev-197-g92996da
vertexdeclaration.c File Reference
#include "config.h"
#include "d3d9_private.h"
Include dependency graph for vertexdeclaration.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d9)
 
static struct d3d9_vertex_declarationimpl_from_IDirect3DVertexDeclaration9 (IDirect3DVertexDeclaration9 *iface)
 
HRESULT vdecl_convert_fvf (DWORD fvf, D3DVERTEXELEMENT9 **ppVertexElements)
 
static HRESULT WINAPI d3d9_vertex_declaration_QueryInterface (IDirect3DVertexDeclaration9 *iface, REFIID riid, void **out)
 
static ULONG WINAPI d3d9_vertex_declaration_AddRef (IDirect3DVertexDeclaration9 *iface)
 
static ULONG WINAPI d3d9_vertex_declaration_Release (IDirect3DVertexDeclaration9 *iface)
 
static HRESULT WINAPI d3d9_vertex_declaration_GetDevice (IDirect3DVertexDeclaration9 *iface, IDirect3DDevice9 **device)
 
static HRESULT WINAPI d3d9_vertex_declaration_GetDeclaration (IDirect3DVertexDeclaration9 *iface, D3DVERTEXELEMENT9 *elements, UINT *element_count)
 
struct d3d9_vertex_declarationunsafe_impl_from_IDirect3DVertexDeclaration9 (IDirect3DVertexDeclaration9 *iface)
 
static void STDMETHODCALLTYPE d3d9_vertexdeclaration_wined3d_object_destroyed (void *parent)
 
static HRESULT convert_to_wined3d_declaration (const D3DVERTEXELEMENT9 *d3d9_elements, struct wined3d_vertex_element **wined3d_elements, UINT *element_count)
 
static HRESULT vertexdeclaration_init (struct d3d9_vertex_declaration *declaration, struct d3d9_device *device, const D3DVERTEXELEMENT9 *elements)
 
HRESULT d3d9_vertex_declaration_create (struct d3d9_device *device, const D3DVERTEXELEMENT9 *elements, struct d3d9_vertex_declaration **declaration)
 

Variables

struct {
   enum wined3d_format_id   format
 
   unsigned int   component_count
 
   unsigned int   component_size
 
d3d_dtype_lookup []
 
static const struct IDirect3DVertexDeclaration9Vtbl d3d9_vertex_declaration_vtbl
 
static const struct wined3d_parent_ops d3d9_vertexdeclaration_wined3d_parent_ops
 

Function Documentation

◆ convert_to_wined3d_declaration()

static HRESULT convert_to_wined3d_declaration ( const D3DVERTEXELEMENT9 d3d9_elements,
struct wined3d_vertex_element **  wined3d_elements,
UINT element_count 
)
static

Definition at line 322 of file vertexdeclaration.c.

324{
326 UINT count = 1;
327 UINT i;
328
329 TRACE("d3d9_elements %p, wined3d_elements %p, element_count %p\n", d3d9_elements, wined3d_elements, element_count);
330
331 element = d3d9_elements;
332 while (element++->Stream != 0xff && count++ < 128);
333
334 if (count == 128) return E_FAIL;
335
336 /* Skip the END element */
337 --count;
338
339 if (!(*wined3d_elements = heap_alloc(count * sizeof(**wined3d_elements))))
340 {
341 FIXME("Memory allocation failed\n");
343 }
344
345 for (i = 0; i < count; ++i)
346 {
347 if (d3d9_elements[i].Type >= ARRAY_SIZE(d3d_dtype_lookup))
348 {
349 WARN("Invalid element type %#x.\n", d3d9_elements[i].Type);
350 heap_free(*wined3d_elements);
351 return E_FAIL;
352 }
353 (*wined3d_elements)[i].format = d3d_dtype_lookup[d3d9_elements[i].Type].format;
354 (*wined3d_elements)[i].input_slot = d3d9_elements[i].Stream;
355 (*wined3d_elements)[i].offset = d3d9_elements[i].Offset;
356 (*wined3d_elements)[i].output_slot = WINED3D_OUTPUT_SLOT_SEMANTIC;
357 (*wined3d_elements)[i].input_slot_class = WINED3D_INPUT_PER_VERTEX_DATA;
358 (*wined3d_elements)[i].instance_data_step_rate = 0;
359 (*wined3d_elements)[i].method = d3d9_elements[i].Method;
360 (*wined3d_elements)[i].usage = d3d9_elements[i].Usage;
361 (*wined3d_elements)[i].usage_idx = d3d9_elements[i].UsageIndex;
362 }
363
364 *element_count = count;
365
366 return D3D_OK;
367}
Type
Definition: Type.h:7
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
static const struct @229 d3d_dtype_lookup[]
#define D3D_OK
Definition: d3d.h:106
#define E_FAIL
Definition: ddrawi.h:102
GLuint GLuint GLsizei count
Definition: gl.h:1545
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
static IStream Stream
Definition: htmldoc.c:1115
unsigned int UINT
Definition: ndis.h:50
#define D3DERR_OUTOFVIDEOMEMORY
Definition: d3d8.h:85
#define TRACE(s)
Definition: solgame.cpp:4
#define WINED3D_OUTPUT_SLOT_SEMANTIC
Definition: wined3d.h:1566
@ WINED3D_INPUT_PER_VERTEX_DATA
Definition: wined3d.h:1785

◆ d3d9_vertex_declaration_AddRef()

static ULONG WINAPI d3d9_vertex_declaration_AddRef ( IDirect3DVertexDeclaration9 *  iface)
static

Definition at line 219 of file vertexdeclaration.c.

220{
223
224 TRACE("%p increasing refcount to %u.\n", iface, refcount);
225
226 if (refcount == 1)
227 {
232 }
233
234 return refcount;
235}
#define InterlockedIncrement
Definition: armddk.h:53
static struct d3d9_vertex_declaration * impl_from_IDirect3DVertexDeclaration9(IDirect3DVertexDeclaration9 *iface)
#define IDirect3DDevice9Ex_AddRef(p)
Definition: d3d9.h:1916
uint32_t ULONG
Definition: typedefs.h:59
ULONG CDECL wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration)
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368

◆ d3d9_vertex_declaration_create()

HRESULT d3d9_vertex_declaration_create ( struct d3d9_device device,
const D3DVERTEXELEMENT9 elements,
struct d3d9_vertex_declaration **  declaration 
)

Definition at line 415 of file vertexdeclaration.c.

417{
419 HRESULT hr;
420
421 if (!(object = heap_alloc_zero(sizeof(*object))))
422 return E_OUTOFMEMORY;
423
425 if (FAILED(hr))
426 {
427 WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
428 heap_free(object);
429 return hr;
430 }
431
432 TRACE("Created vertex declaration %p.\n", object);
434
435 return D3D_OK;
436}
static HRESULT vertexdeclaration_init(struct d3d9_vertex_declaration *declaration, struct d3d9_device *device, const D3DVERTEXELEMENT9 *elements)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183
D3DVERTEXELEMENT9 * elements
Definition: d3d9_private.h:242
Definition: devices.h:37

Referenced by d3d9_device_CreateVertexDeclaration(), and device_get_fvf_declaration().

◆ d3d9_vertex_declaration_GetDeclaration()

static HRESULT WINAPI d3d9_vertex_declaration_GetDeclaration ( IDirect3DVertexDeclaration9 *  iface,
D3DVERTEXELEMENT9 elements,
UINT element_count 
)
static

Definition at line 272 of file vertexdeclaration.c.

274{
276
277 TRACE("iface %p, elements %p, element_count %p.\n", iface, elements, element_count);
278
279 *element_count = declaration->element_count;
280
281 /* Passing a NULL elements is used to just retrieve the number of elements */
282 if (!elements)
283 return D3D_OK;
284
285 TRACE("Copying %p to %p.\n", declaration->elements, elements);
286 memcpy(elements, declaration->elements, sizeof(*declaration->elements) * declaration->element_count);
287
288 return D3D_OK;
289}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

◆ d3d9_vertex_declaration_GetDevice()

static HRESULT WINAPI d3d9_vertex_declaration_GetDevice ( IDirect3DVertexDeclaration9 *  iface,
IDirect3DDevice9 **  device 
)
static

Definition at line 258 of file vertexdeclaration.c.

259{
261
262 TRACE("iface %p, device %p.\n", iface, device);
263
264 *device = (IDirect3DDevice9 *)declaration->parent_device;
266
267 TRACE("Returning device %p.\n", *device);
268
269 return D3D_OK;
270}
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1507

◆ d3d9_vertex_declaration_QueryInterface()

static HRESULT WINAPI d3d9_vertex_declaration_QueryInterface ( IDirect3DVertexDeclaration9 *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 200 of file vertexdeclaration.c.

202{
203 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
204
205 if (IsEqualGUID(riid, &IID_IDirect3DVertexDeclaration9)
207 {
209 *out = iface;
210 return S_OK;
211 }
212
213 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
214
215 *out = NULL;
216 return E_NOINTERFACE;
217}
const GUID IID_IUnknown
#define IDirect3DVertexDeclaration9_AddRef(p)
Definition: d3d9.h:1184
#define NULL
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static FILE * out
Definition: regtests2xml.c:44
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ d3d9_vertex_declaration_Release()

static ULONG WINAPI d3d9_vertex_declaration_Release ( IDirect3DVertexDeclaration9 *  iface)
static

Definition at line 237 of file vertexdeclaration.c.

238{
241
242 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
243
244 if (!refcount)
245 {
246 IDirect3DDevice9Ex *parent_device = declaration->parent_device;
250
251 /* Release the device last, as it may cause the device to be destroyed. */
253 }
254
255 return refcount;
256}
#define InterlockedDecrement
Definition: armddk.h:52
#define IDirect3DDevice9Ex_Release(p)
Definition: d3d9.h:1917
IDirect3DDevice9Ex * parent_device
Definition: d3d9_private.h:246
ULONG CDECL wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration *declaration)

◆ d3d9_vertexdeclaration_wined3d_object_destroyed()

static void STDMETHODCALLTYPE d3d9_vertexdeclaration_wined3d_object_destroyed ( void parent)
static

Definition at line 310 of file vertexdeclaration.c.

311{
313 heap_free(declaration->elements);
315}
r parent
Definition: btrfs.c:3010

◆ impl_from_IDirect3DVertexDeclaration9()

static struct d3d9_vertex_declaration * impl_from_IDirect3DVertexDeclaration9 ( IDirect3DVertexDeclaration9 *  iface)
inlinestatic

Definition at line 54 of file vertexdeclaration.c.

55{
56 return CONTAINING_RECORD(iface, struct d3d9_vertex_declaration, IDirect3DVertexDeclaration9_iface);
57}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by d3d9_vertex_declaration_AddRef(), d3d9_vertex_declaration_GetDeclaration(), d3d9_vertex_declaration_GetDevice(), and d3d9_vertex_declaration_Release().

◆ unsafe_impl_from_IDirect3DVertexDeclaration9()

struct d3d9_vertex_declaration * unsafe_impl_from_IDirect3DVertexDeclaration9 ( IDirect3DVertexDeclaration9 *  iface)

Definition at line 302 of file vertexdeclaration.c.

303{
304 if (!iface)
305 return NULL;
306 assert(iface->lpVtbl == &d3d9_vertex_declaration_vtbl);
307 return CONTAINING_RECORD(iface, struct d3d9_vertex_declaration, IDirect3DVertexDeclaration9_iface);
308}
static const struct IDirect3DVertexDeclaration9Vtbl d3d9_vertex_declaration_vtbl
#define assert(x)
Definition: debug.h:53

Referenced by d3d9_device_ProcessVertices(), and d3d9_device_SetVertexDeclaration().

◆ vdecl_convert_fvf()

HRESULT vdecl_convert_fvf ( DWORD  fvf,
D3DVERTEXELEMENT9 **  ppVertexElements 
)

Definition at line 59 of file vertexdeclaration.c.

61 {
62
63 unsigned int idx, idx2;
64 unsigned int offset;
65 BOOL has_pos = (fvf & D3DFVF_POSITION_MASK) != 0;
66 BOOL has_blend = (fvf & D3DFVF_XYZB5) > D3DFVF_XYZRHW;
67 BOOL has_blend_idx = has_blend &&
68 (((fvf & D3DFVF_XYZB5) == D3DFVF_XYZB5) ||
71 BOOL has_normal = (fvf & D3DFVF_NORMAL) != 0;
72 BOOL has_psize = (fvf & D3DFVF_PSIZE) != 0;
73
74 BOOL has_diffuse = (fvf & D3DFVF_DIFFUSE) != 0;
75 BOOL has_specular = (fvf & D3DFVF_SPECULAR) !=0;
76
77 DWORD num_textures = (fvf & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
78 DWORD texcoords = (fvf & 0xFFFF0000) >> 16;
79
80 D3DVERTEXELEMENT9 end_element = D3DDECL_END();
81 D3DVERTEXELEMENT9 *elements = NULL;
82
83 unsigned int size;
84 DWORD num_blends = 1 + (((fvf & D3DFVF_XYZB5) - D3DFVF_XYZB1) >> 1);
85 if (has_blend_idx) num_blends--;
86
87 /* Compute declaration size */
88 size = has_pos + (has_blend && num_blends > 0) + has_blend_idx + has_normal +
89 has_psize + has_diffuse + has_specular + num_textures + 1;
90
91 /* convert the declaration */
92 if (!(elements = heap_alloc(size * sizeof(*elements))))
94
95 elements[size-1] = end_element;
96 idx = 0;
97 if (has_pos) {
98 if (!has_blend && (fvf & D3DFVF_XYZRHW)) {
99 elements[idx].Type = D3DDECLTYPE_FLOAT4;
100 elements[idx].Usage = D3DDECLUSAGE_POSITIONT;
101 }
102 else if (!has_blend && (fvf & D3DFVF_XYZW) == D3DFVF_XYZW) {
103 elements[idx].Type = D3DDECLTYPE_FLOAT4;
104 elements[idx].Usage = D3DDECLUSAGE_POSITION;
105 }
106 else {
107 elements[idx].Type = D3DDECLTYPE_FLOAT3;
108 elements[idx].Usage = D3DDECLUSAGE_POSITION;
109 }
110 elements[idx].UsageIndex = 0;
111 idx++;
112 }
113 if (has_blend && (num_blends > 0)) {
114 if (((fvf & D3DFVF_XYZB5) == D3DFVF_XYZB2) && (fvf & D3DFVF_LASTBETA_D3DCOLOR))
115 elements[idx].Type = D3DDECLTYPE_D3DCOLOR;
116 else {
117 switch(num_blends) {
118 case 1: elements[idx].Type = D3DDECLTYPE_FLOAT1; break;
119 case 2: elements[idx].Type = D3DDECLTYPE_FLOAT2; break;
120 case 3: elements[idx].Type = D3DDECLTYPE_FLOAT3; break;
121 case 4: elements[idx].Type = D3DDECLTYPE_FLOAT4; break;
122 default:
123 ERR("Unexpected amount of blend values: %u\n", num_blends);
124 }
125 }
127 elements[idx].UsageIndex = 0;
128 idx++;
129 }
130 if (has_blend_idx) {
131 if (fvf & D3DFVF_LASTBETA_UBYTE4 ||
132 (((fvf & D3DFVF_XYZB5) == D3DFVF_XYZB2) && (fvf & D3DFVF_LASTBETA_D3DCOLOR)))
133 elements[idx].Type = D3DDECLTYPE_UBYTE4;
134 else if (fvf & D3DFVF_LASTBETA_D3DCOLOR)
135 elements[idx].Type = D3DDECLTYPE_D3DCOLOR;
136 else
137 elements[idx].Type = D3DDECLTYPE_FLOAT1;
139 elements[idx].UsageIndex = 0;
140 idx++;
141 }
142 if (has_normal) {
143 elements[idx].Type = D3DDECLTYPE_FLOAT3;
144 elements[idx].Usage = D3DDECLUSAGE_NORMAL;
145 elements[idx].UsageIndex = 0;
146 idx++;
147 }
148 if (has_psize) {
149 elements[idx].Type = D3DDECLTYPE_FLOAT1;
150 elements[idx].Usage = D3DDECLUSAGE_PSIZE;
151 elements[idx].UsageIndex = 0;
152 idx++;
153 }
154 if (has_diffuse) {
155 elements[idx].Type = D3DDECLTYPE_D3DCOLOR;
156 elements[idx].Usage = D3DDECLUSAGE_COLOR;
157 elements[idx].UsageIndex = 0;
158 idx++;
159 }
160 if (has_specular) {
161 elements[idx].Type = D3DDECLTYPE_D3DCOLOR;
162 elements[idx].Usage = D3DDECLUSAGE_COLOR;
163 elements[idx].UsageIndex = 1;
164 idx++;
165 }
166 for (idx2 = 0; idx2 < num_textures; idx2++) {
167 unsigned int numcoords = (texcoords >> (idx2*2)) & 0x03;
168 switch (numcoords) {
170 elements[idx].Type = D3DDECLTYPE_FLOAT1;
171 break;
173 elements[idx].Type = D3DDECLTYPE_FLOAT2;
174 break;
176 elements[idx].Type = D3DDECLTYPE_FLOAT3;
177 break;
179 elements[idx].Type = D3DDECLTYPE_FLOAT4;
180 break;
181 }
182 elements[idx].Usage = D3DDECLUSAGE_TEXCOORD;
183 elements[idx].UsageIndex = idx2;
184 idx++;
185 }
186
187 /* Now compute offsets, and initialize the rest of the fields */
188 for (idx = 0, offset = 0; idx < size-1; idx++) {
189 elements[idx].Stream = 0;
190 elements[idx].Method = D3DDECLMETHOD_DEFAULT;
191 elements[idx].Offset = offset;
192 offset += d3d_dtype_lookup[elements[idx].Type].component_count
193 * d3d_dtype_lookup[elements[idx].Type].component_size;
194 }
195
196 *ppVertexElements = elements;
197 return D3D_OK;
198}
#define ERR(fmt,...)
Definition: precomp.h:57
#define D3DFVF_DIFFUSE
Definition: d3d8types.h:122
#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_NORMAL
Definition: d3d8types.h:120
#define D3DFVF_TEXTUREFORMAT4
Definition: d3d8types.h:63
#define D3DFVF_XYZB2
Definition: d3d8types.h:116
#define D3DFVF_TEXTUREFORMAT3
Definition: d3d8types.h:62
#define D3DFVF_TEXCOUNT_MASK
Definition: d3d8types.h:124
#define D3DFVF_TEXTUREFORMAT1
Definition: d3d8types.h:60
#define D3DFVF_PSIZE
Definition: d3d8types.h:121
#define D3DFVF_TEXTUREFORMAT2
Definition: d3d8types.h:61
#define D3DFVF_SPECULAR
Definition: d3d8types.h:123
#define D3DFVF_POSITION_MASK
Definition: d3d8types.h:112
@ D3DDECLUSAGE_BLENDWEIGHT
Definition: d3d9types.h:221
@ D3DDECLUSAGE_BLENDINDICES
Definition: d3d9types.h:222
@ D3DDECLUSAGE_POSITIONT
Definition: d3d9types.h:229
@ D3DDECLUSAGE_NORMAL
Definition: d3d9types.h:223
@ D3DDECLUSAGE_TEXCOORD
Definition: d3d9types.h:225
@ D3DDECLUSAGE_POSITION
Definition: d3d9types.h:220
@ D3DDECLUSAGE_PSIZE
Definition: d3d9types.h:224
@ D3DDECLUSAGE_COLOR
Definition: d3d9types.h:230
#define D3DFVF_LASTBETA_D3DCOLOR
Definition: d3d9types.h:160
@ D3DDECLTYPE_UBYTE4
Definition: d3d9types.h:260
@ D3DDECLTYPE_FLOAT3
Definition: d3d9types.h:257
@ D3DDECLTYPE_FLOAT1
Definition: d3d9types.h:255
@ D3DDECLTYPE_D3DCOLOR
Definition: d3d9types.h:259
@ D3DDECLTYPE_FLOAT2
Definition: d3d9types.h:256
@ D3DDECLTYPE_FLOAT4
Definition: d3d9types.h:258
#define D3DDECL_END()
Definition: d3d9types.h:311
#define D3DFVF_XYZW
Definition: d3d9types.h:143
@ D3DDECLMETHOD_DEFAULT
Definition: d3d9types.h:242
unsigned int idx
Definition: utils.c:41
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920

Referenced by device_get_fvf_declaration().

◆ vertexdeclaration_init()

static HRESULT vertexdeclaration_init ( struct d3d9_vertex_declaration declaration,
struct d3d9_device device,
const D3DVERTEXELEMENT9 elements 
)
static

Definition at line 369 of file vertexdeclaration.c.

371{
372 struct wined3d_vertex_element *wined3d_elements;
373 UINT wined3d_element_count;
374 UINT element_count;
375 HRESULT hr;
376
377 hr = convert_to_wined3d_declaration(elements, &wined3d_elements, &wined3d_element_count);
378 if (FAILED(hr))
379 {
380 WARN("Failed to create wined3d vertex declaration elements, hr %#x.\n", hr);
381 return hr;
382 }
383
384 declaration->IDirect3DVertexDeclaration9_iface.lpVtbl = &d3d9_vertex_declaration_vtbl;
385 declaration->refcount = 1;
386
387 element_count = wined3d_element_count + 1;
388 if (!(declaration->elements = heap_alloc(element_count * sizeof(*declaration->elements))))
389 {
390 heap_free(wined3d_elements);
391 ERR("Failed to allocate vertex declaration elements memory.\n");
393 }
394 memcpy(declaration->elements, elements, element_count * sizeof(*elements));
395 declaration->element_count = element_count;
396
398 hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements, wined3d_element_count,
401 heap_free(wined3d_elements);
402 if (FAILED(hr))
403 {
404 heap_free(declaration->elements);
405 WARN("Failed to create wined3d vertex declaration, hr %#x.\n", hr);
406 return hr;
407 }
408
409 declaration->parent_device = &device->IDirect3DDevice9Ex_iface;
411
412 return D3D_OK;
413}
static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elements_size, struct wined3d_vertex_element **wined3d_elements)
static const struct wined3d_parent_ops d3d9_vertexdeclaration_wined3d_parent_ops
HRESULT CDECL wined3d_vertex_declaration_create(struct wined3d_device *device, const struct wined3d_vertex_element *elements, UINT element_count, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_vertex_declaration **declaration)

Referenced by d3d9_vertex_declaration_create(), and wined3d_vertex_declaration_create().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d9  )

Variable Documentation

◆ component_count

◆ component_size

unsigned int component_size

Definition at line 31 of file vertexdeclaration.c.

Referenced by GPOS_apply_MarkToLigature().

◆ d3d9_vertex_declaration_vtbl

const struct IDirect3DVertexDeclaration9Vtbl d3d9_vertex_declaration_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI d3d9_vertex_declaration_GetDeclaration(IDirect3DVertexDeclaration9 *iface, D3DVERTEXELEMENT9 *elements, UINT *element_count)
static HRESULT WINAPI d3d9_vertex_declaration_GetDevice(IDirect3DVertexDeclaration9 *iface, IDirect3DDevice9 **device)
static HRESULT WINAPI d3d9_vertex_declaration_QueryInterface(IDirect3DVertexDeclaration9 *iface, REFIID riid, void **out)
static ULONG WINAPI d3d9_vertex_declaration_AddRef(IDirect3DVertexDeclaration9 *iface)
static ULONG WINAPI d3d9_vertex_declaration_Release(IDirect3DVertexDeclaration9 *iface)

Definition at line 291 of file vertexdeclaration.c.

Referenced by unsafe_impl_from_IDirect3DVertexDeclaration9(), and vertexdeclaration_init().

◆ d3d9_vertexdeclaration_wined3d_parent_ops

const struct wined3d_parent_ops d3d9_vertexdeclaration_wined3d_parent_ops
static
Initial value:
=
{
}
static void STDMETHODCALLTYPE d3d9_vertexdeclaration_wined3d_object_destroyed(void *parent)

Definition at line 317 of file vertexdeclaration.c.

Referenced by vertexdeclaration_init().

◆ 

const struct { ... } d3d_dtype_lookup[]
Initial value:
=
{
{WINED3DFMT_R32_FLOAT, 1, sizeof(float)},
{WINED3DFMT_R16G16_SINT, 2, sizeof(short int)},
{WINED3DFMT_R16G16B16A16_SINT, 4, sizeof(short int)},
{WINED3DFMT_R16G16_SNORM, 2, sizeof(short int)},
{WINED3DFMT_R16G16B16A16_SNORM, 4, sizeof(short int)},
{WINED3DFMT_R16G16_UNORM, 2, sizeof(short int)},
{WINED3DFMT_R16G16B16A16_UNORM, 4, sizeof(short int)},
{WINED3DFMT_R10G10B10X2_UINT, 3, sizeof(short int)},
{WINED3DFMT_R10G10B10X2_SNORM, 3, sizeof(short int)},
{WINED3DFMT_R16G16_FLOAT, 2, sizeof(short int)},
{WINED3DFMT_R16G16B16A16_FLOAT, 4, sizeof(short int)}
}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
static float(__cdecl *square_half_float)(float x
@ WINED3DFMT_R16G16_UNORM
Definition: wined3d.h:171
@ WINED3DFMT_R10G10B10X2_UINT
Definition: wined3d.h:124
@ WINED3DFMT_R32G32_FLOAT
Definition: wined3d.h:150
@ WINED3DFMT_R16G16_SNORM
Definition: wined3d.h:173
@ WINED3DFMT_B8G8R8A8_UNORM
Definition: wined3d.h:223
@ WINED3DFMT_R16G16B16A16_SINT
Definition: wined3d.h:148
@ WINED3DFMT_R32G32B32_FLOAT
Definition: wined3d.h:140
@ WINED3DFMT_R16G16B16A16_FLOAT
Definition: wined3d.h:144
@ WINED3DFMT_R8G8B8A8_UNORM
Definition: wined3d.h:164
@ WINED3DFMT_R16G16B16A16_UNORM
Definition: wined3d.h:145
@ WINED3DFMT_R32_FLOAT
Definition: wined3d.h:177
@ WINED3DFMT_R16G16_FLOAT
Definition: wined3d.h:170
@ WINED3DFMT_R8G8B8A8_UINT
Definition: wined3d.h:166
@ WINED3DFMT_R10G10B10X2_SNORM
Definition: wined3d.h:125
@ WINED3DFMT_R32G32B32A32_FLOAT
Definition: wined3d.h:136
@ WINED3DFMT_R16G16B16A16_SNORM
Definition: wined3d.h:147
@ WINED3DFMT_R16G16_SINT
Definition: wined3d.h:174
unsigned char BYTE
Definition: xxhash.c:193

Referenced by convert_to_wined3d_declaration(), and vdecl_convert_fvf().

◆ format

Definition at line 29 of file vertexdeclaration.c.

Referenced by append_decl_element().