mesa: implement AMD_shader_stencil_export
authorMarek Olšák <maraeo@gmail.com>
Mon, 2 May 2011 14:41:04 +0000 (16:41 +0200)
committerMarek Olšák <maraeo@gmail.com>
Tue, 3 May 2011 10:03:22 +0000 (12:03 +0200)
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>
src/glsl/glsl_parser_extras.cpp
src/glsl/glsl_parser_extras.h
src/glsl/ir_variable.cpp
src/mesa/main/extensions.c

index 5bb3a6f25a34d7dbcd75f1766542f4cf1b6bf5fb..18bff88deec12894d80a052f50a94094e0af721f 100644 (file)
@@ -255,6 +255,16 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
       state->AMD_conservative_depth_enable = (ext_mode != extension_disable);
       state->AMD_conservative_depth_warn = (ext_mode == extension_warn);
       unsupported = !state->extensions->AMD_conservative_depth;
+   } else if (strcmp(name, "GL_AMD_shader_stencil_export") == 0) {
+      state->AMD_shader_stencil_export_enable = (ext_mode != extension_disable);
+      state->AMD_shader_stencil_export_warn = (ext_mode == extension_warn);
+
+      /* This extension is only supported in fragment shaders.
+       * Both the ARB and AMD variants share the same ARB flag
+       * in gl_extensions.
+       */
+      unsupported = (state->target != fragment_shader)
+        || !state->extensions->ARB_shader_stencil_export;
    } else if (strcmp(name, "GL_OES_texture_3D") == 0 && state->es_shader) {
       state->OES_texture_3D_enable = (ext_mode != extension_disable);
       state->OES_texture_3D_warn = (ext_mode == extension_warn);
index 6df0e160ae382ef360060550ea7010cd62a618e9..f9147653f359897b67741dc1ecad073892e1bce2 100644 (file)
@@ -172,6 +172,8 @@ struct _mesa_glsl_parse_state {
    unsigned ARB_shader_stencil_export_warn:1;
    unsigned AMD_conservative_depth_enable:1;
    unsigned AMD_conservative_depth_warn:1;
+   unsigned AMD_shader_stencil_export_enable:1;
+   unsigned AMD_shader_stencil_export_warn:1;
    unsigned OES_texture_3D_enable:1;
    unsigned OES_texture_3D_warn:1;
    /*@}*/
index f3577175691f7cb38313f08d463ca0e905dd558c..b8487694c51fa0787908184af8a5aa391421eca7 100644 (file)
@@ -766,6 +766,22 @@ generate_ARB_shader_stencil_export_variables(exec_list *instructions,
       fd->warn_extension = "GL_ARB_shader_stencil_export";
 }
 
+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 @@ initialize_fs_variables(exec_list *instructions,
    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
index beec70abdd46693a9932cde27784965ae9d5efd1..1062cde9e292fc54d7333d80867351490699dc6d 100644 (file)
@@ -260,6 +260,7 @@ static const struct extension extension_table[] = {
    { "GL_3DFX_texture_compression_FXT1",           o(TDFX_texture_compression_FXT1),           GL,             1999 },
    { "GL_AMD_conservative_depth",                  o(AMD_conservative_depth),                  GL,             2009 },
    { "GL_AMD_draw_buffers_blend",                  o(ARB_draw_buffers_blend),                  GL,             2009 },
+   { "GL_AMD_shader_stencil_export",               o(ARB_shader_stencil_export),               GL,             2009 },
    { "GL_APPLE_client_storage",                    o(APPLE_client_storage),                    GL,             2002 },
    { "GL_APPLE_object_purgeable",                  o(APPLE_object_purgeable),                  GL,             2006 },
    { "GL_APPLE_packed_pixels",                     o(APPLE_packed_pixels),                     GL,             2002 },