glsl: add AMD_vertex_shader_layer support
authorJordan Justen <jordan.l.justen@intel.com>
Wed, 27 Mar 2013 20:58:04 +0000 (13:58 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Mon, 13 May 2013 20:57:52 +0000 (13:57 -0700)
This GLSL extension requires that AMD_vertex_shader_layer be
enabled by the driver.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/builtin_variables.cpp
src/glsl/glcpp/glcpp-parse.y
src/glsl/glsl_parser_extras.cpp
src/glsl/glsl_parser_extras.h

index 15f5bf318db9496cb460e49bcd80fda0fcc2e52d..4bb361c2e4599d0d36adf6f707d1afc80ea3226b 100644 (file)
@@ -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,
index f0d2ab007990ad0cf94c5386279f304d1a328c19..81ba04bcc0e850a7e331510cb29a38d3a7c62de1 100644 (file)
@@ -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);
           }
        }
 
index f7d8f4a4b6c7e1290798c67c0d857479a5cdd5a5..c0dd713703f9d20c652c45fba3f176c1cd9ab7aa 100644 (file)
@@ -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
index c77dda84ef6885755653289726ad400a7e63e51a..16e180d3ee4e6a2357cca1fe3e7398c1a0a7c953 100644 (file)
@@ -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. */