[PATCH i-g-t] tests/intel/kms_ccs: recycle framebuffers
Juha-Pekka Heikkila
juhapekka.heikkila at gmail.com
Tue Oct 15 16:26:36 UTC 2024
framebuffers used in tests don't need to be recreated for each
rendering pipe. Here all framebuffers are buffered and recycled.
This cut execution time of crc tests to roughtly half when running
on discrete graphics.
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
tests/intel/kms_ccs.c | 117 ++++++++++++++++++++++++++++++------------
1 file changed, 85 insertions(+), 32 deletions(-)
diff --git a/tests/intel/kms_ccs.c b/tests/intel/kms_ccs.c
index 49c8828d2..a2be1c47e 100644
--- a/tests/intel/kms_ccs.c
+++ b/tests/intel/kms_ccs.c
@@ -188,6 +188,16 @@ typedef struct {
bool user_seed;
} data_t;
+int fb_list_length;
+struct {
+ struct igt_fb fb;
+ int width, height;
+ double r, g, b;
+ u64 modifier;
+ u32 format;
+} *fb_list;
+
+
static const struct {
double r;
double g;
@@ -750,13 +760,50 @@ static void xe2_ccs_blit(data_t *data, struct igt_fb *fb, struct igt_fb *temp_fb
access_flat_ccs_surface(fb, true);
}
+static struct igt_fb *get_fb(int fd, u64 modifier, double r, double g, double b,
+ int width, int height, u32 format, int *goodfb)
+{
+ for (int i = 0; i < fb_list_length; i++) {
+ if (fb_list[i].width == width && fb_list[i].height == height &&
+ fb_list[i].modifier == modifier && fb_list[i].format == format &&
+ fb_list[i].r == r && fb_list[i].g == g && fb_list[i].b == b) {
+ if (goodfb)
+ *goodfb = true;
+
+ return &fb_list[i].fb;
+ }
+ }
+
+ fb_list = realloc(fb_list, sizeof(*fb_list) * (fb_list_length + 1));
+ fb_list[fb_list_length].width = width;
+ fb_list[fb_list_length].height = height;
+ fb_list[fb_list_length].r = r;
+ fb_list[fb_list_length].g = g;
+ fb_list[fb_list_length].b = b;
+ fb_list[fb_list_length].modifier = modifier;
+ fb_list[fb_list_length].format = format;
+
+ if (r + g + b == 0)
+ igt_create_pattern_fb(fd, width, height, format, modifier,
+ &fb_list[fb_list_length].fb);
+ else
+ igt_create_color_fb(fd, width, height, format, modifier, r, g, b,
+ &fb_list[fb_list_length].fb);
+
+ return &fb_list[fb_list_length++].fb;
+}
+
static void generate_fb(data_t *data, struct igt_fb *fb,
int width, int height,
enum test_fb_flags fb_flags)
{
struct drm_mode_fb_cmd2 f = {0};
uint64_t modifier;
- cairo_t *cr;
+ struct igt_fb *temp_fb;
+ bool do_fast_clear = igt_fb_is_gen12_rc_ccs_cc_modifier(data->ccs_modifier);
+ bool do_solid_fill = do_fast_clear || data->plane;
+ int c = !!data->plane;
+ int goodfb = false;
const float cc_color[4] = {colors[!!data->plane].r,
colors[!!data->plane].g,
colors[!!data->plane].b,
@@ -772,47 +819,48 @@ static void generate_fb(data_t *data, struct igt_fb *fb,
else
modifier = DRM_FORMAT_MOD_LINEAR;
- create_fb_prepare_add(data->drm_fd, width, height,
- data->format, modifier,
- fb, &f);
+ if (data->flags & TEST_RANDOM) {
+ create_fb_prepare_add(data->drm_fd, width, height,
+ data->format, modifier,
+ fb, &f);
+ } else {
+ if (do_solid_fill)
+ temp_fb = get_fb(data->drm_fd, modifier,
+ colors[c].r, colors[c].g, colors[c].b,
+ width, height, data->format, &goodfb);
+ else
+ temp_fb = get_fb(data->drm_fd, modifier, 0.0, 0.0, 0.0,
+ width, height, data->format, &goodfb);
+
+ *fb = *temp_fb;
+ addfb_init(fb, &f);
+ }
if (data->flags & TEST_RANDOM) {
srand(data->seed);
fill_fb_random(data->drm_fd, fb);
} else {
- bool do_fast_clear = igt_fb_is_gen12_rc_ccs_cc_modifier(data->ccs_modifier);
- bool do_solid_fill = do_fast_clear || data->plane;
- int c = !!data->plane;
-
if (do_fast_clear && (fb_flags & FB_COMPRESSED)) {
fast_clear_fb(data->drm_fd, fb, cc_color);
- } else {
+ } else if (!goodfb) {
if (modifier == I915_FORMAT_MOD_4_TILED_BMG_CCS ||
modifier == I915_FORMAT_MOD_4_TILED_LNL_CCS) {
- struct igt_fb temp_fb;
- // non compressed temporary pattern image
- if (do_solid_fill)
- igt_create_color_fb(data->drm_fd, width, height,
- fb->drm_format, I915_FORMAT_MOD_4_TILED,
- colors[c].r, colors[c].g, colors[c].b,
- &temp_fb);
- else
- igt_create_pattern_fb(data->drm_fd, width, height,
- fb->drm_format, I915_FORMAT_MOD_4_TILED,
- &temp_fb);
-
- xe2_ccs_blit(data, fb, &temp_fb);
- igt_remove_fb(data->drm_fd, &temp_fb);
- } else {
- cr = igt_get_cairo_ctx(data->drm_fd, fb);
-
if (do_solid_fill)
- igt_paint_color(cr, 0, 0, width, height,
- colors[c].r, colors[c].g, colors[c].b);
+ temp_fb = get_fb(data->drm_fd,
+ I915_FORMAT_MOD_4_TILED,
+ colors[c].r,
+ colors[c].g,
+ colors[c].b,
+ width, height,
+ data->format, NULL);
else
- igt_paint_test_pattern(cr, width, height);
+ temp_fb = get_fb(data->drm_fd,
+ I915_FORMAT_MOD_4_TILED,
+ 0.0, 0.0, 0.0,
+ width, height,
+ data->format, NULL);
- igt_put_cairo_ctx(cr);
+ xe2_ccs_blit(data, fb, temp_fb);
}
}
}
@@ -939,8 +987,8 @@ static bool try_config(data_t *data, enum test_fb_flags fb_flags,
igt_plane_set_rotation(primary, IGT_ROTATION_0);
igt_display_commit2(display, commit);
- igt_remove_fb(data->drm_fd, &fb_sprite);
- igt_remove_fb(data->drm_fd, &fb);
+ if (data->flags & TEST_RANDOM)
+ igt_remove_fb(data->drm_fd, &fb);
igt_assert_eq(ret, data->flags & TEST_BAD_ROTATION_90 ? -EINVAL : 0);
@@ -1123,12 +1171,17 @@ igt_main_args("cs:", NULL, help_str, opt_handler, &data)
if (!data.user_seed)
data.seed = time(NULL);
+
+ fb_list_length = 0;
}
for (int c = 0; c < ARRAY_SIZE(tests); c++)
test_output(&data, c);
igt_fixture {
+ for (int i = 0; i < fb_list_length; i++)
+ igt_remove_fb(data.drm_fd, &fb_list[i].fb);
+
igt_display_fini(&data.display);
drm_close_driver(data.drm_fd);
}
--
2.45.2
More information about the igt-dev
mailing list