Module: wine
Branch: master
Commit: 936b950112e0ca06ffc4600efcfa86e8526939ad
URL: https://gitlab.winehq.org/wine/wine/-/commit/936b950112e0ca06ffc4600efcfa86…
Author: Zebediah Figura <zfigura(a)codeweavers.com>
Date: Wed Nov 15 15:02:01 2023 -0600
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.
---
dlls/wined3d/arb_program_shader.c | 3 ++-
dlls/wined3d/state.c | 12 ++++++------
dlls/wined3d/utils.c | 6 +++---
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 3ae82383146..153786c25e7 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -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;
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 1dcef265b95..2fb75785daf 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -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()");
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index e833bdc8d90..dd83b2fcef7 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -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,
Module: wine
Branch: master
Commit: 5d5adce343d2356a90a62692f4350d34d3ad3391
URL: https://gitlab.winehq.org/wine/wine/-/commit/5d5adce343d2356a90a62692f4350d…
Author: Zebediah Figura <zfigura(a)codeweavers.com>
Date: Sun Nov 12 14:25:04 2023 -0600
wined3d: Remove an outdated comment.
The comment was originally added in 4b831a5d3e15af9dccf7114bb4440133cb8fe721.
At that point, it referred only to non-FFP shader constants. Subsequently
38934fe70d7ffd2353351a7986346f4a205adc1f moved bumpenv constant loading to the
misc pipeline, apparently out of concerns that bumpenv constants might interact
badly with shader constants.
It's not clear whether those concerns were ever justified, and normal shader
constants are now sufficiently untangled from each other anyway. However,
bumpenv constants, like e.g. color keys, affect both FFP and non-FFP pipelines,
so it makes the most sense for them to remain in the misc state table anyway.
---
dlls/wined3d/state.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 5333382ab81..1dcef265b95 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -4379,10 +4379,6 @@ const struct wined3d_state_entry_template misc_state_template_gl[] =
{ STATE_POINTSPRITECOORDORIGIN, { STATE_POINTSPRITECOORDORIGIN, state_nop }, ARB_CLIP_CONTROL },
{ STATE_POINTSPRITECOORDORIGIN, { STATE_POINTSPRITECOORDORIGIN, psorigin }, WINED3D_GL_VERSION_2_0 },
{ STATE_POINTSPRITECOORDORIGIN, { STATE_POINTSPRITECOORDORIGIN, psorigin_w }, WINED3D_GL_EXT_NONE },
-
- /* TODO: Move shader constant loading to vertex and fragment pipeline respectively, as soon as the pshader and
- * vshader loadings are untied from each other
- */
{ STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), shader_bumpenv }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },