[Mesa-dev] [PATCH 2/3] glsl: add AMD_vertex_shader_layer support
Ian Romanick
idr at freedesktop.org
Tue Apr 30 09:57:06 PDT 2013
On 04/27/2013 04:32 PM, Jordan Justen wrote:
> This GLSL extension requires that AMD_vertex_shader_layer be
> enabled by the driver.
Most (all?) extensions also add a preprocessor define. Can you poke at
AMD's driver to see if GL_AMD_vertex_shader_layer is defined? If so,
then we need to add it too.
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> ---
> src/glsl/builtin_variables.cpp | 31 +++++++++++++++++++++++++++++++
> src/glsl/glsl_parser_extras.cpp | 1 +
> src/glsl/glsl_parser_extras.h | 2 ++
> 3 files changed, 34 insertions(+)
>
> diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
> index b0c7a20..098c3f1 100644
> --- a/src/glsl/builtin_variables.cpp
> +++ b/src/glsl/builtin_variables.cpp
> @@ -39,6 +39,12 @@ generate_ARB_draw_instanced_variables(exec_list *,
> struct _mesa_glsl_parse_state *,
> bool, _mesa_glsl_parser_targets);
>
> +static void
> +generate_AMD_vertex_shader_layer_variables(exec_list *instructions,
> + struct _mesa_glsl_parse_state *state,
> + bool warn,
> + _mesa_glsl_parser_targets target);
> +
> struct builtin_variable {
> enum ir_variable_mode mode;
> int slot;
> @@ -818,6 +824,8 @@ generate_130_vs_variables(exec_list *instructions,
> "gl_ClipDistance", clip_distance_array_type, ir_var_shader_out,
> VARYING_SLOT_CLIP_DIST0);
>
> + generate_AMD_vertex_shader_layer_variables(instructions, state, false,
> + vertex_shader);
> }
>
>
> @@ -1020,6 +1028,29 @@ generate_ARB_draw_instanced_variables(exec_list *instructions,
> }
> }
>
> +static void
> +generate_AMD_vertex_shader_layer_variables(exec_list *instructions,
> + struct _mesa_glsl_parse_state *state,
> + bool warn,
> + _mesa_glsl_parser_targets target)
> +{
> + /* gl_Layer is only available in the vertex shader for the
> + * AMD_vertex_shader_layer extension. It will also be available in the
> + * geometry shader when GLSL 1.50 is supported.
> + */
> + if (target != vertex_shader)
> + return;
> +
> + if (state->AMD_vertex_shader_layer_enable) {
> + ir_variable *inst =
> + add_variable(instructions, state->symbols,
> + "gl_Layer", glsl_type::int_type,
> + ir_var_shader_out, VARYING_SLOT_LAYER);
> +
> + if (warn)
> + inst->warn_extension = "GL_AMD_vertex_shader_layer";
> + }
> +}
>
> static void
> generate_ARB_shader_stencil_export_variables(exec_list *instructions,
> diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
> index 0992294..e419264 100644
> --- a/src/glsl/glsl_parser_extras.cpp
> +++ b/src/glsl/glsl_parser_extras.cpp
> @@ -468,6 +468,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
> EXT(ARB_shading_language_packing, true, false, true, true, false, ARB_shading_language_packing),
> EXT(ARB_texture_multisample, true, false, true, true, false, ARB_texture_multisample),
> EXT(ARB_texture_query_lod, false, false, true, true, false, ARB_texture_query_lod),
> + EXT(AMD_vertex_shader_layer, true, false, false, true, false, AMD_vertex_shader_layer),
> };
>
> #undef EXT
> diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
> index 95891b5..3386365 100644
> --- a/src/glsl/glsl_parser_extras.h
> +++ b/src/glsl/glsl_parser_extras.h
> @@ -284,6 +284,8 @@ struct _mesa_glsl_parse_state {
> bool ARB_texture_multisample_warn;
> bool ARB_texture_query_lod_enable;
> bool ARB_texture_query_lod_warn;
> + bool AMD_vertex_shader_layer_enable;
> + bool AMD_vertex_shader_layer_warn;
> /*@}*/
>
> /** Extensions supported by the OpenGL implementation. */
>
More information about the mesa-dev
mailing list