summaryrefslogtreecommitdiffstats
path: root/src/glsl/loop_controls.cpp
diff options
context:
space:
mode:
authorTapani Pälli <[email protected]>2014-07-30 13:02:52 +0300
committerTapani Pälli <[email protected]>2014-08-07 07:31:49 +0300
commit151fb1e808c051a078071c89ff996bdad037ed65 (patch)
tree20bb9d4ff2a4ed22830af837e10c552a4e38c698 /src/glsl/loop_controls.cpp
parent787bac38084650ef5600ac2ecd969449b4a447f3 (diff)
glsl: support unsigned increment in ir_loop controls
Current version can create ir_expression where operands have different base type, patch adds support for unsigned type. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Tested-by: Michel Dänzer <[email protected]> https://bugs.freedesktop.org/show_bug.cgi?id=80880
Diffstat (limited to 'src/glsl/loop_controls.cpp')
-rw-r--r--src/glsl/loop_controls.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp
index 36b49eb462e..1c1d34fefe6 100644
--- a/src/glsl/loop_controls.cpp
+++ b/src/glsl/loop_controls.cpp
@@ -123,9 +123,20 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
bool valid_loop = false;
for (unsigned i = 0; i < Elements(bias); i++) {
- iter = (increment->type->is_integer())
- ? new(mem_ctx) ir_constant(iter_value + bias[i])
- : new(mem_ctx) ir_constant(float(iter_value + bias[i]));
+ /* Increment may be of type int, uint or float. */
+ switch (increment->type->base_type) {
+ case GLSL_TYPE_INT:
+ iter = new(mem_ctx) ir_constant(iter_value + bias[i]);
+ break;
+ case GLSL_TYPE_UINT:
+ iter = new(mem_ctx) ir_constant(unsigned(iter_value + bias[i]));
+ break;
+ case GLSL_TYPE_FLOAT:
+ iter = new(mem_ctx) ir_constant(float(iter_value + bias[i]));
+ break;
+ default:
+ unreachable(!"Unsupported type for loop iterator.");
+ }
ir_expression *const mul =
new(mem_ctx) ir_expression(ir_binop_mul, increment->type, iter,