nir: handle doubles in nir_deref_get_const_initializer_load()
authorConnor Abbott <connor.w.abbott@intel.com>
Fri, 14 Aug 2015 17:40:03 +0000 (10:40 -0700)
committerSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Mon, 11 Apr 2016 06:27:05 +0000 (08:27 +0200)
v2 (Sam):
- Use proper bitsize value when calling to nir_load_const_instr_create()
  (Jason).

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

index 56a50090fdd0f9776e2c244e6d2c451f4172a1a0..8d38d3384d888c1b007ee2eea4eb16e4db5e36c4 100644 (file)
@@ -694,9 +694,10 @@ nir_deref_get_const_initializer_load(nir_shader *shader, nir_deref_var *deref)
       tail = tail->child;
    }
 
+   unsigned bit_size = glsl_get_bit_size(glsl_get_base_type(tail->type));
    nir_load_const_instr *load =
       nir_load_const_instr_create(shader, glsl_get_vector_elements(tail->type),
-                                  32);
+                                  bit_size);
 
    matrix_offset *= load->def.num_components;
    for (unsigned i = 0; i < load->def.num_components; i++) {
@@ -706,6 +707,9 @@ nir_deref_get_const_initializer_load(nir_shader *shader, nir_deref_var *deref)
       case GLSL_TYPE_UINT:
          load->value.u32[i] = constant->value.u[matrix_offset + i];
          break;
+      case GLSL_TYPE_DOUBLE:
+         load->value.f64[i] = constant->value.d[matrix_offset + i];
+         break;
       case GLSL_TYPE_BOOL:
          load->value.u32[i] = constant->value.b[matrix_offset + i] ?
                              NIR_TRUE : NIR_FALSE;