*/
NIR_INTRINSIC_COMPONENT = 8,
+ /**
+ * Interpolation mode (only meaningful for FS inputs).
+ */
+ NIR_INTRINSIC_INTERP_MODE = 9,
+
NIR_INTRINSIC_NUM_INDEX_FLAGS,
} nir_intrinsic_index_flag;
INTRINSIC_IDX_ACCESSORS(desc_set, DESC_SET, unsigned)
INTRINSIC_IDX_ACCESSORS(binding, BINDING, unsigned)
INTRINSIC_IDX_ACCESSORS(component, COMPONENT, unsigned)
+INTRINSIC_IDX_ACCESSORS(interp_mode, INTERP_MODE, unsigned)
/**
* \group texture information
return &load->dest.ssa;
}
+static inline nir_ssa_def *
+nir_load_barycentric(nir_builder *build, nir_intrinsic_op op,
+ unsigned interp_mode)
+{
+ nir_intrinsic_instr *bary = nir_intrinsic_instr_create(build->shader, op);
+ nir_ssa_dest_init(&bary->instr, &bary->dest, 2, 32, NULL);
+ nir_intrinsic_set_interp_mode(bary, interp_mode);
+ nir_builder_instr_insert(build, &bary->instr);
+ return &bary->dest.ssa;
+}
+
static inline void
nir_jump(nir_builder *build, nir_jump_type jump_type)
{
SYSTEM_VALUE(helper_invocation, 1, 0, xx, xx, xx)
SYSTEM_VALUE(channel_num, 1, 0, xx, xx, xx)
+/**
+ * Barycentric coordinate intrinsics.
+ *
+ * These set up the barycentric coordinates for a particular interpolation.
+ * The first three are for the simple cases: pixel, centroid, or per-sample
+ * (at gl_SampleID). The next two handle interpolating at a specified
+ * sample location, or interpolating with a vec2 offset,
+ *
+ * The interp_mode index should be either the INTERP_MODE_SMOOTH or
+ * INTERP_MODE_NOPERSPECTIVE enum values.
+ *
+ * The vec2 value produced by these intrinsics is intended for use as the
+ * barycoord source of a load_interpolated_input intrinsic.
+ */
+
+#define BARYCENTRIC(name, sources, source_components) \
+ INTRINSIC(load_barycentric_##name, sources, ARR(source_components), \
+ true, 2, 0, 1, INTERP_MODE, xx, xx, \
+ NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+
+/* no sources. const_index[] = { interp_mode } */
+BARYCENTRIC(pixel, 0, 0)
+BARYCENTRIC(centroid, 0, 0)
+BARYCENTRIC(sample, 0, 0)
+/* src[] = { sample_id }. const_index[] = { interp_mode } */
+BARYCENTRIC(at_sample, 1, 1)
+/* src[] = { offset.xy }. const_index[] = { interp_mode } */
+BARYCENTRIC(at_offset, 1, 2)
+
/*
* Load operations pull data from some piece of GPU memory. All load
* operations operate in terms of offsets into some piece of theoretical
LOAD(input, 1, 2, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
/* src[] = { vertex, offset }. const_index[] = { base, component } */
LOAD(per_vertex_input, 2, 2, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+/* src[] = { barycoord, offset }. const_index[] = { base, component } */
+LOAD(interpolated_input, 2, 2, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+
/* src[] = { buffer_index, offset }. No const_index */
LOAD(ssbo, 2, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
/* src[] = { offset }. const_index[] = { base, component } */