summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2016-05-29 10:49:03 -0400
committerIlia Mirkin <[email protected]>2016-06-06 20:48:46 -0400
commit5189f0243a3dd8698c645bbe762b8a1a3caaf1a9 (patch)
tree52424a33a94512e4845b9557d6a9e215eab302af /src/compiler
parent13b859de044d0f970fcafd4bbb643a307c6ab4eb (diff)
mesa: hook up core bits of GL_ARB_shader_group_vote
Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/builtin_functions.cpp22
-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/compiler/glsl/ir.cpp9
-rw-r--r--src/compiler/glsl/ir.h9
-rw-r--r--src/compiler/glsl/ir_validate.cpp8
7 files changed, 53 insertions, 1 deletions
diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index edd02bb031b..db0dcb6288f 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -528,6 +528,12 @@ barrier_supported(const _mesa_glsl_parse_state *state)
state->stage == MESA_SHADER_TESS_CTRL;
}
+static bool
+vote(const _mesa_glsl_parse_state *state)
+{
+ return state->ARB_shader_group_vote_enable;
+}
+
/** @} */
/******************************************************************************/
@@ -853,6 +859,8 @@ private:
ir_function_signature *_shader_clock(builtin_available_predicate avail,
const glsl_type *type);
+ ir_function_signature *_vote(enum ir_expression_operation opcode);
+
#undef B0
#undef B1
#undef B2
@@ -2935,6 +2943,10 @@ builtin_builder::create_builtins()
glsl_type::uvec2_type),
NULL);
+ add_function("anyInvocationARB", _vote(ir_unop_vote_any), NULL);
+ add_function("allInvocationsARB", _vote(ir_unop_vote_all), NULL);
+ add_function("allInvocationsEqualARB", _vote(ir_unop_vote_eq), NULL);
+
#undef F
#undef FI
#undef FIUD
@@ -5576,6 +5588,16 @@ builtin_builder::_shader_clock(builtin_available_predicate avail,
return sig;
}
+ir_function_signature *
+builtin_builder::_vote(enum ir_expression_operation opcode)
+{
+ ir_variable *value = in_var(glsl_type::bool_type, "value");
+
+ MAKE_SIG(glsl_type::bool_type, vote, 1, value);
+ body.emit(ret(expr(opcode, value)));
+ return sig;
+}
+
/** @} */
/******************************************************************************/
diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y b/src/compiler/glsl/glcpp/glcpp-parse.y
index 402272796d0..2cfa6a6825a 100644
--- a/src/compiler/glsl/glcpp/glcpp-parse.y
+++ b/src/compiler/glsl/glcpp/glcpp-parse.y
@@ -2467,6 +2467,9 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio
if (extensions->ARB_cull_distance)
add_builtin_define(parser, "GL_ARB_cull_distance", 1);
+
+ if (extensions->ARB_shader_group_vote)
+ add_builtin_define(parser, "GL_ARB_shader_group_vote", 1);
}
}
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index ba658aec23f..fde8c193597 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -594,6 +594,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
EXT(ARB_shader_bit_encoding, true, false, ARB_shader_bit_encoding),
EXT(ARB_shader_clock, true, false, ARB_shader_clock),
EXT(ARB_shader_draw_parameters, true, false, ARB_shader_draw_parameters),
+ EXT(ARB_shader_group_vote, true, false, ARB_shader_group_vote),
EXT(ARB_shader_image_load_store, true, false, ARB_shader_image_load_store),
EXT(ARB_shader_image_size, true, false, ARB_shader_image_size),
EXT(ARB_shader_precision, true, false, ARB_shader_precision),
diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h
index a0c19033ac6..8c43292d8aa 100644
--- a/src/compiler/glsl/glsl_parser_extras.h
+++ b/src/compiler/glsl/glsl_parser_extras.h
@@ -575,6 +575,8 @@ struct _mesa_glsl_parse_state {
bool ARB_shader_clock_warn;
bool ARB_shader_draw_parameters_enable;
bool ARB_shader_draw_parameters_warn;
+ bool ARB_shader_group_vote_enable;
+ bool ARB_shader_group_vote_warn;
bool ARB_shader_image_load_store_enable;
bool ARB_shader_image_load_store_warn;
bool ARB_shader_image_size_enable;
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index 5bb3ac3c214..7961f00ffd1 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -341,6 +341,12 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
this->type = glsl_type::int_type;
break;
+ case ir_unop_vote_any:
+ case ir_unop_vote_all:
+ case ir_unop_vote_eq:
+ this->type = glsl_type::bool_type;
+ break;
+
default:
assert(!"not reached: missing automatic type setup for ir_expression");
this->type = op0->type;
@@ -563,6 +569,9 @@ static const char *const operator_strs[] = {
"interpolate_at_centroid",
"get_buffer_size",
"ssbo_unsized_array_length",
+ "vote_any",
+ "vote_all",
+ "vote_eq",
"+",
"-",
"*",
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index 2afa94cf170..36293563e25 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -1482,9 +1482,16 @@ enum ir_expression_operation {
ir_unop_ssbo_unsized_array_length,
/**
+ * Vote among threads on the value of the boolean argument.
+ */
+ ir_unop_vote_any,
+ ir_unop_vote_all,
+ ir_unop_vote_eq,
+
+ /**
* A sentinel marking the last of the unary operations.
*/
- ir_last_unop = ir_unop_ssbo_unsized_array_length,
+ ir_last_unop = ir_unop_vote_eq,
ir_binop_add,
ir_binop_sub,
diff --git a/src/compiler/glsl/ir_validate.cpp b/src/compiler/glsl/ir_validate.cpp
index 757f17cbf38..126f9bf227a 100644
--- a/src/compiler/glsl/ir_validate.cpp
+++ b/src/compiler/glsl/ir_validate.cpp
@@ -453,6 +453,14 @@ ir_validate::visit_leave(ir_expression *ir)
assert(ir->operands[0]->type->base_type == GLSL_TYPE_SUBROUTINE);
assert(ir->type->base_type == GLSL_TYPE_INT);
break;
+
+ case ir_unop_vote_any:
+ case ir_unop_vote_all:
+ case ir_unop_vote_eq:
+ assert(ir->type == glsl_type::bool_type);
+ assert(ir->operands[0]->type == glsl_type::bool_type);
+ break;
+
case ir_binop_add:
case ir_binop_sub:
case ir_binop_mul: