ReactOS 0.4.15-dev-8235-gcd88a97
vertexdeclaration.c File Reference
#include "config.h"
#include "wine/port.h"
#include "wined3d_private.h"
Include dependency graph for vertexdeclaration.c:

Go to the source code of this file.

Classes

struct  wined3d_fvf_convert_state
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d_decl)
 
static void dump_wined3d_vertex_element (const struct wined3d_vertex_element *element)
 
ULONG CDECL wined3d_vertex_declaration_incref (struct wined3d_vertex_declaration *declaration)
 
static void wined3d_vertex_declaration_destroy_object (void *object)
 
ULONG CDECL wined3d_vertex_declaration_decref (struct wined3d_vertex_declaration *declaration)
 
void *CDECL wined3d_vertex_declaration_get_parent (const struct wined3d_vertex_declaration *declaration)
 
static BOOL declaration_element_valid_ffp (const struct wined3d_vertex_element *element)
 
static HRESULT vertexdeclaration_init (struct wined3d_vertex_declaration *declaration, struct wined3d_device *device, const struct wined3d_vertex_element *elements, UINT element_count, void *parent, const struct wined3d_parent_ops *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)
 
static void append_decl_element (struct wined3d_fvf_convert_state *state, enum wined3d_format_id format_id, enum wined3d_decl_usage usage, UINT usage_idx)
 
static unsigned int convert_fvf_to_declaration (const struct wined3d_gl_info *gl_info, DWORD fvf, struct wined3d_vertex_element **elements)
 
HRESULT CDECL wined3d_vertex_declaration_create_from_fvf (struct wined3d_device *device, DWORD fvf, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_vertex_declaration **declaration)
 

Function Documentation

◆ append_decl_element()

static void append_decl_element ( struct wined3d_fvf_convert_state state,
enum wined3d_format_id  format_id,
enum wined3d_decl_usage  usage,
UINT  usage_idx 
)
static

Definition at line 307 of file vertexdeclaration.c.

309{
310 struct wined3d_vertex_element *elements = state->elements;
311 const struct wined3d_format *format;
312 UINT offset = state->offset;
313 UINT idx = state->idx;
314
315 elements[idx].format = format_id;
316 elements[idx].input_slot = 0;
317 elements[idx].offset = offset;
320 elements[idx].instance_data_step_rate = 0;
322 elements[idx].usage = usage;
323 elements[idx].usage_idx = usage_idx;
324
326 state->offset += format->attribute_size;
327 ++state->idx;
328}
static int state
Definition: maze.c:121
BYTE usage_idx
const struct wined3d_format * wined3d_get_format(const struct wined3d_gl_info *gl_info, enum wined3d_format_id format_id, unsigned int resource_usage)
Definition: utils.c:3831
unsigned int idx
Definition: utils.c:41
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
static UINT format_id
Definition: clipboard.c:1343
unsigned int UINT
Definition: ndis.h:50
unsigned int output_slot
Definition: wined3d.h:1794
enum wined3d_format_id format
Definition: wined3d.h:1791
unsigned int input_slot
Definition: wined3d.h:1792
enum wined3d_input_classification input_slot_class
Definition: wined3d.h:1795
unsigned int instance_data_step_rate
Definition: wined3d.h:1796
unsigned int offset
Definition: wined3d.h:1793
@ WINED3D_DECL_METHOD_DEFAULT
Definition: wined3d.h:775
#define WINED3D_OUTPUT_SLOT_SEMANTIC
Definition: wined3d.h:1566
@ WINED3D_INPUT_PER_VERTEX_DATA
Definition: wined3d.h:1785

Referenced by convert_fvf_to_declaration().

◆ convert_fvf_to_declaration()

static unsigned int convert_fvf_to_declaration ( const struct wined3d_gl_info gl_info,
DWORD  fvf,
struct wined3d_vertex_element **  elements 
)
static

Definition at line 330 of file vertexdeclaration.c.

