summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2017-03-30 11:18:30 +0200
committerNicolai Hähnle <[email protected]>2017-04-05 15:25:51 +0200
commitd37b7b5232e419135776f9a6169adb4aad3900fb (patch)
treec7bb5487102ab2b727b2de527c8f5ce0a87d0847 /src/compiler
parentb8440ec9fa1ddaf33b590fcf9120122e3acbf497 (diff)
glsl: add ARB_shader_ballot operations
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/ir.cpp12
-rw-r--r--src/compiler/glsl/ir_expression_operation.py7
-rw-r--r--src/compiler/glsl/ir_validate.cpp16
3 files changed, 35 insertions, 0 deletions
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index f80bd811ac0..2bbc7a1cf72 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -381,6 +381,14 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
this->type = glsl_type::int_type;
break;
+ case ir_unop_ballot:
+ this->type = glsl_type::uint64_t_type;
+ break;
+
+ case ir_unop_read_first_invocation:
+ this->type = op0->type;
+ break;
+
case ir_unop_vote_any:
case ir_unop_vote_all:
case ir_unop_vote_eq:
@@ -496,6 +504,10 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
this->type = op0->type->get_scalar_type();
break;
+ case ir_binop_read_invocation:
+ this->type = op0->type;
+ break;
+
default:
assert(!"not reached: missing automatic type setup for ir_expression");
this->type = glsl_type::float_type;
diff --git a/src/compiler/glsl/ir_expression_operation.py b/src/compiler/glsl/ir_expression_operation.py
index bde9c01db9b..1d29560733e 100644
--- a/src/compiler/glsl/ir_expression_operation.py
+++ b/src/compiler/glsl/ir_expression_operation.py
@@ -570,6 +570,10 @@ ir_expression_operation = [
# of its length.
operation("ssbo_unsized_array_length", 1),
+ # ARB_shader_ballot operations
+ operation("ballot", 1, source_types=(bool_type,), dest_type=uint64_type),
+ operation("read_first_invocation", 1),
+
# Vote among threads on the value of the boolean argument.
operation("vote_any", 1),
operation("vote_all", 1),
@@ -666,6 +670,9 @@ ir_expression_operation = [
# operand1 is the sample ID
operation("interpolate_at_sample", 2),
+ # ARB_shader_ballot operation
+ operation("read_invocation", 2),
+
# Fused floating-point multiply-add, part of ARB_gpu_shader5.
operation("fma", 3, source_types=real_types, c_expression="{src0} * {src1} + {src2}"),
diff --git a/src/compiler/glsl/ir_validate.cpp b/src/compiler/glsl/ir_validate.cpp
index 5a1202b0b0d..76a4ed17e77 100644
--- a/src/compiler/glsl/ir_validate.cpp
+++ b/src/compiler/glsl/ir_validate.cpp
@@ -582,6 +582,22 @@ ir_validate::visit_leave(ir_expression *ir)
assert(ir->type->base_type == GLSL_TYPE_INT);
break;
+ case ir_unop_ballot:
+ assert(ir->type == glsl_type::uint64_t_type);
+ assert(ir->operands[0]->type == glsl_type::bool_type);
+ break;
+
+ case ir_binop_read_invocation:
+ assert(ir->operands[1]->type == glsl_type::uint_type);
+ /* fall-through */
+ case ir_unop_read_first_invocation:
+ assert(ir->type == ir->operands[0]->type);
+ assert(ir->type->is_scalar() || ir->type->is_vector());
+ assert(ir->type->base_type == GLSL_TYPE_FLOAT ||
+ ir->type->base_type == GLSL_TYPE_INT ||
+ ir->type->base_type == GLSL_TYPE_UINT);
+ break;
+
case ir_unop_vote_any:
case ir_unop_vote_all:
case ir_unop_vote_eq: