[i-g-t 4/4] lib/igt_fb: Add blitter support for XE driver
Bhanuprakash Modem
bhanuprakash.modem at intel.com
Wed Jun 14 11:33:50 UTC 2023
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
lib/igt_fb.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 56 insertions(+), 5 deletions(-)
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 84ab7826f..f7a11238c 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2519,7 +2519,7 @@ static bool blitter_ok(const struct igt_fb *fb)
static bool use_enginecopy(const struct igt_fb *fb)
{
- if (!is_xe_device(fb->fd) && blitter_ok(fb))
+ if (blitter_ok(fb))
return false;
return (!HAS_FLATCCS(intel_get_drm_devid(fb->fd)) && is_ccs_modifier(fb->modifier)) ||
@@ -2818,6 +2818,48 @@ static uint32_t blt_compression_format(struct blt_copy_data *blt,
}
}
+static void copy_with_blit(struct fb_blit_upload *blit,
+ const struct igt_fb *dst_fb,
+ const struct igt_fb *src_fb)
+{
+ uint32_t src_tiling, dst_tiling;
+
+ igt_assert_eq(dst_fb->fd, src_fb->fd);
+
+ src_tiling = igt_fb_mod_to_tiling(src_fb->modifier);
+ dst_tiling = igt_fb_mod_to_tiling(dst_fb->modifier);
+
+ for (int i = 0; i < dst_fb->num_planes; i++) {
+ struct intel_buf src, dst;
+
+ igt_assert_eq(dst_fb->plane_bpp[i], src_fb->plane_bpp[i]);
+ igt_assert_eq(dst_fb->plane_width[i], src_fb->plane_width[i]);
+ igt_assert_eq(dst_fb->plane_height[i], src_fb->plane_height[i]);
+
+ intel_buf_init(blit->bops, &src, src_fb->plane_width[i],
+ src_fb->plane_height[i], src_fb->plane_bpp[i],
+ 0, src_tiling, 0);
+ intel_buf_init(blit->bops, &dst, dst_fb->plane_width[i],
+ dst_fb->plane_height[i], dst_fb->plane_bpp[i],
+ 0, dst_tiling, 0);
+
+ intel_bb_emit_blt_copy(blit->ibb,
+ &src, 0, 0, src_fb->strides[i],
+ &dst, 0, 0, dst_fb->strides[i],
+ dst_fb->plane_width[i],
+ dst_fb->plane_height[i],
+ dst_fb->plane_bpp[i]);
+
+ intel_bb_emit_bbe(blit->ibb);
+ intel_bb_flush_blit(blit->ibb);
+ igt_assert(intel_bb_sync(blit->ibb) == 0);
+ intel_bb_reset(blit->ibb, false);
+
+ intel_buf_destroy(&src);
+ intel_buf_destroy(&dst);
+ }
+}
+
static void blitcopy(const struct igt_fb *dst_fb,
const struct igt_fb *src_fb)
{
@@ -2964,9 +3006,14 @@ static void free_linear_mapping(struct fb_blit_upload *blit)
igt_nouveau_delete_bo(&linear->fb);
} else if (is_xe_device(fd)) {
gem_munmap(linear->map, linear->fb.size);
- copy_with_engine(blit, fb, &linear->fb);
- syncobj_wait(fd, &blit->ibb->engine_syncobj, 1, INT64_MAX, 0, NULL);
+ if (use_enginecopy(fb)) {
+ copy_with_engine(blit, fb, &linear->fb);
+ syncobj_wait(fd, &blit->ibb->engine_syncobj, 1, INT64_MAX, 0, NULL);
+ } else {
+ copy_with_blit(blit, &linear->fb, fb);
+ }
+
gem_close(fd, linear->fb.gem_handle);
} else {
gem_munmap(linear->map, linear->fb.size);
@@ -3005,7 +3052,8 @@ static void setup_linear_mapping(struct fb_blit_upload *blit)
struct igt_fb *fb = blit->fb;
struct fb_blit_linear *linear = &blit->linear;
- if (!igt_vc4_is_tiled(fb->modifier) && use_enginecopy(fb)) {
+ if (is_xe_device(fd) ||
+ (!igt_vc4_is_tiled(fb->modifier) && use_enginecopy(fb))) {
blit->bops = buf_ops_create(fd);
blit->ibb = intel_bb_create(fd, 4096);
}
@@ -3046,7 +3094,10 @@ static void setup_linear_mapping(struct fb_blit_upload *blit)
linear->map = igt_nouveau_mmap_bo(&linear->fb, PROT_READ | PROT_WRITE);
} else if (is_xe_device(fd)) {
- copy_with_engine(blit, &linear->fb, fb);
+ if (use_enginecopy(fb))
+ copy_with_engine(blit, &linear->fb, fb);
+ else
+ copy_with_blit(blit, &linear->fb, fb);
linear->map = xe_bo_mmap_ext(fd, linear->fb.gem_handle,
linear->fb.size, PROT_READ | PROT_WRITE);
--
2.40.0
More information about the Intel-gfx-trybot
mailing list