Am 02.04.2014 09:47, schrieb Thomas Hellstrom: > On 04/01/2014 05:04 PM, Rob Clark wrote: >> From: Rob Clark <robcl...@freedesktop.org> >> >> Otherwise it will trick the gallium driver into thinking that the render >> target has actually changed (due to different pipe_surface pointing to >> same underlying pipe_resource). This is really badness for tiling GPUs >> like adreno. > > Rob, if we want to cache gallium surfaces like this, we need to > condition it on the same context being used. > We can't reuse a surface created with one context for rendering with > another context. (I know the mesa state tracker needs to > fix this up as well). > > While this can be done easily within XA for non-shared xa_surfaces, I > wonder what happens in the case of > shared xa_surfaces? More specifically, is rendering allowed to be cached > in the gallium surface until explicitly flushed to the texture? (I'm > unsure about gallium surface semantics here). The surface itself is supposed to be "transparent", think of it as simply a means to get access (as a render target) to the resource, so surfaces themselves do not have any pixel content. So I guess they'd be synchronized (or rather the underlying resources are) if rendering is synchronized from two contexts. That's at least how I think it should work...
> /Thomas > >> Signed-off-by: Rob Clark <robcl...@freedesktop.org> >> --- >> src/gallium/state_trackers/xa/xa_context.c | 35 >> +++++++++++++++++++++++------- >> src/gallium/state_trackers/xa/xa_priv.h | 3 ++- >> src/gallium/state_trackers/xa/xa_tracker.c | 1 + >> 3 files changed, 30 insertions(+), 9 deletions(-) >> >> diff --git a/src/gallium/state_trackers/xa/xa_context.c >> b/src/gallium/state_trackers/xa/xa_context.c >> index 867999a..18f0b85 100644 >> --- a/src/gallium/state_trackers/xa/xa_context.c >> +++ b/src/gallium/state_trackers/xa/xa_context.c >> @@ -179,6 +179,25 @@ xa_surface_unmap(struct xa_surface *srf) >> } >> } >> >> +static int >> +xa_srf_create(struct xa_context *ctx, struct xa_surface *srf) >> +{ >> + struct pipe_screen *screen = ctx->pipe->screen; >> + struct pipe_surface srf_templ; >> + >> + if (!screen->is_format_supported(screen, srf->tex->format, >> + PIPE_TEXTURE_2D, 0, >> + PIPE_BIND_RENDER_TARGET)) >> + return -XA_ERR_INVAL; >> + >> + u_surface_default_template(&srf_templ, srf->tex); >> + srf->srf = ctx->pipe->create_surface(ctx->pipe, srf->tex, &srf_templ); >> + if (!srf->srf) >> + return -XA_ERR_NORES; >> + >> + return XA_ERR_NONE; >> +} >> + >> int >> xa_ctx_srf_create(struct xa_context *ctx, struct xa_surface *dst) >> { >> @@ -188,15 +207,15 @@ xa_ctx_srf_create(struct xa_context *ctx, struct >> xa_surface *dst) >> if (ctx->srf) >> return -XA_ERR_INVAL; >> >> - if (!screen->is_format_supported(screen, dst->tex->format, >> - PIPE_TEXTURE_2D, 0, >> - PIPE_BIND_RENDER_TARGET)) >> - return -XA_ERR_INVAL; >> + if (!dst->srf) { >> + int ret = xa_srf_create(ctx, dst); >> + if (ret != XA_ERR_NONE) >> + return ret; >> + } >> >> - u_surface_default_template(&srf_templ, dst->tex); >> - ctx->srf = ctx->pipe->create_surface(ctx->pipe, dst->tex, &srf_templ); >> - if (!ctx->srf) >> - return -XA_ERR_NORES; >> + assert(dst->srf); >> + >> + pipe_surface_reference(&ctx->srf, dst->srf); >> >> return XA_ERR_NONE; >> } >> diff --git a/src/gallium/state_trackers/xa/xa_priv.h >> b/src/gallium/state_trackers/xa/xa_priv.h >> index 7a43386..5ade6c1 100644 >> --- a/src/gallium/state_trackers/xa/xa_priv.h >> +++ b/src/gallium/state_trackers/xa/xa_priv.h >> @@ -46,7 +46,7 @@ >> #define XA_EXPORT >> #endif >> >> -#define XA_VB_SIZE (100 * 4 * 3 * 4) >> +#define XA_VB_SIZE (170 * 4 * 3 * 4) >> #define XA_LAST_SURFACE_TYPE (xa_type_yuv_component + 1) >> #define XA_MAX_SAMPLERS 3 >> >> @@ -65,6 +65,7 @@ struct xa_surface { >> struct pipe_resource template; >> struct xa_tracker *xa; >> struct pipe_resource *tex; >> + struct pipe_surface *srf; >> struct pipe_transfer *transfer; >> unsigned int flags; >> struct xa_format_descriptor fdesc; >> diff --git a/src/gallium/state_trackers/xa/xa_tracker.c >> b/src/gallium/state_trackers/xa/xa_tracker.c >> index 9add584..7fed20a 100644 >> --- a/src/gallium/state_trackers/xa/xa_tracker.c >> +++ b/src/gallium/state_trackers/xa/xa_tracker.c >> @@ -474,6 +474,7 @@ xa_surface_unref(struct xa_surface *srf) >> if (srf == NULL || --srf->refcount) { >> return; >> } >> + pipe_surface_reference(&srf->srf, NULL); >> pipe_resource_reference(&srf->tex, NULL); >> free(srf); >> } _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev