return dest;
}
-nir_ssa_def *
-vtn_vector_extract(struct vtn_builder *b, nir_ssa_def *src, unsigned index)
-{
- if (index > src->num_components)
- return nir_ssa_undef(&b->nb, src->num_components, src->bit_size);
- else
- return nir_channel(&b->nb, src, index);
-}
-
nir_ssa_def *
vtn_vector_insert(struct vtn_builder *b, nir_ssa_def *src, nir_ssa_def *insert,
unsigned index)
return &vec->dest.dest.ssa;
}
-nir_ssa_def *
-vtn_vector_extract_dynamic(struct vtn_builder *b, nir_ssa_def *src,
- nir_ssa_def *index)
-{
- return nir_vector_extract(&b->nb, src, nir_i2i(&b->nb, index, 32));
-}
-
nir_ssa_def *
vtn_vector_insert_dynamic(struct vtn_builder *b, nir_ssa_def *src,
nir_ssa_def *insert, nir_ssa_def *index)
struct vtn_ssa_value *ret = rzalloc(b, struct vtn_ssa_value);
ret->type = glsl_scalar_type(glsl_get_base_type(cur->type));
- ret->def = vtn_vector_extract(b, cur->def, indices[i]);
+ ret->def = nir_channel(&b->nb, cur->def, indices[i]);
return ret;
} else {
vtn_fail_if(indices[i] >= glsl_get_length(cur->type),
switch (opcode) {
case SpvOpVectorExtractDynamic:
- ssa->def = vtn_vector_extract_dynamic(b, vtn_ssa_value(b, w[3])->def,
- vtn_ssa_value(b, w[4])->def);
+ ssa->def = nir_vector_extract(&b->nb, vtn_ssa_value(b, w[3])->def,
+ vtn_ssa_value(b, w[4])->def);
break;
case SpvOpVectorInsertDynamic:
if (vec_array_deref) {
assert(vec_deref);
- if (nir_src_is_const(vec_deref->arr.index)) {
- val->ssa->def = vtn_vector_extract(b, &intrin->dest.ssa,
- nir_src_as_uint(vec_deref->arr.index));
- } else {
- val->ssa->def = vtn_vector_extract_dynamic(b, &intrin->dest.ssa,
- vec_deref->arr.index.ssa);
- }
+ val->ssa->def = nir_vector_extract(&b->nb, &intrin->dest.ssa,
+ vec_deref->arr.index.ssa);
} else {
val->ssa->def = &intrin->dest.ssa;
}
if (vec_array_deref) {
assert(vec_deref);
- if (nir_src_is_const(vec_deref->arr.index)) {
- val->ssa->def = vtn_vector_extract(b, &intrin->dest.ssa,
- nir_src_as_uint(vec_deref->arr.index));
- } else {
- val->ssa->def = vtn_vector_extract_dynamic(b, &intrin->dest.ssa,
- vec_deref->arr.index.ssa);
- }
+ val->ssa->def = nir_vector_extract(&b->nb, &intrin->dest.ssa,
+ vec_deref->arr.index.ssa);
} else {
val->ssa->def = &intrin->dest.ssa;
}
} else {
struct vtn_ssa_value *ssa = vtn_create_ssa_value(b, glsl_scalar_type(glsl_get_base_type(dest_type)));
struct vtn_ssa_value *val = vtn_ssa_value(b, w[5]);
- ssa->def = vtn_vector_extract(b, val->def, i);
+ ssa->def = nir_channel(&b->nb, val->def, i);
vtn_local_store(b, ssa, arr_deref, p->type->access);
}
}
struct vtn_ssa_value *vtn_ssa_transpose(struct vtn_builder *b,
struct vtn_ssa_value *src);
-nir_ssa_def *vtn_vector_extract(struct vtn_builder *b, nir_ssa_def *src,
- unsigned index);
-nir_ssa_def *vtn_vector_extract_dynamic(struct vtn_builder *b, nir_ssa_def *src,
- nir_ssa_def *index);
nir_ssa_def *vtn_vector_insert(struct vtn_builder *b, nir_ssa_def *src,
nir_ssa_def *insert, unsigned index);
nir_ssa_def *vtn_vector_insert_dynamic(struct vtn_builder *b, nir_ssa_def *src,
if (src_tail != src) {
val->type = src->type;
- if (nir_src_is_const(src->arr.index))
- val->def = vtn_vector_extract(b, val->def,
- nir_src_as_uint(src->arr.index));
- else
- val->def = vtn_vector_extract_dynamic(b, val->def, src->arr.index.ssa);
+ val->def = nir_vector_extract(&b->nb, val->def, src->arr.index.ssa);
}
return val;