From eaef138dce6921250a4ea3ac3ccca7387098f0fc Mon Sep 17 00:00:00 2001 From: Elizabeth Figura Date: Wed, 7 Aug 2024 20:25:24 -0500 Subject: [PATCH] wined3d: Use the FFP HLSL pipeline for pretransformed draws as well. --- dlls/wined3d/context.c | 2 +- dlls/wined3d/glsl_shader.c | 4 ++-- dlls/wined3d/shader.c | 20 +++++++++++++++++++- dlls/wined3d/stateblock.c | 6 +++++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 1a6ad5dc79a..c05c833f4b3 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -161,8 +161,8 @@ void wined3d_stream_info_from_declaration(struct wined3d_stream_info *stream_inf const struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info) { /* We need to deal with frequency data! */ + BOOL use_vshader = use_vs(state) || (d3d_info->ffp_hlsl && state->shader[WINED3D_SHADER_TYPE_VERTEX]); struct wined3d_vertex_declaration *declaration = state->vertex_declaration; - BOOL use_vshader = use_vs(state); unsigned int i; stream_info->use_map = 0; diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 785050e7631..61b53da540a 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -10425,10 +10425,10 @@ static void set_glsl_shader_program(const struct wined3d_context_gl *context_gl, vs_id = ctx_data->glsl_program->vs.id; vs_list = &ctx_data->glsl_program->vs.shader_entry; - if (use_vs(state)) + if (use_vs(state) || d3d_info->ffp_hlsl) vshader = state->shader[WINED3D_SHADER_TYPE_VERTEX]; } - else if (use_vs(state)) + else if (use_vs(state) || d3d_info->ffp_hlsl) { struct vs_compile_args vs_compile_args; diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 2a67f3944bd..7c18c96dbf6 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -2701,9 +2701,27 @@ void find_vs_compile_args(const struct wined3d_state *state, const struct wined3 && state->transforms[WINED3D_TS_PROJECTION]._24 == 0.0f && state->transforms[WINED3D_TS_PROJECTION]._34 == 0.0f && state->transforms[WINED3D_TS_PROJECTION]._44 == 1.0f) - args->fog_src = VS_FOG_Z; + { + /* Fog source is vertex output Z. + * + * However, if drawing RHW (which means we are using an HLSL + * replacement shader, since we got here), and depth testing is + * disabled, primitives are not supposed to be clipped by the + * viewport. We handle this in the vertex shader by essentially + * flushing output Z to zero. + * + * Fog needs to still read from the original Z, however. In this + * case we read from oFog, which contains the original Z. */ + + if (state->vertex_declaration->position_transformed) + args->fog_src = VS_FOG_COORD; + else + args->fog_src = VS_FOG_Z; + } else + { args->fog_src = VS_FOG_W; + } } else { diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 8d2bfcf8f8a..d24b356dc1f 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1575,6 +1575,9 @@ void CDECL wined3d_stateblock_set_vertex_declaration(struct wined3d_stateblock * || declaration->normal != prev->normal || declaration->point_size != prev->point_size) stateblock->changed.ffp_vs_settings = 1; } + + if (declaration->position_transformed != prev->position_transformed) + stateblock->changed.ffp_vs_settings = 1; } else { @@ -3814,7 +3817,8 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, * FFP pipeline cares about. The rest should eventually be removed from * those structs and left only in vs_compile_args / ps_compile_args. */ - if (changed->ffp_vs_settings && !state->vs) + if (changed->ffp_vs_settings + && (!state->vs || !state->vertex_declaration || state->vertex_declaration->position_transformed)) { if (device->adapter->d3d_info.ffp_hlsl) {