wined3d: Use context->stream_info.position_transformed instead of context->last_was_rhw in state handlers.

Use of last_was_rhw in these state handlers is, firstly, confusing to read.
The variable is actually supposed to be set for *this* draw, not the last one,
and state handlers indeed expect that, but that fact isn't obvious. Reading from
context->stream_info instead is clearer.

Secondly, since last_was_rhw is set by the STATE_VDECL handler, any other state
depending on it (including some, though not all, of the sites changed here) thus
has an implicit state handler ordering assumption. This is, needless to say,
fragile. context->stream_info is computed before state handlers, so that
dependency is a bit less fragile.
This commit is contained in:
Zebediah Figura 2023-11-15 15:02:01 -06:00 committed by Alexandre Julliard
parent 5d5adce343
commit 936b950112
3 changed files with 11 additions and 10 deletions

View file

@ -6715,7 +6715,8 @@ static void state_arbfp_fog(struct wined3d_context *context, const struct wined3
}
else
{
if (state->render_states[WINED3D_RS_FOGVERTEXMODE] == WINED3D_FOG_NONE || context->last_was_rhw)
if (state->render_states[WINED3D_RS_FOGVERTEXMODE] == WINED3D_FOG_NONE
|| context->stream_info.position_transformed)
new_source = FOGSOURCE_COORD;
else
new_source = FOGSOURCE_FFP;

View file

@ -1230,7 +1230,7 @@ static void depth(struct wined3d_context *context, const struct wined3d_state *s
}
}
if (context->last_was_rhw && !isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION)))
if (context->stream_info.position_transformed && !isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION)))
context_apply_state(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION));
}
@ -1303,7 +1303,7 @@ static void state_fog_vertexpart(struct wined3d_context *context, const struct w
/* Otherwise use per-vertex fog in any case */
gl_info->gl_ops.gl.p_glHint(GL_FOG_HINT, GL_FASTEST);
if (state->render_states[WINED3D_RS_FOGVERTEXMODE] == WINED3D_FOG_NONE || context->last_was_rhw)
if (state->render_states[WINED3D_RS_FOGVERTEXMODE] == WINED3D_FOG_NONE || context->stream_info.position_transformed)
{
/* No fog at all, or transformed vertices: Use fog coord */
if (!context->fog_coord)
@ -1436,7 +1436,7 @@ void state_fog_fragpart(struct wined3d_context *context, const struct wined3d_st
{
/* If processed vertices are used, fall through to the NONE case */
case WINED3D_FOG_EXP:
if (!context->last_was_rhw)
if (!context->stream_info.position_transformed)
{
gl_info->gl_ops.gl.p_glFogi(GL_FOG_MODE, GL_EXP);
checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
@ -1446,7 +1446,7 @@ void state_fog_fragpart(struct wined3d_context *context, const struct wined3d_st
/* drop through */
case WINED3D_FOG_EXP2:
if (!context->last_was_rhw)
if (!context->stream_info.position_transformed)
{
gl_info->gl_ops.gl.p_glFogi(GL_FOG_MODE, GL_EXP2);
checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
@ -1456,7 +1456,7 @@ void state_fog_fragpart(struct wined3d_context *context, const struct wined3d_st
/* drop through */
case WINED3D_FOG_LINEAR:
if (!context->last_was_rhw)
if (!context->stream_info.position_transformed)
{
gl_info->gl_ops.gl.p_glFogi(GL_FOG_MODE, GL_LINEAR);
checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
@ -3620,7 +3620,7 @@ static void transform_view(struct wined3d_context *context, const struct wined3d
clipplane(context, state, STATE_CLIPPLANE(k));
}
if (context->last_was_rhw)
if (context->stream_info.position_transformed)
{
gl_info->gl_ops.gl.p_glLoadIdentity();
checkGLcall("glLoadIdentity()");

View file

@ -5644,7 +5644,7 @@ void get_identity_matrix(struct wined3d_matrix *mat)
void get_modelview_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
unsigned int index, struct wined3d_matrix *mat)
{
if (context->last_was_rhw)
if (context->stream_info.position_transformed)
get_identity_matrix(mat);
else
multiply_matrix(mat, &state->transforms[WINED3D_TS_VIEW], &state->transforms[WINED3D_TS_WORLD_MATRIX(index)]);
@ -5687,7 +5687,7 @@ void get_projection_matrix(const struct wined3d_context *context, const struct w
else
center_offset = 0.0f;
if (context->last_was_rhw)
if (context->stream_info.position_transformed)
{
/* Transform D3D RHW coordinates to OpenGL clip coordinates. */
float x = state->viewports[0].x;
@ -5859,7 +5859,7 @@ void get_texture_matrix(const struct wined3d_context *context, const struct wine
compute_texture_matrix(&state->transforms[WINED3D_TS_TEXTURE0 + tex],
state->texture_states[tex][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS],
generated, context->last_was_rhw,
generated, context->stream_info.position_transformed,
context->stream_info.use_map & (1u << (WINED3D_FFP_TEXCOORD0 + coord_idx))
? context->stream_info.elements[WINED3D_FFP_TEXCOORD0 + coord_idx].format->id
: WINED3DFMT_UNKNOWN,