glsl: add support for shader stencil export
authorDave Airlie <airlied@redhat.com>
Tue, 5 Oct 2010 23:36:02 +0000 (09:36 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 12 Oct 2010 23:30:05 +0000 (09:30 +1000)
This adds proper support for the GL_ARB_shader_stencil_export extension
to the GLSL compiler. Thanks to Ian for pointing out where I need to add things.

src/glsl/glsl_parser_extras.cpp
src/glsl/glsl_parser_extras.h
src/glsl/ir_variable.cpp
src/mesa/main/extensions.c
src/mesa/main/mtypes.h

index 844a746c65cc5b6b287679b8681f6881b10777fc..1337bed2b482610f04f959cccb97341b7cc40cbe 100644 (file)
@@ -203,6 +203,14 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
       state->EXT_texture_array_warn = (ext_mode == extension_warn);
 
       unsupported = !state->extensions->EXT_texture_array;
+   } else if (strcmp(name, "GL_ARB_shader_stencil_export") == 0) {
+      if (state->target != fragment_shader) {
+        unsupported = true;
+      } else {
+        state->ARB_shader_stencil_export_enable = (ext_mode != extension_disable);
+        state->ARB_shader_stencil_export_warn = (ext_mode == extension_warn);
+        unsupported = !state->extensions->ARB_shader_stencil_export;
+      }
    } else {
       unsupported = true;
    }
index b573831d5f0010bc1a520c3e5594a1b439669c8a..fe71c7a990196f7861d50d41d8654152cc311a95 100644 (file)
@@ -133,6 +133,8 @@ struct _mesa_glsl_parse_state {
    unsigned ARB_texture_rectangle_warn:1;
    unsigned EXT_texture_array_enable:1;
    unsigned EXT_texture_array_warn:1;
+   unsigned ARB_shader_stencil_export_enable:1;
+   unsigned ARB_shader_stencil_export_warn:1;
    /*@}*/
 
    /** Extensions supported by the OpenGL implementation. */
index ddc3bb0b9f391e3f516843ccd385f0074882d26b..f2c900f718fe1feb82552498769decec8bc0c8d3 100644 (file)
@@ -422,6 +422,20 @@ generate_ARB_draw_buffers_variables(exec_list *instructions,
    }
 }
 
+static void
+generate_ARB_shader_stencil_export_variables(exec_list *instructions,
+                                            struct _mesa_glsl_parse_state *state,
+                                            bool warn)
+{
+   /* gl_FragStencilRefARB is only available in the fragment shader.
+    */
+   ir_variable *const fd =
+      add_variable("gl_FragStencilRefARB", ir_var_out, FRAG_RESULT_STENCIL,
+                  glsl_type::int_type, instructions, state->symbols);
+
+   if (warn)
+      fd->warn_extension = "GL_ARB_shader_stencil_export";
+}
 
 static void
 generate_120_fs_variables(exec_list *instructions,
@@ -471,6 +485,10 @@ initialize_fs_variables(exec_list *instructions,
       generate_130_fs_variables(instructions, state);
       break;
    }
+
+   if (state->ARB_shader_stencil_export_enable)
+      generate_ARB_shader_stencil_export_variables(instructions, state,
+                                                  state->ARB_shader_stencil_export_warn);
 }
 
 void
index 9df0ae4598a456b1696917c67f2e573704ff8da7..99583a6345ddf36d423f8a30e2ae9421144b9e4a 100644 (file)
@@ -75,6 +75,7 @@ static const struct {
    { OFF, "GL_ARB_sampler_objects",            F(ARB_sampler_objects) },
    { OFF, "GL_ARB_seamless_cube_map",          F(ARB_seamless_cube_map) },
    { OFF, "GL_ARB_shader_objects",             F(ARB_shader_objects) },
+   { OFF, "GL_ARB_shader_stencil_export",      F(ARB_shader_stencil_export) },
    { OFF, "GL_ARB_shading_language_100",       F(ARB_shading_language_100) },
    { OFF, "GL_ARB_shadow",                     F(ARB_shadow) },
    { OFF, "GL_ARB_shadow_ambient",             F(ARB_shadow_ambient) },
index 3609e2969e83e3a4564ceccf142d857ad2f81655..4851f0460cc7081cd9565bff30c437ea36287b8f 100644 (file)
@@ -2588,6 +2588,7 @@ struct gl_extensions
    GLboolean ARB_sampler_objects;
    GLboolean ARB_seamless_cube_map;
    GLboolean ARB_shader_objects;
+   GLboolean ARB_shader_stencil_export;
    GLboolean ARB_shading_language_100;
    GLboolean ARB_shadow;
    GLboolean ARB_shadow_ambient;