332{
333 BOOL has_pos = !!(fvf & WINED3DFVF_POSITION_MASK);
334 BOOL has_blend = (fvf & WINED3DFVF_XYZB5) > WINED3DFVF_XYZRHW;
335 BOOL has_blend_idx = has_blend &&
336 (((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB5) ||
339 BOOL has_normal = !!(fvf & WINED3DFVF_NORMAL);
340 BOOL has_psize = !!(fvf & WINED3DFVF_PSIZE);
341 BOOL has_diffuse = !!(fvf & WINED3DFVF_DIFFUSE);
342 BOOL has_specular = !!(fvf & WINED3DFVF_SPECULAR);
343
345 DWORD texcoords = (fvf & 0xffff0000) >> 16;
347 unsigned int size;
348 unsigned int idx;
349 DWORD num_blends = 1 + (((fvf & WINED3DFVF_XYZB5) - WINED3DFVF_XYZB1) >> 1);
350 if (has_blend_idx) num_blends--;
351
352 /* Compute declaration size */
353 size = has_pos + (has_blend && num_blends > 0) + has_blend_idx + has_normal +
354 has_psize + has_diffuse + has_specular + num_textures;
355
356 state.gl_info = gl_info;
357 if (!(state.elements = heap_calloc(size, sizeof(*state.elements))))
358 return ~0u;
359 state.offset = 0;
360 state.idx = 0;
361
362 if (has_pos)
363 {
364 if (!has_blend && (fvf & WINED3DFVF_XYZRHW))
366 else if ((fvf & WINED3DFVF_XYZW) == WINED3DFVF_XYZW)
368 else
370 }
371
372 if (has_blend && (num_blends > 0))
373 {
376 else
377 {
378 switch (num_blends)
379 {
380 case 1:
382 break;
383 case 2:
385 break;
386 case 3:
388 break;
389 case 4:
391 break;
392 default:
393 ERR("Unexpected amount of blend values: %u\n", num_blends);
394 }
395 }
396 }
397
398 if (has_blend_idx)
399 {
403 else if (fvf & WINED3DFVF_LASTBETA_D3DCOLOR)
405 else
407 }
408
409 if (has_normal)
411 if (has_psize)
413 if (has_diffuse)
415 if (has_specular)
417
418 for (idx = 0; idx < num_textures; ++idx)
419 {
420 switch ((texcoords >> (idx * 2)) & 0x03)
421 {
424 break;
427 break;
430 break;
433 break;
434 }
435 }
436
437 *elements = state.elements;
438 return size;
439}
#define ERR(fmt,...)
Definition: debug.h:113
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
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
static void * heap_calloc(SIZE_T count, SIZE_T size)
Definition: heap.h:49
const struct wined3d_gl_info * gl_info
struct wined3d_vertex_element * elements
static void append_decl_element(struct wined3d_fvf_convert_state *state, enum wined3d_format_id format_id, enum wined3d_decl_usage usage, UINT usage_idx)
#define WINED3DFVF_PSIZE
Definition: wined3d.h:969
#define WINED3DFVF_TEXTUREFORMAT4
Definition: wined3d.h:990
#define WINED3DFVF_TEXTUREFORMAT3
Definition: wined3d.h:989
#define WINED3DFVF_XYZB5
Definition: wined3d.h:966
@ WINED3D_DECL_USAGE_BLEND_INDICES
Definition: wined3d.h:788
@ WINED3D_DECL_USAGE_NORMAL
Definition: wined3d.h:789
@ WINED3D_DECL_USAGE_PSIZE
Definition: wined3d.h:790
@ WINED3D_DECL_USAGE_BLEND_WEIGHT
Definition: wined3d.h:787
@ WINED3D_DECL_USAGE_POSITION
Definition: wined3d.h:786
@ WINED3D_DECL_USAGE_COLOR
Definition: wined3d.h:796
@ WINED3D_DECL_USAGE_POSITIONT
Definition: wined3d.h:795
@ WINED3D_DECL_USAGE_TEXCOORD
Definition: wined3d.h:791
#define WINED3DFVF_SPECULAR
Definition: wined3d.h:971
#define WINED3DFVF_TEXCOUNT_SHIFT
Definition: wined3d.h:973
#define WINED3DFVF_DIFFUSE
Definition: wined3d.h:970
#define WINED3DFVF_XYZW
Definition: wined3d.h:967
#define WINED3DFVF_POSITION_MASK
Definition: wined3d.h:959
#define WINED3DFVF_TEXTUREFORMAT1
Definition: wined3d.h:987
#define WINED3DFVF_LASTBETA_UBYTE4
Definition: wined3d.h:983
#define WINED3DFVF_XYZB1
Definition: wined3d.h:962
#define WINED3DFVF_TEXCOUNT_MASK
Definition: wined3d.h:972
#define WINED3DFVF_XYZRHW
Definition: wined3d.h:961
#define WINED3DFVF_NORMAL
Definition: wined3d.h:968
@ WINED3DFMT_R32G32_FLOAT
Definition: wined3d.h:150
@ WINED3DFMT_B8G8R8A8_UNORM
Definition: wined3d.h:223
@ WINED3DFMT_R32G32B32_FLOAT
Definition: wined3d.h:140
@ WINED3DFMT_R32_FLOAT
Definition: wined3d.h:177
@ WINED3DFMT_R8G8B8A8_UINT
Definition: wined3d.h:166
@ WINED3DFMT_R32G32B32A32_FLOAT
Definition: wined3d.h:136
#define WINED3DFVF_XYZB2
Definition: wined3d.h:963
#define WINED3DFVF_LASTBETA_D3DCOLOR
Definition: wined3d.h:984
#define WINED3DFVF_TEXTUREFORMAT2
Definition: wined3d.h:988

Referenced by wined3d_vertex_declaration_create_from_fvf().

◆ declaration_element_valid_ffp()

static BOOL declaration_element_valid_ffp ( const struct wined3d_vertex_element element)
static

Definition at line 84 of file vertexdeclaration.c.

85{
86 switch(element->usage)
87 {
90 switch(element->format)
91 {
99 return TRUE;
100 default:
101 return FALSE;
102 }
103
105 switch(element->format)
106 {
117 return TRUE;
118 default:
119 return FALSE;
120 }
121
123 switch(element->format)
124 {
126 return TRUE;
127 default:
128 return FALSE;
129 }
130
132 switch(element->format)
133 {
138 return TRUE;
139 default:
140 return FALSE;
141 }
142
144 switch(element->format)
145 {
154 return TRUE;
155 default:
156 return FALSE;
157 }
158
160 switch(element->format)
161 {
171 return TRUE;
172 default:
173 return FALSE;
174 }
175
176 default:
177 return FALSE;
178 }
179}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ WINED3DFMT_R16G16B16A16_SINT
Definition: wined3d.h:148
@ WINED3DFMT_R16G16B16A16_FLOAT
Definition: wined3d.h:144
@ WINED3DFMT_R8G8B8A8_UNORM
Definition: wined3d.h:164
@ WINED3DFMT_R16G16B16A16_UNORM
Definition: wined3d.h:145
@ WINED3DFMT_R16G16_FLOAT
Definition: wined3d.h:170
@ WINED3DFMT_R16G16B16A16_SNORM
Definition: wined3d.h:147
@ WINED3DFMT_R16G16_SINT
Definition: wined3d.h:174

Referenced by vertexdeclaration_init().

◆ dump_wined3d_vertex_element()

static void dump_wined3d_vertex_element ( const struct wined3d_vertex_element element)
static

Definition at line 31 of file vertexdeclaration.c.

32{
33 TRACE(" format: %s (%#x)\n", debug_d3dformat(element->format), element->format);
34 TRACE(" input_slot: %u\n", element->input_slot);
35 TRACE(" offset: %u\n", element->offset);
36 TRACE(" output_slot: %u\n", element->output_slot);
37 TRACE(" input slot class: %s\n", debug_d3dinput_classification(element->input_slot_class));
38 TRACE("instance data step rate: %u\n", element->instance_data_step_rate);
39 TRACE(" method: %s (%#x)\n", debug_d3ddeclmethod(element->method), element->method);
40 TRACE(" usage: %s (%#x)\n", debug_d3ddeclusage(element->usage), element->usage);
41 TRACE(" usage_idx: %u\n", element->usage_idx);
42}
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3980
const char * debug_d3dinput_classification(enum wined3d_input_classification classification)
Definition: utils.c:4315
const char * debug_d3ddeclmethod(enum wined3d_decl_method method)
Definition: utils.c:4270
const char * debug_d3ddeclusage(enum wined3d_decl_usage usage)
Definition: utils.c:4289
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by vertexdeclaration_init().

◆ vertexdeclaration_init()

static HRESULT vertexdeclaration_init ( struct wined3d_vertex_declaration declaration,
struct wined3d_device device,
const struct wined3d_vertex_element elements,
UINT  element_count,
void parent,
const struct wined3d_parent_ops parent_ops 
)
static

Definition at line 181 of file vertexdeclaration.c.

184{
185 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
186 unsigned int i;
187
188 if (TRACE_ON(d3d_decl))
189 {
190 for (i = 0; i < element_count; ++i)
191 {
192 dump_wined3d_vertex_element(elements + i);
193 }
194 }
195
196 declaration->ref = 1;
197 declaration->parent = parent;
198 declaration->parent_ops = parent_ops;
199 declaration->device = device;
200 if (!(declaration->elements = heap_calloc(element_count, sizeof(*declaration->elements))))
201 {
202 ERR("Failed to allocate elements memory.\n");
203 return E_OUTOFMEMORY;
204 }
205 declaration->element_count = element_count;
206
207 /* Do some static analysis on the elements to make reading the
208 * declaration more comfortable for the drawing code. */
209 for (i = 0; i < element_count; ++i)
210 {
212
213 e->format = wined3d_get_format(gl_info, elements[i].format, 0);
214 e->ffp_valid = declaration_element_valid_ffp(&elements[i]);
215 e->input_slot = elements[i].input_slot;
216 e->offset = elements[i].offset;
217 e->output_slot = elements[i].output_slot;
218 e->input_slot_class = elements[i].input_slot_class;
219 e->instance_data_step_rate = elements[i].instance_data_step_rate;
220 e->method = elements[i].method;
221 e->usage = elements[i].usage;
222 e->usage_idx = elements[i].usage_idx;
223
224 if (e->usage == WINED3D_DECL_USAGE_POSITIONT)
225 declaration->position_transformed = TRUE;
226
227 /* Find the streams used in the declaration. The vertex buffers have
228 * to be loaded when drawing, but filter tesselation pseudo streams. */
229 if (e->input_slot >= MAX_STREAMS) continue;
230
231 if (!e->format->gl_vtx_format)
232 {
233 FIXME("The application tries to use an unsupported format (%s), returning E_FAIL.\n",
234 debug_d3dformat(elements[i].format));
235 heap_free(declaration->elements);
236 return E_FAIL;
237 }
238
239 if (e->offset == WINED3D_APPEND_ALIGNED_ELEMENT)
240 {
241 const struct wined3d_vertex_declaration_element *prev;
242 unsigned int j;
243
244 e->offset = 0;
245 for (j = 1; j <= i; ++j)
246 {
247 prev = &declaration->elements[i - j];
248 if (prev->input_slot == e->input_slot)
249 {
250 e->offset = (prev->offset + prev->format->byte_count + 3) & ~3;
251 break;
252 }
253 }
254 }
255
256 if (e->offset & 0x3)
257 {
258 WARN("Declaration element %u is not 4 byte aligned(%u), returning E_FAIL.\n", i, e->offset);
259 heap_free(declaration->elements);
260 return E_FAIL;
261 }
262
263 if (elements[i].format == WINED3DFMT_R16G16_FLOAT || elements[i].format == WINED3DFMT_R16G16B16A16_FLOAT)
264 {
265 if (!gl_info->supported[ARB_HALF_FLOAT_VERTEX]) declaration->half_float_conv_needed = TRUE;
266 }
267 }
268
269 return WINED3D_OK;
270}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define FIXME(fmt,...)
Definition: debug.h:114
#define WARN(fmt,...)
Definition: debug.h:115
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
#define TRACE_ON(x)
Definition: compat.h:75
r parent
Definition: btrfs.c:3010
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
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 e
Definition: ke_i.h:82
Definition: devices.h:37
BOOL supported[WINED3D_GL_EXT_COUNT]
const struct wined3d_format * format
static void dump_wined3d_vertex_element(const struct wined3d_vertex_element *element)
static BOOL declaration_element_valid_ffp(const struct wined3d_vertex_element *element)
#define WINED3D_OK
Definition: wined3d.h:37
#define WINED3D_APPEND_ALIGNED_ELEMENT
Definition: wined3d.h:1564
@ ARB_HALF_FLOAT_VERTEX
Definition: wined3d_gl.h:78
#define MAX_STREAMS

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d_decl  )

◆ wined3d_vertex_declaration_create()

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 
)

