Re: [PATCH v3 5/9] Add new spice-gl stubs API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> - spice_gl_scanout() to take the current scanout
> 
> - spice_gl_draw_async() to draw the scanout, is like other Spice async
>   functions, it takes a cookie and will return in the
>   QXLInterface.async_complete()
> 
> Two new fields are also added to QXLState, in order to save the current
> scanout, and the pending async.
> 
> A scanout can't be updated if there are pending draw atm. Discarding
> outdated draws is left as a future improvement to allow updating the
> scanout without waiting for draw async to be done.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxx>
> ---
>  server/red-dispatcher.c  | 35 +++++++++++++++++++++++++++++++++++
>  server/reds.c            |  1 +
>  server/reds.h            |  2 ++
>  server/spice-qxl.h       | 11 +++++++++++
>  server/spice-server.syms |  6 ++++++
>  5 files changed, 55 insertions(+)
> 
> diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
> index b4bbe85..f776f66 100644
> --- a/server/red-dispatcher.c
> +++ b/server/red-dispatcher.c
> @@ -959,6 +959,41 @@ void spice_qxl_driver_unload(QXLInstance *instance)
>      red_dispatcher_driver_unload(instance->st->dispatcher);
>  }
>  
> +SPICE_GNUC_VISIBLE
> +void spice_gl_scanout(QXLInstance *qxl,
> +                      int fd,
> +                      uint32_t width, uint32_t height,
> +                      uint32_t stride, uint32_t format,
> +                      int y_0_top)
> +{
> +    spice_return_if_fail(qxl != NULL);
> +    spice_return_if_fail(qxl->st->gl_draw_async == NULL);

Here you need to close fd on error or you will get a file
descriptor leak.

Frediano

> +
> +    if (qxl->st->scanout.drm_dma_buf_fd != -1) {
> +        close(qxl->st->scanout.drm_dma_buf_fd);
> +    }
> +
> +    qxl->st->scanout = (SpiceMsgDisplayGlScanoutUnix) {
> +        .flags = y_0_top ? SPICE_GL_SCANOUT_FLAGS_Y0TOP : 0,
> +        .drm_dma_buf_fd = fd,
> +        .width = width,
> +        .height = height,
> +        .stride = stride,
> +        .drm_fourcc_format = format
> +    };
> +}
> +
> +SPICE_GNUC_VISIBLE
> +void spice_gl_draw_async(QXLInstance *qxl,
> +                         uint32_t x, uint32_t y,
> +                         uint32_t w, uint32_t h,
> +                         uint64_t cookie)
> +{
> +    spice_return_if_fail(qxl != NULL);
> +    spice_return_if_fail(qxl->st->scanout.drm_dma_buf_fd != -1);
> +    spice_return_if_fail(qxl->st->gl_draw_async == NULL);

Here you should signal the cookie (or return an error to be handled by the
caller or rendering will stuck

Frediano


> +}
> +
>  void red_dispatcher_async_complete(struct RedDispatcher *dispatcher,
>                                     AsyncCommand *async_command)
>  {
> diff --git a/server/reds.c b/server/reds.c
> index f0087a8..156e653 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -3233,6 +3233,7 @@ SPICE_GNUC_VISIBLE int
> spice_server_add_interface(SpiceServer *s,
>  
>          qxl = SPICE_CONTAINEROF(sin, QXLInstance, base);
>          qxl->st = spice_new0(QXLState, 1);
> +        qxl->st->scanout.drm_dma_buf_fd = -1;
>          qxl->st->qif = SPICE_CONTAINEROF(interface, QXLInterface, base);
>          red_dispatcher_init(qxl);
>  
> diff --git a/server/reds.h b/server/reds.h
> index e398607..c1ab878 100644
> --- a/server/reds.h
> +++ b/server/reds.h
> @@ -36,6 +36,8 @@ extern RedsState *reds;
>  struct QXLState {
>      QXLInterface          *qif;
>      struct RedDispatcher  *dispatcher;
> +    SpiceMsgDisplayGlScanoutUnix scanout;
> +    struct AsyncCommand *gl_draw_async;
>  };
>  
>  struct TunnelWorker;
> diff --git a/server/spice-qxl.h b/server/spice-qxl.h
> index e1f14e7..466b95c 100644
> --- a/server/spice-qxl.h
> +++ b/server/spice-qxl.h
> @@ -193,4 +193,15 @@ struct QXLInstance {
>      QXLState           *st;
>  };
>  
> +void spice_gl_scanout(QXLInstance *instance,
> +                      int fd,
> +                      uint32_t width, uint32_t height,
> +                      uint32_t stride, uint32_t format,
> +                      int y_0_top);
> +
> +void spice_gl_draw_async(QXLInstance *instance,
> +                         uint32_t x, uint32_t y,
> +                         uint32_t w, uint32_t h,
> +                         uint64_t cookie);
> +
>  #endif /* SPICE_QXL_H_ */
> diff --git a/server/spice-server.syms b/server/spice-server.syms
> index 4137546..db7d973 100644
> --- a/server/spice-server.syms
> +++ b/server/spice-server.syms
> @@ -167,3 +167,9 @@ SPICE_SERVER_0.12.7 {
>  global:
>      spice_server_set_keepalive_timeout;
>  } SPICE_SERVER_0.12.6;
> +
> +SPICE_SERVER_0.13.1 {
> +global:
> +    spice_gl_scanout;
> +    spice_gl_draw_async;
> +} SPICE_SERVER_0.12.7;
> --
> 2.5.0
> 
> 
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]