[PATCH weston v9 13/62] compositor-drm: Return FB directly from render

Pekka Paalanen ppaalanen at gmail.com
Wed Mar 22 12:39:40 UTC 2017


On Fri,  3 Mar 2017 23:05:24 +0000
Daniel Stone <daniels at collabora.com> wrote:

> Instead of setting state members directly in the drm_output_render
> functions (to paint using Pixman or GL), just return a drm_fb, and let
> the core function place it in state.
> 
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> 
> Differential Revision: https://phabricator.freedesktop.org/D1419
> 
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> ---
>  libweston/compositor-drm.c | 30 +++++++++++++++++++-----------
>  1 file changed, 19 insertions(+), 11 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 423bd51..3f6fafc 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -653,11 +653,12 @@ drm_output_prepare_scanout_view(struct drm_output *output,
>  	return &output->fb_plane;
>  }
>  
> -static void
> +static struct drm_fb *
>  drm_output_render_gl(struct drm_output *output, pixman_region32_t *damage)
>  {
>  	struct drm_backend *b = to_drm_backend(output->base.compositor);
>  	struct gbm_bo *bo;
> +	struct drm_fb *ret;
>  
>  	output->base.compositor->renderer->repaint_output(&output->base,
>  							  damage);
> @@ -665,20 +666,21 @@ drm_output_render_gl(struct drm_output *output, pixman_region32_t *damage)
>  	bo = gbm_surface_lock_front_buffer(output->gbm_surface);
>  	if (!bo) {
>  		weston_log("failed to lock front buffer: %m\n");
> -		return;
> +		return NULL;
>  	}
>  
> -	output->fb_pending = drm_fb_get_from_bo(bo, b, output->gbm_format,
> -						BUFFER_GBM_SURFACE);
> -	if (!output->fb_pending) {
> +	ret = drm_fb_get_from_bo(bo, b, output->gbm_format, BUFFER_GBM_SURFACE);
> +	if (!ret) {
>  		weston_log("failed to get drm_fb for bo\n");
>  		gbm_surface_release_buffer(output->gbm_surface, bo);
> -		return;
> +		return NULL;
>  	}
> -	output->fb_pending->gbm_surface = output->gbm_surface;
> +	ret->gbm_surface = output->gbm_surface;
> +
> +	return ret;
>  }
>  
> -static void
> +static struct drm_fb *
>  drm_output_render_pixman(struct drm_output *output, pixman_region32_t *damage)
>  {
>  	struct weston_compositor *ec = output->base.compositor;
> @@ -694,7 +696,6 @@ drm_output_render_pixman(struct drm_output *output, pixman_region32_t *damage)
>  
>  	output->current_image ^= 1;
>  
> -	output->fb_pending = drm_fb_ref(output->dumb[output->current_image]);
>  	pixman_renderer_output_set_buffer(&output->base,
>  					  output->image[output->current_image]);
>  
> @@ -702,6 +703,8 @@ drm_output_render_pixman(struct drm_output *output, pixman_region32_t *damage)
>  
>  	pixman_region32_fini(&total_damage);
>  	pixman_region32_fini(&previous_damage);
> +
> +	return drm_fb_ref(output->dumb[output->current_image]);
>  }
>  
>  static void
> @@ -709,6 +712,7 @@ drm_output_render(struct drm_output *output, pixman_region32_t *damage)
>  {
>  	struct weston_compositor *c = output->base.compositor;
>  	struct drm_backend *b = to_drm_backend(c);
> +	struct drm_fb *fb;
>  
>  	/* If we already have a client buffer promoted to scanout, then we don't
>  	 * want to render. */
> @@ -716,9 +720,13 @@ drm_output_render(struct drm_output *output, pixman_region32_t *damage)
>  		return;
>  
>  	if (b->use_pixman)
> -		drm_output_render_pixman(output, damage);
> +		fb = drm_output_render_pixman(output, damage);
>  	else
> -		drm_output_render_gl(output, damage);
> +		fb = drm_output_render_gl(output, damage);
> +
> +	if (!fb)
> +		return;
> +	output->fb_pending = fb;
>  
>  	pixman_region32_subtract(&c->primary_plane.damage,
>  				 &c->primary_plane.damage, damage);

Hi,

this patch has an unmentioned effect: if rendering fails, damage is not
cleared. This is good and logical.

Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20170322/51e6f727/attachment.sig>


More information about the wayland-devel mailing list