summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/glsl/builtin_functions.cpp110
-rw-r--r--src/compiler/glsl/glcpp/glcpp-parse.y3
-rw-r--r--src/compiler/glsl/glsl_parser_extras.cpp1
-rw-r--r--src/compiler/glsl/glsl_parser_extras.h2
-rw-r--r--src/mesa/main/extensions_table.h1
-rw-r--r--src/mesa/main/mtypes.h1
6 files changed, 118 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)
diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y b/src/compiler/glsl/glcpp/glcpp-parse.y
index e677811d6a7..007b70b020d 100644
--- a/src/compiler/glsl/glcpp/glcpp-parse.y
+++ b/src/compiler/glsl/glcpp/glcpp-parse.y
@@ -2482,6 +2482,9 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio
if (extensions->ARB_shader_atomic_counters)
add_builtin_define(parser, "GL_ARB_shader_atomic_counters", 1);
+ if (extensions->ARB_shader_atomic_counter_ops)
+ add_builtin_define(parser, "GL_ARB_shader_atomic_counter_ops", 1);
+
if (extensions->ARB_viewport_array)
add_builtin_define(parser, "GL_ARB_viewport_array", 1);
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 7e4a891f1dc..1c6cd43cd68 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -573,6 +573,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
EXT(ARB_gpu_shader_fp64, true, false, ARB_gpu_shader_fp64),
EXT(ARB_sample_shading, true, false, ARB_sample_shading),
EXT(ARB_separate_shader_objects, true, false, dummy_true),
+ EXT(ARB_shader_atomic_counter_ops, true, false, ARB_shader_atomic_counter_ops),
EXT(ARB_shader_atomic_counters, true, false, ARB_shader_atomic_counters),
EXT(ARB_shader_bit_encoding, true, false, ARB_shader_bit_encoding),
EXT(ARB_shader_clock, true, false, ARB_shader_clock),
diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h
index 74825a0bd35..12a3a46928c 100644
--- a/src/compiler/glsl/glsl_parser_extras.h
+++ b/src/compiler/glsl/glsl_parser_extras.h
@@ -533,6 +533,8 @@ struct _mesa_glsl_parse_state {
bool ARB_sample_shading_warn;
bool ARB_separate_shader_objects_enable;
bool ARB_separate_shader_objects_warn;
+ bool ARB_shader_atomic_counter_ops_enable;
+ bool ARB_shader_atomic_counter_ops_warn;
bool ARB_shader_atomic_counters_enable;
bool ARB_shader_atomic_counters_warn;
bool ARB_shader_bit_encoding_enable;
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index 674eb5c4ebf..54a5bb057a3 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -96,6 +96,7 @@ EXT(ARB_sampler_objects , dummy_true
EXT(ARB_seamless_cube_map , ARB_seamless_cube_map , GLL, GLC, x , x , 2009)
EXT(ARB_seamless_cubemap_per_texture , AMD_seamless_cubemap_per_texture , GLL, GLC, x , x , 2013)
EXT(ARB_separate_shader_objects , dummy_true , GLL, GLC, x , x , 2010)
+EXT(ARB_shader_atomic_counter_ops , ARB_shader_atomic_counter_ops , GLL, GLC, x , x , 2015)
EXT(ARB_shader_atomic_counters , ARB_shader_atomic_counters , GLL, GLC, x , x , 2011)
EXT(ARB_shader_bit_encoding , ARB_shader_bit_encoding , GLL, GLC, x , x , 2010)
EXT(ARB_shader_clock , ARB_shader_clock , GLL, GLC, x , x , 2015)
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b99f41cdc42..5d8bfe4bb09 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3815,6 +3815,7 @@ struct gl_extensions
GLboolean ARB_query_buffer_object;
GLboolean ARB_sample_shading;
GLboolean ARB_seamless_cube_map;
+ GLboolean ARB_shader_atomic_counter_ops;
GLboolean ARB_shader_atomic_counters;
GLboolean ARB_shader_bit_encoding;
GLboolean ARB_shader_clock;