nir/lower_load_const_to_scalar: support doubles and multiple bit sizes
authorIago Toral Quiroga <itoral@igalia.com>
Wed, 10 Feb 2016 15:05:11 +0000 (16:05 +0100)
committerSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Mon, 11 Apr 2016 06:27:05 +0000 (08:27 +0200)
v2 (Sam):
- Add assert to detect bitsizes differents than 32 and 64 (Jason).

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir_lower_load_const_to_scalar.c

index d290c303cd2e343257b966195680f0bae646be5f..db5865fb0c09c0aac6233a8a57b01268e186c75a 100644 (file)
@@ -49,8 +49,12 @@ lower_load_const_instr_scalar(nir_load_const_instr *lower)
    nir_ssa_def *loads[4];
    for (unsigned i = 0; i < lower->def.num_components; i++) {
       nir_load_const_instr *load_comp =
-         nir_load_const_instr_create(b.shader, 1, 32);
-      load_comp->value.u32[0] = lower->value.u32[i];
+         nir_load_const_instr_create(b.shader, 1, lower->def.bit_size);
+      if (lower->def.bit_size == 64)
+         load_comp->value.f64[0] = lower->value.f64[i];
+      else
+         load_comp->value.u32[0] = lower->value.u32[i];
+      assert(lower->def.bit_size == 64 || lower->def.bit_size == 32);
       nir_builder_instr_insert(&b, &load_comp->instr);
       loads[i] = &load_comp->def;
    }