wined3d: Align vertex attribute offsets to their size, if smaller than 4.
This should not change behaviour for d3d9 and earlier, where all formats have sizes that are multiples of 4. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=43422 Signed-off-by: Jan Sikorski <jsikorski@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ec648ea7d0
commit
81dfece45c
|
@ -200,6 +200,7 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara
|
|||
for (i = 0; i < element_count; ++i)
|
||||
{
|
||||
struct wined3d_vertex_declaration_element *e = &declaration->elements[i];
|
||||
unsigned int alignment;
|
||||
|
||||
e->format = wined3d_get_format(adapter, elements[i].format, 0);
|
||||
e->ffp_valid = declaration_element_valid_ffp(&elements[i]);
|
||||
|
@ -212,6 +213,9 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara
|
|||
e->usage = elements[i].usage;
|
||||
e->usage_idx = elements[i].usage_idx;
|
||||
|
||||
if ((alignment = e->format->byte_count) > 4)
|
||||
alignment = 4;
|
||||
|
||||
if (e->usage == WINED3D_DECL_USAGE_POSITIONT)
|
||||
declaration->position_transformed = TRUE;
|
||||
|
||||
|
@ -239,15 +243,16 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara
|
|||
prev = &declaration->elements[i - j];
|
||||
if (prev->input_slot == e->input_slot)
|
||||
{
|
||||
e->offset = (prev->offset + prev->format->byte_count + 3) & ~3;
|
||||
e->offset = (prev->offset + prev->format->byte_count + alignment - 1) & ~(alignment - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e->offset & 0x3)
|
||||
if (e->offset & (alignment - 1))
|
||||
{
|
||||
WARN("Declaration element %u is not 4 byte aligned(%u), returning E_FAIL.\n", i, e->offset);
|
||||
WARN("Declaration element %u with format %s and offset %u is not %u byte aligned.\n",
|
||||
i, debug_d3dformat(elements[i].format), e->offset, alignment);
|
||||
heap_free(declaration->elements);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue