Module: Mesa Branch: master Commit: 220f70667dacc37f0e5cb871f6054214519d191f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=220f70667dacc37f0e5cb871f6054214519d191f
Author: Jordan Justen <jordan.l.jus...@intel.com> Date: Wed Mar 27 13:58:04 2013 -0700 glsl: add AMD_vertex_shader_layer support This GLSL extension requires that AMD_vertex_shader_layer be enabled by the driver. Signed-off-by: Jordan Justen <jordan.l.jus...@intel.com> Reviewed-by: Ian Romanick <ian.d.roman...@intel.com> --- src/glsl/builtin_variables.cpp | 31 +++++++++++++++++++++++++++++++ src/glsl/glcpp/glcpp-parse.y | 3 +++ src/glsl/glsl_parser_extras.cpp | 1 + src/glsl/glsl_parser_extras.h | 2 ++ 4 files changed, 37 insertions(+), 0 deletions(-) diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index 15f5bf3..4bb361c 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/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index f0d2ab0..81ba04b 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -1239,6 +1239,9 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api) if (extensions->ARB_gpu_shader5) add_builtin_define(parser, "GL_ARB_gpu_shader5", 1); + + if (extensions->AMD_vertex_shader_layer) + add_builtin_define(parser, "GL_AMD_vertex_shader_layer", 1); } } diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index f7d8f4a..c0dd713 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -469,6 +469,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = { 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(ARB_gpu_shader5, true, true, true, true, false, ARB_gpu_shader5), + 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 c77dda8..16e180d 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -286,6 +286,8 @@ struct _mesa_glsl_parse_state { bool ARB_texture_query_lod_warn; bool ARB_gpu_shader5_enable; bool ARB_gpu_shader5_warn; + bool AMD_vertex_shader_layer_enable; + bool AMD_vertex_shader_layer_warn; /*@}*/ /** Extensions supported by the OpenGL implementation. */ _______________________________________________ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit