Thanks for adding Gallium support. Reviewed-by: Marek Olšák <marek.ol...@amd.com>
Marek On Thu, Jan 29, 2015 at 10:14 PM, Martin Peres <martin.pe...@linux.intel.com> wrote: > While trying to understand a GLSL pass, curro and I tried running Unigine > Tropics and the GLSL compilers would not compile the shaders. > > The reason is due to the fact that the shaders do not specify the needed GLSL > version but also use in the same shader keywords that could never co-exist > because one got deleted when the other one was added (for instance, > gl_TexCoord and gl_InstanceID). The current solution was to use the > force_glsl_extensions_warn workaround but it broke when GL_ARB_gpu_shader5 > got introduced as this workaround also enabled this extension which reserved > the name "sample" which is then used by most of Unigine Tropics' shaders. > > To fix this, the easiest solution seem to introduce a workaround to > disable GL_ARB_gpu_shader5 in the GLSL compiler. This is what this patch > does along with modifying drirc to enable this workaround on tropics. > > This patch has been tested on Haswell. It should also work on Gallium-based > drivers but I did not test it. > > I would like to thank curro for helping me understand the whole issue and > directed me to the right place in the code. > > Signed-off-by: Martin Peres <martin.pe...@linux.intel.com> > --- > src/gallium/include/state_tracker/st_api.h | 1 + > src/gallium/state_trackers/dri/dri_screen.c | 3 +++ > src/glsl/glsl_parser_extras.cpp | 3 +++ > src/mesa/drivers/dri/common/drirc | 1 + > src/mesa/drivers/dri/common/xmlpool/t_options.h | 4 ++++ > src/mesa/drivers/dri/i915/intel_screen.c | 1 + > src/mesa/drivers/dri/i965/brw_context.c | 3 +++ > src/mesa/drivers/dri/i965/intel_screen.c | 1 + > src/mesa/main/mtypes.h | 7 +++++++ > src/mesa/state_tracker/st_extensions.c | 3 +++ > 10 files changed, 27 insertions(+) > > diff --git a/src/gallium/include/state_tracker/st_api.h > b/src/gallium/include/state_tracker/st_api.h > index 86fdc69..01bc98d 100644 > --- a/src/gallium/include/state_tracker/st_api.h > +++ b/src/gallium/include/state_tracker/st_api.h > @@ -246,6 +246,7 @@ struct st_config_options > unsigned force_glsl_version; > boolean force_s3tc_enable; > boolean allow_glsl_extension_directive_midshader; > + boolean disable_glsl_extension_gpu_shader5; > }; > > /** > diff --git a/src/gallium/state_trackers/dri/dri_screen.c > b/src/gallium/state_trackers/dri/dri_screen.c > index 9cdebf8..091aecf 100644 > --- a/src/gallium/state_trackers/dri/dri_screen.c > +++ b/src/gallium/state_trackers/dri/dri_screen.c > @@ -70,6 +70,7 @@ const __DRIconfigOptionsExtension gallium_config_options = { > DRI_CONF_DISABLE_SHADER_BIT_ENCODING("false") > DRI_CONF_FORCE_GLSL_VERSION(0) > DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER("false") > + DRI_CONF_DISABLE_GLSL_EXTENSION_GPU_SHADER5("false") > DRI_CONF_SECTION_END > > DRI_CONF_SECTION_MISCELLANEOUS > @@ -98,6 +99,8 @@ dri_fill_st_options(struct st_config_options *options, > driQueryOptionb(optionCache, "force_s3tc_enable"); > options->allow_glsl_extension_directive_midshader = > driQueryOptionb(optionCache, > "allow_glsl_extension_directive_midshader"); > + options->disable_glsl_extension_gpu_shader5 = > + driQueryOptionb(optionCache, "disable_glsl_extension_gpu_shader5"); > } > > static const __DRIconfig ** > diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp > index ccdf031..fff04b8 100644 > --- a/src/glsl/glsl_parser_extras.cpp > +++ b/src/glsl/glsl_parser_extras.cpp > @@ -217,6 +217,9 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct > gl_context *_ctx, > sizeof(this->atomic_counter_offsets)); > this->allow_extension_directive_midshader = > ctx->Const.AllowGLSLExtensionDirectiveMidShader; > + > + if (ctx->Const.DisableGLSLExtensionGpuShader5) > + this->ARB_gpu_shader5_enable = false; > } > > /** > diff --git a/src/mesa/drivers/dri/common/drirc > b/src/mesa/drivers/dri/common/drirc > index cecd6a9..3199cfc 100644 > --- a/src/mesa/drivers/dri/common/drirc > +++ b/src/mesa/drivers/dri/common/drirc > @@ -41,6 +41,7 @@ TODO: document the other workarounds. > > <application name="Unigine Tropics" executable="Tropics"> > <option name="force_glsl_extensions_warn" value="true" /> > + <option name="disable_glsl_extension_gpu_shader5" value="true" /> > <option name="disable_blend_func_extended" value="true" /> > </application> > > diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h > b/src/mesa/drivers/dri/common/xmlpool/t_options.h > index 4e5a721..d1869d6 100644 > --- a/src/mesa/drivers/dri/common/xmlpool/t_options.h > +++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h > @@ -110,6 +110,10 @@ > 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 > > +#define DRI_CONF_DISABLE_GLSL_EXTENSION_GPU_SHADER5(def) \ > +DRI_CONF_OPT_BEGIN_B(disable_glsl_extension_gpu_shader5, def) \ > + DRI_CONF_DESC(en,gettext("Disable GLSL support for the > GL_ARB_gpu_shader5")) \ > +DRI_CONF_OPT_END > > > /** > diff --git a/src/mesa/drivers/dri/i915/intel_screen.c > b/src/mesa/drivers/dri/i915/intel_screen.c > index 00d8580..748eee7 100644 > --- a/src/mesa/drivers/dri/i915/intel_screen.c > +++ b/src/mesa/drivers/dri/i915/intel_screen.c > @@ -74,6 +74,7 @@ DRI_CONF_BEGIN > DRI_CONF_FORCE_GLSL_EXTENSIONS_WARN("false") > DRI_CONF_DISABLE_GLSL_LINE_CONTINUATIONS("false") > DRI_CONF_DISABLE_BLEND_FUNC_EXTENDED("false") > + DRI_CONF_DISABLE_GLSL_EXTENSION_GPU_SHADER5("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/drivers/dri/i965/brw_context.c > b/src/mesa/drivers/dri/i965/brw_context.c > index e20da0b..6fa54a3 100644 > --- a/src/mesa/drivers/dri/i965/brw_context.c > +++ b/src/mesa/drivers/dri/i965/brw_context.c > @@ -649,6 +649,9 @@ brw_process_driconf_options(struct brw_context *brw) > > ctx->Const.AllowGLSLExtensionDirectiveMidShader = > driQueryOptionb(options, "allow_glsl_extension_directive_midshader"); > + > + ctx->Const.DisableGLSLExtensionGpuShader5 = > + driQueryOptionb(options, "disable_glsl_extension_gpu_shader5"); > } > > GLboolean > diff --git a/src/mesa/drivers/dri/i965/intel_screen.c > b/src/mesa/drivers/dri/i965/intel_screen.c > index cea7ddf..013222f 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_DISABLE_GLSL_LINE_CONTINUATIONS("false") > DRI_CONF_DISABLE_BLEND_FUNC_EXTENDED("false") > DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER("false") > + DRI_CONF_DISABLE_GLSL_EXTENSION_GPU_SHADER5("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 81a7c0e..7623789 100644 > --- a/src/mesa/main/mtypes.h > +++ b/src/mesa/main/mtypes.h > @@ -3506,6 +3506,13 @@ struct gl_constants > GLboolean AllowGLSLExtensionDirectiveMidShader; > > /** > + * Disables gl_arb_gpu_shader5 to make sure some shader using the > restricted > + * name sample can still work when using the ForceGLSLExtensionsWarn > + * work-around. > + */ > + GLboolean DisableGLSLExtensionGpuShader5; > + > + /** > * Does the driver support real 32-bit integers? (Otherwise, integers are > * simulated via floats.) > */ > diff --git a/src/mesa/state_tracker/st_extensions.c > b/src/mesa/state_tracker/st_extensions.c > index 48ed9d2..0bfacd5 100644 > --- a/src/mesa/state_tracker/st_extensions.c > +++ b/src/mesa/state_tracker/st_extensions.c > @@ -812,6 +812,9 @@ void st_init_extensions(struct pipe_screen *screen, > if (options->allow_glsl_extension_directive_midshader) > consts->AllowGLSLExtensionDirectiveMidShader = GL_TRUE; > > + if (options->disable_glsl_extension_gpu_shader5) > + consts->DisableGLSLExtensionGpuShader5 = GL_TRUE; > + > consts->MinMapBufferAlignment = > screen->get_param(screen, PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT); > > -- > 2.2.2 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev