From: Elizabeth Figura zfigura@codeweavers.com
We cannot get rid of the WINED3D_TS_PROJECTION state handler yet, because table fog still depends on it. --- dlls/wined3d/ffp_gl.c | 4 ++-- dlls/wined3d/glsl_shader.c | 14 +++++++------- dlls/wined3d/stateblock.c | 12 ++++++++++++ dlls/wined3d/wined3d_private.h | 1 + 4 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/ffp_gl.c b/dlls/wined3d/ffp_gl.c index 447de1b68b0..3bcd67f9c02 100644 --- a/dlls/wined3d/ffp_gl.c +++ b/dlls/wined3d/ffp_gl.c @@ -759,8 +759,8 @@ static void depth(struct wined3d_context *context, const struct wined3d_state *s } }
- if (context->stream_info.position_transformed && !isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION))) - context_apply_state(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); + if (context->stream_info.position_transformed) + context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_PROJ; }
static void depth_stencil(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index e055e88103e..977e5f1ae07 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1478,7 +1478,7 @@ static void reset_program_constant_version(struct wine_rb_entry *entry, void *co }
static void get_projection_matrix(const struct wined3d_context *context, - const struct wined3d_state *state, struct wined3d_matrix *mat) + const struct wined3d_ffp_vs_constants *constants, const struct wined3d_state *state, struct wined3d_matrix *mat) { const struct wined3d_d3d_info *d3d_info = context->d3d_info; bool clip_control, flip; @@ -1558,7 +1558,7 @@ static void get_projection_matrix(const struct wined3d_context *context, x_offset, y_offset, z_offset, 1.0f, };
- multiply_matrix(mat, &projection, &state->transforms[WINED3D_TS_PROJECTION]); + multiply_matrix(mat, &projection, &constants->projection_matrix); } }
@@ -1814,9 +1814,12 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv,
if (update_mask & WINED3D_SHADER_CONST_FFP_PROJ) { + const struct wined3d_ffp_vs_constants *constants; struct wined3d_matrix projection;
- get_projection_matrix(context, state, &projection); + constants = wined3d_buffer_load_sysmem(context->device->push_constants[WINED3D_PUSH_CONSTANTS_VS_FFP], context); + + get_projection_matrix(context, constants, state, &projection); GL_EXTCALL(glUniformMatrix4fv(prog->vs.projection_matrix_location, 1, FALSE, &projection._11)); checkGLcall("glUniformMatrix4fv"); } @@ -11922,18 +11925,15 @@ static void glsl_vertex_pipe_projection(struct wined3d_context *context, if (state->render_states[WINED3D_RS_FOGENABLE] && state->render_states[WINED3D_RS_FOGTABLEMODE] != WINED3D_FOG_NONE) context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_VERTEX; - context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_PROJ; }
static void glsl_vertex_pipe_viewport(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { - if (!isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION))) - glsl_vertex_pipe_projection(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); if (!isStateDirty(context, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE)) && state->render_states[WINED3D_RS_POINTSCALEENABLE]) context->constant_update_mask |= WINED3D_SHADER_CONST_VS_POINTSIZE; - context->constant_update_mask |= WINED3D_SHADER_CONST_POS_FIXUP; + context->constant_update_mask |= WINED3D_SHADER_CONST_POS_FIXUP | WINED3D_SHADER_CONST_FFP_PROJ; }
static void glsl_vertex_pipe_pointsize(struct wined3d_context *context, diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 0618f982315..8e638033eb0 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -2251,6 +2251,8 @@ static void wined3d_stateblock_invalidate_push_constants(struct wined3d_stateblo stateblock->changed.lights = 1; stateblock->changed.texture_matrices = 1; stateblock->changed.material = 1; + stateblock->changed.transforms = 1; + wined3d_bitmap_set(stateblock->changed.transform, WINED3D_TS_PROJECTION); }
static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, const struct wined3d_stateblock *device_state, @@ -3334,6 +3336,16 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, changed->clipplane = wined3d_mask_from_size(WINED3D_MAX_CLIP_DISTANCES); }
+ if (idx == WINED3D_TS_PROJECTION) + { + wined3d_device_context_push_constants(context, + WINED3D_PUSH_CONSTANTS_VS_FFP, WINED3D_SHADER_CONST_FFP_PROJ, + offsetof(struct wined3d_ffp_vs_constants, projection_matrix), + sizeof(state->transforms[idx]), &state->transforms[idx]); + /* wined3d_ffp_vs_settings.ortho_fog still needs the + * device state to be set. */ + } + if (!(idx >= WINED3D_TS_TEXTURE0 && idx <= WINED3D_TS_TEXTURE7)) wined3d_device_set_transform(device, idx, &state->transforms[idx]); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 693aa9efeee..30f836f901f 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2768,6 +2768,7 @@ BOOL wined3d_get_app_name(char *app_name, unsigned int app_name_size);
struct wined3d_ffp_vs_constants { + struct wined3d_matrix projection_matrix; struct wined3d_matrix texture_matrices[WINED3D_MAX_FFP_TEXTURES]; struct wined3d_material material; struct wined3d_ffp_light_constants