wined3d: Store vertex attribute size instead of component size in wined3d_format.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2016-07-18 13:27:35 +02:00 committed by Alexandre Julliard
parent 57d2b83d0d
commit 8c0ddf9827
4 changed files with 21 additions and 21 deletions

View File

@ -210,7 +210,7 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *buffer,
const enum wined3d_buffer_conversion_type conversion_type, const enum wined3d_buffer_conversion_type conversion_type,
const struct wined3d_stream_info_element *attrib, DWORD *stride_this_run) const struct wined3d_stream_info_element *attrib, DWORD *stride_this_run)
{ {
DWORD attrib_size; const struct wined3d_format *format = attrib->format;
BOOL ret = FALSE; BOOL ret = FALSE;
unsigned int i; unsigned int i;
DWORD_PTR data; DWORD_PTR data;
@ -222,12 +222,12 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *buffer,
*/ */
if (!attrib->stride) if (!attrib->stride)
{ {
FIXME("%s used with stride 0, let's hope we get the vertex stride from somewhere else\n", FIXME("%s used with stride 0, let's hope we get the vertex stride from somewhere else.\n",
debug_d3dformat(attrib->format->id)); debug_d3dformat(format->id));
} }
else if(attrib->stride != *stride_this_run && *stride_this_run) else if (attrib->stride != *stride_this_run && *stride_this_run)
{ {
FIXME("Got two concurrent strides, %d and %d\n", attrib->stride, *stride_this_run); FIXME("Got two concurrent strides, %d and %d.\n", attrib->stride, *stride_this_run);
} }
else else
{ {
@ -237,7 +237,7 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *buffer,
/* We rely that this happens only on the first converted attribute that is found, /* We rely that this happens only on the first converted attribute that is found,
* if at all. See above check * if at all. See above check
*/ */
TRACE("Reconverting because converted attributes occur, and the stride changed\n"); TRACE("Reconverting because converted attributes occur, and the stride changed.\n");
buffer->stride = *stride_this_run; buffer->stride = *stride_this_run;
HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, buffer->conversion_map); HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, buffer->conversion_map);
buffer->conversion_map = wined3d_calloc(buffer->stride, sizeof(*buffer->conversion_map)); buffer->conversion_map = wined3d_calloc(buffer->stride, sizeof(*buffer->conversion_map));
@ -246,8 +246,7 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *buffer,
} }
data = ((DWORD_PTR)attrib->data.addr) % buffer->stride; data = ((DWORD_PTR)attrib->data.addr) % buffer->stride;
attrib_size = attrib->format->component_count * attrib->format->component_size; for (i = 0; i < format->attribute_size; ++i)
for (i = 0; i < attrib_size; ++i)
{ {
DWORD_PTR idx = (data + i) % buffer->stride; DWORD_PTR idx = (data + i) % buffer->stride;
if (buffer->conversion_map[idx] != conversion_type) if (buffer->conversion_map[idx] != conversion_type)

View File

@ -3253,26 +3253,26 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE; gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
} }
static unsigned int gl_type_size(GLenum type) static unsigned int calculate_vertex_attribute_size(GLenum type, unsigned int component_count)
{ {
switch (type) switch (type)
{ {
case GL_HALF_FLOAT: case GL_HALF_FLOAT:
return sizeof(GLhalfNV); return component_count * sizeof(GLhalfNV);
case GL_FLOAT: case GL_FLOAT:
return sizeof(GLfloat); return component_count * sizeof(GLfloat);
case GL_BYTE: case GL_BYTE:
return sizeof(GLbyte); return component_count * sizeof(GLbyte);
case GL_UNSIGNED_BYTE: case GL_UNSIGNED_BYTE:
return sizeof(GLubyte); return component_count * sizeof(GLubyte);
case GL_SHORT: case GL_SHORT:
return sizeof(GLshort); return component_count * sizeof(GLshort);
case GL_UNSIGNED_SHORT: case GL_UNSIGNED_SHORT:
return sizeof(GLushort); return component_count * sizeof(GLushort);
case GL_INT: case GL_INT:
return sizeof(GLint); return component_count * sizeof(GLint);
case GL_UNSIGNED_INT: case GL_UNSIGNED_INT:
return sizeof(GLuint); return component_count * sizeof(GLuint);
default: default:
FIXME("Unhandled GL type %#x.\n", type); FIXME("Unhandled GL type %#x.\n", type);
return 0; return 0;
@ -3301,9 +3301,10 @@ static BOOL init_format_vertex_info(struct wined3d_gl_info *gl_info)
format->gl_vtx_type = format_vertex_info[i].gl_vtx_type; format->gl_vtx_type = format_vertex_info[i].gl_vtx_type;
format->gl_vtx_format = format_vertex_info[i].component_count; format->gl_vtx_format = format_vertex_info[i].component_count;
format->gl_normalized = format_vertex_info[i].gl_normalized; format->gl_normalized = format_vertex_info[i].gl_normalized;
if (!(format->component_size = gl_type_size(format_vertex_info[i].gl_vtx_type))) if (!(format->attribute_size = calculate_vertex_attribute_size(format->gl_vtx_type,
format->component_count)))
{ {
ERR("Invalid component size for vertex format %s (%#x).\n", ERR("Invalid attribute size for vertex format %s (%#x).\n",
debug_d3dformat(format_vertex_info[i].id), format_vertex_info[i].id); debug_d3dformat(format_vertex_info[i].id), format_vertex_info[i].id);
return FALSE; return FALSE;
} }

View File

@ -315,7 +315,7 @@ static void append_decl_element(struct wined3d_fvf_convert_state *state,
elements[idx].usage_idx = usage_idx; elements[idx].usage_idx = usage_idx;
format = wined3d_get_format(state->gl_info, format_id); format = wined3d_get_format(state->gl_info, format_id);
state->offset += format->component_count * format->component_size; state->offset += format->attribute_size;
++state->idx; ++state->idx;
} }

View File

@ -3630,7 +3630,7 @@ struct wined3d_format
GLenum gl_vtx_type; GLenum gl_vtx_type;
GLint gl_vtx_format; GLint gl_vtx_format;
GLboolean gl_normalized; GLboolean gl_normalized;
unsigned int component_size; unsigned int attribute_size;
GLint glInternal; GLint glInternal;
GLint glGammaInternal; GLint glGammaInternal;