From b1e56143c5979161b4b12c1e1ad0e68c8fa8665e Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 8 Dec 2020 14:13:56 +0200 Subject: [PATCH] tests: extend output-damage to GL shadow framebuffer Extend the existing output-damage test to test blit_shadow_to_output() specifically. This function had problems originally, so make sure they can't reappear. The added quirk is explained in the test. An additional check of the quirk in gl_renderer_output_create() ensures that the shadow framebuffer is really used. The test could false-pass if the shadow is not used. Signed-off-by: Pekka Paalanen --- include/libweston/libweston.h | 2 ++ libweston/renderer-gl/gl-renderer.c | 11 +++++++++- tests/output-damage-test.c | 31 ++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 07bb3209..4cdd2744 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -196,6 +196,8 @@ enum weston_hdcp_protection { struct weston_testsuite_quirks { /** Force GL-renderer to do a full upload of wl_shm buffers. */ bool gl_force_full_upload; + /** Ensure GL shadow fb is used, and always repaint it fully. */ + bool gl_force_full_redraw_of_shadow_fb; }; /** Weston test suite data that is given to compositor diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 61a354bd..dfd64a02 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -1750,7 +1750,10 @@ gl_renderer_repaint_output(struct weston_output *output, if (shadow_exists(go)) { /* Repaint into shadow. */ - repaint_views(output, output_damage); + if (compositor->test_data.test_quirks.gl_force_full_redraw_of_shadow_fb) + repaint_views(output, &output->region); + else + repaint_views(output, output_damage); glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(go->borders[GL_RENDERER_BORDER_LEFT].width, @@ -3316,10 +3319,13 @@ gl_renderer_output_create(struct weston_output *output, { struct gl_output_state *go; struct gl_renderer *gr = get_renderer(output->compositor); + const struct weston_testsuite_quirks *quirks; GLint internal_format; bool ret; int i; + quirks = &output->compositor->test_data.test_quirks; + go = zalloc(sizeof *go); if (go == NULL) return -1; @@ -3357,6 +3363,9 @@ gl_renderer_output_create(struct weston_output *output, free(go); return -1; } + } else if (quirks->gl_force_full_redraw_of_shadow_fb) { + weston_log("ERROR: gl_force_full_redraw_of_shadow_fb quirk used but shadow fb was not enabled.\n"); + abort(); } output->renderer_state = go; diff --git a/tests/output-damage-test.c b/tests/output-damage-test.c index aa3557c0..03ee4dd1 100644 --- a/tests/output-damage-test.c +++ b/tests/output-damage-test.c @@ -38,6 +38,7 @@ .scale = s, \ .transform = WL_OUTPUT_TRANSFORM_ ## t, \ .transform_name = #t, \ + .gl_shadow_fb = false, \ .meta.name = "pixman " #s " " #t, \ }, \ { \ @@ -45,7 +46,16 @@ .scale = s, \ .transform = WL_OUTPUT_TRANSFORM_ ## t, \ .transform_name = #t, \ - .meta.name = "GL " #s " " #t, \ + .gl_shadow_fb = false, \ + .meta.name = "GL no-shadow " #s " " #t, \ + }, \ + { \ + .renderer = RENDERER_GL, \ + .scale = s, \ + .transform = WL_OUTPUT_TRANSFORM_ ## t, \ + .transform_name = #t, \ + .gl_shadow_fb = true, \ + .meta.name = "GL shadow " #s " " #t, \ } struct setup_args { @@ -54,6 +64,7 @@ struct setup_args { int scale; enum wl_output_transform transform; const char *transform_name; + bool gl_shadow_fb; }; static const struct setup_args my_setup_args[] = { @@ -118,6 +129,24 @@ fixture_setup(struct weston_test_harness *harness, const struct setup_args *arg) */ setup.test_quirks.gl_force_full_upload = true; + if (arg->gl_shadow_fb) { + /* + * A second case for GL-renderer: the shadow framebuffer + * + * This tests blit_shadow_to_output() specifically. The quirk + * forces the shadow framebuffer to be redrawn completely, which + * means the test surface will be completely filled with a new + * color regardless of damage. The blit uses damage too, and + * the damage pattern that is tested for needs to appear in + * that step. + */ + setup.test_quirks.gl_force_full_redraw_of_shadow_fb = true; + weston_ini_setup(&setup, + cfgln("[output]"), + cfgln("name=headless"), + cfgln("use-renderer-shadow=true")); + } + return weston_test_harness_execute_as_client(harness, &setup); } DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args, meta);