summaryrefslogtreecommitdiff
path: root/lib/igt_matrix.h
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2018-06-06 16:28:31 +0300
committerVille Syrjälä <ville.syrjala@linux.intel.com>2018-06-06 16:28:31 +0300
commitc07af1f4713b4d014de8fd0d401f9e3ed639f6d6 (patch)
treed5310540eccbcaef5be515a4e80665ac5bf62818 /lib/igt_matrix.h
parentc8f1ae58e1b7da17af4722a5ce5a9cd8b9a34059 (diff)
lib/igt_matrix: Unroll and inline igt_matrix_transform()
Using the current igt_matrix for NV12 conversion ends up being about 4x as slow as the current non-igt_matrix based code. Unrolling and inlining igt_matrix_transform() improves that factor to ~1.5x. Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_matrix.h')
-rw-r--r--lib/igt_matrix.h43
1 files changed, 41 insertions, 2 deletions
diff --git a/lib/igt_matrix.h b/lib/igt_matrix.h
index 33acb815..7a2b9ad8 100644
--- a/lib/igt_matrix.h
+++ b/lib/igt_matrix.h
@@ -44,13 +44,52 @@ struct igt_mat4 {
float d[16];
};
+#define m(row, col) ((col) * 4 + (row))
+
void igt_matrix_print(const struct igt_mat4 *m);
struct igt_mat4 igt_matrix_identity(void);
struct igt_mat4 igt_matrix_scale(float x, float y, float z);
struct igt_mat4 igt_matrix_translate(float x, float y, float z);
-struct igt_vec4 igt_matrix_transform(const struct igt_mat4 *m,
- const struct igt_vec4 *v);
struct igt_mat4 igt_matrix_multiply(const struct igt_mat4 *a,
const struct igt_mat4 *b);
+/**
+ * igt_matrix_transform:
+ *
+ * Transform the vector @v by the matrix @m. @m is on the left,
+ * @v on the right.
+ *
+ * Returns:
+ * The transformed vector.
+ */
+static inline struct igt_vec4
+igt_matrix_transform(const struct igt_mat4 *m,
+ const struct igt_vec4 *v)
+{
+ struct igt_vec4 ret = {
+ .d = { m->d[m(0, 0)] * v->d[0] +
+ m->d[m(0, 1)] * v->d[1] +
+ m->d[m(0, 2)] * v->d[2] +
+ m->d[m(0, 3)] * v->d[3],
+
+ m->d[m(1, 0)] * v->d[0] +
+ m->d[m(1, 1)] * v->d[1] +
+ m->d[m(1, 2)] * v->d[2] +
+ m->d[m(1, 3)] * v->d[3],
+
+ m->d[m(2, 0)] * v->d[0] +
+ m->d[m(2, 1)] * v->d[1] +
+ m->d[m(2, 2)] * v->d[2] +
+ m->d[m(2, 3)] * v->d[3],
+
+ m->d[m(3, 0)] * v->d[0] +
+ m->d[m(3, 1)] * v->d[1] +
+ m->d[m(3, 2)] * v->d[2] +
+ m->d[m(3, 3)] * v->d[3],
+ },
+ };
+
+ return ret;
+}
+
#endif /* __IGT_MATRIX_H__ */