From b62f4139eda58e8e25cbc58864fcea2599a20e97 Mon Sep 17 00:00:00 2001 From: Matteo Bruni Date: Sat, 30 Jul 2016 19:56:55 +0200 Subject: [PATCH] wined3d: Swizzle D3DCOLOR attributes in the GLSL FFP replacement when necessary. Signed-off-by: Matteo Bruni Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/buffer.c | 8 +++----- dlls/wined3d/context.c | 2 +- dlls/wined3d/glsl_shader.c | 4 ++-- dlls/wined3d/utils.c | 4 ++++ dlls/wined3d/wined3d_private.h | 2 ++ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 039b3a132af..9e0892eb7a6 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -744,9 +744,9 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte const struct wined3d_state *state) { DWORD flags = buffer->flags & (WINED3D_BUFFER_SYNC | WINED3D_BUFFER_DISCARD); + const struct wined3d_gl_info *gl_info = context->gl_info; struct wined3d_device *device = buffer->resource.device; UINT start, end, len, vertices; - const struct wined3d_gl_info *gl_info; BOOL decl_changed = FALSE; unsigned int i, j; BYTE *data; @@ -783,7 +783,7 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte if (!use_vs(state)) { - if (!context->gl_info->supported[ARB_VERTEX_ARRAY_BGRA]) + if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && !context->d3d_info->ffp_generic_attributes) fixup_flags |= WINED3D_BUFFER_FIXUP_D3DCOLOR; if (!context->d3d_info->xyzrhw) fixup_flags |= WINED3D_BUFFER_FIXUP_XYZRHW; @@ -873,13 +873,11 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte return; } - buffer_direct_upload(buffer, context->gl_info, flags); + buffer_direct_upload(buffer, gl_info, flags); return; } - gl_info = context->gl_info; - if(!(buffer->flags & WINED3D_BUFFER_DOUBLEBUFFER)) { buffer_get_sysmem(buffer, context); diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index a85f3fc26ee..bb97fb9ecf4 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -3214,7 +3214,7 @@ static void context_update_stream_info(struct wined3d_context *context, const st else { WORD slow_mask = -!d3d_info->ffp_generic_attributes & (1u << WINED3D_FFP_PSIZE); - slow_mask |= -!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] + slow_mask |= -(!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && !d3d_info->ffp_generic_attributes) & ((1u << WINED3D_FFP_DIFFUSE) | (1u << WINED3D_FFP_SPECULAR) | (1u << WINED3D_FFP_BLENDWEIGHT)); if ((stream_info->position_transformed && !d3d_info->xyzrhw) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index b0de8c62d17..626432b0ee4 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -6598,8 +6598,8 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr for (i = 0; i < ARRAY_SIZE(attrib_info); ++i) { if (attrib_info[i].name[0]) - shader_addline(buffer, "%s %s = vs_in%u;\n", - attrib_info[i].type, attrib_info[i].name, i); + shader_addline(buffer, "%s %s = vs_in%u%s;\n", attrib_info[i].type, attrib_info[i].name, + i, settings->swizzle_map & (1u << i) ? ".zyxw" : ""); } for (i = 0; i < MAX_TEXTURES; ++i) { diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index b686b092942..93b610dc0e5 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5559,6 +5559,8 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context, else settings->flatshading = FALSE; + settings->swizzle_map = si->swizzle_map; + return; } @@ -5644,6 +5646,8 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context, else settings->flatshading = FALSE; + settings->swizzle_map = si->swizzle_map; + settings->padding = 0; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index f182ca20ede..4984ba2caef 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2299,6 +2299,8 @@ struct wined3d_ffp_vs_settings DWORD padding : 10; DWORD texgen[MAX_TEXTURES]; + + WORD swizzle_map; /* MAX_ATTRIBS, 16 */ }; struct wined3d_ffp_vs_desc