Definition at line 272 of file vertexdeclaration.c.

275{
277 HRESULT hr;
278
279 TRACE("device %p, elements %p, element_count %u, parent %p, parent_ops %p, declaration %p.\n",
281
282 if (!(object = heap_alloc_zero(sizeof(*object))))
283 return E_OUTOFMEMORY;
284
286 if (FAILED(hr))
287 {
288 WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
289 heap_free(object);
290 return hr;
291 }
292
293 TRACE("Created vertex declaration %p.\n", object);
295
296 return WINED3D_OK;
297}
static HRESULT vertexdeclaration_init(struct d3d9_vertex_declaration *declaration, struct d3d9_device *device, const D3DVERTEXELEMENT9 *elements)
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183
struct wined3d_vertex_declaration_element * elements
const struct wined3d_parent_ops * parent_ops

Referenced by d3d8_vertex_declaration_init(), vertexdeclaration_init(), and wined3d_vertex_declaration_create_from_fvf().

◆ wined3d_vertex_declaration_create_from_fvf()

HRESULT CDECL wined3d_vertex_declaration_create_from_fvf ( struct wined3d_device device,
DWORD  fvf,
void parent,
const struct wined3d_parent_ops parent_ops,
struct wined3d_vertex_declaration **  declaration 
)

Definition at line 441 of file vertexdeclaration.c.

444{
445 struct wined3d_vertex_element *elements;
446 unsigned int size;
447 DWORD hr;
448
449 TRACE("device %p, fvf %#x, parent %p, parent_ops %p, declaration %p.\n",
450 device, fvf, parent, parent_ops, declaration);
451
452 size = convert_fvf_to_declaration(&device->adapter->gl_info, fvf, &elements);
453 if (size == ~0U) return E_OUTOFMEMORY;
454
456 heap_free(elements);
457 return hr;
458}
#define U(x)
Definition: wordpad.c:45
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)
static unsigned int convert_fvf_to_declaration(const struct wined3d_gl_info *gl_info, DWORD fvf, struct wined3d_vertex_element **elements)

