[igt-dev] [PATCH i-g-t 4/5] lib/igt_fb: Check for stride before creating cairo surface

Deepak Rawat drawat at vmware.com
Thu Sep 6 00:03:49 UTC 2018


Cairo surface creation will fail if stride of provided buffer is not
same as expected by cairo. This fails for vmwgfx odd length framebuffer
as in vmwgfx stride is always width * bpp.

Signed-off-by: Deepak Rawat <drawat at vmware.com>
---
 lib/igt_fb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index ba995a1a..2724e323 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1349,6 +1349,9 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb)
 		ptr = gem_mmap__gtt(fd, fb->gem_handle, fb->size,
 				    PROT_READ | PROT_WRITE);
 
+	igt_require(fb->stride == cairo_format_stride_for_width(
+		drm_format_to_cairo(fb->drm_format), fb->width));
+
 	fb->cairo_surface =
 		cairo_image_surface_create_for_data(ptr,
 						    drm_format_to_cairo(fb->drm_format),
-- 
2.17.1



More information about the igt-dev mailing list