nir_ssa_def *offset = vtn_get_nir_ssa(b, w[5 + a]);
struct vtn_value *p = vtn_value(b, w[6 + a], vtn_value_type_pointer);
+ struct vtn_ssa_value *comps[NIR_MAX_VEC_COMPONENTS];
+ nir_ssa_def *ncomps[NIR_MAX_VEC_COMPONENTS];
+
+ nir_ssa_def *moffset = nir_imul_imm(&b->nb, offset,
+ (vec_aligned && components == 3) ? 4 : components);
+ nir_deref_instr *deref = vtn_pointer_to_deref(b, p->pointer);
+
+ unsigned alignment = vec_aligned ? glsl_get_cl_alignment(type->type) :
+ glsl_get_bit_size(type->type) / 8;
enum glsl_base_type ptr_base_type =
glsl_get_base_type(p->pointer->type->type);
if (base_type != ptr_base_type) {
"vload/vstore cannot do type conversion. "
"vload/vstore_half can only convert from half to other "
"floating-point types.");
- }
- struct vtn_ssa_value *comps[NIR_MAX_VEC_COMPONENTS];
- nir_ssa_def *ncomps[NIR_MAX_VEC_COMPONENTS];
-
- nir_ssa_def *moffset = nir_imul_imm(&b->nb, offset,
- (vec_aligned && components == 3) ? 4 : components);
- nir_deref_instr *deref = vtn_pointer_to_deref(b, p->pointer);
+ /* Above-computed alignment was for floats/doubles, not halves */
+ alignment /= glsl_get_bit_size(type->type) / glsl_base_type_get_bit_size(ptr_base_type);
+ }
- unsigned alignment = vec_aligned ? glsl_get_cl_alignment(type->type) :
- glsl_get_bit_size(type->type) / 8;
deref = nir_alignment_deref_cast(&b->nb, deref, alignment, 0);
for (int i = 0; i < components; i++) {