From: Paul Gofman gofmanp@gmail.com
NVIDIA drivers perform too aggressive optimization involving change of computation order (aka 'fastmath') by default. The setting helps to workaround bugs like https://bugs.winehq.org/show_bug.cgi?id=35207.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/wined3d/glsl_shader.c | 3 +++ dlls/wined3d/wined3d_main.c | 3 +++ dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 7 insertions(+)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 660005f57e9..4613d78f94c 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -2416,6 +2416,9 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont unsigned int i; DWORD map;
+ if (wined3d_settings.strict_shader_math) + shader_addline(buffer, "#pragma optionNV(fastmath off)\n"); + prefix = shader_glsl_get_prefix(version->type);
/* Prototype the subroutines */ diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c index 1b64d2cf5dc..fb70b946770 100644 --- a/dlls/wined3d/wined3d_main.c +++ b/dlls/wined3d/wined3d_main.c @@ -82,6 +82,7 @@ struct wined3d_settings wined3d_settings = TRUE, /* Prefer multisample textures to multisample renderbuffers. */ ~0u, /* Don't force a specific sample count by default. */ FALSE, /* Don't range check relative addressing indices in float constants. */ + FALSE, /* No strict shader math by default. */ ~0U, /* No VS shader model limit by default. */ ~0U, /* No HS shader model limit by default. */ ~0U, /* No DS shader model limit by default. */ @@ -312,6 +313,8 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL) TRACE("Checking relative addressing indices in float constants.\n"); wined3d_settings.check_float_constants = TRUE; } + if (!get_config_key_dword(hkey, appkey, "strict_shader_math", &wined3d_settings.strict_shader_math)) + ERR_(winediag)("Setting strict shader math to %#x.\n", wined3d_settings.strict_shader_math); if (!get_config_key_dword(hkey, appkey, "MaxShaderModelVS", &wined3d_settings.max_sm_vs)) TRACE("Limiting VS shader model to %u.\n", wined3d_settings.max_sm_vs); if (!get_config_key_dword(hkey, appkey, "MaxShaderModelHS", &wined3d_settings.max_sm_hs)) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index b3f3847045d..f2b9b5feb25 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -398,6 +398,7 @@ struct wined3d_settings unsigned int multisample_textures; unsigned int sample_count; BOOL check_float_constants; + unsigned int strict_shader_math; unsigned int max_sm_vs; unsigned int max_sm_hs; unsigned int max_sm_ds;