}
return attribs;
}
+
+void
+nir_rewrite_image_intrinsic(nir_intrinsic_instr *intrin, nir_ssa_def *src)
+{
+ switch (intrin->intrinsic) {
+#define CASE(op) \
+ case nir_intrinsic_image_deref_##op: \
+ intrin->intrinsic = nir_intrinsic_image_##op; \
+ break;
+ CASE(load)
+ CASE(store)
+ CASE(atomic_add)
+ CASE(atomic_min)
+ CASE(atomic_max)
+ CASE(atomic_and)
+ CASE(atomic_or)
+ CASE(atomic_xor)
+ CASE(atomic_exchange)
+ CASE(atomic_comp_swap)
+ CASE(atomic_fadd)
+ CASE(size)
+ CASE(samples)
+ CASE(load_raw_intel)
+ CASE(store_raw_intel)
+#undef CASE
+ default:
+ unreachable("Unhanded image intrinsic");
+ }
+
+ nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
+ nir_variable *var = nir_deref_instr_get_variable(deref);
+
+ nir_intrinsic_set_image_dim(intrin, glsl_get_sampler_dim(deref->type));
+ nir_intrinsic_set_image_array(intrin, glsl_sampler_type_is_array(deref->type));
+ nir_intrinsic_set_access(intrin, var->data.image.access);
+ nir_intrinsic_set_format(intrin, var->data.image.format);
+
+ nir_instr_rewrite_src(&intrin->instr, &intrin->src[0],
+ nir_src_for_ssa(src));
+}
return align_offset ? 1 << (ffs(align_offset) - 1) : align_mul;
}
+/* Converts a image_deref_* intrinsic into a image_* one */
+void nir_rewrite_image_intrinsic(nir_intrinsic_instr *instr,
+ nir_ssa_def *handle);
+
/**
* \group texture information
*
nir_ssa_def *index =
nir_iadd(&b, nir_imm_int(&b, var->data.driver_location),
get_aoa_deref_offset(&b, deref, 1));
- brw_nir_rewrite_image_intrinsic(intrin, index);
+ nir_rewrite_image_intrinsic(intrin, index);
break;
}
return progress;
}
-
-void
-brw_nir_rewrite_image_intrinsic(nir_intrinsic_instr *intrin,
- nir_ssa_def *index)
-{
- nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
- nir_variable *var = nir_deref_instr_get_variable(deref);
-
- switch (intrin->intrinsic) {
-#define CASE(op) \
- case nir_intrinsic_image_deref_##op: \
- intrin->intrinsic = nir_intrinsic_image_##op; \
- break;
- CASE(load)
- CASE(store)
- CASE(atomic_add)
- CASE(atomic_min)
- CASE(atomic_max)
- CASE(atomic_and)
- CASE(atomic_or)
- CASE(atomic_xor)
- CASE(atomic_exchange)
- CASE(atomic_comp_swap)
- CASE(atomic_fadd)
- CASE(size)
- CASE(samples)
- CASE(load_raw_intel)
- CASE(store_raw_intel)
-#undef CASE
- default:
- unreachable("Unhanded image intrinsic");
- }
-
- nir_intrinsic_set_image_dim(intrin, glsl_get_sampler_dim(deref->type));
- nir_intrinsic_set_image_array(intrin, glsl_sampler_type_is_array(deref->type));
- nir_intrinsic_set_access(intrin, var->data.image.access);
- nir_intrinsic_set_format(intrin, var->data.image.format);
-
- nir_instr_rewrite_src(&intrin->instr, &intrin->src[0],
- nir_src_for_ssa(index));
-}
} else {
unsigned binding_offset = state->set[set].surface_offsets[binding];
index = nir_iadd(b, index, nir_imm_int(b, binding_offset));
- brw_nir_rewrite_image_intrinsic(intrin, index);
+ nir_rewrite_image_intrinsic(intrin, index);
}
}
b.cursor = nir_before_instr(&intrin->instr);
nir_ssa_def *index = nir_iadd(&b, nir_imm_int(&b, image_var_idx),
get_aoa_deref_offset(&b, deref, 1));
- brw_nir_rewrite_image_intrinsic(intrin, index);
+ nir_rewrite_image_intrinsic(intrin, index);
break;
}