nvfx: add nouveau_resource_on_gpu
authorLuca Barbieri <luca@luca-barbieri.com>
Fri, 6 Aug 2010 23:56:01 +0000 (01:56 +0200)
committerLuca Barbieri <luca@luca-barbieri.com>
Sat, 21 Aug 2010 18:42:14 +0000 (20:42 +0200)
Add a function to get whether a resource is likely on the GPU or not.

Currently always returns TRUE.

src/gallium/drivers/nvfx/nvfx_resource.h

index d28bfab9615063b375684a6b71e5bd0159822319..bdbf3dd3d891276cfac0d6e5566be5918090de6a 100644 (file)
@@ -3,9 +3,11 @@
 #define NVFX_RESOURCE_H
 
 #include "util/u_transfer.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include <nouveau/nouveau_bo.h>
 
 struct pipe_resource;
-struct nouveau_bo;
 
 
 /* This gets further specialized into either buffer or texture
@@ -22,6 +24,18 @@ struct nvfx_resource {
 
 #define NVFX_RESOURCE_FLAG_LINEAR (PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
 
+static inline int
+nvfx_resource_on_gpu(struct pipe_resource* pr)
+{
+#if 0
+       // a compiler error here means you need to apply libdrm-nouveau-add-domain.patch to libdrm
+       // TODO: return FALSE if not VRAM and on a PCI-E system
+       return ((struct nvfx_resource*)pr)->bo->domain & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART);
+#else
+       return TRUE;
+#endif
+}
+
 #define NVFX_MAX_TEXTURE_LEVELS  16
 
 struct nvfx_miptree {