Preparation for refactoring, which itself is preparation for a Vulkan FFP implementation and will almost certainly be delayed until after code freeze.
From: Elizabeth Figura zfigura@codeweavers.com
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 },
From: Elizabeth Figura zfigura@codeweavers.com
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,
From: Elizabeth Figura zfigura@codeweavers.com
As with the previous commit, this is clearer and avoids a state ordering assumption. --- dlls/wined3d/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index dd83b2fcef7..ac53f477edd 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5865,7 +5865,7 @@ void get_texture_matrix(const struct wined3d_context *context, const struct wine : WINED3DFMT_UNKNOWN, device->shader_backend->shader_has_ffp_proj_control(device->shader_priv), mat);
- if ((context->lastWasPow2Texture & (1u << tex)) && texture) + if (texture && !(texture->flags & WINED3D_TEXTURE_POW2_MAT_IDENT)) { if (generated) FIXME("Non-power-of-two texture being used with generated texture coords.\n");
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/arb_program_shader.c | 12 ------------ dlls/wined3d/glsl_shader.c | 12 ------------ dlls/wined3d/shader.c | 12 ------------ dlls/wined3d/shader_spirv.c | 12 ------------ dlls/wined3d/utils.c | 3 +-- dlls/wined3d/wined3d_private.h | 1 - 6 files changed, 1 insertion(+), 51 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 153786c25e7..ee693924a24 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -286,7 +286,6 @@ struct shader_arb_priv
const struct wined3d_vertex_pipe_ops *vertex_pipe; const struct wined3d_fragment_pipe_ops *fragment_pipe; - BOOL ffp_proj_control; };
/* Context activation for state handlers is done by the caller. */ @@ -4843,7 +4842,6 @@ static HRESULT shader_arb_alloc(struct wined3d_device *device, const struct wine const struct wined3d_fragment_pipe_ops *fragment_pipe) { const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info; - struct fragment_caps fragment_caps; void *vertex_priv, *fragment_priv; struct shader_arb_priv *priv;
@@ -4874,8 +4872,6 @@ static HRESULT shader_arb_alloc(struct wined3d_device *device, const struct wine
priv->vertex_pipe = vertex_pipe; priv->fragment_pipe = fragment_pipe; - fragment_pipe->get_caps(device->adapter, &fragment_caps); - priv->ffp_proj_control = fragment_caps.proj_control;
device->vertex_priv = vertex_priv; device->fragment_priv = fragment_priv; @@ -5695,13 +5691,6 @@ static void shader_arb_handle_instruction(const struct wined3d_shader_instructio shader_arb_add_instruction_modifiers(ins); }
-static BOOL shader_arb_has_ffp_proj_control(void *shader_priv) -{ - struct shader_arb_priv *priv = shader_priv; - - return priv->ffp_proj_control; -} - static void shader_arb_precompile(void *shader_priv, struct wined3d_shader *shader) {}
static uint64_t shader_arb_shader_compile(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc, @@ -5729,7 +5718,6 @@ const struct wined3d_shader_backend_ops arb_program_shader_backend = shader_arb_init_context_state, shader_arb_get_caps, shader_arb_color_fixup_supported, - shader_arb_has_ffp_proj_control, shader_arb_shader_compile, };
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index a9775d94cf1..5dfcbb689b7 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -137,7 +137,6 @@ struct shader_glsl_priv const struct wined3d_fragment_pipe_ops *fragment_pipe; struct wine_rb_tree ffp_vertex_shaders; struct wine_rb_tree ffp_fragment_shaders; - BOOL ffp_proj_control; BOOL legacy_lighting; };
@@ -11060,7 +11059,6 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win const struct wined3d_fragment_pipe_ops *fragment_pipe) { SIZE_T stack_size = wined3d_log2i(max(WINED3D_MAX_VS_CONSTS_F, WINED3D_MAX_PS_CONSTS_F)) + 1; - struct fragment_caps fragment_caps; void *vertex_priv, *fragment_priv; struct shader_glsl_priv *priv;
@@ -11113,8 +11111,6 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win priv->next_constant_version = 1; priv->vertex_pipe = vertex_pipe; priv->fragment_pipe = fragment_pipe; - fragment_pipe->get_caps(device->adapter, &fragment_caps); - priv->ffp_proj_control = fragment_caps.proj_control; priv->legacy_lighting = device->wined3d->flags & WINED3D_LEGACY_FFP_LIGHTING;
device->vertex_priv = vertex_priv; @@ -11524,13 +11520,6 @@ static void shader_glsl_handle_instruction(const struct wined3d_shader_instructi shader_glsl_add_instruction_modifiers(ins); }
-static BOOL shader_glsl_has_ffp_proj_control(void *shader_priv) -{ - struct shader_glsl_priv *priv = shader_priv; - - return priv->ffp_proj_control; -} - static uint64_t shader_glsl_shader_compile(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc, enum wined3d_shader_type shader_type) { @@ -11556,7 +11545,6 @@ const struct wined3d_shader_backend_ops glsl_shader_backend = shader_glsl_init_context_state, shader_glsl_get_caps, shader_glsl_color_fixup_supported, - shader_glsl_has_ffp_proj_control, shader_glsl_shader_compile, };
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 8e2b9b4de66..428389a7177 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -1922,7 +1922,6 @@ struct shader_none_priv { const struct wined3d_vertex_pipe_ops *vertex_pipe; const struct wined3d_fragment_pipe_ops *fragment_pipe; - BOOL ffp_proj_control; };
static void shader_none_handle_instruction(const struct wined3d_shader_instruction *ins) {} @@ -1966,7 +1965,6 @@ static void shader_none_disable(void *shader_priv, struct wined3d_context *conte static HRESULT shader_none_alloc(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe, const struct wined3d_fragment_pipe_ops *fragment_pipe) { - struct fragment_caps fragment_caps; void *vertex_priv, *fragment_priv; struct shader_none_priv *priv;
@@ -1990,8 +1988,6 @@ static HRESULT shader_none_alloc(struct wined3d_device *device, const struct win
priv->vertex_pipe = vertex_pipe; priv->fragment_pipe = fragment_pipe; - fragment_pipe->get_caps(device->adapter, &fragment_caps); - priv->ffp_proj_control = fragment_caps.proj_control;
device->vertex_priv = vertex_priv; device->fragment_priv = fragment_priv; @@ -2027,13 +2023,6 @@ static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup) return TRUE; }
-static BOOL shader_none_has_ffp_proj_control(void *shader_priv) -{ - struct shader_none_priv *priv = shader_priv; - - return priv->ffp_proj_control; -} - static uint64_t shader_none_shader_compile(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc, enum wined3d_shader_type shader_type) { @@ -2058,7 +2047,6 @@ const struct wined3d_shader_backend_ops none_shader_backend = shader_none_init_context_state, shader_none_get_caps, shader_none_color_fixup_supported, - shader_none_has_ffp_proj_control, shader_none_shader_compile, };
diff --git a/dlls/wined3d/shader_spirv.c b/dlls/wined3d/shader_spirv.c index 2d98dd526ef..b5b0e1f0462 100644 --- a/dlls/wined3d/shader_spirv.c +++ b/dlls/wined3d/shader_spirv.c @@ -49,7 +49,6 @@ struct shader_spirv_priv { const struct wined3d_vertex_pipe_ops *vertex_pipe; const struct wined3d_fragment_pipe_ops *fragment_pipe; - bool ffp_proj_control;
struct shader_spirv_resource_bindings bindings; }; @@ -968,7 +967,6 @@ static void shader_spirv_destroy(struct wined3d_shader *shader) static HRESULT shader_spirv_alloc(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe, const struct wined3d_fragment_pipe_ops *fragment_pipe) { - struct fragment_caps fragment_caps; void *vertex_priv, *fragment_priv; struct shader_spirv_priv *priv;
@@ -992,8 +990,6 @@ static HRESULT shader_spirv_alloc(struct wined3d_device *device,
priv->vertex_pipe = vertex_pipe; priv->fragment_pipe = fragment_pipe; - fragment_pipe->get_caps(device->adapter, &fragment_caps); - priv->ffp_proj_control = fragment_caps.proj_control; memset(&priv->bindings, 0, sizeof(priv->bindings));
device->vertex_priv = vertex_priv; @@ -1049,13 +1045,6 @@ static BOOL shader_spirv_color_fixup_supported(struct color_fixup_desc fixup) return is_identity_fixup(fixup); }
-static BOOL shader_spirv_has_ffp_proj_control(void *shader_priv) -{ - struct shader_spirv_priv *priv = shader_priv; - - return priv->ffp_proj_control; -} - static uint64_t shader_spirv_compile(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc, enum wined3d_shader_type shader_type) { @@ -1081,7 +1070,6 @@ static const struct wined3d_shader_backend_ops spirv_shader_backend_vk = .shader_init_context_state = shader_spirv_init_context_state, .shader_get_caps = shader_spirv_get_caps, .shader_color_fixup_supported = shader_spirv_color_fixup_supported, - .shader_has_ffp_proj_control = shader_spirv_has_ffp_proj_control, .shader_compile = shader_spirv_compile, };
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index ac53f477edd..b2b234c8e29 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5850,7 +5850,6 @@ static void compute_texture_matrix(const struct wined3d_matrix *matrix, uint32_t void get_texture_matrix(const struct wined3d_context *context, const struct wined3d_state *state, const unsigned int tex, struct wined3d_matrix *mat) { - const struct wined3d_device *device = context->device; BOOL generated = (state->texture_states[tex][WINED3D_TSS_TEXCOORD_INDEX] & 0xffff0000) != WINED3DTSS_TCI_PASSTHRU; unsigned int coord_idx = min(state->texture_states[tex][WINED3D_TSS_TEXCOORD_INDEX & 0x0000ffff], @@ -5863,7 +5862,7 @@ void get_texture_matrix(const struct wined3d_context *context, const struct wine context->stream_info.use_map & (1u << (WINED3D_FFP_TEXCOORD0 + coord_idx)) ? context->stream_info.elements[WINED3D_FFP_TEXCOORD0 + coord_idx].format->id : WINED3DFMT_UNKNOWN, - device->shader_backend->shader_has_ffp_proj_control(device->shader_priv), mat); + context->d3d_info->ffp_fragment_caps.proj_control, mat);
if (texture && !(texture->flags & WINED3D_TEXTURE_POW2_MAT_IDENT)) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index d1a2469ab23..ea78312fef3 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1557,7 +1557,6 @@ struct wined3d_shader_backend_ops void (*shader_init_context_state)(struct wined3d_context *context); void (*shader_get_caps)(const struct wined3d_adapter *adapter, struct shader_caps *caps); BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup); - BOOL (*shader_has_ffp_proj_control)(void *shader_priv); uint64_t (*shader_compile)(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc, enum wined3d_shader_type shader_type); };
From: Elizabeth Figura zfigura@codeweavers.com
Fixes: 370b8299ab8d33664ffbb8bdbaafd04c8f566c23 --- dlls/wined3d/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index b2b234c8e29..a46a4c7257d 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5852,7 +5852,7 @@ void get_texture_matrix(const struct wined3d_context *context, const struct wine { BOOL generated = (state->texture_states[tex][WINED3D_TSS_TEXCOORD_INDEX] & 0xffff0000) != WINED3DTSS_TCI_PASSTHRU; - unsigned int coord_idx = min(state->texture_states[tex][WINED3D_TSS_TEXCOORD_INDEX & 0x0000ffff], + unsigned int coord_idx = min(state->texture_states[tex][WINED3D_TSS_TEXCOORD_INDEX] & 0x0000ffff, WINED3D_MAX_FFP_TEXTURES - 1); struct wined3d_texture *texture = wined3d_state_get_ffp_texture(state, tex);