[Mesa-dev] [PATCH 1/2] mesa: add GL_ARB_shader_atomic_counter_ops support
Ilia Mirkin
imirkin at alum.mit.edu
Mon Mar 7 06:14:51 UTC 2016
ping
On Sat, Feb 20, 2016 at 12:13 AM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
> src/compiler/glsl/builtin_functions.cpp | 110 +++++++++++++++++++++++++++++++
> src/compiler/glsl/glcpp/glcpp-parse.y | 3 +
> src/compiler/glsl/glsl_parser_extras.cpp | 1 +
> src/compiler/glsl/glsl_parser_extras.h | 2 +
> src/mesa/main/extensions_table.h | 1 +
> src/mesa/main/mtypes.h | 1 +
> 6 files changed, 118 insertions(+)
>
> diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
> index b862da0..d4dc271 100644
> --- a/src/compiler/glsl/builtin_functions.cpp
> +++ b/src/compiler/glsl/builtin_functions.cpp
> @@ -439,6 +439,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;
> @@ -819,8 +825,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);
> @@ -983,48 +995,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);
> @@ -2729,6 +2752,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,
> @@ -5203,6 +5263,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)
> {
> @@ -5238,6 +5317,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 fe55782..e4c003a 100644
> --- a/src/compiler/glsl/glcpp/glcpp-parse.y
> +++ b/src/compiler/glsl/glcpp/glcpp-parse.y
> @@ -2496,6 +2496,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 b8e7dcc..02af433 100644
> --- a/src/compiler/glsl/glsl_parser_extras.cpp
> +++ b/src/compiler/glsl/glsl_parser_extras.cpp
> @@ -577,6 +577,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 38641c0..5d76cb7 100644
> --- a/src/compiler/glsl/glsl_parser_extras.h
> +++ b/src/compiler/glsl/glsl_parser_extras.h
> @@ -538,6 +538,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 a6e9f1b..7368983 100644
> --- a/src/mesa/main/extensions_table.h
> +++ b/src/mesa/main/extensions_table.h
> @@ -97,6 +97,7 @@ EXT(ARB_seamless_cube_map , ARB_seamless_cube_map
> 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_counters , ARB_shader_atomic_counters , GLL, GLC, x , x , 2011)
> +EXT(ARB_shader_atomic_counter_ops , ARB_shader_atomic_counter_ops , GLL, GLC, x , x , 2015)
> 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)
> EXT(ARB_shader_draw_parameters , ARB_shader_draw_parameters , GLL, GLC, x , x , 2013)
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index ff83858..ba1ce24 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -3816,6 +3816,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;
> --
> 2.4.10
>
More information about the mesa-dev
mailing list