summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorJerome Glisse <[email protected]>2013-03-07 17:03:04 -0500
committerRob Clark <[email protected]>2013-07-25 13:59:55 -0400
commit8b21a3825b132f0769cc3e2698c55d6f6af65e84 (patch)
tree9babd2a93cae53b9848981a17a95e7ae1828256c /src/gallium/state_trackers
parentd156c032c97d2c7a6ef2ec87212a4ef74dd9cb6e (diff)
xa: move surface to ref/unref api
This make ddx life easier. Signed-off-by: Jerome Glisse <[email protected]> Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/xa/xa_priv.h1
-rw-r--r--src/gallium/state_trackers/xa/xa_tracker.c16
-rw-r--r--src/gallium/state_trackers/xa/xa_tracker.h3
3 files changed, 18 insertions, 2 deletions
diff --git a/src/gallium/state_trackers/xa/xa_priv.h b/src/gallium/state_trackers/xa/xa_priv.h
index 2ab11b82b26..ee182e79222 100644
--- a/src/gallium/state_trackers/xa/xa_priv.h
+++ b/src/gallium/state_trackers/xa/xa_priv.h
@@ -59,6 +59,7 @@ struct xa_format_descriptor {
};
struct xa_surface {
+ int refcount;
struct pipe_resource template;
struct xa_tracker *xa;
struct pipe_resource *tex;
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index 945ed36a292..cda6501fcd4 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -328,6 +328,7 @@ surface_create(struct xa_tracker *xa,
if (!srf->tex)
goto out_no_tex;
+ srf->refcount = 1;
srf->xa = xa;
srf->flags = flags;
srf->fdesc = fdesc;
@@ -451,9 +452,22 @@ xa_surface_redefine(struct xa_surface *srf,
return XA_ERR_NONE;
}
+XA_EXPORT struct xa_surface*
+xa_surface_ref(struct xa_surface *srf)
+{
+ if (srf == NULL) {
+ return NULL;
+ }
+ srf->refcount++;
+ return srf;
+}
+
XA_EXPORT void
-xa_surface_destroy(struct xa_surface *srf)
+xa_surface_unref(struct xa_surface *srf)
{
+ if (srf == NULL || --srf->refcount) {
+ return;
+ }
pipe_resource_reference(&srf->tex, NULL);
free(srf);
}
diff --git a/src/gallium/state_trackers/xa/xa_tracker.h b/src/gallium/state_trackers/xa/xa_tracker.h
index 4d2452e9286..65a67bb58d7 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.h
+++ b/src/gallium/state_trackers/xa/xa_tracker.h
@@ -176,7 +176,8 @@ extern struct xa_surface * xa_surface_from_handle(struct xa_tracker *xa,
enum xa_formats xa_surface_format(const struct xa_surface *srf);
-extern void xa_surface_destroy(struct xa_surface *srf);
+extern struct xa_surface *xa_surface_ref(struct xa_surface *srf);
+extern void xa_surface_unref(struct xa_surface *srf);
extern int xa_surface_redefine(struct xa_surface *srf,
int width,