[igt-dev] [PATCH i-g-t 2/2] tests/kms_cursor_crc: reduce cpu work on restoring image
Govindapillai, Vinod
vinod.govindapillai at intel.com
Fri Oct 14 08:40:30 UTC 2022
On Mon, 2022-10-10 at 12:35 +0300, Juha-Pekka Heikkila wrote:
> on creating reference images for crcs re-render only parts
> which have changed.
>
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
> tests/kms_cursor_crc.c | 31 +++++++++++++++++++++----------
> 1 file changed, 21 insertions(+), 10 deletions(-)
Reviewed-by: Vinod Govindapillai <vinod.govindapillai at intel.com>
>
> diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
> index 8d3426dda..2d6b43f76 100644
> --- a/tests/kms_cursor_crc.c
> +++ b/tests/kms_cursor_crc.c
> @@ -53,6 +53,13 @@ enum cursor_buffers {
> MAXCURSORBUFFER
> };
>
> +typedef struct {
> + int x;
> + int y;
> + int width;
> + int height;
> +} cursorarea;
> +
> typedef struct {
> int drm_fd;
> igt_display_t display;
> @@ -73,6 +80,7 @@ typedef struct {
> uint32_t devid;
> double alpha;
> int vblank_wait_count; /* because of msm */
> + cursorarea oldcursorarea[MAXCURSORBUFFER];
> } data_t;
>
> #define TEST_DPMS (1<<0)
> @@ -83,13 +91,6 @@ typedef struct {
> #define BLUE 0.0, 0.0, 1.0
> #define WHITE 1.0, 1.0, 1.0
>
> -typedef struct {
> - int x;
> - int y;
> - int width;
> - int height;
> -} cursorarea;
> -
> static void draw_cursor(cairo_t *cr, cursorarea *cursor, double alpha)
> {
> int wl, wr, ht, hb;
> @@ -176,11 +177,16 @@ static void restore_image(data_t *data, uint32_t buffer, cursorarea *cursor)
> cr = igt_get_cairo_ctx(data->drm_fd, &data->primary_fb[buffer]);
> cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
> cairo_set_source_surface(cr, data->surface, 0, 0);
> - cairo_rectangle(cr, 0, 0, data->screenw, data->screenh);
> + cairo_rectangle(cr, data->oldcursorarea[buffer].x,
> + data->oldcursorarea[buffer].y,
> + data->oldcursorarea[buffer].width,
> + data->oldcursorarea[buffer].height);
> cairo_fill(cr);
>
> - if (cursor)
> + if (cursor) {
> draw_cursor(cr, cursor, data->alpha);
> + data->oldcursorarea[buffer] = *cursor;
> + }
>
> igt_put_cairo_ctx(cr);
> }
> @@ -235,7 +241,7 @@ static void do_single_test(data_t *data, int x, int y, bool hw_test,
>
> if (data->flags & TEST_SUSPEND)
> igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
> - SUSPEND_TEST_NONE);
> + SUSPEND_TEST_NONE);
>
> igt_pipe_crc_start(pipe_crc);
> igt_pipe_crc_get_current(data->drm_fd, pipe_crc, &crc_after);
> @@ -509,6 +515,11 @@ static void prepare_crtc(data_t *data, int cursor_w, int cursor_h)
> data->curh = cursor_h;
> data->refresh = mode->vrefresh;
>
> + /* initialize old cursor area to full screen so first run will copy image in place */
> + data->oldcursorarea[HWCURSORBUFFER] = (cursorarea){0, 0, data->screenw, data-
> >screenh};
> + data->oldcursorarea[SWCOMPARISONBUFFER1] = (cursorarea){0, 0, data->screenw, data-
> >screenh};
> + data->oldcursorarea[SWCOMPARISONBUFFER2] = (cursorarea){0, 0, data->screenw, data-
> >screenh};
> +
> data->surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
> data->screenw,
> data->screenh);
More information about the igt-dev
mailing list