[Mesa-stable] [PATCH] mesa: add AllowGLSLCrossStageInterpolationMismatch workaround
Tapani Pälli
tapani.palli at intel.com
Wed Dec 20 07:58:43 UTC 2017
This fixes issues seen with certain versions of Unreal Engine 4 editor
and games built with that using GLSL 4.30.
v2: add driinfo_gallium change (Emil Velikov)
Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97852
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103801
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104288
Acked-by: Andres Gomez <agomez at igalia.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
This rebased on 17.3 and I've squashed in a commit which adds more games
to the drirc list.
src/compiler/glsl/link_varyings.cpp | 51 ++++++++++++++--------
.../auxiliary/pipe-loader/driinfo_gallium.h | 1 +
src/gallium/include/state_tracker/st_api.h | 1 +
src/gallium/state_trackers/dri/dri_screen.c | 2 +
src/mesa/drivers/dri/i965/brw_context.c | 3 ++
src/mesa/main/mtypes.h | 5 +++
src/mesa/state_tracker/st_extensions.c | 2 +
src/util/drirc | 16 +++++++
src/util/xmlpool/t_options.h | 4 ++
9 files changed, 67 insertions(+), 18 deletions(-)
diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
index a966179037..5995736017 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -191,7 +191,8 @@ process_xfb_layout_qualifiers(void *mem_ctx, const gl_linked_shader *sh,
* matching input to another stage.
*/
static void
-cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
+cross_validate_types_and_qualifiers(struct gl_context *ctx,
+ struct gl_shader_program *prog,
const ir_variable *input,
const ir_variable *output,
gl_shader_stage consumer_stage,
@@ -345,17 +346,30 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
}
if (input_interpolation != output_interpolation &&
prog->data->Version < 440) {
- linker_error(prog,
- "%s shader output `%s' specifies %s "
- "interpolation qualifier, "
- "but %s shader input specifies %s "
- "interpolation qualifier\n",
- _mesa_shader_stage_to_string(producer_stage),
- output->name,
- interpolation_string(output->data.interpolation),
- _mesa_shader_stage_to_string(consumer_stage),
- interpolation_string(input->data.interpolation));
- return;
+ if (!ctx->Const.AllowGLSLCrossStageInterpolationMismatch) {
+ linker_error(prog,
+ "%s shader output `%s' specifies %s "
+ "interpolation qualifier, "
+ "but %s shader input specifies %s "
+ "interpolation qualifier\n",
+ _mesa_shader_stage_to_string(producer_stage),
+ output->name,
+ interpolation_string(output->data.interpolation),
+ _mesa_shader_stage_to_string(consumer_stage),
+ interpolation_string(input->data.interpolation));
+ return;
+ } else {
+ linker_warning(prog,
+ "%s shader output `%s' specifies %s "
+ "interpolation qualifier, "
+ "but %s shader input specifies %s "
+ "interpolation qualifier\n",
+ _mesa_shader_stage_to_string(producer_stage),
+ output->name,
+ interpolation_string(output->data.interpolation),
+ _mesa_shader_stage_to_string(consumer_stage),
+ interpolation_string(input->data.interpolation));
+ }
}
}
@@ -363,7 +377,8 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
* Validate front and back color outputs against single color input
*/
static void
-cross_validate_front_and_back_color(struct gl_shader_program *prog,
+cross_validate_front_and_back_color(struct gl_context *ctx,
+ struct gl_shader_program *prog,
const ir_variable *input,
const ir_variable *front_color,
const ir_variable *back_color,
@@ -371,11 +386,11 @@ cross_validate_front_and_back_color(struct gl_shader_program *prog,
gl_shader_stage producer_stage)
{
if (front_color != NULL && front_color->data.assigned)
- cross_validate_types_and_qualifiers(prog, input, front_color,
+ cross_validate_types_and_qualifiers(ctx, prog, input, front_color,
consumer_stage, producer_stage);
if (back_color != NULL && back_color->data.assigned)
- cross_validate_types_and_qualifiers(prog, input, back_color,
+ cross_validate_types_and_qualifiers(ctx, prog, input, back_color,
consumer_stage, producer_stage);
}
@@ -528,7 +543,7 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
const ir_variable *const back_color =
parameters.get_variable("gl_BackColor");
- cross_validate_front_and_back_color(prog, input,
+ cross_validate_front_and_back_color(ctx, prog, input,
front_color, back_color,
consumer->Stage, producer->Stage);
} else if (strcmp(input->name, "gl_SecondaryColor") == 0 && input->data.used) {
@@ -538,7 +553,7 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
const ir_variable *const back_color =
parameters.get_variable("gl_BackSecondaryColor");
- cross_validate_front_and_back_color(prog, input,
+ cross_validate_front_and_back_color(ctx, prog, input,
front_color, back_color,
consumer->Stage, producer->Stage);
} else {
@@ -581,7 +596,7 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
*/
if (!(input->get_interface_type() &&
output->get_interface_type()))
- cross_validate_types_and_qualifiers(prog, input, output,
+ cross_validate_types_and_qualifiers(ctx, prog, input, output,
consumer->Stage,
producer->Stage);
} else {
diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
index d2d2c9d3a5..003a3d7089 100644
--- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
+++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
@@ -23,6 +23,7 @@ DRI_CONF_SECTION_DEBUG
DRI_CONF_FORCE_GLSL_VERSION(0)
DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER("false")
DRI_CONF_ALLOW_GLSL_BUILTIN_VARIABLE_REDECLARATION("false")
+ DRI_CONF_ALLOW_GLSL_CROSS_STAGE_INTERPOLATION_MISMATCH("false")
DRI_CONF_ALLOW_HIGHER_COMPAT_VERSION("false")
DRI_CONF_FORCE_GLSL_ABS_SQRT("false")
DRI_CONF_GLSL_CORRECT_DERIVATIVES_AFTER_DISCARD("false")
diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
index 2232c3efa1..08a0386d24 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -222,6 +222,7 @@ struct st_config_options
boolean allow_higher_compat_version;
boolean glsl_zero_init;
boolean force_glsl_abs_sqrt;
+ boolean allow_glsl_cross_stage_interpolation_mismatch;
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 91f50fe8e3..ddef97a7a8 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -81,6 +81,8 @@ dri_fill_st_options(struct dri_screen *screen)
options->glsl_zero_init = driQueryOptionb(optionCache, "glsl_zero_init");
options->force_glsl_abs_sqrt =
driQueryOptionb(optionCache, "force_glsl_abs_sqrt");
+ options->allow_glsl_cross_stage_interpolation_mismatch =
+ driQueryOptionb(optionCache, "allow_glsl_cross_stage_interpolation_mismatch");
driComputeOptionsSha1(optionCache, options->config_options_sha1);
}
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 263c805f36..160c136be0 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -806,6 +806,9 @@ brw_process_driconf_options(struct brw_context *brw)
ctx->Const.AllowGLSLBuiltinVariableRedeclaration =
driQueryOptionb(options, "allow_glsl_builtin_variable_redeclaration");
+ ctx->Const.AllowGLSLCrossStageInterpolationMismatch =
+ driQueryOptionb(options, "allow_glsl_cross_stage_interpolation_mismatch");
+
ctx->Const.AllowHigherCompatVersion =
driQueryOptionb(options, "allow_higher_compat_version");
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 216bbc49ea..ff1152b289 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3703,6 +3703,11 @@ struct gl_constants
GLboolean AllowGLSLBuiltinVariableRedeclaration;
/**
+ * Allow GLSL interpolation qualifier mismatch across shader stages.
+ */
+ GLboolean AllowGLSLCrossStageInterpolationMismatch;
+
+ /**
* Allow creating a higher compat profile (version 3.1+) for apps that
* request it. Be careful when adding that driconf option because some
* features are unimplemented and might not work correctly.
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 3dec5a87d7..f10dd5e99d 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -907,6 +907,8 @@ void st_init_extensions(struct pipe_screen *screen,
consts->AllowGLSLBuiltinVariableRedeclaration = options->allow_glsl_builtin_variable_redeclaration;
+ consts->AllowGLSLCrossStageInterpolationMismatch = options->allow_glsl_cross_stage_interpolation_mismatch;
+
consts->dri_config_options_sha1 = options->config_options_sha1;
if (consts->GLSLVersion >= 400)
diff --git a/src/util/drirc b/src/util/drirc
index 05630eb1a9..6ed35d8f4a 100644
--- a/src/util/drirc
+++ b/src/util/drirc
@@ -160,6 +160,22 @@ TODO: document the other workarounds.
<option name="glsl_correct_derivatives_after_discard" value="true"/>
</application>
+ <application name="Unreal 4 Editor" executable="UE4Editor">
+ <option name="allow_glsl_cross_stage_interpolation_mismatch" value="true"/>
+ </application>
+
+ <application name="Observer" executable="TheObserver-Linux-Shipping">
+ <option name="allow_glsl_cross_stage_interpolation_mismatch" value="true"/>
+ </application>
+
+ <application name="Steamroll" executable="Steamroll-Linux-Shipping">
+ <option name="allow_glsl_cross_stage_interpolation_mismatch" value="true"/>
+ </application>
+
+ <application name="Refunct" executable="Refunct-Linux-Shipping">
+ <option name="allow_glsl_cross_stage_interpolation_mismatch" value="true"/>
+ </application>
+
<!-- The GL thread whitelist is below, workarounds are above.
Keep it that way. -->
diff --git a/src/util/xmlpool/t_options.h b/src/util/xmlpool/t_options.h
index 41f6ebd62d..bd553085c8 100644
--- a/src/util/xmlpool/t_options.h
+++ b/src/util/xmlpool/t_options.h
@@ -135,6 +135,10 @@ DRI_CONF_OPT_BEGIN_B(glsl_correct_derivatives_after_discard, def) \
DRI_CONF_DESC(en,gettext("Implicit and explicit derivatives after a discard behave as if the discard didn't happen")) \
DRI_CONF_OPT_END
+#define DRI_CONF_ALLOW_GLSL_CROSS_STAGE_INTERPOLATION_MISMATCH(def) \
+DRI_CONF_OPT_BEGIN_B(allow_glsl_cross_stage_interpolation_mismatch, def) \
+ DRI_CONF_DESC(en,gettext("Allow interpolation qualifier mismatch across shader stages")) \
+DRI_CONF_OPT_END
/**
* \brief Image quality-related options
--
2.13.6
More information about the mesa-stable
mailing list