Commit 936b9501 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Use context->stream_info.position_transformed instead of…

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.
parent 5d5adce3
...@@ -6715,7 +6715,8 @@ static void state_arbfp_fog(struct wined3d_context *context, const struct wined3 ...@@ -6715,7 +6715,8 @@ static void state_arbfp_fog(struct wined3d_context *context, const struct wined3
} }
else 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; new_source = FOGSOURCE_COORD;
else else
new_source = FOGSOURCE_FFP; new_source = FOGSOURCE_FFP;
......
...@@ -1230,7 +1230,7 @@ static void depth(struct wined3d_context *context, const struct wined3d_state *s ...@@ -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)); 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 ...@@ -1303,7 +1303,7 @@ static void state_fog_vertexpart(struct wined3d_context *context, const struct w
/* Otherwise use per-vertex fog in any case */ /* Otherwise use per-vertex fog in any case */
gl_info->gl_ops.gl.p_glHint(GL_FOG_HINT, GL_FASTEST); 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 */ /* No fog at all, or transformed vertices: Use fog coord */
if (!context->fog_coord) if (!context->fog_coord)
...@@ -1436,7 +1436,7 @@ void state_fog_fragpart(struct wined3d_context *context, const struct wined3d_st ...@@ -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 */ /* If processed vertices are used, fall through to the NONE case */
case WINED3D_FOG_EXP: 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); gl_info->gl_ops.gl.p_glFogi(GL_FOG_MODE, GL_EXP);
checkGLcall("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 ...@@ -1446,7 +1446,7 @@ void state_fog_fragpart(struct wined3d_context *context, const struct wined3d_st
/* drop through */ /* drop through */
case WINED3D_FOG_EXP2: 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); gl_info->gl_ops.gl.p_glFogi(GL_FOG_MODE, GL_EXP2);
checkGLcall("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 ...@@ -1456,7 +1456,7 @@ void state_fog_fragpart(struct wined3d_context *context, const struct wined3d_st
/* drop through */ /* drop through */
case WINED3D_FOG_LINEAR: 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); gl_info->gl_ops.gl.p_glFogi(GL_FOG_MODE, GL_LINEAR);
checkGLcall("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 ...@@ -3620,7 +3620,7 @@ static void transform_view(struct wined3d_context *context, const struct wined3d
clipplane(context, state, STATE_CLIPPLANE(k)); clipplane(context, state, STATE_CLIPPLANE(k));
} }
if (context->last_was_rhw) if (context->stream_info.position_transformed)
{ {
gl_info->gl_ops.gl.p_glLoadIdentity(); gl_info->gl_ops.gl.p_glLoadIdentity();
checkGLcall("glLoadIdentity()"); checkGLcall("glLoadIdentity()");
......
...@@ -5644,7 +5644,7 @@ void get_identity_matrix(struct wined3d_matrix *mat) ...@@ -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, void get_modelview_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
unsigned int index, struct wined3d_matrix *mat) unsigned int index, struct wined3d_matrix *mat)
{ {
if (context->last_was_rhw) if (context->stream_info.position_transformed)
get_identity_matrix(mat); get_identity_matrix(mat);
else else
multiply_matrix(mat, &state->transforms[WINED3D_TS_VIEW], &state->transforms[WINED3D_TS_WORLD_MATRIX(index)]); 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 ...@@ -5687,7 +5687,7 @@ void get_projection_matrix(const struct wined3d_context *context, const struct w
else else
center_offset = 0.0f; center_offset = 0.0f;
if (context->last_was_rhw) if (context->stream_info.position_transformed)
{ {
/* Transform D3D RHW coordinates to OpenGL clip coordinates. */ /* Transform D3D RHW coordinates to OpenGL clip coordinates. */
float x = state->viewports[0].x; float x = state->viewports[0].x;
...@@ -5859,7 +5859,7 @@ void get_texture_matrix(const struct wined3d_context *context, const struct wine ...@@ -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], compute_texture_matrix(&state->transforms[WINED3D_TS_TEXTURE0 + tex],
state->texture_states[tex][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS], 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.use_map & (1u << (WINED3D_FFP_TEXCOORD0 + coord_idx))
? context->stream_info.elements[WINED3D_FFP_TEXCOORD0 + coord_idx].format->id ? context->stream_info.elements[WINED3D_FFP_TEXCOORD0 + coord_idx].format->id
: WINED3DFMT_UNKNOWN, : WINED3DFMT_UNKNOWN,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment