From 9af691e74a06cdef61cba1623047398043ef3c2b Mon Sep 17 00:00:00 2001 From: Matteo Bruni Date: Mon, 31 May 2021 21:12:53 +0200 Subject: [PATCH] wined3d: Don't skip FFP vertex pipeline state handlers when STATE_VDECL is dirty. This fixes the non-default ARB shader backend, broken since 2ddb6b66a7cda0bf6aaddc0c6899e35cc92ceee9, although the fundamental issue was there long before that. Originally the STATE_VDECL handler did some bookkeeping (basically, computing what is now the stream info data) that's a prerequisite for running other state handlers. For this reason a somewhat complicated dance was put in place, with the dependent handlers returning right away until the STATE_VDECL handler could prepare everything up and the STATE_VDECL handler in turn explicitly calling these "downstream" handlers so that they could do their job. With the commit mentioned above the state dirty flags are cleared after the corresponding handlers are executed, which means that the relevant handlers are skipped twice and some stuff is never set up properly. Stream info is computed by context_apply_draw_state() before going through the state handler table for a long time now, getting rid of this obscure handler interdependency. So let's just get rid of the skipping altogether. Signed-off-by: Matteo Bruni Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard (cherry picked from commit e106bbdd39a5f27bce028ed992033eb0a5635f60) Signed-off-by: Michael Stefaniuc --- dlls/wined3d/state.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index e40c23daf03..269d7452c9f 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -272,11 +272,7 @@ static void state_lighting(struct wined3d_context *context, const struct wined3d /* Lighting is not enabled if transformed vertices are drawn, but lighting * does not affect the stream sources, so it is not grouped for - * performance reasons. This state reads the decoded vertex declaration, - * so if it is dirty don't do anything. The vertex declaration applying - * function calls this function for updating. */ - if (isStateDirty(context, STATE_VDECL)) - return; + * performance reasons. */ if (state->render_states[WINED3D_RS_LIGHTING] && !context->stream_info.position_transformed) @@ -1504,12 +1500,6 @@ static void state_colormat(struct wined3d_context *context, const struct wined3d const struct wined3d_gl_info *gl_info = context_gl->gl_info; GLenum Parm = 0; - /* Depends on the decoded vertex declaration to read the existence of - * diffuse data. The vertex declaration will call this function if the - * fixed function pipeline is used. */ - if (isStateDirty(&context_gl->c, STATE_VDECL)) - return; - context_gl->untracked_material_count = 0; if ((context_gl->c.stream_info.use_map & (1u << WINED3D_FFP_DIFFUSE)) && state->render_states[WINED3D_RS_COLORVERTEX]) @@ -1650,9 +1640,6 @@ static void state_normalize(struct wined3d_context *context, const struct wined3 { const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; - if (isStateDirty(context, STATE_VDECL)) - return; - /* Without vertex normals, we set the current normal to 0/0/0 to remove the diffuse factor * from the opengl lighting equation, as d3d does. Normalization of 0/0/0 can lead to a division * by zero and is not properly defined in opengl, so avoid it @@ -3438,10 +3425,9 @@ static void transform_texture(struct wined3d_context *context, const struct wine unsigned int mapped_stage = context_gl->tex_unit_map[tex]; struct wined3d_matrix mat; - /* Ignore this when a vertex shader is used, or if the streams aren't sorted out yet */ - if (use_vs(state) || isStateDirty(context, STATE_VDECL)) + if (use_vs(state)) { - TRACE("Using a vertex shader, or stream sources not sorted out yet, skipping\n"); + TRACE("Using a vertex shader, skipping.\n"); return; } @@ -4007,8 +3993,6 @@ static void transform_projection(struct wined3d_context *context, const struct w static void streamsrc(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { - if (isStateDirty(context, STATE_VDECL)) - return; wined3d_context_gl_update_stream_sources(wined3d_context_gl(context), state); }