driconf: add force_glsl_abs_sqrt option
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 17 Mar 2017 00:06:54 +0000 (01:06 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 22 Mar 2017 21:01:01 +0000 (22:01 +0100)
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@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/include/state_tracker/st_api.h
src/gallium/state_trackers/dri/dri_screen.c
src/mesa/drivers/dri/common/xmlpool/t_options.h
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/intel_screen.c
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_extensions.c

index bf9a7e95d7cb3b5260ea90cf1f4ce390c6311827..9d0eb3a8a67549c9383f52a9e314c5eb28d2ec4c 100644 (file)
@@ -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];
 };
 
index 799a2649b04126a84f1085ec75437397c2821e23..998e8ef8cbc30e390b8e021119c060dfc76a8951 100644 (file)
@@ -76,6 +76,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
@@ -110,6 +111,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);
 }
index c7c658d0aac5a6997f564b1c023bcb2095aa3aab..cd4f0252b926b4d255d43ec475a3408ebbadb638 100644 (file)
@@ -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
+
 
 
 /**
index 648ae50814535f2faeefd0429d5f596cd390c28d..624abe6d523112a5ac402ea739f501a23489f3d3 100644 (file)
@@ -937,6 +937,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 =
index a35cf69eeded7b7e61bb19da4f7beed2b5a19463..c7f111d04afbcb9f19376a29bcb25fca212016d1 100644 (file)
@@ -90,6 +90,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.")
index 7e970843d5cb3b386ed33c2341ce61576726dc5f..be78b96810d0994e9b03e4fa39b4d83a96528cc5 100644 (file)
@@ -3555,6 +3555,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.
     */
index 0dc2580a88cd0b7b1fc467441ad384eb7595e6ec..16f86856a344ca0f33864a5cc17fca66a41a58b1 100644 (file)
@@ -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)