vtn/opencl: Fix alignment for half vload/vstore

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7565>
This commit is contained in:
Jesse Natalie 2020-11-11 14:24:02 -08:00 committed by Marge Bot
parent 9c4dce1d96
commit 949f8572ec

View file

@ -632,17 +632,6 @@ _handle_v_load_store(struct vtn_builder *b, enum OpenCLstd_Entrypoints opcode,
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);
enum glsl_base_type ptr_base_type =
glsl_get_base_type(p->pointer->type->type);
if (base_type != ptr_base_type) {
vtn_fail_if(ptr_base_type != GLSL_TYPE_FLOAT16 ||
(base_type != GLSL_TYPE_FLOAT &&
base_type != GLSL_TYPE_DOUBLE),
"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];
@ -652,6 +641,20 @@ _handle_v_load_store(struct vtn_builder *b, enum OpenCLstd_Entrypoints opcode,
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) {
vtn_fail_if(ptr_base_type != GLSL_TYPE_FLOAT16 ||
(base_type != GLSL_TYPE_FLOAT &&
base_type != GLSL_TYPE_DOUBLE),
"vload/vstore cannot do type conversion. "
"vload/vstore_half can only convert from half to other "
"floating-point types.");
/* 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);
}
deref = nir_alignment_deref_cast(&b->nb, deref, alignment, 0);
for (int i = 0; i < components; i++) {