[Mesa-dev] [RFC PATCH 51/56] glsl: Add builtin barrier() function

Chris Forbes chrisf at ijw.co.nz
Sat Sep 20 18:41:31 PDT 2014


---
 src/glsl/builtin_functions.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index 9be7f6d..f502105 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -99,6 +99,12 @@ gs_only(const _mesa_glsl_parse_state *state)
 }
 
 static bool
+tcs_only(const _mesa_glsl_parse_state *state)
+{
+   return state->stage == MESA_SHADER_TESS_CTRL;
+}
+
+static bool
 v110(const _mesa_glsl_parse_state *state)
 {
    return !state->es_shader;
@@ -620,6 +626,7 @@ private:
                                             const glsl_type *stream_type);
    ir_function_signature *_EndStreamPrimitive(builtin_available_predicate avail,
                                               const glsl_type *stream_type);
+   B0(barrier)
 
    B2(textureQueryLod);
    B1(textureQueryLevels);
@@ -1752,6 +1759,7 @@ builtin_builder::create_builtins()
                 _EndStreamPrimitive(gs_streams, glsl_type::uint_type),
                 _EndStreamPrimitive(gs_streams, glsl_type::int_type),
                 NULL);
+   add_function("barrier", _barrier(), NULL);
 
    add_function("textureQueryLOD",
                 _textureQueryLod(glsl_type::sampler1D_type,  glsl_type::float_type),
@@ -3997,6 +4005,15 @@ builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail,
 }
 
 ir_function_signature *
+builtin_builder::_barrier()
+{
+   MAKE_SIG(glsl_type::void_type, tcs_only, 0);
+
+   body.emit(new(mem_ctx) ir_barrier());
+   return sig;
+}
+
+ir_function_signature *
 builtin_builder::_textureQueryLod(const glsl_type *sampler_type,
                                   const glsl_type *coord_type)
 {
-- 
2.1.0



More information about the mesa-dev mailing list