Mesa (gallium-resources): nouveau: fix for gallium-resources

Luca Barbieri lb at kemper.freedesktop.org
Sat Apr 3 01:41:26 UTC 2010


Module: Mesa
Branch: gallium-resources
Commit: b94f3e7389cbd1b6465de3c04e8059ce73f1ea1f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b94f3e7389cbd1b6465de3c04e8059ce73f1ea1f

Author: Luca Barbieri <luca at luca-barbieri.com>
Date:   Sat Apr  3 01:48:33 2010 +0200

nouveau: fix for gallium-resources

---

 src/gallium/drivers/nouveau/nouveau_screen.c |   25 +++++++++----
 src/gallium/drivers/nouveau/nouveau_screen.h |    4 ++-
 src/gallium/drivers/nouveau/nouveau_winsys.h |   49 --------------------------
 src/gallium/drivers/nv50/nv50_buffer.c       |    3 +-
 src/gallium/drivers/nvfx/nvfx_buffer.c       |    3 +-
 src/gallium/drivers/nvfx/nvfx_miptree.c      |    7 +---
 src/gallium/drivers/nvfx/nvfx_resource.c     |   16 ++++----
 src/gallium/drivers/nvfx/nvfx_resource.h     |    2 +-
 8 files changed, 34 insertions(+), 75 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
index 746ddca..b11faa4 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -37,33 +37,42 @@ nouveau_screen_get_vendor(struct pipe_screen *pscreen)
 
 struct nouveau_bo *
 nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment,
-		      unsigned usage, unsigned size)
+		      unsigned usage, unsigned bind, unsigned size)
 {
 	struct nouveau_device *dev = nouveau_screen(pscreen)->device;
 	struct nouveau_bo *bo = NULL;
 	uint32_t flags = NOUVEAU_BO_MAP, tile_mode = 0, tile_flags = 0;
 	int ret;
 
-	if (usage & NOUVEAU_BUFFER_USAGE_TRANSFER)
+	/* TODO: this is somewhat wrong */
+	if (usage == PIPE_USAGE_STAGING)
 		flags |= NOUVEAU_BO_GART;
 	else
-	if (usage & NOUVEAU_BUFFER_USAGE_VERTEX) {
+	if (bind & PIPE_BIND_VERTEX_BUFFER) {
 		if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF))
 			flags |= NOUVEAU_BO_GART;
 	} else
-	if (usage & NOUVEAU_BUFFER_USAGE_INDEX) {
+	if (usage & PIPE_BIND_INDEX_BUFFER) {
 		if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF))
 			flags |= NOUVEAU_BO_GART;
 	}
 
