From f0c28269942273bf573ce48085b592d4751d6eb2 Mon Sep 17 00:00:00 2001 From: vanfanel Date: Sat, 14 Jan 2017 14:38:18 +0100 Subject: [PATCH 1/3] DISPMANX: Fix refreshrate calculation by updating menu surface asynchronously --- gfx/drivers/dispmanx_gfx.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index 4cbf47a986..fbfb3be7c5 100644 --- a/gfx/drivers/dispmanx_gfx.c +++ b/gfx/drivers/dispmanx_gfx.c @@ -296,6 +296,20 @@ static void dispmanx_surface_setup(void *data, int src_width, int src_height, vc_dispmanx_update_submit_sync(_dispvars->update); } +static void dispmanx_surface_update_async(void *data, const void *frame, + struct dispmanx_surface *surface) +{ + struct dispmanx_video *_dispvars = data; + struct dispmanx_page *page = NULL; + + /* Since it's an async update, there's no need for multiple pages */ + page = &(surface->pages[0]); + + /* Frame blitting. Nothing else is needed if we only have a page. */ + vc_dispmanx_resource_write_data(page->resource, surface->pixformat, + surface->pitch, (void*)frame, &(surface->bmp_rect)); +} + static void dispmanx_surface_update(void *data, const void *frame, struct dispmanx_surface *surface) { @@ -473,7 +487,8 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, } } - if (_dispvars->menu_active) + //if (_dispvars->menu_active) + if (video_info.fps_show) { char buf[128]; video_monitor_get_fps(video_info, buf, sizeof(buf), NULL, 0); @@ -510,6 +525,7 @@ static void dispmanx_set_texture_frame(void *data, const void *frame, bool rgb32 _dispvars->menu_height = height; _dispvars->menu_pitch = width * (rgb32 ? 4 : 2); + /* Menu surface only needs a page as it will be updated asynchronously. */ dispmanx_surface_setup(_dispvars, width, height, @@ -518,13 +534,15 @@ static void dispmanx_set_texture_frame(void *data, const void *frame, bool rgb32 VC_IMAGE_RGBA16, 210, _dispvars->aspect_ratio, - 3, + 1, 0, &_dispvars->menu_surface); } - /* We update the menu surface if menu is active. */ - dispmanx_surface_update(_dispvars, frame, _dispvars->menu_surface); + /* We update the menu surface if menu is active. + * This update is asynchronous, yet menu screen update + * will be synced because main surface updating is synchronous */ + dispmanx_surface_update_async(_dispvars, frame, _dispvars->menu_surface); } static void dispmanx_gfx_set_nonblock_state(void *data, bool state) From da640aaa2842e258ebf167b2b4041d9e0e9e6b5d Mon Sep 17 00:00:00 2001 From: vanfanel Date: Sat, 14 Jan 2017 15:54:20 +0100 Subject: [PATCH 2/3] DISPMANX: Honor swapchain setting properly --- gfx/drivers/dispmanx_gfx.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index fbfb3be7c5..ea1f2e69eb 100644 --- a/gfx/drivers/dispmanx_gfx.c +++ b/gfx/drivers/dispmanx_gfx.c @@ -318,16 +318,6 @@ static void dispmanx_surface_update(void *data, const void *frame, settings_t *settings = config_get_ptr(); - if (settings->video.max_swapchain_images >= 3) - { - /* Wait until last issued flip completes to get a free page. Also, - * dispmanx doesn't support issuing more than one pageflip. */ - slock_lock(_dispvars->pending_mutex); - if (_dispvars->pageflip_pending > 0) - scond_wait(_dispvars->vsync_condition, _dispvars->pending_mutex); - slock_unlock(_dispvars->pending_mutex); - } - page = dispmanx_get_free_page(_dispvars, surface); /* Frame blitting */ @@ -458,6 +448,8 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, if (width == 0 || height == 0) return true; + settings_t *settings = config_get_ptr(); + _dispvars->core_width = width; _dispvars->core_height = height; _dispvars->core_pitch = pitch; @@ -476,7 +468,7 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, _dispvars->rgb32 ? VC_IMAGE_XRGB8888 : VC_IMAGE_RGB565, 255, _dispvars->aspect_ratio, - 3, + settings->video.max_swapchain_images, 0, &_dispvars->main_surface); From 8640522073ba44c8667affce080fa987587ed05a Mon Sep 17 00:00:00 2001 From: vanfanel Date: Sat, 14 Jan 2017 15:56:54 +0100 Subject: [PATCH 3/3] DISPMANX: remove commented line --- gfx/drivers/dispmanx_gfx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index ea1f2e69eb..7ea191aad3 100644 --- a/gfx/drivers/dispmanx_gfx.c +++ b/gfx/drivers/dispmanx_gfx.c @@ -479,7 +479,6 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, } } - //if (_dispvars->menu_active) if (video_info.fps_show) { char buf[128];