[igt-dev] [PATCH i-g-t v9 2/5] lib/intel_batchbuffer: Add CCS width/height functions for Intel igt_buf
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Fri Jan 17 14:14:50 UTC 2020
igt_buf has some fields which can be interpreted differently across
vendors (ccs structure). Patch adds functions which are aware of
meaning of this field.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Katarzyna Dec <katarzyna.dec at intel.com>
---
lib/intel_batchbuffer.c | 47 +++++++++++++++++++++++++++++++++++++++++
lib/intel_batchbuffer.h | 2 ++
2 files changed, 49 insertions(+)
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 3dc89024..ab907913 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -43,6 +43,7 @@
#include "ioctl_wrappers.h"
#include "media_spin.h"
#include "gpgpu_fill.h"
+#include "igt_aux.h"
#include <i915_drm.h>
@@ -529,6 +530,52 @@ unsigned igt_buf_height(const struct igt_buf *buf)
return buf->surface[0].size/buf->surface[0].stride;
}
+/**
+ * igt_buf_intel_ccs_width:
+ * @buf: the Intel i-g-t buffer object
+ * @gen: device generation
+ *
+ * Computes the width of ccs buffer when considered as Intel surface data.
+ *
+ * Returns:
+ * The width of the ccs buffer data.
+ */
+unsigned int igt_buf_intel_ccs_width(int gen, const struct igt_buf *buf)
+{
+ /*
+ * GEN12+: The CCS unit size is 64 bytes mapping 4 main surface
+ * tiles. Thus the width of the CCS unit is 4*32=128 pixels on the
+ * main surface.
+ */
+ if (gen >= 12)
+ return DIV_ROUND_UP(igt_buf_width(buf), 128) * 64;
+
+ return DIV_ROUND_UP(igt_buf_width(buf), 1024) * 128;
+}
+
+/**
+ * igt_buf_intel_ccs_height:
+ * @buf: the i-g-t buffer object
+ * @gen: device generation
+ *
+ * Computes the height of ccs buffer when considered as Intel surface data.
+ *
+ * Returns:
+ * The height of the ccs buffer data.
+ */
+unsigned int igt_buf_intel_ccs_height(int gen, const struct igt_buf *buf)
+{
+ /*
+ * GEN12+: The CCS unit size is 64 bytes mapping 4 main surface
+ * tiles. Thus the height of the CCS unit is 32 pixel rows on the main
+ * surface.
+ */
+ if (gen >= 12)
+ return DIV_ROUND_UP(igt_buf_height(buf), 32);
+
+ return DIV_ROUND_UP(igt_buf_height(buf), 512) * 32;
+}
+
/*
* pitches are in bytes if the surfaces are linear, number of dwords
* otherwise
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index fd7ef03f..85eb3ffd 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -262,6 +262,8 @@ static inline bool igt_buf_compressed(const struct igt_buf *buf)
unsigned igt_buf_width(const struct igt_buf *buf);
unsigned igt_buf_height(const struct igt_buf *buf);
+unsigned int igt_buf_intel_ccs_width(int gen, const struct igt_buf *buf);
+unsigned int igt_buf_intel_ccs_height(int gen, const struct igt_buf *buf);
void igt_blitter_fast_copy(struct intel_batchbuffer *batch,
const struct igt_buf *src, unsigned src_delta,
--
2.23.0
More information about the igt-dev
mailing list