extern const nir_intrinsic_info nir_intrinsic_infos[nir_num_intrinsics];
+static inline unsigned
+nir_intrinsic_src_components(nir_intrinsic_instr *intr, unsigned srcn)
+{
+ const nir_intrinsic_info *info = &nir_intrinsic_infos[intr->intrinsic];
+ assert(srcn < info->num_srcs);
+ if (info->src_components[srcn])
+ return info->src_components[srcn];
+ else
+ return intr->num_components;
+}
+
+static inline unsigned
+nir_intrinsic_dest_components(nir_intrinsic_instr *intr)
+{
+ const nir_intrinsic_info *info = &nir_intrinsic_infos[intr->intrinsic];
+ if (!info->has_dest)
+ return 0;
+ else if (info->dest_components)
+ return info->dest_components;
+ else
+ return intr->num_components;
+}
#define INTRINSIC_IDX_ACCESSORS(name, flag, type) \
static inline type \
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
for (unsigned i = 0;
i < nir_intrinsic_infos[intrin->intrinsic].num_srcs; i++) {
- unsigned num_components =
- nir_intrinsic_infos[intrin->intrinsic].src_components[i];
- if (!num_components)
- num_components = intrin->num_components;
+ unsigned num_components = nir_intrinsic_src_components(intrin, i);
while (copy_prop_src(&intrin->src[i], instr, NULL, num_components))
progress = true;
unsigned num_srcs = nir_intrinsic_infos[instr->intrinsic].num_srcs;
for (unsigned i = 0; i < num_srcs; i++) {
- unsigned components_read =
- nir_intrinsic_infos[instr->intrinsic].src_components[i];
- if (components_read == 0)
- components_read = instr->num_components;
+ unsigned components_read = nir_intrinsic_src_components(instr, i);
validate_assert(state, components_read > 0);
}
if (nir_intrinsic_infos[instr->intrinsic].has_dest) {
- unsigned components_written =
- nir_intrinsic_infos[instr->intrinsic].dest_components;
- if (components_written == 0)
- components_written = instr->num_components;
+ unsigned components_written = nir_intrinsic_dest_components(instr);
validate_assert(state, components_written > 0);
struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_ssa);
struct vtn_type *type = vtn_value(b, w[1], vtn_value_type_type)->type;
- unsigned dest_components =
- nir_intrinsic_infos[intrin->intrinsic].dest_components;
+ unsigned dest_components = nir_intrinsic_dest_components(intrin);
if (intrin->intrinsic == nir_intrinsic_image_var_size) {
dest_components = intrin->num_components =
glsl_get_vector_elements(type->type);
int idx, comp;
if (info->has_dest) {
- unsigned n;
- if (info->dest_components)
- n = info->dest_components;
- else
- n = intr->num_components;
+ unsigned n = nir_intrinsic_dest_components(intr);
dst = get_dst(ctx, &intr->dest, n);
} else {
dst = NULL;
const unsigned arr_dims = type->sampler_array ? 1 : 0;
const unsigned surf_dims = type->coordinate_components() - arr_dims;
const unsigned format = var->data.image.format;
+ const unsigned dest_components = nir_intrinsic_dest_components(instr);
/* Get the arguments of the image intrinsic. */
const fs_reg image = get_nir_image_deref(instr->variables[0]);
else
tmp = emit_image_atomic(bld, image, addr, src0, src1,
- surf_dims, arr_dims, info->dest_components,
+ surf_dims, arr_dims, dest_components,
get_image_atomic_op(instr->intrinsic, type));
/* Assign the result. */
- if (nir_intrinsic_infos[instr->intrinsic].has_dest) {
- for (unsigned c = 0; c < info->dest_components; ++c) {
- bld.MOV(offset(retype(dest, base_type), bld, c),
- offset(tmp, bld, c));
- }
+ for (unsigned c = 0; c < dest_components; ++c) {
+ bld.MOV(offset(retype(dest, base_type), bld, c),
+ offset(tmp, bld, c));
}
break;
}