[PATCH i-g-t 3/7] lib/intel_bufops: Add width and height to intel_buf

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Wed Feb 28 14:54:03 UTC 2024


While width calculated as division of stride and bpp/8 is correct
it limits its use to linear buffers (tiled requires stride is
tile width multiplied).

>From now on width and height are independent so partial blit (render)
should be now possible.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Matthew Auld <matthew.auld at intel.com>
---
 lib/intel_bufops.c | 2 ++
 lib/intel_bufops.h | 6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/intel_bufops.c b/lib/intel_bufops.c
index c8f91aef82..9d3d17def9 100644
--- a/lib/intel_bufops.c
+++ b/lib/intel_bufops.c
@@ -836,6 +836,8 @@ static void __intel_buf_init(struct buf_ops *bops,
 	memset(buf, 0, sizeof(*buf));
 
 	buf->bops = bops;
+	buf->width = width;
+	buf->height = height;
 	buf->addr.offset = INTEL_BUF_INVALID_ADDRESS;
 	IGT_INIT_LIST_HEAD(&buf->link);
 	buf->mocs = INTEL_BUF_MOCS_DEFAULT;
diff --git a/lib/intel_bufops.h b/lib/intel_bufops.h
index 0b68482b25..cd0aebdab1 100644
--- a/lib/intel_bufops.h
+++ b/lib/intel_bufops.h
@@ -24,6 +24,8 @@ struct intel_buf {
 	bool is_owner;
 	uint32_t handle;
 	uint64_t size;
+	uint32_t width;
+	uint32_t height;
 	uint32_t tiling;
 	uint32_t bpp;
 	uint32_t compression;
@@ -77,12 +79,12 @@ static inline bool intel_buf_compressed(const struct intel_buf *buf)
 
 static inline unsigned int intel_buf_width(const struct intel_buf *buf)
 {
-	return buf->surface[0].stride / (buf->bpp / 8);
+	return buf->width;
 }
 
 static inline unsigned int intel_buf_height(const struct intel_buf *buf)
 {
-	return buf->surface[0].size / buf->surface[0].stride;
+	return buf->height;
 }
 
 static inline unsigned int
-- 
2.34.1



More information about the igt-dev mailing list