From 62cd0aad09579b46342eac020499e30318920866 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 9 Feb 2023 12:34:08 +0100 Subject: [PATCH] test: add dynamic@change-fb-modifier --- test/meson.build | 1 + test/test_dynamic.c | 56 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/test/meson.build b/test/meson.build index 354e6a4..a6cacb4 100644 --- a/test/meson.build +++ b/test/meson.build @@ -54,6 +54,7 @@ tests = { 'dynamic': [ 'same', 'change-fb', + 'change-fb-modifier', 'unset-fb', 'set-fb', 'add-layer', diff --git a/test/test_dynamic.c b/test/test_dynamic.c index c932b2b..f9fc299 100644 --- a/test/test_dynamic.c +++ b/test/test_dynamic.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -100,16 +101,66 @@ run_same(struct context *ctx) static void run_change_fb(struct context *ctx) { + uint32_t fb_id; + drmModeFB2 fb_info; + + fb_id = liftoff_mock_drm_create_fb(ctx->layer); + fb_info = (drmModeFB2) { + .fb_id = fb_id, + .width = 1920, + .height = 1080, + .flags = DRM_MODE_FB_MODIFIERS, + .pixel_format = DRM_FORMAT_ARGB8888, + .modifier = DRM_FORMAT_MOD_LINEAR, + }; + liftoff_mock_drm_set_fb_info(&fb_info); + liftoff_layer_set_property(ctx->layer, "FB_ID", fb_id); + first_commit(ctx); assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); - liftoff_layer_set_property(ctx->layer, "FB_ID", - liftoff_mock_drm_create_fb(ctx->layer)); + /* Create a new FB with the exact same FB info as the first one. */ + fb_id = liftoff_mock_drm_create_fb(ctx->layer); + fb_info.fb_id = fb_id; + liftoff_mock_drm_set_fb_info(&fb_info); + liftoff_layer_set_property(ctx->layer, "FB_ID", fb_id); second_commit(ctx, true); assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); } +static void +run_change_fb_modifier(struct context *ctx) +{ + uint32_t fb_id; + drmModeFB2 fb_info; + + fb_id = liftoff_mock_drm_create_fb(ctx->layer); + fb_info = (drmModeFB2) { + .fb_id = fb_id, + .width = 1920, + .height = 1080, + .flags = DRM_MODE_FB_MODIFIERS, + .pixel_format = DRM_FORMAT_ARGB8888, + .modifier = I915_FORMAT_MOD_Y_TILED, + }; + liftoff_mock_drm_set_fb_info(&fb_info); + liftoff_layer_set_property(ctx->layer, "FB_ID", fb_id); + + first_commit(ctx); + assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); + + /* Simulate the situation where the previous FB gets removed, and a new + * one gets re-created with the same FB ID but a different modifier. + * This should prevent the first configuration from being re-used. */ + fb_info.modifier = I915_FORMAT_MOD_X_TILED; + liftoff_mock_drm_set_fb_info(&fb_info); + liftoff_layer_set_property(ctx->layer, "FB_ID", fb_id); + + second_commit(ctx, false); + assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer); +} + static void run_unset_fb(struct context *ctx) { @@ -274,6 +325,7 @@ run_change_fb_damage_clips(struct context *ctx) static const struct test_case tests[] = { { .name = "same", .run = run_same }, { .name = "change-fb", .run = run_change_fb }, + { .name = "change-fb-modifier", .run = run_change_fb_modifier }, { .name = "unset-fb", .run = run_unset_fb }, { .name = "set-fb", .run = run_set_fb }, { .name = "add-layer", .run = run_add_layer },