nir/spirv: Add a missing break statement
[mesa.git] / src / glsl / lower_vector_insert.cpp
index 0e640cc3240ab98aba866c70c1de6ac7bfa55dfc..26d31b03c128991f6a336b1321e7019743d68502 100644 (file)
@@ -27,6 +27,8 @@
 
 using namespace ir_builder;
 
+namespace {
+
 class vector_insert_visitor : public ir_rvalue_visitor {
 public:
    vector_insert_visitor(bool lower_nonconstant_index)
@@ -48,6 +50,7 @@ public:
    bool lower_nonconstant_index;
 };
 
+} /* anonymous namespace */
 
 void
 vector_insert_visitor::handle_rvalue(ir_rvalue **rv)
@@ -105,9 +108,13 @@ vector_insert_visitor::handle_rvalue(ir_rvalue **rv)
       factory.emit(assign(temp, expr->operands[0]));
       factory.emit(assign(src_temp, expr->operands[1]));
 
+      assert(expr->operands[2]->type == glsl_type::int_type ||
+             expr->operands[2]->type == glsl_type::uint_type);
+
       for (unsigned i = 0; i < expr->type->vector_elements; i++) {
          ir_constant *const cmp_index =
-            new(factory.mem_ctx) ir_constant(int(i));
+            ir_constant::zero(factory.mem_ctx, expr->operands[2]->type);
+         cmp_index->value.u[0] = i;
 
          ir_variable *const cmp_result =
             factory.make_temp(glsl_type::bool_type, "index_condition");