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:
parent
57d2b83d0d
commit
8c0ddf9827
|
@ -210,7 +210,7 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *buffer,
|
|||
const enum wined3d_buffer_conversion_type conversion_type,
|
||||
const struct wined3d_stream_info_element *attrib, DWORD *stride_this_run)
|
||||
{
|
||||
DWORD attrib_size;
|
||||
const struct wined3d_format *format = attrib->format;
|
||||
BOOL ret = FALSE;
|
||||
unsigned int i;
|
||||
DWORD_PTR data;
|
||||
|
@ -222,12 +222,12 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *buffer,
|
|||
*/
|
||||
if (!attrib->stride)
|
||||
{
|
||||
FIXME("%s used with stride 0, let's hope we get the vertex stride from somewhere else\n",
|
||||
debug_d3dformat(attrib->format->id));
|
||||
FIXME("%s used with stride 0, let's hope we get the vertex stride from somewhere else.\n",
|
||||
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
|
||||
{
|
||||
|
@ -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,
|
||||
* 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;
|
||||
HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, 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;
|
||||
attrib_size = attrib->format->component_count * attrib->format->component_size;
|
||||
for (i = 0; i < attrib_size; ++i)
|
||||
for (i = 0; i < format->attribute_size; ++i)
|
||||
{
|
||||
DWORD_PTR idx = (data + i) % buffer->stride;
|
||||
if (buffer->conversion_map[idx] != conversion_type)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
static unsigned int gl_type_size(GLenum type)
|
||||
static unsigned int calculate_vertex_attribute_size(GLenum type, unsigned int component_count)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GL_HALF_FLOAT:
|
||||
return sizeof(GLhalfNV);
|
||||
return component_count * sizeof(GLhalfNV);
|
||||
case GL_FLOAT:
|
||||
return sizeof(GLfloat);
|
||||
return component_count * sizeof(GLfloat);
|
||||
case GL_BYTE:
|
||||
return sizeof(GLbyte);
|
||||
return component_count * sizeof(GLbyte);
|
||||
case GL_UNSIGNED_BYTE:
|
||||
return sizeof(GLubyte);
|
||||
return component_count * sizeof(GLubyte);
|
||||
case GL_SHORT:
|
||||
return sizeof(GLshort);
|
||||
return component_count * sizeof(GLshort);
|
||||
case GL_UNSIGNED_SHORT:
|
||||
return sizeof(GLushort);
|
||||
return component_count * sizeof(GLushort);
|
||||
case GL_INT:
|
||||
return sizeof(GLint);
|
||||
return component_count * sizeof(GLint);
|
||||
case GL_UNSIGNED_INT:
|
||||
return sizeof(GLuint);
|
||||
return component_count * sizeof(GLuint);
|
||||
default:
|
||||
FIXME("Unhandled GL type %#x.\n", type);
|
||||
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_format = format_vertex_info[i].component_count;
|
||||
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);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -315,7 +315,7 @@ static void append_decl_element(struct wined3d_fvf_convert_state *state,
|
|||
elements[idx].usage_idx = usage_idx;
|
||||
|
||||
format = wined3d_get_format(state->gl_info, format_id);
|
||||
state->offset += format->component_count * format->component_size;
|
||||
state->offset += format->attribute_size;
|
||||
++state->idx;
|
||||
}
|
||||
|
||||
|
|
|
@ -3630,7 +3630,7 @@ struct wined3d_format
|
|||
GLenum gl_vtx_type;
|
||||
GLint gl_vtx_format;
|
||||
GLboolean gl_normalized;
|
||||
unsigned int component_size;
|
||||
unsigned int attribute_size;
|
||||
|
||||
GLint glInternal;
|
||||
GLint glGammaInternal;
|
||||
|
|
Loading…
Reference in New Issue