[igt-dev] [PATCH i-g-t 2/2] tests/kms_cursor_crc: reduce cpu work on restoring image
Juha-Pekka Heikkila
juhapekka.heikkila at gmail.com
Fri Oct 7 13:18:11 UTC 2022
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(-)
diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
index f9a1f868..a9f47640 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);
--
2.25.1
More information about the igt-dev
mailing list