st/xa: Cache render target surface
authorThomas Hellstrom <thellstrom@vmware.com>
Tue, 8 Apr 2014 20:48:51 +0000 (16:48 -0400)
committerThomas Hellstrom <thellstrom@vmware.com>
Thu, 17 Apr 2014 07:56:28 +0000 (09:56 +0200)
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.

This also appears to fix a rendering error with Motif on vmwgfx.
Why that is is still under investigation.

Based on an idea by Rob Clark.

Cc: "10.0 10.1" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Rob Clark <robclark@freedesktop.org>
src/gallium/state_trackers/xa/xa_context.c

index 867999a..37de45b 100644 (file)
@@ -78,6 +78,8 @@ xa_context_destroy(struct xa_context *r)
     }
 
     xa_ctx_sampler_views_destroy(r);
+    if (r->srf)
+        pipe_surface_reference(&r->srf, NULL);
 
     if (r->cso) {
        cso_release_all(r->cso);
@@ -185,8 +187,15 @@ xa_ctx_srf_create(struct xa_context *ctx, struct xa_surface *dst)
     struct pipe_screen *screen = ctx->pipe->screen;
     struct pipe_surface srf_templ;
 
-    if (ctx->srf)
-       return -XA_ERR_INVAL;
+    /*
+     * Cache surfaces unless we change render target
+     */
+    if (ctx->srf) {
+        if (ctx->srf->texture == dst->tex)
+            return XA_ERR_NONE;
+
+        pipe_surface_reference(&ctx->srf, NULL);
+    }
 
     if (!screen->is_format_supported(screen,  dst->tex->format,
                                     PIPE_TEXTURE_2D, 0,
@@ -204,7 +213,10 @@ xa_ctx_srf_create(struct xa_context *ctx, struct xa_surface *dst)
 void
 xa_ctx_srf_destroy(struct xa_context *ctx)
 {
-    pipe_surface_reference(&ctx->srf, NULL);
+    /*
+     * Cache surfaces unless we change render target.
+     * Final destruction on context destroy.
+     */
 }
 
 XA_EXPORT int