[Intel-gfx] [PATCH i-g-t 1/2] igt_fb: Transfer existing content to Cairo surface for Y/Yf frame buffers
Damien Lespiau
damien.lespiau at intel.com
Wed Apr 29 07:02:41 PDT 2015
On Wed, Apr 29, 2015 at 01:24:34PM +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
>
> Rendering into Y and Yf tiled frame buffers with Cairo was losing the
> previous content ie. was starting from black. This is different than the
> behaviour with linear and X tiled so make it the same by blitting the
> initial content when creating the rendering context.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> Cc: Damien Lespiau <damien.lespiau at intel.com>
This looks fine to me, pushed.
--
Damien
> ---
> lib/igt_fb.c | 56 ++++++++++++++++++++++++++++++++++++++++----------------
> 1 file changed, 40 insertions(+), 16 deletions(-)
>
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 6dc22bb..fe0c63f 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -650,11 +650,27 @@ struct fb_blit_upload {
> } linear;
> };
>
> +static unsigned int fb_mod_to_obj_tiling(uint64_t fb_mod)
> +{
> + switch (fb_mod) {
> + case LOCAL_DRM_FORMAT_MOD_NONE:
> + return I915_TILING_NONE;
> + case LOCAL_I915_FORMAT_MOD_X_TILED:
> + return I915_TILING_X;
> + case LOCAL_I915_FORMAT_MOD_Y_TILED:
> + return I915_TILING_Y;
> + case LOCAL_I915_FORMAT_MOD_Yf_TILED:
> + return I915_TILING_Yf;
> + default:
> + igt_assert(0);
> + }
> +}
> +
> static void destroy_cairo_surface__blit(void *arg)
> {
> struct fb_blit_upload *blit = arg;
> struct igt_fb *fb = blit->fb;
> - unsigned int obj_tiling = I915_TILING_NONE;
> + unsigned int obj_tiling = fb_mod_to_obj_tiling(fb->tiling);
>
> munmap(blit->linear.map, blit->linear.size);
> fb->cairo_surface = NULL;
> @@ -662,18 +678,6 @@ static void destroy_cairo_surface__blit(void *arg)
> gem_set_domain(blit->fd, blit->linear.handle,
> I915_GEM_DOMAIN_GTT, 0);
>
> - switch (fb->tiling) {
> - case LOCAL_I915_FORMAT_MOD_X_TILED:
> - obj_tiling = I915_TILING_X;
> - break;
> - case LOCAL_I915_FORMAT_MOD_Y_TILED:
> - obj_tiling = I915_TILING_Y;
> - break;
> - case LOCAL_I915_FORMAT_MOD_Yf_TILED:
> - obj_tiling = I915_TILING_Yf;
> - break;
> - }
> -
> igt_blitter_fast_copy__raw(blit->fd,
> blit->linear.handle,
> blit->linear.stride,
> @@ -695,6 +699,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)
> {
> struct fb_blit_upload *blit;
> cairo_format_t cairo_format;
> + unsigned int obj_tiling = fb_mod_to_obj_tiling(fb->tiling);
> int bpp, ret;
>
> blit = malloc(sizeof(*blit));
> @@ -716,6 +721,28 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)
>
> blit->fd = fd;
> blit->fb = fb;
> +
> + /* Copy fb content to linear BO */
> + gem_set_domain(fd, blit->linear.handle,
> + I915_GEM_DOMAIN_GTT, 0);
> +
> + igt_blitter_fast_copy__raw(fd,
> + fb->gem_handle,
> + fb->stride,
> + obj_tiling,
> + 0, 0, /* src_x, src_y */
> + fb->width, fb->height,
> + blit->linear.handle,
> + blit->linear.stride,
> + I915_TILING_NONE,
> + 0, 0 /* dst_x, dst_y */);
> +
> + gem_sync(fd, blit->linear.handle);
> +
> + gem_set_domain(fd, blit->linear.handle,
> + I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
> +
> + /* Setup cairo context */
> blit->linear.map = gem_mmap__cpu(fd,
> blit->linear.handle,
> 0,
> @@ -723,9 +750,6 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)
> PROT_READ | PROT_WRITE);
> igt_assert(blit->linear.map);
>
> - gem_set_domain(fd, blit->linear.handle,
> - I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
> -
> cairo_format = drm_format_to_cairo(fb->drm_format);
> fb->cairo_surface =
> cairo_image_surface_create_for_data(blit->linear.map,
> --
> 2.3.5
>
More information about the Intel-gfx
mailing list