-	if (usage & NOUVEAU_BUFFER_USAGE_PIXEL) {
-		if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE)
+	if (bind & (PIPE_BIND_RENDER_TARGET |
+			PIPE_BIND_DEPTH_STENCIL |
+			PIPE_BIND_BLIT_SOURCE |
+			PIPE_BIND_BLIT_DESTINATION |
+			PIPE_BIND_SCANOUT |
+			PIPE_BIND_DISPLAY_TARGET |
+			PIPE_BIND_SAMPLER_VIEW))
+	{
+		/* TODO: this may be incorrect or suboptimal */
+		if (!(bind & PIPE_BIND_SCANOUT))
 			flags |= NOUVEAU_BO_GART;
-		if (!(usage & NOUVEAU_BUFFER_USAGE_CPU_READ_WRITE))
+		if (usage != PIPE_USAGE_DYNAMIC)
 			flags |= NOUVEAU_BO_VRAM;
 
 		if (dev->chipset == 0x50 || dev->chipset >= 0x80) {
-			if (usage & NOUVEAU_BUFFER_USAGE_ZETA)
+			if (bind & PIPE_BIND_DEPTH_STENCIL)
 				tile_flags = 0x2800;
 			else
 				tile_flags = 0x7000;
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h
index 1ba4113..37caf51 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.h
+++ b/src/gallium/drivers/nouveau/nouveau_screen.h
@@ -1,6 +1,8 @@
 #ifndef __NOUVEAU_SCREEN_H__
 #define __NOUVEAU_SCREEN_H__
 
+#define PIPE_USAGE_STAGING         5
+
 struct nouveau_screen {
 	struct pipe_screen base;
 	struct nouveau_device *device;
@@ -21,7 +23,7 @@ nouveau_screen(struct pipe_screen *pscreen)
  */
 struct nouveau_bo *
 nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment,
-		      unsigned usage, unsigned size);
+		      unsigned usage, unsigned bind, unsigned size);
 struct nouveau_bo *
 nouveau_screen_bo_user(struct pipe_screen *pscreen, void *ptr, unsigned bytes);
 void *
diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h
index 423255c..b144bef 100644
--- a/src/gallium/drivers/nouveau/nouveau_winsys.h
+++ b/src/gallium/drivers/nouveau/nouveau_winsys.h
@@ -16,19 +16,6 @@
 #define NOUVEAU_CAP_HW_VTXBUF (0xbeef0000)
 #define NOUVEAU_CAP_HW_IDXBUF (0xbeef0001)
 
-/* These were poorly defined flags at the pipe interface previously.
- * They have been removed, but nouveau can continue to use its own
- * versions internally:
- */
-#define NOUVEAU_BUFFER_USAGE_PIXEL           0x1
-#define NOUVEAU_BUFFER_USAGE_VERTEX          0x2
-#define NOUVEAU_BUFFER_USAGE_CPU_READ_WRITE  0x4
-#define NOUVEAU_BUFFER_USAGE_GPU_WRITE       0x8
-#define NOUVEAU_BUFFER_USAGE_DISCARD         0x10
-#define NOUVEAU_BUFFER_USAGE_TEXTURE         0x20
-#define NOUVEAU_BUFFER_USAGE_ZETA            0x40
-#define NOUVEAU_BUFFER_USAGE_TRANSFER        0x80
-
 static inline uint32_t
 nouveau_screen_transfer_flags(unsigned pipe)
 {
@@ -49,42 +36,6 @@ nouveau_screen_transfer_flags(unsigned pipe)
 	return flags;
 }
 
-static INLINE unsigned 
-nouveau_screen_bind_flags( unsigned bind )
-{
-	unsigned buf_usage = 0;
-
-	if (bind & PIPE_BIND_VERTEX_BUFFER)
-		buf_usage |= NOUVEAU_BUFFER_USAGE_VERTEX;
-
-	if (bind & PIPE_BIND_INDEX_BUFFER)
-		buf_usage |= PIPE_BIND_INDEX_BUFFER;
-
-	if (bind & (PIPE_BIND_RENDER_TARGET |
-		    PIPE_BIND_DEPTH_STENCIL |
-		    PIPE_BIND_BLIT_SOURCE |
-		    PIPE_BIND_BLIT_DESTINATION |
-		    PIPE_BIND_SCANOUT |
-		    PIPE_BIND_DISPLAY_TARGET |
-		    PIPE_BIND_SAMPLER_VIEW))
-		buf_usage |= NOUVEAU_BUFFER_USAGE_PIXEL;
-
-	if (bind & (PIPE_BIND_TRANSFER_WRITE |
-		    PIPE_BIND_TRANSFER_READ))
-		buf_usage |= NOUVEAU_BUFFER_USAGE_CPU_READ_WRITE;
-
-	/* Not sure where these two came from:
-	 */
-	if (0)
-		buf_usage |= NOUVEAU_BUFFER_USAGE_TRANSFER;
-
-	if (0)
-		buf_usage |= NOUVEAU_BUFFER_USAGE_ZETA;
-
-	return buf_usage;
-}
-
-
 extern struct pipe_screen *
 nvfx_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
 
diff --git a/src/gallium/drivers/nv50/nv50_buffer.c b/src/gallium/drivers/nv50/nv50_buffer.c
index 550f05c..094e05e 100644
--- a/src/gallium/drivers/nv50/nv50_buffer.c
+++ b/src/gallium/drivers/nv50/nv50_buffer.c
@@ -100,7 +100,8 @@ nv50_buffer_create(struct pipe_screen *pscreen,
 
 	buffer->bo = nouveau_screen_bo_new(pscreen,
 					   16,
-					   nouveau_screen_bind_flags(buffer->base.bind),
+					   buffer->base._usage,
+					   buffer->base.bind,
 					   buffer->base.width0);
 
 	if (buffer->bo == NULL)
diff --git a/src/gallium/drivers/nvfx/nvfx_buffer.c b/src/gallium/drivers/nvfx/nvfx_buffer.c
index 36c3e8f..24e0a0c 100644
--- a/src/gallium/drivers/nvfx/nvfx_buffer.c
+++ b/src/gallium/drivers/nvfx/nvfx_buffer.c
@@ -103,7 +103,8 @@ nvfx_buffer_create(struct pipe_screen *pscreen,
 
 	buffer->bo = nouveau_screen_bo_new(pscreen,
 					   16,
-					   nouveau_screen_bind_flags(buffer->base.bind),
+					   buffer->base._usage,
+					   buffer->base.bind,
 					   buffer->base.width0);
 
 	if (buffer->bo == NULL)
diff --git a/src/gallium/drivers/nvfx/nvfx_miptree.c b/src/gallium/drivers/nvfx/nvfx_miptree.c
index 432fb29..a5965ca 100644
--- a/src/gallium/drivers/nvfx/nvfx_miptree.c
+++ b/src/gallium/drivers/nvfx/nvfx_miptree.c
@@ -124,8 +124,6 @@ struct pipe_resource *
 nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_resource *pt)
 {
 	struct nvfx_miptree *mt;
-	unsigned buf_usage = NOUVEAU_BUFFER_USAGE_PIXEL |
-	                     NOUVEAU_BUFFER_USAGE_TEXTURE;
 	static int no_swizzle = -1;
 	if(no_swizzle < 0)
 		no_swizzle = debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE);
@@ -179,9 +177,6 @@ nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_resource *pt)
 		}
 	}
 
