[Mesa-dev] [PATCH 2/3] gallium/ddebug: Support compute states.

Nicolai Hähnle nhaehnle at gmail.com
Thu Apr 21 18:02:41 UTC 2016


On 21.04.2016 10:42, Bas Nieuwenhuizen wrote:
> Note that compute states have a different struct than
> the other shader states, so we cannot reuse the macro.

Couldn't you still share bind and delete? This requires dealing with the 
possibility of not having TGSI, but that'll be useful for graphics 
shaders anyway, with drivers using NIR.

Nicolai

>
> Signed-off-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
> ---
>   src/gallium/drivers/ddebug/dd_context.c | 37 +++++++++++++++++++++++++++++++++
>   1 file changed, 37 insertions(+)
>
> diff --git a/src/gallium/drivers/ddebug/dd_context.c b/src/gallium/drivers/ddebug/dd_context.c
> index 72a950a..731f6a5 100644
> --- a/src/gallium/drivers/ddebug/dd_context.c
> +++ b/src/gallium/drivers/ddebug/dd_context.c
> @@ -295,6 +295,40 @@ DD_SHADER(GEOMETRY, gs)
>   DD_SHADER(TESS_CTRL, tcs)
>   DD_SHADER(TESS_EVAL, tes)
>
> +static void * \
> +dd_context_create_compute_state(struct pipe_context *_pipe,
> +                                 const struct pipe_compute_state *state)
> +{
> +   struct pipe_context *pipe = dd_context(_pipe)->pipe;
> +   struct dd_state *hstate = CALLOC_STRUCT(dd_state);
> +
> +   if (!hstate)
> +      return NULL;
> +   hstate->cso = pipe->create_compute_state(pipe, state);
> +   return hstate;
> +}
> +
> +static void
> +dd_context_bind_compute_state(struct pipe_context *_pipe, void *state)
> +{
> +   struct dd_context *dctx = dd_context(_pipe);
> +   struct pipe_context *pipe = dctx->pipe;
> +   struct dd_state *hstate = state;
> +
> +   dctx->shaders[PIPE_SHADER_COMPUTE] = hstate;
> +   pipe->bind_compute_state(pipe, hstate ? hstate->cso : NULL);
> +}
> +
> +static void
> +dd_context_delete_compute_state(struct pipe_context *_pipe, void *state)
> +{
> +   struct dd_context *dctx = dd_context(_pipe);
> +   struct pipe_context *pipe = dctx->pipe;
> +   struct dd_state *hstate = state;
> +
> +   pipe->delete_compute_state(pipe, hstate->cso);
> +   FREE(hstate);
> +}
>
>   /********************************************************************
>    * immediate states
> @@ -703,6 +737,9 @@ dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe)
>      CTX_INIT(create_tes_state);
>      CTX_INIT(bind_tes_state);
>      CTX_INIT(delete_tes_state);
> +   CTX_INIT(create_compute_state);
> +   CTX_INIT(bind_compute_state);
> +   CTX_INIT(delete_compute_state);
>      CTX_INIT(create_vertex_elements_state);
>      CTX_INIT(bind_vertex_elements_state);
>      CTX_INIT(delete_vertex_elements_state);
>


More information about the mesa-dev mailing list