[Mesa-dev] [PATCH 3/6] glsl: add support for the clock2x32ARB function

Emil Velikov emil.l.velikov at gmail.com
Wed Oct 7 04:51:54 PDT 2015


Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/glsl/builtin_functions.cpp | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index f0f6be2..ee3dc52 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -401,6 +401,12 @@ shader_atomic_counters(const _mesa_glsl_parse_state *state)
 }
 
 static bool
+shader_clock(const _mesa_glsl_parse_state *state)
+{
+   return state->ARB_shader_clock_enable;
+}
+
+static bool
 shader_storage_buffer_object(const _mesa_glsl_parse_state *state)
 {
    return state->ARB_shader_storage_buffer_object_enable;
@@ -782,6 +788,10 @@ private:
    ir_function_signature *_memory_barrier(
       builtin_available_predicate avail);
 
+   ir_function_signature *_shader_clock_intrinsic(builtin_available_predicate avail);
+   ir_function_signature *_shader_clock(builtin_available_predicate avail,
+                                        const glsl_type *type);
+
 #undef B0
 #undef B1
 #undef B2
@@ -952,6 +962,10 @@ builtin_builder::create_intrinsics()
    add_function("__intrinsic_memory_barrier",
                 _memory_barrier_intrinsic(shader_image_load_store),
                 NULL);
+
+   add_function("__intrinsic_shader_clock",
+                _shader_clock_intrinsic(shader_clock),
+                NULL);
 }
 
 /**
@@ -2741,6 +2755,11 @@ builtin_builder::create_builtins()
                 _memory_barrier(shader_image_load_store),
                 NULL);
 
+   add_function("clock2x32ARB",
+                _shader_clock(shader_clock,
+                              glsl_type::uvec2_type),
+                NULL);
+
 #undef F
 #undef FI
 #undef FIUD
@@ -5251,6 +5270,27 @@ builtin_builder::_memory_barrier(builtin_available_predicate avail)
    return sig;
 }
 
+ir_function_signature *
+builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail)
+{
+   MAKE_INTRINSIC(glsl_type::void_type, avail, 0);
+   return sig;
+}
+
+ir_function_signature *
+builtin_builder::_shader_clock(builtin_available_predicate avail,
+                               const glsl_type *type)
+{
+   MAKE_SIG(glsl_type::void_type, avail, 0);
+
+   ir_variable *retval = body.make_temp(type, "clock_retval");
+
+   body.emit(call(shader->symbols->get_function("__intrinsic_shader_clock"),
+                  retval, sig->parameters));
+   body.emit(ret(retval));
+   return sig;
+}
+
 /** @} */
 
 /******************************************************************************/
-- 
2.5.0



More information about the mesa-dev mailing list