-	if (pt->_usage == PIPE_USAGE_DYNAMIC)
-		buf_usage |= NOUVEAU_BUFFER_USAGE_CPU_READ_WRITE;
-
 	/* apparently we can't render to swizzled surfaces smaller than 64 bytes, so make them linear.
 	 * If the user did not ask for a render target, they can still render to it, but it will cost them an extra copy.
 	 * This also happens for small mipmaps of large textures. */
@@ -192,7 +187,7 @@ nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_resource *pt)
 	nvfx_miptree_layout(mt);
 
 	mt->base.bo = nouveau_screen_bo_new(pscreen, 256,
-					    buf_usage, mt->total_size);
+            pt->_usage, pt->bind, mt->total_size);
 	if (!mt->base.bo) {
 		FREE(mt);
 		return NULL;
diff --git a/src/gallium/drivers/nvfx/nvfx_resource.c b/src/gallium/drivers/nvfx/nvfx_resource.c
index 5bf1e5c..10cdeed 100644
--- a/src/gallium/drivers/nvfx/nvfx_resource.c
+++ b/src/gallium/drivers/nvfx/nvfx_resource.c
@@ -42,15 +42,15 @@ nvfx_resource_from_handle(struct pipe_screen * screen,
 }
 
 void
-nvfx_init_resource_functions(struct pipe_context *pcontext)
+nvfx_init_resource_functions(struct pipe_context *pipe)
 {
-	pcontext->get_transfer = u_get_transfer_vtbl;
-	pcontext->transfer_map = u_transfer_map_vtbl;
-	pcontext->transfer_flush_region = u_transfer_flush_region_vtbl;
-	pcontext->transfer_unmap = u_transfer_unmap_vtbl;
-	pcontext->transfer_destroy = u_transfer_destroy_vtbl;
-	pcontext->transfer_inline_write = u_transfer_inline_write_vtbl;
-	pcontext->is_resource_referenced = nvfx_resource_is_referenced;
+	pipe->get_transfer = u_get_transfer_vtbl;
+	pipe->transfer_map = u_transfer_map_vtbl;
+	pipe->transfer_flush_region = u_transfer_flush_region_vtbl;
+	pipe->transfer_unmap = u_transfer_unmap_vtbl;
+	pipe->transfer_destroy = u_transfer_destroy_vtbl;
+	pipe->transfer_inline_write = u_transfer_inline_write_vtbl;
+	pipe->is_resource_referenced = nvfx_resource_is_referenced;
 }
 
 void
diff --git a/src/gallium/drivers/nvfx/nvfx_resource.h b/src/gallium/drivers/nvfx/nvfx_resource.h
index 93133e8..a68c14c 100644
--- a/src/gallium/drivers/nvfx/nvfx_resource.h
+++ b/src/gallium/drivers/nvfx/nvfx_resource.h
@@ -50,7 +50,7 @@ nvfx_surface_buffer(struct pipe_surface *surf)
 
 
 void
-nvfx_init_resource_functions(struct pipe_context *pcontext);
+nvfx_init_resource_functions(struct pipe_context *pipe);
 
 void
 nvfx_screen_init_resource_functions(struct pipe_screen *pscreen);




More information about the mesa-commit mailing list