diff options
author | Nicolai Hähnle <[email protected]> | 2017-03-30 11:18:47 +0200 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2017-04-05 15:25:54 +0200 |
commit | 961b8e9afe79251babb18f8885ee4646f2296a9a (patch) | |
tree | 0659044ce05fca881b7b123cd5645c5fa25ce6d8 /src/compiler/glsl/builtin_functions.cpp | |
parent | d37b7b5232e419135776f9a6169adb4aad3900fb (diff) |
glsl: add ARB_shader_ballot builtin functions
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/compiler/glsl/builtin_functions.cpp')
-rw-r--r-- | src/compiler/glsl/builtin_functions.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp index b2fcdf37e07..d902a91a774 100644 --- a/src/compiler/glsl/builtin_functions.cpp +++ b/src/compiler/glsl/builtin_functions.cpp @@ -487,6 +487,12 @@ shader_atomic_counter_ops(const _mesa_glsl_parse_state *state) } static bool +shader_ballot(const _mesa_glsl_parse_state *state) +{ + return state->ARB_shader_ballot_enable; +} + +static bool shader_clock(const _mesa_glsl_parse_state *state) { return state->ARB_shader_clock_enable; @@ -942,6 +948,10 @@ private: ir_function_signature *_memory_barrier(const char *intrinsic_name, builtin_available_predicate avail); + ir_function_signature *_ballot(); + ir_function_signature *_read_first_invocation(const glsl_type *type); + ir_function_signature *_read_invocation(const glsl_type *type); + ir_function_signature *_shader_clock_intrinsic(builtin_available_predicate avail, const glsl_type *type); ir_function_signature *_shader_clock(builtin_available_predicate avail, @@ -3112,6 +3122,42 @@ builtin_builder::create_builtins() compute_shader), NULL); + add_function("ballotARB", _ballot(), NULL); + + add_function("readInvocationARB", + _read_invocation(glsl_type::float_type), + _read_invocation(glsl_type::vec2_type), + _read_invocation(glsl_type::vec3_type), + _read_invocation(glsl_type::vec4_type), + + _read_invocation(glsl_type::int_type), + _read_invocation(glsl_type::ivec2_type), + _read_invocation(glsl_type::ivec3_type), + _read_invocation(glsl_type::ivec4_type), + + _read_invocation(glsl_type::uint_type), + _read_invocation(glsl_type::uvec2_type), + _read_invocation(glsl_type::uvec3_type), + _read_invocation(glsl_type::uvec4_type), + NULL); + + add_function("readFirstInvocationARB", + _read_first_invocation(glsl_type::float_type), + _read_first_invocation(glsl_type::vec2_type), + _read_first_invocation(glsl_type::vec3_type), + _read_first_invocation(glsl_type::vec4_type), + + _read_first_invocation(glsl_type::int_type), + _read_first_invocation(glsl_type::ivec2_type), + _read_first_invocation(glsl_type::ivec3_type), + _read_first_invocation(glsl_type::ivec4_type), + + _read_first_invocation(glsl_type::uint_type), + _read_first_invocation(glsl_type::uvec2_type), + _read_first_invocation(glsl_type::uvec3_type), + _read_first_invocation(glsl_type::uvec4_type), + NULL); + add_function("clock2x32ARB", _shader_clock(shader_clock, glsl_type::uvec2_type), @@ -5954,6 +6000,37 @@ builtin_builder::_memory_barrier(const char *intrinsic_name, } ir_function_signature * +builtin_builder::_ballot() +{ + ir_variable *value = in_var(glsl_type::bool_type, "value"); + + MAKE_SIG(glsl_type::uint64_t_type, shader_ballot, 1, value); + body.emit(ret(expr(ir_unop_ballot, value))); + return sig; +} + +ir_function_signature * +builtin_builder::_read_first_invocation(const glsl_type *type) +{ + ir_variable *value = in_var(type, "value"); + + MAKE_SIG(type, shader_ballot, 1, value); + body.emit(ret(expr(ir_unop_read_first_invocation, value))); + return sig; +} + +ir_function_signature * +builtin_builder::_read_invocation(const glsl_type *type) +{ + ir_variable *value = in_var(type, "value"); + ir_variable *invocation = in_var(glsl_type::uint_type, "invocation"); + + MAKE_SIG(type, shader_ballot, 2, value, invocation); + body.emit(ret(expr(ir_binop_read_invocation, value, invocation))); + return sig; +} + +ir_function_signature * builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail, const glsl_type *type) { |