[Mesa-dev] [PATCH 2/2] st/mesa, gallium: add a workaround for Unigine Heaven 4.0 and Valley 1.0

Marek Olšák maraeo at gmail.com
Tue Jul 8 11:29:45 PDT 2014


From: Marek Olšák <marek.olsak at amd.com>

Most (all?) Unigine shaders fail to compile without this if sample shading
is advertised. This is, of course, Unigine developers' fault.
---
 src/gallium/include/state_tracker/st_api.h          |  1 +
 src/gallium/state_trackers/dri/common/dri_context.c |  2 ++
 src/gallium/state_trackers/dri/common/dri_screen.c  |  1 +
 src/mesa/drivers/dri/common/drirc                   | 20 +++++++++++++++++---
 src/mesa/drivers/dri/common/xmlpool/t_options.h     |  5 +++++
 src/mesa/state_tracker/st_extensions.c              |  3 +++
 6 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
index 9dcb76f..46f0436 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -245,6 +245,7 @@ struct st_config_options
    boolean force_glsl_extensions_warn;
    unsigned force_glsl_version;
    boolean force_s3tc_enable;
+   boolean allow_glsl_extension_directive_midshader;
 };
 
 /**
diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c
index f6979a7..827f847 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -55,6 +55,8 @@ dri_fill_st_options(struct st_config_options *options,
       driQueryOptioni(optionCache, "force_glsl_version");
    options->force_s3tc_enable =
       driQueryOptionb(optionCache, "force_s3tc_enable");
+   options->allow_glsl_extension_directive_midshader =
+      driQueryOptionb(optionCache, "allow_glsl_extension_directive_midshader");
 }
 
 GLboolean
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c
index dceb628..f894e5d 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.c
+++ b/src/gallium/state_trackers/dri/common/dri_screen.c
@@ -69,6 +69,7 @@ const __DRIconfigOptionsExtension gallium_config_options = {
          DRI_CONF_DISABLE_BLEND_FUNC_EXTENDED("false")
          DRI_CONF_DISABLE_SHADER_BIT_ENCODING("false")
          DRI_CONF_FORCE_GLSL_VERSION(0)
+         DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER("false")
       DRI_CONF_SECTION_END
 
       DRI_CONF_SECTION_MISCELLANEOUS
diff --git a/src/mesa/drivers/dri/common/drirc b/src/mesa/drivers/dri/common/drirc
index ebc04cd..4b9841b 100644
--- a/src/mesa/drivers/dri/common/drirc
+++ b/src/mesa/drivers/dri/common/drirc
@@ -11,17 +11,21 @@ Application bugs worked around in this file:
   is still 1.10.
 
 * Unigine Heaven 3.0 with ARB_texture_multisample uses a "ivec4 * vec4"
-  expression, which fails to compile with GLSL 1.10.
+  expression, which is illegal in GLSL 1.10.
   Adding "#version 130" fixes this.
 
 * Unigine Heaven 3.0 with ARB_shader_bit_encoding uses the uint keyword, which
-  fails to compile with GLSL 1.10.
+  is illegal in GLSL 1.10.
   Adding "#version 130" fixes this.
 
 * Unigine Heaven 3.0 with ARB_shader_bit_encoding uses a "uint & int"
-  expression, which fails (and should fail) to compile with any GLSL version.
+  expression, which is illegal in any GLSL version.
   Disabling ARB_shader_bit_encoding fixes this.
 
+* If ARB_sample_shading is supported, Unigine Heaven 4.0 and Valley 1.0 uses
+  an #extension directive in the middle of its shaders, which is illegal
+  in GLSL.
+
 TODO: document the other workarounds.
 
 -->
@@ -45,6 +49,7 @@ TODO: document the other workarounds.
             <option name="disable_blend_func_extended" value="true" />
             <option name="force_glsl_version" value="130" />
             <option name="disable_shader_bit_encoding" value="true" />
+            <option name="allow_glsl_extension_directive_midshader" value="true" />
 	</application>
 
         <application name="Unigine Heaven (64-bit)" executable="heaven_x64">
@@ -52,6 +57,15 @@ TODO: document the other workarounds.
             <option name="disable_blend_func_extended" value="true" />
             <option name="force_glsl_version" value="130" />
             <option name="disable_shader_bit_encoding" value="true" />
+            <option name="allow_glsl_extension_directive_midshader" value="true" />
+	</application>
+
+        <application name="Unigine Valley (32-bit)" executable="valley_x86">
+            <option name="allow_glsl_extension_directive_midshader" value="true" />
+	</application>
+
+        <application name="Unigine Valley (64-bit)" executable="valley_x64">
+            <option name="allow_glsl_extension_directive_midshader" value="true" />
 	</application>
 
         <application name="Unigine OilRush (32-bit)" executable="OilRush_x86">
diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h b/src/mesa/drivers/dri/common/xmlpool/t_options.h
index fc9e104..b73a662 100644
--- a/src/mesa/drivers/dri/common/xmlpool/t_options.h
+++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h
@@ -105,6 +105,11 @@ DRI_CONF_OPT_BEGIN_V(force_glsl_version, int, def, "0:999") \
         DRI_CONF_DESC(en,gettext("Force a default GLSL version for shaders that lack an explicit #version line")) \
 DRI_CONF_OPT_END
 
+#define DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER(def) \
+DRI_CONF_OPT_BEGIN_B(allow_glsl_extension_directive_midshader, def) \
+        DRI_CONF_DESC(en,gettext("Allow GLSL #extension directives in the middle of shaders")) \
+DRI_CONF_OPT_END
+
 
 
 /**
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 4207cb6..aa59fbf 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -772,6 +772,9 @@ void st_init_extensions(struct st_context *st)
    if (st->options.disable_glsl_line_continuations)
       ctx->Const.DisableGLSLLineContinuations = 1;
 
+   if (st->options.allow_glsl_extension_directive_midshader)
+      ctx->Const.AllowGLSLExtensionDirectiveMidShader = GL_TRUE;
+
    ctx->Const.MinMapBufferAlignment =
       screen->get_param(screen, PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT);
 
-- 
1.9.1



More information about the mesa-dev mailing list