[PATCH 2/7] wined3d: Store vertex attribute size instead of component size in wined3d_format.
Józef Kucia
jkucia at codeweavers.com
Mon Jul 18 06:27:35 CDT 2016
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/wined3d/buffer.c | 15 +++++++--------
dlls/wined3d/utils.c | 23 ++++++++++++-----------
dlls/wined3d/vertexdeclaration.c | 2 +-
dlls/wined3d/wined3d_private.h | 2 +-
4 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 674daec..79d1246 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -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)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index e1a7952..522a891 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -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;
}
diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c
index c8704e9..70c2d98 100644
--- a/dlls/wined3d/vertexdeclaration.c
+++ b/dlls/wined3d/vertexdeclaration.c
@@ -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;
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index bb71740..b400994 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -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;
--
2.7.3
More information about the wine-patches
mailing list