[igt-dev] [PATCH i-g-t v3 1/2] lib/igt_fb: Don't use blitter for large buffers

Ville Syrjala
2019-04-08T17:13:09Z

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

The blitter stride is limited to <32k. Fall back to gtt mmap or
rendercopy if we're about to exceed that.

Not quite sure why we're not just using gtt mmap for Y tiling
always. But let's keep it like that for now.

v2: Use rendercopy as the fallback for Yf
v3: Deal with gen4+ tiled stride correctly (Chris)

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
lib/igt_fb.c | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 6adf422228e8..d2f756dba2e9 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1576,6 +1576,31 @@ struct fb_blit_upload {
struct intel_batchbuffer *batch;
};

+static int max_blitter_stride(int fd, uint64_t modifier)
+{
+ int stride = 32768;
+
+ if (intel_gen(intel_get_drm_devid(fd)) >= 4 &&
+ modifier != DRM_FORMAT_MOD_NONE)
+ stride *= 4;
+
+ return stride;
+}
+
+static bool use_rendercopy(const struct igt_fb *fb)
+{
+ return is_ccs_modifier(fb->modifier) ||
+ (fb->modifier == I915_FORMAT_MOD_Yf_TILED &&
+ fb->strides[0] >= max_blitter_stride(fb->fd, fb->modifier));
+}
+
+static bool use_blitter(const struct igt_fb *fb)
+{
+ return (fb->modifier == I915_FORMAT_MOD_Y_TILED ||
+ fb->modifier == I915_FORMAT_MOD_Yf_TILED) &&
+ fb->strides[0] < max_blitter_stride(fb->fd, fb->modifier);
+}
+
static void init_buf(struct fb_blit_upload *blit,
struct igt_buf *buf,
const struct igt_fb *fb,
@@ -2755,7 +2780,7 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
blit->base.fd = fd;
blit->base.fb = fb;

- if (is_ccs_modifier(fb->modifier)) {
+ if (use_rendercopy(fb)) {
blit->base.bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
blit->base.batch = intel_batchbuffer_alloc(blit->base.bufmgr,
intel_get_drm_devid(fd));
@@ -2767,9 +2792,7 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
&blit->shadow_fb);
igt_assert(blit->shadow_ptr);

- if (fb->modifier == LOCAL_I915_FORMAT_MOD_Y_TILED ||
- fb->modifier == LOCAL_I915_FORMAT_MOD_Yf_TILED ||
- is_ccs_modifier(fb->modifier)) {
+ if (use_rendercopy(fb) || use_blitter(fb)) {
setup_linear_mapping(&blit->base);
} else {
blit->base.linear.fb = *fb;
@@ -2849,10 +2872,9 @@ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb)
((f->cairo_id == CAIRO_FORMAT_INVALID) &&
(f->pixman_id != PIXMAN_invalid)))
create_cairo_surface__convert(fd, fb);
- else if (is_ccs_modifier(fb->modifier))
+ else if (use_rendercopy(fb))
create_cairo_surface__rendercopy(fd, fb);
- else if (fb->modifier == LOCAL_I915_FORMAT_MOD_Y_TILED ||
- fb->modifier == LOCAL_I915_FORMAT_MOD_Yf_TILED)
+ else if (use_blitter(fb))
create_cairo_surface__blit(fd, fb);
else
create_cairo_surface__gtt(fd, fb);
--
2.21.0