[Mesa-dev] [PATCH 08/20] mesa/st: add support for semaphore object create/import/delete v2

Marek Olšák maraeo at gmail.com
Mon Jan 29 17:56:46 UTC 2018


The new files are missing the license.

Marek

On Tue, Jan 23, 2018 at 7:04 PM, Andres Rodriguez <andresx7 at gmail.com> wrote:
> Add basic semaphore object operations.
>
> v2: s/semaphore/fence for pipe objects
>
> Signed-off-by: Andres Rodriguez <andresx7 at gmail.com>
> ---
>  src/mesa/Makefile.sources                       |  2 +
>  src/mesa/meson.build                            |  2 +
>  src/mesa/state_tracker/st_cb_semaphoreobjects.c | 55 +++++++++++++++++++++++++
>  src/mesa/state_tracker/st_cb_semaphoreobjects.h | 25 +++++++++++
>  src/mesa/state_tracker/st_context.c             |  2 +
>  5 files changed, 86 insertions(+)
>  create mode 100644 src/mesa/state_tracker/st_cb_semaphoreobjects.c
>  create mode 100644 src/mesa/state_tracker/st_cb_semaphoreobjects.h
>
> diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
> index 53fa486364..2e89da4133 100644
> --- a/src/mesa/Makefile.sources
> +++ b/src/mesa/Makefile.sources
> @@ -485,6 +485,8 @@ STATETRACKER_FILES = \
>         state_tracker/st_cb_rasterpos.h \
>         state_tracker/st_cb_readpixels.c \
>         state_tracker/st_cb_readpixels.h \
> +       state_tracker/st_cb_semaphoreobjects.c \
> +       state_tracker/st_cb_semaphoreobjects.h \
>         state_tracker/st_cb_strings.c \
>         state_tracker/st_cb_strings.h \
>         state_tracker/st_cb_syncobj.c \
> diff --git a/src/mesa/meson.build b/src/mesa/meson.build
> index 998953d641..d10747fdb1 100644
> --- a/src/mesa/meson.build
> +++ b/src/mesa/meson.build
> @@ -536,6 +536,8 @@ files_libmesa_gallium = files(
>    'state_tracker/st_cb_readpixels.h',
>    'state_tracker/st_cb_strings.c',
>    'state_tracker/st_cb_strings.h',
> +  'state_tracker/st_cb_semaphoreobjects.c',
> +  'state_tracker/st_cb_semaphoreobjects.h',
>    'state_tracker/st_cb_syncobj.c',
>    'state_tracker/st_cb_syncobj.h',
>    'state_tracker/st_cb_texturebarrier.c',
> diff --git a/src/mesa/state_tracker/st_cb_semaphoreobjects.c b/src/mesa/state_tracker/st_cb_semaphoreobjects.c
> new file mode 100644
> index 0000000000..25e3043c40
> --- /dev/null
> +++ b/src/mesa/state_tracker/st_cb_semaphoreobjects.c
> @@ -0,0 +1,55 @@
> +#include "main/imports.h"
> +#include "main/mtypes.h"
> +
> +#include "main/externalobjects.h"
> +
> +#include "st_context.h"
> +#include "st_cb_semaphoreobjects.h"
> +
> +#include "state_tracker/drm_driver.h"
> +#include "pipe/p_context.h"
> +#include "pipe/p_screen.h"
> +
> +static struct gl_semaphore_object *
> +st_semaphoreobj_alloc(struct gl_context *ctx, GLuint name)
> +{
> +   struct st_semaphore_object *st_obj = ST_CALLOC_STRUCT(st_semaphore_object);
> +   if (!st_obj)
> +      return NULL;
> +
> +   _mesa_initialize_semaphore_object(ctx, &st_obj->Base, name);
> +   return &st_obj->Base;
> +}
> +
> +static void
> +st_semaphoreobj_free(struct gl_context *ctx,
> +                     struct gl_semaphore_object *semObj)
> +{
> +   _mesa_delete_semaphore_object(ctx, semObj);
> +}
> +
> +
> +static void
> +st_import_semaphoreobj_fd(struct gl_context *ctx,
> +                       struct gl_semaphore_object *semObj,
> +                       int fd)
> +{
> +   struct st_semaphore_object *st_obj = st_semaphore_object(semObj);
> +   struct st_context *st = st_context(ctx);
> +   struct pipe_context *pipe = st->pipe;
> +
> +   pipe->create_fence_fd(pipe, &st_obj->fence, fd, PIPE_FD_TYPE_SYNCOBJ);
> +
> +#if !defined(_WIN32)
> +   /* We own fd, but we no longer need it. So get rid of it */
> +   close(fd);
> +#endif
> +}
> +
> +void
> +st_init_semaphoreobject_functions(struct dd_function_table *functions)
> +{
> +   functions->NewSemaphoreObject = st_semaphoreobj_alloc;
> +   functions->DeleteSemaphoreObject = st_semaphoreobj_free;
> +   functions->ImportSemaphoreFd = st_import_semaphoreobj_fd;
> +}
> diff --git a/src/mesa/state_tracker/st_cb_semaphoreobjects.h b/src/mesa/state_tracker/st_cb_semaphoreobjects.h
> new file mode 100644
> index 0000000000..5004c607bf
> --- /dev/null
> +++ b/src/mesa/state_tracker/st_cb_semaphoreobjects.h
> @@ -0,0 +1,25 @@
> +#ifndef ST_CB_SEMAPHOREOBJECTS_H
> +#define ST_CB_SEMAPHOREOBJECTS_H
> +
> +#include "main/compiler.h"
> +#include "main/mtypes.h"
> +
> +struct dd_function_table;
> +struct pipe_screen;
> +
> +struct st_semaphore_object
> +{
> +   struct gl_semaphore_object Base;
> +   struct pipe_fence_handle *fence;
> +};
> +
> +static inline struct st_semaphore_object *
> +st_semaphore_object(struct gl_semaphore_object *obj)
> +{
> +   return (struct st_semaphore_object *)obj;
> +}
> +
> +extern void
> +st_init_semaphoreobject_functions(struct dd_function_table *functions);
> +
> +#endif
> diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
> index 3ba4847926..f5a5b4fca7 100644
> --- a/src/mesa/state_tracker/st_context.c
> +++ b/src/mesa/state_tracker/st_context.c
> @@ -60,6 +60,7 @@
>  #include "st_cb_program.h"
>  #include "st_cb_queryobj.h"
>  #include "st_cb_readpixels.h"
> +#include "st_cb_semaphoreobjects.h"
>  #include "st_cb_texture.h"
>  #include "st_cb_xformfb.h"
>  #include "st_cb_flush.h"
> @@ -738,6 +739,7 @@ st_init_driver_functions(struct pipe_screen *screen,
>     st_init_query_functions(functions);
>     st_init_cond_render_functions(functions);
>     st_init_readpixels_functions(functions);
> +   st_init_semaphoreobject_functions(functions);
>     st_init_texture_functions(functions);
>     st_init_texture_barrier_functions(functions);
>     st_init_flush_functions(screen, functions);
> --
> 2.14.1
>


More information about the mesa-dev mailing list