diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 4b8a7a994b3..b74836d79c4 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -26083,7 +26083,7 @@ static void test_color_vertex(void) ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr); colour = getPixelColor(device, 320, 240); - todo_wine_if (i == 13 || i == 14 || i == 16 || i == 18 || i == 19) + todo_wine_if (i == 13 || i == 14 || i == 19) ok(color_match(colour, tests[i].result, 1), "Expected colour 0x%08x for test %u, got 0x%08x.\n", tests[i].result, i, colour); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 12786f4a068..c0648f2aace 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3383,7 +3383,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO lighting = state->render_states[WINED3D_RS_LIGHTING] && (dst_fvf & (WINED3DFVF_DIFFUSE | WINED3DFVF_SPECULAR)); wined3d_get_material_colour_source(&diffuse_source, &emissive_source, - &ambient_source, &specular_source, state, stream_info); + &ambient_source, &specular_source, state); output_colour_format = wined3d_get_format(device->adapter, WINED3DFMT_B8G8R8A8_UNORM, 0); material_specular_state_colour = state->render_states[WINED3D_RS_SPECULARENABLE] ? &state->material.specular : &black; diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index ae618266d79..0fbff8e4597 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -11759,13 +11759,13 @@ static void glsl_vertex_pipe_vdecl(struct wined3d_context *context, const struct wined3d_vertex_declaration *vdecl = state->vertex_declaration; struct wined3d_context_gl *context_gl = wined3d_context_gl(context); const struct wined3d_gl_info *gl_info = context_gl->gl_info; - BOOL specular = !!(context->stream_info.use_map & (1u << WINED3D_FFP_SPECULAR)); - BOOL diffuse = !!(context->stream_info.use_map & (1u << WINED3D_FFP_DIFFUSE)); BOOL normal = !!(context->stream_info.use_map & (1u << WINED3D_FFP_NORMAL)); const BOOL legacy_clip_planes = needs_legacy_glsl_syntax(gl_info); BOOL transformed = context->stream_info.position_transformed; BOOL wasrhw = context->last_was_rhw; bool point_size = vdecl->point_size; + bool specular = vdecl->specular; + bool diffuse = vdecl->diffuse; unsigned int i; context->last_was_rhw = transformed; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 98b58cbeb06..df502af247f 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6629,7 +6629,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context, settings->per_vertex_point_size = vdecl->point_size; wined3d_get_material_colour_source(&diffuse_source, &emissive_source, - &ambient_source, &specular_source, state, si); + &ambient_source, &specular_source, state); settings->diffuse_source = diffuse_source; settings->emissive_source = emissive_source; settings->ambient_source = ambient_source; diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c index d86b6afc41c..9affc604f13 100644 --- a/dlls/wined3d/vertexdeclaration.c +++ b/dlls/wined3d/vertexdeclaration.c @@ -222,6 +222,10 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara declaration->position_transformed = true; else if (e->usage == WINED3D_DECL_USAGE_PSIZE) declaration->point_size = true; + else if (e->usage == WINED3D_DECL_USAGE_COLOR && !e->usage_idx) + declaration->diffuse = true; + else if (e->usage == WINED3D_DECL_USAGE_COLOR && e->usage_idx == 1) + declaration->specular = true; /* Find the streams used in the declaration. The vertex buffers have * to be loaded when drawing, but filter tessellation pseudo streams. */ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index ff192c1b3f4..a1a981d5a4c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3493,6 +3493,8 @@ struct wined3d_vertex_declaration bool position_transformed; bool point_size; + bool diffuse; + bool specular; }; bool wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info, @@ -4625,21 +4627,22 @@ static inline void wined3d_not_from_cs(const struct wined3d_cs *cs) assert(cs->thread_id != GetCurrentThreadId()); } -static inline enum wined3d_material_color_source validate_material_colour_source(WORD use_map, - enum wined3d_material_color_source source) +static inline enum wined3d_material_color_source validate_material_colour_source( + const struct wined3d_vertex_declaration *vdecl, enum wined3d_material_color_source source) { - if (source == WINED3D_MCS_COLOR1 && use_map & (1u << WINED3D_FFP_DIFFUSE)) + if (source == WINED3D_MCS_COLOR1 && vdecl->diffuse) return source; - if (source == WINED3D_MCS_COLOR2 && use_map & (1u << WINED3D_FFP_SPECULAR)) + if (source == WINED3D_MCS_COLOR2 && vdecl->specular) return source; return WINED3D_MCS_MATERIAL; } static inline void wined3d_get_material_colour_source(enum wined3d_material_color_source *diffuse, enum wined3d_material_color_source *emissive, enum wined3d_material_color_source *ambient, - enum wined3d_material_color_source *specular, const struct wined3d_state *state, - const struct wined3d_stream_info *si) + enum wined3d_material_color_source *specular, const struct wined3d_state *state) { + const struct wined3d_vertex_declaration *vdecl = state->vertex_declaration; + if (!state->render_states[WINED3D_RS_LIGHTING]) { *diffuse = WINED3D_MCS_COLOR1; @@ -4656,10 +4659,10 @@ static inline void wined3d_get_material_colour_source(enum wined3d_material_colo return; } - *diffuse = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_DIFFUSEMATERIALSOURCE]); - *emissive = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_EMISSIVEMATERIALSOURCE]); - *ambient = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_AMBIENTMATERIALSOURCE]); - *specular = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_SPECULARMATERIALSOURCE]); + *diffuse = validate_material_colour_source(vdecl, state->render_states[WINED3D_RS_DIFFUSEMATERIALSOURCE]); + *emissive = validate_material_colour_source(vdecl, state->render_states[WINED3D_RS_EMISSIVEMATERIALSOURCE]); + *ambient = validate_material_colour_source(vdecl, state->render_states[WINED3D_RS_AMBIENTMATERIALSOURCE]); + *specular = validate_material_colour_source(vdecl, state->render_states[WINED3D_RS_SPECULARMATERIALSOURCE]); } static inline void wined3d_vec4_transform(struct wined3d_vec4 *dst,