[Mesa-dev] [PATCH 1/4] driconf: add force_glsl_abs_sqrt option
Samuel Pitoiset
samuel.pitoiset at gmail.com
Fri Mar 17 00:06:54 UTC 2017
This will allow to force computing the absolute value for sqrt()
and inversesqrt() in order to follow D3D9 behaviour for buggy
apps that rely on it.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/gallium/include/state_tracker/st_api.h | 1 +
src/gallium/state_trackers/dri/dri_screen.c | 3 +++
src/mesa/drivers/dri/common/xmlpool/t_options.h | 5 +++++
src/mesa/drivers/dri/i965/brw_context.c | 3 +++
src/mesa/drivers/dri/i965/intel_screen.c | 1 +
src/mesa/main/mtypes.h | 6 ++++++
src/mesa/state_tracker/st_extensions.c | 2 ++
7 files changed, 21 insertions(+)
diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
index a9997744cd..868181d168 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -248,6 +248,7 @@ struct st_config_options
boolean allow_glsl_extension_directive_midshader;
boolean allow_higher_compat_version;
boolean glsl_zero_init;
+ boolean force_glsl_abs_sqrt;
unsigned char config_options_sha1[20];
};
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index 9b37dff677..55b1752f4a 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -71,6 +71,7 @@ const __DRIconfigOptionsExtension gallium_config_options = {
DRI_CONF_FORCE_GLSL_VERSION(0)
DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER("false")
DRI_CONF_ALLOW_HIGHER_COMPAT_VERSION("false")
+ DRI_CONF_FORCE_GLSL_ABS_SQRT("false")
DRI_CONF_SECTION_END
DRI_CONF_SECTION_MISCELLANEOUS
@@ -105,6 +106,8 @@ dri_fill_st_options(struct dri_screen *screen)
options->allow_higher_compat_version =
driQueryOptionb(optionCache, "allow_higher_compat_version");
options->glsl_zero_init = driQueryOptionb(optionCache, "glsl_zero_init");
+ options->force_glsl_abs_sqrt =
+ driQueryOptionb(optionCache, "force_glsl_abs_sqrt");
driComputeOptionsSha1(optionCache, options->config_options_sha1);
}
diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h b/src/mesa/drivers/dri/common/xmlpool/t_options.h
index f200093177..1ed8a9b4f9 100644
--- a/src/mesa/drivers/dri/common/xmlpool/t_options.h
+++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h
@@ -120,6 +120,11 @@ DRI_CONF_OPT_BEGIN_B(allow_higher_compat_version, def) \
DRI_CONF_DESC(en,gettext("Allow a higher compat profile (version 3.1+) for apps that request it")) \
DRI_CONF_OPT_END
+#define DRI_CONF_FORCE_GLSL_ABS_SQRT(def) \
+DRI_CONF_OPT_BEGIN_B(force_glsl_abs_sqrt, def) \
+ DRI_CONF_DESC(en,gettext("Force computing the absolute value for sqrt() and inversesqrt()")) \
+DRI_CONF_OPT_END
+
/**
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 32cfb2efe4..f584fab180 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -922,6 +922,9 @@ brw_process_driconf_options(struct brw_context *brw)
ctx->Const.AllowHigherCompatVersion =
driQueryOptionb(options, "allow_higher_compat_version");
+ ctx->Const.ForceGLSLAbsSqrt =
+ driQueryOptionb(options, "force_glsl_abs_sqrt");
+
ctx->Const.GLSLZeroInit = driQueryOptionb(options, "glsl_zero_init");
brw->dual_color_blend_by_location =
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 10dab2317e..e5fa0cc17a 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -81,6 +81,7 @@ DRI_CONF_BEGIN
DRI_CONF_DUAL_COLOR_BLEND_BY_LOCATION("false")
DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER("false")
DRI_CONF_ALLOW_HIGHER_COMPAT_VERSION("false")
+ DRI_CONF_FORCE_GLSL_ABS_SQRT("false")
DRI_CONF_OPT_BEGIN_B(shader_precompile, "true")
DRI_CONF_DESC(en, "Perform code generation at shader link time.")
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index e53d5762f9..01c656e64e 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3556,6 +3556,12 @@ struct gl_constants
GLboolean AllowHigherCompatVersion;
/**
+ * Force computing the absolute value for sqrt() and inversesqrt() to follow
+ * D3D9 when apps rely on this behaviour.
+ */
+ GLboolean ForceGLSLAbsSqrt;
+
+ /**
* Force uninitialized variables to default to zero.
*/
GLboolean GLSLZeroInit;
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 0dc2580a88..16f86856a3 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -881,6 +881,8 @@ void st_init_extensions(struct pipe_screen *screen,
consts->AllowHigherCompatVersion = options->allow_higher_compat_version;
+ consts->ForceGLSLAbsSqrt = options->force_glsl_abs_sqrt;
+
consts->dri_config_options_sha1 = options->config_options_sha1;
if (consts->GLSLVersion >= 400)
--
2.12.0
More information about the mesa-dev
mailing list