All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org,
	Praveen Paneri <praveen.paneri@intel.com>
Subject: Re: [PATCH 2/4] lib/igt_draw: Add Y-tiling support
Date: Wed, 26 Oct 2016 08:30:28 +0200	[thread overview]
Message-ID: <20161026063028.drpnydxcsmmsapg7@phenom.ffwll.local> (raw)
In-Reply-To: <fd2ddc7d-547f-020f-7a2b-f93ac7265f26@linux.intel.com>

On Tue, Oct 25, 2016 at 09:08:37AM +0100, Tvrtko Ursulin wrote:
> 
> On 24/10/2016 17:55, Praveen Paneri wrote:
> > This patch adds Y-tiling support for igt_draw_rect function.
> > 
> > Change-Id: I139e9773b7df286febe9ffa3dce358df079dac14
> 
> You can remove (and should) remove Gerrit tags when sending stuff upstream.

Personally I don't care. There's definitely some upstream folks who want
those removed, and will reject your patches if gerrit tags are still there
(so really remove them for anything touching non-intel code). But
personally I don't care, and if it somehow helps you track stuff
internally I'm ok with carrying them around.

Iirc a while back we had the idea of an VPG-Id: or similar, for exactly
this purpose.

/maintainer out

Cheers, Daniel

> 
> Regards,
> 
> Tvrtko
> 
> > Signed-off-by: Praveen Paneri <praveen.paneri@intel.com>
> > ---
> >  lib/igt_draw.c | 148 ++++++++++++++++++++++++++++++++++++++++++---------------
> >  1 file changed, 110 insertions(+), 38 deletions(-)
> > 
> > diff --git a/lib/igt_draw.c b/lib/igt_draw.c
> > index 3afb827..29a725f 100644
> > --- a/lib/igt_draw.c
> > +++ b/lib/igt_draw.c
> > @@ -137,7 +137,7 @@ static int swizzle_addr(int addr, int swizzle)
> >  /* It's all in "pixel coordinates", so make sure you multiply/divide by the bpp
> >   * if you need to. */
> >  static int linear_x_y_to_tiled_pos(int x, int y, uint32_t stride, int swizzle,
> > -				   int bpp)
> > +				   int bpp, int tiling)
> >  {
> >  	int x_tile_size, y_tile_size;
> >  	int x_tile_n, y_tile_n, x_tile_off, y_tile_off;
> > @@ -146,23 +146,54 @@ static int linear_x_y_to_tiled_pos(int x, int y, uint32_t stride, int swizzle,
> >  	int tiled_pos, tiles_per_line;
> >  	int pixel_size = bpp / 8;
> > 
> > -	line_size = stride;
> > -	x_tile_size = 512;
> > -	y_tile_size = 8;
> > -	tile_size = x_tile_size * y_tile_size;
> > -	tiles_per_line = line_size / x_tile_size;
> > -
> > -	y_tile_n = y / y_tile_size;
> > -	y_tile_off = y % y_tile_size;
> > -
> > -	x_tile_n = (x * pixel_size) / x_tile_size;
> > -	x_tile_off = (x * pixel_size) % x_tile_size;
> > -
> > -	tile_n = y_tile_n * tiles_per_line + x_tile_n;
> > -	tile_off = y_tile_off * x_tile_size + x_tile_off;
> > -	tiled_pos = tile_n * tile_size + tile_off;
> > -
> > -	tiled_pos = swizzle_addr(tiled_pos, swizzle);
> > +	if (tiling == I915_TILING_X ) {
> > +		line_size = stride;
> > +		x_tile_size = 512;
> > +		y_tile_size = 8;
> > +		tile_size = x_tile_size * y_tile_size;
> > +		tiles_per_line = line_size / x_tile_size;
> > +
> > +		y_tile_n = y / y_tile_size;
> > +		y_tile_off = y % y_tile_size;
> > +
> > +		x_tile_n = (x * pixel_size) / x_tile_size;
> > +		x_tile_off = (x * pixel_size) % x_tile_size;
> > +
> > +		tile_n = y_tile_n * tiles_per_line + x_tile_n;
> > +		tile_off = y_tile_off * x_tile_size + x_tile_off;
> > +		tiled_pos = tile_n * tile_size + tile_off;
> > +
> > +		tiled_pos = swizzle_addr(tiled_pos, swizzle);
> > +	} else {
> > +		int x_oword_n, x_oword_off;
> > +		int oword_size;
> > +
> > +		/* Y-tile arrangement */
> > +		line_size = stride;
> > +		oword_size = 16;
> > +		x_tile_size = 128;
> > +		y_tile_size = 32;
> > +		tile_size = x_tile_size * y_tile_size;
> > +		tiles_per_line = line_size / x_tile_size;
> > +
> > +		y_tile_n = y / y_tile_size;
> > +		y_tile_off = y % y_tile_size;
> > +
> > +		x_tile_n = (x * pixel_size) / x_tile_size;
> > +		x_tile_off = (x * pixel_size) % x_tile_size;
> > +
> > +		tile_n = y_tile_n * tiles_per_line + x_tile_n;
> > +
> > +		/* computation inside the tile */
> > +		x_oword_n = x_tile_off / oword_size;
> > +		x_oword_off = x_tile_off % oword_size;
> > +		tile_off = x_oword_n * y_tile_size * oword_size
> > +			   + y_tile_off * oword_size
> > +			   + x_oword_off;
> > +		tiled_pos = tile_n * tile_size + tile_off;
> > +
> > +		tiled_pos = swizzle_addr(tiled_pos, swizzle);
> > +	}
> > 
> >  	return tiled_pos / pixel_size;
> >  }
> > @@ -170,7 +201,8 @@ static int linear_x_y_to_tiled_pos(int x, int y, uint32_t stride, int swizzle,
> >  /* It's all in "pixel coordinates", so make sure you multiply/divide by the bpp
> >   * if you need to. */
> >  static void tiled_pos_to_x_y_linear(int tiled_pos, uint32_t stride,
> > -				    int swizzle, int bpp, int *x, int *y)
> > +				    int swizzle, int bpp, int *x, int *y,
> > +				    int tiling)
> >  {
> >  	int tile_n, tile_off, tiles_per_line, line_size;
> >  	int x_tile_off, y_tile_off;
> > @@ -181,22 +213,50 @@ static void tiled_pos_to_x_y_linear(int tiled_pos, uint32_t stride,
> >  	tiled_pos = swizzle_addr(tiled_pos, swizzle);
> > 
> >  	line_size = stride;
> > -	x_tile_size = 512;
> > -	y_tile_size = 8;
> > -	tile_size = x_tile_size * y_tile_size;
> > -	tiles_per_line = line_size / x_tile_size;
> > +	if (tiling == I915_TILING_X ) {
> > +		x_tile_size = 512;
> > +		y_tile_size = 8;
> > +		tile_size = x_tile_size * y_tile_size;
> > +		tiles_per_line = line_size / x_tile_size;
> > +
> > +		tile_n = tiled_pos / tile_size;
> > +		tile_off = tiled_pos % tile_size;
> > +
> > +		y_tile_off = tile_off / x_tile_size;
> > +		x_tile_off = tile_off % x_tile_size;
> > 
> > -	tile_n = tiled_pos / tile_size;
> > -	tile_off = tiled_pos % tile_size;
> > +		x_tile_n = tile_n % tiles_per_line;
> > +		y_tile_n = tile_n / tiles_per_line;
> > +
> > +		*x = (x_tile_n * x_tile_size + x_tile_off) / pixel_size;
> > +		*y = y_tile_n * y_tile_size + y_tile_off;
> > +	} else {
> > +		int x_oword_n, x_oword_off;
> > +		int oword_size;
> > 
> > -	y_tile_off = tile_off / x_tile_size;
> > -	x_tile_off = tile_off % x_tile_size;
> > +		oword_size = 16;
> > +		x_tile_size = 128;
> > +		y_tile_size = 32;
> > +		tile_size = x_tile_size * y_tile_size;
> > +		tiles_per_line = line_size / x_tile_size;
> > 
> > -	x_tile_n = tile_n % tiles_per_line;
> > -	y_tile_n = tile_n / tiles_per_line;
> > +		tile_n = tiled_pos / tile_size;
> > +		tile_off = tiled_pos % tile_size;
> > 
> > -	*x = (x_tile_n * x_tile_size + x_tile_off) / pixel_size;
> > -	*y = y_tile_n * y_tile_size + y_tile_off;
> > +		x_tile_n = tile_n % tiles_per_line;
> > +		y_tile_n = tile_n / tiles_per_line;
> > +
> > +		x_oword_n = tile_off / (oword_size * y_tile_size);
> > +		x_oword_off = tile_off % oword_size;
> > +
> > +		x_tile_off = x_oword_n * oword_size + x_oword_off;
> > +		y_tile_off = (tile_off - x_oword_n * oword_size * y_tile_size)
> > +			     / oword_size;
> > +
> > +		*x = (x_tile_n * x_tile_size + x_tile_off) / pixel_size;
> > +		*y = y_tile_n * y_tile_size + y_tile_off;
> > +
> > +	}
> >  }
> > 
> >  static void set_pixel(void *_ptr, int index, uint32_t color, int bpp)
> > @@ -225,14 +285,15 @@ static void draw_rect_ptr_linear(void *ptr, uint32_t stride,
> >  }
> > 
> >  static void draw_rect_ptr_tiled(void *ptr, uint32_t stride, int swizzle,
> > -				struct rect *rect, uint32_t color, int bpp)
> > +				struct rect *rect, uint32_t color, int bpp,
> > +				int tiling)
> >  {
> >  	int x, y, pos;
> > 
> >  	for (y = rect->y; y < rect->y + rect->h; y++) {
> >  		for (x = rect->x; x < rect->x + rect->w; x++) {
> >  			pos = linear_x_y_to_tiled_pos(x, y, stride, swizzle,
> > -						      bpp);
> > +						      bpp, tiling);
> >  			set_pixel(ptr, pos, color, bpp);
> >  		}
> >  	}
> > @@ -260,7 +321,11 @@ static void draw_rect_mmap_cpu(int fd, struct buf_data *buf, struct rect *rect,
> >  		break;
> >  	case I915_TILING_X:
> >  		draw_rect_ptr_tiled(ptr, buf->stride, swizzle, rect, color,
> > -				    buf->bpp);
> > +				    buf->bpp, tiling);
> > +		break;
> > +	case I915_TILING_Y:
> > +		draw_rect_ptr_tiled(ptr, buf->stride, swizzle, rect, color,
> > +				    buf->bpp, tiling);
> >  		break;
> >  	default:
> >  		igt_assert(false);
> > @@ -310,7 +375,11 @@ static void draw_rect_mmap_wc(int fd, struct buf_data *buf, struct rect *rect,
> >  		break;
> >  	case I915_TILING_X:
> >  		draw_rect_ptr_tiled(ptr, buf->stride, swizzle, rect, color,
> > -				    buf->bpp);
> > +				    buf->bpp, tiling);
> > +		break;
> > +	case I915_TILING_Y:
> > +		draw_rect_ptr_tiled(ptr, buf->stride, swizzle, rect, color,
> > +				    buf->bpp, tiling);
> >  		break;
> >  	default:
> >  		igt_assert(false);
> > @@ -338,7 +407,7 @@ static void draw_rect_pwrite_untiled(int fd, struct buf_data *buf,
> > 
> >  static void draw_rect_pwrite_tiled(int fd, struct buf_data *buf,
> >  				   struct rect *rect, uint32_t color,
> > -				   uint32_t swizzle)
> > +				   uint32_t swizzle, int tiling)
> >  {
> >  	int i;
> >  	int tiled_pos, x, y, pixel_size;
> > @@ -362,7 +431,7 @@ static void draw_rect_pwrite_tiled(int fd, struct buf_data *buf,
> > 
> >  	for (tiled_pos = 0; tiled_pos < buf->size; tiled_pos += pixel_size) {
> >  		tiled_pos_to_x_y_linear(tiled_pos, buf->stride, swizzle,
> > -					buf->bpp, &x, &y);
> > +					buf->bpp, &x, &y, tiling);
> > 
> >  		if (x >= rect->x && x < rect->x + rect->w &&
> >  		    y >= rect->y && y < rect->y + rect->h) {
> > @@ -399,7 +468,10 @@ static void draw_rect_pwrite(int fd, struct buf_data *buf,
> >  		draw_rect_pwrite_untiled(fd, buf, rect, color);
> >  		break;
> >  	case I915_TILING_X:
> > -		draw_rect_pwrite_tiled(fd, buf, rect, color, swizzle);
> > +		draw_rect_pwrite_tiled(fd, buf, rect, color, swizzle, tiling);
> > +		break;
> > +	case I915_TILING_Y:
> > +		draw_rect_pwrite_tiled(fd, buf, rect, color, swizzle, tiling);
> >  		break;
> >  	default:
> >  		igt_assert(false);
> > 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-10-26  6:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-24 16:55 [PATCH 1/4] igt_fb: Add Y-tiling support Praveen Paneri
2016-10-24 16:55 ` [PATCH 2/4] lib/igt_draw: " Praveen Paneri
2016-10-24 17:05   ` Ville Syrjälä
2016-10-25  8:08   ` Tvrtko Ursulin
2016-10-26  6:30     ` Daniel Vetter [this message]
2016-10-24 16:55 ` [PATCH 3/4] lib/igt_draw: Add Y-tiling support for IGT_DRAW_BLT method Praveen Paneri
2016-10-24 16:55 ` [PATCH 4/4] tests/kms_draw_crc: add support for Y tiling Praveen Paneri
2016-10-25  8:06 ` [PATCH 1/4] igt_fb: Add Y-tiling support Tvrtko Ursulin
2016-10-25  8:18   ` Chris Wilson
2016-10-25  8:20     ` Tvrtko Ursulin
2016-10-25  8:31       ` Chris Wilson
2016-10-25 12:06   ` Paneri, Praveen
2016-10-25 12:36     ` Tvrtko Ursulin
2016-10-25 15:02       ` Paneri, Praveen
2016-10-26  6:32         ` Daniel Vetter
2016-10-26  8:09           ` Tvrtko Ursulin
2016-10-26  8:20             ` Ville Syrjälä
2016-10-26 16:38               ` Ville Syrjälä
2016-10-27  6:46             ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161026063028.drpnydxcsmmsapg7@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=praveen.paneri@intel.com \
    --cc=tvrtko.ursulin@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.