summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2010-10-06 09:36:02 +1000
committerDave Airlie <[email protected]>2010-10-13 09:30:05 +1000
commitd9671863eaae41ba28b6fe82e3e7d1dac12f514c (patch)
treea6a7a78b1beb0c5b9132433797f34f680ab17d44 /src/glsl
parent39d1feb51e9dac794751e72f48faf26409a84b1c (diff)
glsl: add support for shader stencil export
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.
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/glsl_parser_extras.cpp8
-rw-r--r--src/glsl/glsl_parser_extras.h2
-rw-r--r--src/glsl/ir_variable.cpp18
3 files changed, 28 insertions, 0 deletions
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 844a746c65c..1337bed2b48 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -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;
}
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index b573831d5f0..fe71c7a9901 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -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. */
diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
index ddc3bb0b9f3..f2c900f718f 100644
--- a/src/glsl/ir_variable.cpp
+++ b/src/glsl/ir_variable.cpp
@@ -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