summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/drm/nouveau
diff options
context:
space:
mode:
authorYounes Manton <younes.m@gmail.com>2008-12-11 17:55:16 -0500
committerYounes Manton <younes.m@gmail.com>2009-01-10 13:52:05 -0500
commitaf2a856caa84755d3b1a0a887d000ce7dc3221dd (patch)
treec2db8ba4af306ca92b6c7cb25a6a61b841f60972 /src/gallium/winsys/drm/nouveau
parent7289c388f442fe532de52058f9167bc331920b1a (diff)
nouveau: Add busy() query, determines if BOs can be mapped immediately.
Diffstat (limited to 'src/gallium/winsys/drm/nouveau')
-rw-r--r--src/gallium/winsys/drm/nouveau/nouveau_bo.c34
-rw-r--r--src/gallium/winsys/drm/nouveau/nouveau_drmif.h3
2 files changed, 37 insertions, 0 deletions
diff --git a/src/gallium/winsys/drm/nouveau/nouveau_bo.c b/src/gallium/winsys/drm/nouveau/nouveau_bo.c
index b5942994d9..76b98bed67 100644
--- a/src/gallium/winsys/drm/nouveau/nouveau_bo.c
+++ b/src/gallium/winsys/drm/nouveau/nouveau_bo.c
@@ -273,6 +273,40 @@ nouveau_bo_del(struct nouveau_bo **bo)
}
int
+nouveau_bo_busy(struct nouveau_bo *bo, uint32_t flags)
+{
+ struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
+ struct nouveau_fence *fence;
+
+ if (!nvbo)
+ return -EINVAL;
+
+ /* If the buffer is pending it must be busy, unless
+ * both are RD, in which case we can allow access */
+ if (nvbo->pending) {
+ if ((nvbo->pending->flags & NOUVEAU_BO_RDWR) == NOUVEAU_BO_RD &&
+ (flags & NOUVEAU_BO_RDWR) == NOUVEAU_BO_RD)
+ return 0;
+ else
+ return 1;
+ }
+
+ if (flags & NOUVEAU_BO_WR)
+ fence = nvbo->fence;
+ else
+ fence = nvbo->wr_fence;
+
+ /* If the buffer is not pending and doesn't have a fence
+ * that conflicts with our flags then it can't be busy
+ */
+ if (!fence)
+ return 0;
+ else
+ /* If the fence is signalled the buffer is not busy, else is busy */
+ return !nouveau_fence(fence)->signalled;
+}
+
+int
nouveau_bo_map(struct nouveau_bo *bo, uint32_t flags)
{
struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
diff --git a/src/gallium/winsys/drm/nouveau/nouveau_drmif.h b/src/gallium/winsys/drm/nouveau/nouveau_drmif.h
index dcd6a5eb0a..5f72800676 100644
--- a/src/gallium/winsys/drm/nouveau/nouveau_drmif.h
+++ b/src/gallium/winsys/drm/nouveau/nouveau_drmif.h
@@ -287,6 +287,9 @@ extern void
nouveau_bo_del(struct nouveau_bo **);
extern int
+nouveau_bo_busy(struct nouveau_bo *bo, uint32_t flags);
+
+extern int
nouveau_bo_map(struct nouveau_bo *, uint32_t flags);
extern void