aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/builtin_functions.cpp
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2016-02-19 23:07:38 -0500
committerIlia Mirkin <[email protected]>2016-03-10 22:34:46 -0500
commit075a5742bf65b35d19a1d86346db1c02f6dba9b2 (patch)
tree93f9a1e06a998ccb687ec92f27d73475707f855f /src/compiler/glsl/builtin_functions.cpp
parenta8819fb1fff4fa64ff6aef9435682fe7633cd2a4 (diff)
mesa: add GL_ARB_shader_atomic_counter_ops support
Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/compiler/glsl/builtin_functions.cpp')
-rw-r--r--src/compiler/glsl/builtin_functions.cpp110
1 files changed, 110 insertions, 0 deletions
diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index 10fb21b9a0d..ff6b628eb64 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -432,6 +432,12 @@ shader_atomic_counters(const _mesa_glsl_parse_state *state)
}
static bool
+shader_atomic_counter_ops(const _mesa_glsl_parse_state *state)
+{
+ return state->ARB_shader_atomic_counter_ops_enable;
+}
+
+static bool
shader_clock(const _mesa_glsl_parse_state *state)
{
return state->ARB_shader_clock_enable;
@@ -792,8 +798,14 @@ private:
B1(interpolateAtSample)
ir_function_signature *_atomic_counter_intrinsic(builtin_available_predicate avail);
+ ir_function_signature *_atomic_counter_intrinsic1(builtin_available_predicate avail);
+ ir_function_signature *_atomic_counter_intrinsic2(builtin_available_predicate avail);
ir_function_signature *_atomic_counter_op(const char *intrinsic,
builtin_available_predicate avail);
+ ir_function_signature *_atomic_counter_op1(const char *intrinsic,
+ builtin_available_predicate avail);
+ ir_function_signature *_atomic_counter_op2(const char *intrinsic,
+ builtin_available_predicate avail);
ir_function_signature *_atomic_intrinsic2(builtin_available_predicate avail,
const glsl_type *type);
@@ -968,48 +980,59 @@ builtin_builder::create_intrinsics()
glsl_type::uint_type),
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type),
+ _atomic_counter_intrinsic1(shader_atomic_counter_ops),
+ NULL);
+ add_function("__intrinsic_atomic_sub",
+ _atomic_counter_intrinsic1(shader_atomic_counter_ops),
NULL);
add_function("__intrinsic_atomic_min",
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::uint_type),
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type),
+ _atomic_counter_intrinsic1(shader_atomic_counter_ops),
NULL);
add_function("__intrinsic_atomic_max",
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::uint_type),
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type),
+ _atomic_counter_intrinsic1(shader_atomic_counter_ops),
NULL);
add_function("__intrinsic_atomic_and",
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::uint_type),
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type),
+ _atomic_counter_intrinsic1(shader_atomic_counter_ops),
NULL);
add_function("__intrinsic_atomic_or",
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::uint_type),
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type),
+ _atomic_counter_intrinsic1(shader_atomic_counter_ops),
NULL);
add_function("__intrinsic_atomic_xor",
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::uint_type),
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type),
+ _atomic_counter_intrinsic1(shader_atomic_counter_ops),
NULL);
add_function("__intrinsic_atomic_exchange",
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::uint_type),
_atomic_intrinsic2(buffer_atomics_supported,
glsl_type::int_type),
+ _atomic_counter_intrinsic1(shader_atomic_counter_ops),
NULL);
add_function("__intrinsic_atomic_comp_swap",
_atomic_intrinsic3(buffer_atomics_supported,
glsl_type::uint_type),
_atomic_intrinsic3(buffer_atomics_supported,
glsl_type::int_type),
+ _atomic_counter_intrinsic2(shader_atomic_counter_ops),
NULL);
add_image_functions(false);
@@ -2714,6 +2737,43 @@ builtin_builder::create_builtins()
shader_atomic_counters),
NULL);
+ add_function("atomicCounterAddARB",
+ _atomic_counter_op1("__intrinsic_atomic_add",
+ shader_atomic_counter_ops),
+ NULL);
+ add_function("atomicCounterSubtractARB",
+ _atomic_counter_op1("__intrinsic_atomic_sub",
+ shader_atomic_counter_ops),
+ NULL);
+ add_function("atomicCounterMinARB",
+ _atomic_counter_op1("__intrinsic_atomic_min",
+ shader_atomic_counter_ops),
+ NULL);
+ add_function("atomicCounterMaxARB",
+ _atomic_counter_op1("__intrinsic_atomic_max",
+ shader_atomic_counter_ops),
+ NULL);
+ add_function("atomicCounterAndARB",
+ _atomic_counter_op1("__intrinsic_atomic_and",
+ shader_atomic_counter_ops),
+ NULL);
+ add_function("atomicCounterOrARB",
+ _atomic_counter_op1("__intrinsic_atomic_or",
+ shader_atomic_counter_ops),
+ NULL);
+ add_function("atomicCounterXorARB",
+ _atomic_counter_op1("__intrinsic_atomic_xor",
+ shader_atomic_counter_ops),
+ NULL);
+ add_function("atomicCounterExchangeARB",
+ _atomic_counter_op1("__intrinsic_atomic_exchange",
+ shader_atomic_counter_ops),
+ NULL);
+ add_function("atomicCounterCompSwapARB",
+ _atomic_counter_op2("__intrinsic_atomic_comp_swap",
+ shader_atomic_counter_ops),
+ NULL);
+
add_function("atomicAdd",
_atomic_op2("__intrinsic_atomic_add",
buffer_atomics_supported,
@@ -5145,6 +5205,25 @@ builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail)
}
ir_function_signature *
+builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail)
+{
+ ir_variable *counter = in_var(glsl_type::atomic_uint_type, "counter");
+ ir_variable *data = in_var(glsl_type::uint_type, "data");
+ MAKE_INTRINSIC(glsl_type::uint_type, avail, 2, counter, data);
+ return sig;
+}
+
+ir_function_signature *
+builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail)
+{
+ ir_variable *counter = in_var(glsl_type::atomic_uint_type, "counter");
+ ir_variable *compare = in_var(glsl_type::uint_type, "compare");
+ ir_variable *data = in_var(glsl_type::uint_type, "data");
+ MAKE_INTRINSIC(glsl_type::uint_type, avail, 3, counter, compare, data);
+ return sig;
+}
+
+ir_function_signature *
builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail,
const glsl_type *type)
{
@@ -5180,6 +5259,37 @@ builtin_builder::_atomic_counter_op(const char *intrinsic,
}
ir_function_signature *
+builtin_builder::_atomic_counter_op1(const char *intrinsic,
+ builtin_available_predicate avail)
+{
+ ir_variable *counter = in_var(glsl_type::atomic_uint_type, "atomic_counter");
+ ir_variable *data = in_var(glsl_type::uint_type, "data");
+ MAKE_SIG(glsl_type::uint_type, avail, 2, counter, data);
+
+ ir_variable *retval = body.make_temp(glsl_type::uint_type, "atomic_retval");
+ body.emit(call(shader->symbols->get_function(intrinsic), retval,
+ sig->parameters));
+ body.emit(ret(retval));
+ return sig;
+}
+
+ir_function_signature *
+builtin_builder::_atomic_counter_op2(const char *intrinsic,
+ builtin_available_predicate avail)
+{
+ ir_variable *counter = in_var(glsl_type::atomic_uint_type, "atomic_counter");
+ ir_variable *compare = in_var(glsl_type::uint_type, "compare");
+ ir_variable *data = in_var(glsl_type::uint_type, "data");
+ MAKE_SIG(glsl_type::uint_type, avail, 3, counter, compare, data);
+
+ ir_variable *retval = body.make_temp(glsl_type::uint_type, "atomic_retval");
+ body.emit(call(shader->symbols->get_function(intrinsic), retval,
+ sig->parameters));
+ body.emit(ret(retval));
+ return sig;
+}
+
+ir_function_signature *
builtin_builder::_atomic_op2(const char *intrinsic,
builtin_available_predicate avail,
const glsl_type *type)