INTRINSIC(store_var, 1, ARR(0), false, 0, 1, 0, 0)
INTRINSIC(copy_var, 0, ARR(), false, 0, 2, 0, 0)
+/*
+ * Interpolation of input. The interp_var_at* intrinsics are similar to the
+ * load_var intrinsic acting an a shader input except that they interpolate
+ * the input differently. The at_sample and at_offset intrinsics take an
+ * aditional source that is a integer sample id or a vec2 position offset
+ * respectively.
+ */
+
+INTRINSIC(interp_var_at_centroid, 0, ARR(0), true, 0, 1, 0,
+ NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+INTRINSIC(interp_var_at_sample, 1, ARR(1), true, 0, 1, 0,
+ NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+INTRINSIC(interp_var_at_offset, 1, ARR(2), true, 0, 1, 0,
+ NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+
/*
* a barrier is an intrinsic with no inputs/outputs but which can't be moved
* around/optimized in general
LOAD(input, 2, NIR_INTRINSIC_CAN_REORDER)
/* LOAD(ssbo, 2, 0) */
-/*
- * Interpolation of input. These are similar to the load_input* intrinsics
- * except they interpolate differently. The interp_at_offset* and
- * interp_at_offset* intrinsics take a second source that is either a
- * sample id or a vec2 position offset.
- */
-
-#define INTERP(name, num_srcs, src_comps) \
- INTRINSIC(interp_##name, num_srcs, ARR(src_comps), true, \
- 0, 0, 2, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER) \
- INTRINSIC(interp_##name##_indirect, 1 + num_srcs, ARR(1, src_comps), true, \
- 0, 0, 2, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
-
-INTERP(at_centroid, 0, 0)
-INTERP(at_sample, 1, 1)
-INTERP(at_offset, 1, 1)
-
/*
* Stores work the same way as loads, except now the first register input is
* the value or array to store and the optional second input is the indirect
bool has_indirect = deref_has_indirect(intrin->variables[0]);
+ /* Figure out the opcode */
nir_intrinsic_op load_op;
switch (mode) {
case nir_var_shader_in:
- if (has_indirect) {
- load_op = nir_intrinsic_load_input_indirect;
- } else {
- load_op = nir_intrinsic_load_input;
- }
+ load_op = has_indirect ? nir_intrinsic_load_input_indirect :
+ nir_intrinsic_load_input;
break;
case nir_var_uniform:
- if (has_indirect) {
- load_op = nir_intrinsic_load_uniform_indirect;
- } else {
- load_op = nir_intrinsic_load_uniform;
- }
+ load_op = has_indirect ? nir_intrinsic_load_uniform_indirect :
+ nir_intrinsic_load_uniform;
break;
default:
unreachable("Unknown variable mode");
}
+
nir_intrinsic_instr *load = nir_intrinsic_instr_create(state->mem_ctx,
load_op);
load->num_components = intrin->num_components;