mesa: implement AMD_shader_stencil_export

It's just an alias of the ARB variant with some GLSL compiler changes.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
index f357717..b848769 100644
--- a/src/glsl/ir_variable.cpp
+++ b/src/glsl/ir_variable.cpp
@@ -767,6 +767,22 @@
 }
 
 static void
+generate_AMD_shader_stencil_export_variables(exec_list *instructions,
+					     struct _mesa_glsl_parse_state *state,
+					     bool warn)
+{
+   /* gl_FragStencilRefAMD is only available in the fragment shader.
+    */
+   ir_variable *const fd =
+      add_variable(instructions, state->symbols,
+		   "gl_FragStencilRefAMD", glsl_type::int_type,
+		   ir_var_out, FRAG_RESULT_STENCIL);
+
+   if (warn)
+      fd->warn_extension = "GL_AMD_shader_stencil_export";
+}
+
+static void
 generate_120_fs_variables(exec_list *instructions,
 			  struct _mesa_glsl_parse_state *state)
 {
@@ -818,6 +834,10 @@
    if (state->ARB_shader_stencil_export_enable)
       generate_ARB_shader_stencil_export_variables(instructions, state,
 						   state->ARB_shader_stencil_export_warn);
+
+   if (state->AMD_shader_stencil_export_enable)
+      generate_AMD_shader_stencil_export_variables(instructions, state,
+						   state->AMD_shader_stencil_export_warn);
 }
 
 void