Referenced by d3d8_vertex_declaration_init_fvf(), and ddraw_find_decl().

◆ wined3d_vertex_declaration_decref()

ULONG CDECL wined3d_vertex_declaration_decref ( struct wined3d_vertex_declaration declaration)

Definition at line 61 of file vertexdeclaration.c.

62{
63 ULONG refcount = InterlockedDecrement(&declaration->ref);
64
65 TRACE("%p decreasing refcount to %u.\n", declaration, refcount);
66
67 if (!refcount)
68 {
69 declaration->parent_ops->wined3d_object_destroyed(declaration->parent);
72 }
73
74 return refcount;
75}
#define InterlockedDecrement
Definition: armddk.h:52
void wined3d_cs_destroy_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:1885
uint32_t ULONG
Definition: typedefs.h:59
static void wined3d_vertex_declaration_destroy_object(void *object)

Referenced by d3d8_vertex_declaration_destroy(), d3d9_device_Release(), d3d9_vertex_declaration_Release(), d3d_vertex_buffer7_Release(), ddraw_destroy_swapchain(), ddraw_find_decl(), state_unbind_resources(), wined3d_device_set_vertex_declaration(), and wined3d_stateblock_capture().

◆ wined3d_vertex_declaration_destroy_object()

static void wined3d_vertex_declaration_destroy_object ( void object)
static

Definition at line 53 of file vertexdeclaration.c.

Referenced by wined3d_vertex_declaration_decref().

◆ wined3d_vertex_declaration_get_parent()

void *CDECL wined3d_vertex_declaration_get_parent ( const struct wined3d_vertex_declaration declaration)

Definition at line 77 of file vertexdeclaration.c.

78{
79 TRACE("declaration %p.\n", declaration);
80
81 return declaration->parent;
82}

Referenced by d3d8_device_GetVertexShader(), d3d9_device_GetFVF(), and d3d9_device_GetVertexDeclaration().

◆ wined3d_vertex_declaration_incref()

ULONG CDECL wined3d_vertex_declaration_incref ( struct wined3d_vertex_declaration declaration)

Definition at line 44 of file vertexdeclaration.c.

45{
46 ULONG refcount = InterlockedIncrement(&declaration->ref);
47
48 TRACE("%p increasing refcount to %u.\n", declaration, refcount);
49
50 return refcount;
51}
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by d3d9_vertex_declaration_AddRef(), d3d_vertex_buffer_create(), device_get_fvf_declaration(), wined3d_device_set_vertex_declaration(), and wined3d_stateblock_capture().