From: "Lisovskiy, Stanislav" <stanislav.lisovskiy@intel.com>
To: Jeevan B <jeevan.b@intel.com>
Cc: igt-dev@lists.freedesktop.org, juha-pekka.heikkila@intel.com,
petri.latvala@intel.com
Subject: Re: [igt-dev] [PATCH i-g-t 04/10] lib/igt_draw: Add pixel math for tile-4
Date: Fri, 25 Feb 2022 10:39:54 +0200 [thread overview]
Message-ID: <20220225083954.GB29898@intel.com> (raw)
In-Reply-To: <20220225050853.8349-5-jeevan.b@intel.com>
On Fri, Feb 25, 2022 at 10:38:47AM +0530, Jeevan B wrote:
> From: Matt Roper <matthew.d.roper@intel.com>
>
> We need to implement the tile-4 math to convert x,y coordinates to
> buffer offsets and vice versa for cases where we're using the CPU to
> tile/detile rather than a GPU engine (e.g., the mmap_cpu and pwrite
> subtests for kms_draw_crc).
>
> The bspec description of tiling-4 is very confusing/misleading, but the
> implementation here does match the tile-4 content generated by GPU
> engines and recognized properly by the display controller.
>
> Cc: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
> Signed-off-by: Jeevan B <jeevan.b@intel.com>
Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> ---
> lib/igt_draw.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 111 insertions(+), 2 deletions(-)
>
> diff --git a/lib/igt_draw.c b/lib/igt_draw.c
> index 0ca43deb..d78ecdf0 100644
> --- a/lib/igt_draw.c
> +++ b/lib/igt_draw.c
> @@ -226,6 +226,71 @@ static int linear_x_y_to_ytiled_pos(int x, int y, uint32_t stride, int swizzle,
> return pos / pixel_size;
> }
>
> +#define OW_SIZE 16 /* in bytes */
> +#define TILE_4_SUBTILE_SIZE 64 /* in bytes */
> +#define TILE_4_WIDTH 128 /* in bytes */
> +#define TILE_4_HEIGHT 32 /* in pixels */
> +#define TILE_4_SUBTILE_WIDTH OW_SIZE /* in bytes */
> +#define TILE_4_SUBTILE_HEIGHT 4 /* in pixels */
> +
> +/*
> + * Subtile remapping for tile 4. Note that map[a]==b implies map[b]==a
> + * so we can use the same table to tile and until.
> + */
> +static const int tile4_subtile_map[] = {
> + 0, 1, 2, 3, 8, 9, 10, 11,
> + 4, 5, 6, 7, 12, 13, 14, 15,
> + 16, 17, 18, 19, 24, 25, 26, 27,
> + 20, 21, 22, 23, 28, 29, 30, 31,
> + 32, 33, 34, 35, 40, 41, 42, 43,
> + 36, 37, 38, 39, 44, 45, 46, 47,
> + 48, 49, 50, 51, 56, 57, 58, 59,
> + 52, 53, 54, 55, 60, 61, 62, 63
> +};
> +
> +static int linear_x_y_to_4tiled_pos(int x, int y, uint32_t stride, int swizzle,
> + int bpp)
> +{
> + int tile_base_pos;
> + int tile_x, tile_y;
> + int subtile_col, subtile_row, subtile_num, new_subtile_num;
> + int pixel_size = bpp / 8;
> + int byte_x = x * pixel_size;
> + int pos;
> +
> + /* Modern platforms that have 4-tiling don't use old bit 6 swizzling */
> + igt_assert_eq(swizzle, I915_BIT_6_SWIZZLE_NONE);
> +
> + /*
> + * Where does the 4k tile start (in bytes)? This is the same for Y and
> + * F so we can use the Y-tile algorithm to get to that point.
> + */
> + tile_base_pos = (y / TILE_4_HEIGHT) * stride * TILE_4_HEIGHT +
> + 4096 * (byte_x / TILE_4_WIDTH);
> +
> + /* Find pixel within tile */
> + tile_x = (byte_x % TILE_4_WIDTH);
> + tile_y = y % TILE_4_HEIGHT;
> +
> + /* And figure out the subtile within the 4k tile */
> + subtile_col = tile_x / TILE_4_SUBTILE_WIDTH;
> + subtile_row = tile_y / TILE_4_SUBTILE_HEIGHT;
> + subtile_num = subtile_row * 8 + subtile_col;
> +
> + /* Swizzle the subtile number according to the bspec diagram */
> + new_subtile_num = tile4_subtile_map[subtile_num];
> +
> + /* Calculate new position */
> + pos = tile_base_pos +
> + new_subtile_num * TILE_4_SUBTILE_SIZE +
> + (tile_y % TILE_4_SUBTILE_HEIGHT) * OW_SIZE +
> + tile_x % TILE_4_SUBTILE_WIDTH;
> + igt_assert(pos % pixel_size == 0);
> + pos /= pixel_size;
> +
> + return pos;
> +}
> +
> static void xtiled_pos_to_x_y_linear(int tiled_pos, uint32_t stride,
> int swizzle, int bpp, int *x, int *y)
> {
> @@ -253,6 +318,44 @@ static void ytiled_pos_to_x_y_linear(int tiled_pos, uint32_t stride,
> *x /= pixel_size;
> }
>
> +static void tile4_pos_to_x_y_linear(int tiled_pos, uint32_t stride,
> + int swizzle, int bpp, int *x, int *y)
> +{
> + int pixel_size = bpp / 8;
> + int tiles_per_line = stride / TILE_4_WIDTH;
> + int tile_num, tile_offset, tile_row, tile_col;
> + int tile_origin_x, tile_origin_y;
> + int subtile_num, subtile_offset, subtile_row, subtile_col;
> + int subtile_origin_x, subtile_origin_y;
> + int oword_num, byte_num;
> +
> + /* Modern platforms that have 4-tiling don't use old bit 6 swizzling */
> + igt_assert_eq(swizzle, I915_BIT_6_SWIZZLE_NONE);
> +
> + /* Calculate the x,y of the start of the 4k tile */
> + tile_num = tiled_pos / 4096;
> + tile_row = tile_num / tiles_per_line;
> + tile_col = tile_num % tiles_per_line;
> + tile_origin_x = tile_col * TILE_4_WIDTH;
> + tile_origin_y = tile_row * TILE_4_HEIGHT;
> +
> + /* Now calculate the x,y offset of the start of the subtile */
> + tile_offset = tiled_pos % 4096;
> + subtile_num = tile4_subtile_map[tile_offset / TILE_4_SUBTILE_SIZE];
> + subtile_row = subtile_num / 8;
> + subtile_col = subtile_num % 8;
> + subtile_origin_x = subtile_col * TILE_4_SUBTILE_WIDTH;
> + subtile_origin_y = subtile_row * TILE_4_SUBTILE_HEIGHT;
> +
> + /* Next the oword and byte within the subtile */
> + subtile_offset = tiled_pos % TILE_4_SUBTILE_SIZE;
> + oword_num = subtile_offset / OW_SIZE;
> + byte_num = subtile_offset % OW_SIZE;
> +
> + *x = (tile_origin_x + subtile_origin_x + byte_num) / pixel_size;
> + *y = tile_origin_y + subtile_origin_y + oword_num;
> +}
> +
> static void set_pixel(void *_ptr, int index, uint32_t color, int bpp)
> {
> if (bpp == 16) {
> @@ -318,10 +421,13 @@ static void draw_rect_ptr_tiled(void *ptr, uint32_t stride, uint32_t tiling,
> swizzle, bpp);
> break;
> case I915_TILING_Y:
> - case I915_TILING_4:
> pos = linear_x_y_to_ytiled_pos(x, y, stride,
> swizzle, bpp);
> break;
> + case I915_TILING_4:
> + pos = linear_x_y_to_4tiled_pos(x, y, stride,
> + swizzle, bpp);
> + break;
> default:
> igt_assert(false);
> }
> @@ -470,10 +576,13 @@ static void draw_rect_pwrite_tiled(int fd, struct buf_data *buf,
> swizzle, buf->bpp, &x, &y);
> break;
> case I915_TILING_Y:
> - case I915_TILING_4:
> ytiled_pos_to_x_y_linear(tiled_pos, buf->stride,
> swizzle, buf->bpp, &x, &y);
> break;
> + case I915_TILING_4:
> + tile4_pos_to_x_y_linear(tiled_pos, buf->stride,
> + swizzle, buf->bpp, &x, &y);
> + break;
> default:
> igt_assert(false);
> }
> --
> 2.17.1
>
next prev parent reply other threads:[~2022-02-25 8:39 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-25 5:08 [igt-dev] [PATCH i-g-t 00/10] Tile 4 plane format support Jeevan B
2022-02-25 5:08 ` [igt-dev] [PATCH i-g-t 01/10] lib/intel_device_info: Add a flag to indicate tiling 4 support Jeevan B
2022-02-25 5:08 ` [igt-dev] [PATCH i-g-t 02/10] include/drm-uapi: Introduce new Tile 4 format Jeevan B
2022-02-25 6:17 ` Zbigniew Kempczyński
2022-02-25 6:33 ` B, Jeevan
2022-02-25 5:08 ` [igt-dev] [PATCH i-g-t 03/10] igt/lib: Add tile 4(F-tile) format support Jeevan B
2022-02-25 8:37 ` Lisovskiy, Stanislav
2022-02-25 5:08 ` [igt-dev] [PATCH i-g-t 04/10] lib/igt_draw: Add pixel math for tile-4 Jeevan B
2022-02-25 8:39 ` Lisovskiy, Stanislav [this message]
2022-02-25 5:08 ` [igt-dev] [PATCH i-g-t 05/10] igt/tests: Add support for Tile4(TileF) format to kms_draw_crc Jeevan B
2022-02-25 8:40 ` Lisovskiy, Stanislav
2022-02-25 5:08 ` [igt-dev] [PATCH i-g-t 06/10] igt/tests: Add support for Tile4(TileF) format to tests/kms_plane_multiple Jeevan B
2022-02-25 8:41 ` Lisovskiy, Stanislav
2022-02-25 5:08 ` [igt-dev] [PATCH i-g-t 07/10] igt/tests: Add support for Tile4(TileF) format to tests/kms_plane_lowres Jeevan B
2022-02-25 8:42 ` Lisovskiy, Stanislav
2022-02-25 5:08 ` [igt-dev] [PATCH i-g-t 08/10] igt/tests: Add support for Tile4(TileF) format to tests/kms_big_fb Jeevan B
2022-02-25 8:42 ` Lisovskiy, Stanislav
2022-02-25 5:08 ` [igt-dev] [PATCH i-g-t 09/10] igt/tests: Add support for Tile4(TileF) format to testdisplay Jeevan B
2022-02-25 8:42 ` Lisovskiy, Stanislav
2022-02-25 5:08 ` [igt-dev] [PATCH i-g-t 10/10] igt/tests: Add support for Tile4(TileF) format to kms_rotation_crc Jeevan B
2022-02-25 8:43 ` Lisovskiy, Stanislav
2022-02-25 5:48 ` [igt-dev] ✓ Fi.CI.BAT: success for Tile 4 plane format support Patchwork
2022-02-25 22:44 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
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=20220225083954.GB29898@intel.com \
--to=stanislav.lisovskiy@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jeevan.b@intel.com \
--cc=juha-pekka.heikkila@intel.com \
--cc=petri.latvala@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox