[Mesa-dev] [PATCH] r600g/compute: Fix Warnings

Bruno Jiménez brunojimen at gmail.com
Thu Aug 7 03:07:04 PDT 2014


I have followed the following convention:
- Positions in the pool are now 'int' (start_in_dw and related)
- Sizes are 'unsigned' (size_in_dw and related)
- IDs are 'unsigned'

The pool and item's status are left as uint32_t
The shadow has been also left as a pointer to an uint32_t
---
 src/gallium/drivers/r600/compute_memory_pool.c | 56 +++++++++++++-------------
 src/gallium/drivers/r600/compute_memory_pool.h | 26 ++++++------
 2 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/src/gallium/drivers/r600/compute_memory_pool.c b/src/gallium/drivers/r600/compute_memory_pool.c
index 0ee8ceb..8bcab00 100644
--- a/src/gallium/drivers/r600/compute_memory_pool.c
+++ b/src/gallium/drivers/r600/compute_memory_pool.c
@@ -76,7 +76,7 @@ static void compute_memory_pool_init(struct compute_memory_pool * pool,
 	unsigned initial_size_in_dw)
 {
 
-	COMPUTE_DBG(pool->screen, "* compute_memory_pool_init() initial_size_in_dw = %ld\n",
+	COMPUTE_DBG(pool->screen, "* compute_memory_pool_init() initial_size_in_dw = %u\n",
 		initial_size_in_dw);
 
 	pool->size_in_dw = initial_size_in_dw;
@@ -104,9 +104,9 @@ void compute_memory_pool_delete(struct compute_memory_pool* pool)
  * \param size_in_dw	The size of the space we are looking for.
  * \return -1 on failure
  */
-int64_t compute_memory_prealloc_chunk(
+int compute_memory_prealloc_chunk(
 	struct compute_memory_pool* pool,
-	int64_t size_in_dw)
+	unsigned size_in_dw)
 {
 	struct compute_memory_item *item;
 
@@ -114,7 +114,7 @@ int64_t compute_memory_prealloc_chunk(
 
 	assert(size_in_dw <= pool->size_in_dw);
 
-	COMPUTE_DBG(pool->screen, "* compute_memory_prealloc_chunk() size_in_dw = %ld\n",
+	COMPUTE_DBG(pool->screen, "* compute_memory_prealloc_chunk() size_in_dw = %u\n",
 		size_in_dw);
 
 	LIST_FOR_EACH_ENTRY(item, pool->item_list, link) {
@@ -139,13 +139,13 @@ int64_t compute_memory_prealloc_chunk(
  */
 struct list_head *compute_memory_postalloc_chunk(
 	struct compute_memory_pool* pool,
-	int64_t start_in_dw)
+	int start_in_dw)
 {
 	struct compute_memory_item *item;
 	struct compute_memory_item *next;
 	struct list_head *next_link;
 
-	COMPUTE_DBG(pool->screen, "* compute_memory_postalloc_chunck() start_in_dw = %ld\n",
+	COMPUTE_DBG(pool->screen, "* compute_memory_postalloc_chunck() start_in_dw = %i\n",
 		start_in_dw);
 
 	/* Check if we can insert it in the front of the list */
@@ -181,12 +181,12 @@ struct list_head *compute_memory_postalloc_chunk(
  * \see compute_memory_finalize_pending
  */
 int compute_memory_grow_defrag_pool(struct compute_memory_pool *pool,
-	struct pipe_context *pipe, int new_size_in_dw)
+	struct pipe_context *pipe, unsigned new_size_in_dw)
 {
 	new_size_in_dw = align(new_size_in_dw, ITEM_ALIGNMENT);
 
 	COMPUTE_DBG(pool->screen, "* compute_memory_grow_defrag_pool() "
-		"new_size_in_dw = %d (%d bytes)\n",
+		"new_size_in_dw = %u (%u bytes)\n",
 		new_size_in_dw, new_size_in_dw * 4);
 
 	assert(new_size_in_dw >= pool->size_in_dw);
@@ -274,17 +274,17 @@ int compute_memory_finalize_pending(struct compute_memory_pool* pool,
 {
 	struct compute_memory_item *item, *next;
 
-	int64_t allocated = 0;
-	int64_t unallocated = 0;
-	int64_t last_pos;
+	unsigned allocated = 0;
+	unsigned unallocated = 0;
+	int last_pos;
 
 	int err = 0;
 
 	COMPUTE_DBG(pool->screen, "* compute_memory_finalize_pending()\n");
 
 	LIST_FOR_EACH_ENTRY(item, pool->item_list, link) {
-		COMPUTE_DBG(pool->screen, "  + list: offset = %i id = %i size = %i "
-			"(%i bytes)\n",item->start_in_dw, item->id,
+		COMPUTE_DBG(pool->screen, "  + list: offset = %i id = %u size = %u "
+			"(%u bytes)\n", item->start_in_dw, item->id,
 			item->size_in_dw, item->size_in_dw * 4);
 	}
 
@@ -347,7 +347,7 @@ void compute_memory_defrag(struct compute_memory_pool *pool,
 	struct pipe_context *pipe)
 {
 	struct compute_memory_item *item;
-	int64_t last_pos;
+	int last_pos;
 
 	COMPUTE_DBG(pool->screen, "* compute_memory_defrag()\n");
 
@@ -374,7 +374,7 @@ void compute_memory_defrag(struct compute_memory_pool *pool,
  */
 int compute_memory_promote_item(struct compute_memory_pool *pool,
 		struct compute_memory_item *item, struct pipe_context *pipe,
-		int64_t start_in_dw)
+		int start_in_dw)
 {
 	struct pipe_screen *screen = (struct pipe_screen *)pool->screen;
 	struct r600_context *rctx = (struct r600_context *)pipe;
@@ -383,8 +383,8 @@ int compute_memory_promote_item(struct compute_memory_pool *pool,
 	struct pipe_box box;
 
 	COMPUTE_DBG(pool->screen, "* compute_memory_promote_item()\n"
-			"  + Promoting Item: %i , starting at: %u (%u bytes) "
-			"size: %u (%u bytes)\n\t\t\tnew start: %u (%u bytes)\n",
+			"  + Promoting Item: %u , starting at: %i (%i bytes) "
+			"size: %u (%u bytes)\n\t\t\tnew start: %i (%i bytes)\n",
 			item->id, item->start_in_dw, item->start_in_dw * 4,
 			item->size_in_dw, item->size_in_dw * 4,
 			start_in_dw, start_in_dw * 4);
@@ -430,7 +430,7 @@ void compute_memory_demote_item(struct compute_memory_pool *pool,
 	struct pipe_box box;
 
 	COMPUTE_DBG(pool->screen, "* compute_memory_demote_item()\n"
-			"  + Demoting Item: %i, starting at: %u (%u bytes) "
+			"  + Demoting Item: %u, starting at: %i (%i bytes) "
 			"size: %u (%u bytes)\n", item->id, item->start_in_dw,
 			item->start_in_dw * 4, item->size_in_dw, item->size_in_dw * 4);
 
@@ -479,7 +479,7 @@ void compute_memory_demote_item(struct compute_memory_pool *pool,
  */
 void compute_memory_move_item(struct compute_memory_pool *pool,
 	struct pipe_resource *src, struct pipe_resource *dst,
-	struct compute_memory_item *item, uint64_t new_start_in_dw,
+	struct compute_memory_item *item, int new_start_in_dw,
 	struct pipe_context *pipe)
 {
 	struct pipe_screen *screen = (struct pipe_screen *)pool->screen;
@@ -489,7 +489,7 @@ void compute_memory_move_item(struct compute_memory_pool *pool,
 	struct compute_memory_item *prev;
 
 	COMPUTE_DBG(pool->screen, "* compute_memory_move_item()\n"
-			"  + Moving item %i from %u (%u bytes) to %u (%u bytes)\n",
+			"  + Moving item %u from %i (%i bytes) to %i (%i bytes)\n",
 			item->id, item->start_in_dw, item->start_in_dw * 4,
 			new_start_in_dw, new_start_in_dw * 4);
 
@@ -530,7 +530,7 @@ void compute_memory_move_item(struct compute_memory_pool *pool,
 			/* The allocation of the temporary resource failed,
 			 * falling back to use mappings */
 			uint32_t *map;
-			int64_t offset;
+			int offset;
 			struct pipe_transfer *trans;
 
 			offset = item->start_in_dw - new_start_in_dw;
@@ -556,13 +556,13 @@ void compute_memory_move_item(struct compute_memory_pool *pool,
  * Frees the memory asociated to the item with id \a id from the pool.
  * \param id	The id of the item to be freed.
  */
-void compute_memory_free(struct compute_memory_pool* pool, int64_t id)
+void compute_memory_free(struct compute_memory_pool* pool, unsigned id)
 {
 	struct compute_memory_item *item, *next;
 	struct pipe_screen *screen = (struct pipe_screen *)pool->screen;
 	struct pipe_resource *res;
 
-	COMPUTE_DBG(pool->screen, "* compute_memory_free() id + %ld \n", id);
+	COMPUTE_DBG(pool->screen, "* compute_memory_free() id + %u \n", id);
 
 	LIST_FOR_EACH_ENTRY_SAFE(item, next, pool->item_list, link) {
 
@@ -603,7 +603,7 @@ void compute_memory_free(struct compute_memory_pool* pool, int64_t id)
 		}
 	}
 
-	fprintf(stderr, "Internal error, invalid id %"PRIi64" "
+	fprintf(stderr, "Internal error, invalid id %u "
 		"for compute_memory_free\n", id);
 
 	assert(0 && "error");
@@ -618,11 +618,11 @@ void compute_memory_free(struct compute_memory_pool* pool, int64_t id)
  */
 struct compute_memory_item* compute_memory_alloc(
 	struct compute_memory_pool* pool,
-	int64_t size_in_dw)
+	unsigned size_in_dw)
 {
 	struct compute_memory_item *new_item = NULL;
 
-	COMPUTE_DBG(pool->screen, "* compute_memory_alloc() size_in_dw = %ld (%ld bytes)\n",
+	COMPUTE_DBG(pool->screen, "* compute_memory_alloc() size_in_dw = %u (%u bytes)\n",
 			size_in_dw, 4 * size_in_dw);
 
 	new_item = (struct compute_memory_item *)
@@ -658,9 +658,9 @@ void compute_memory_transfer(
 	int offset_in_chunk,
 	int size)
 {
-	int64_t aligned_size = pool->size_in_dw;
+	unsigned aligned_size = pool->size_in_dw;
 	struct pipe_resource* gart = (struct pipe_resource*)pool->bo;
-	int64_t internal_offset = chunk->start_in_dw*4 + offset_in_chunk;
+	int internal_offset = chunk->start_in_dw*4 + offset_in_chunk;
 
 	struct pipe_transfer *xfer;
 	uint32_t *map;
diff --git a/src/gallium/drivers/r600/compute_memory_pool.h b/src/gallium/drivers/r600/compute_memory_pool.h
index 161ddd5..31b41f8 100644
--- a/src/gallium/drivers/r600/compute_memory_pool.h
+++ b/src/gallium/drivers/r600/compute_memory_pool.h
@@ -38,14 +38,14 @@ struct compute_memory_pool;
 
 struct compute_memory_item
 {
-	int64_t id;		/**< ID of the memory chunk */
+	unsigned id;		/**< ID of the memory chunk */
 
 	uint32_t status;	/**< Will track the status of the item */
 
 	/** Start pointer in dwords relative in the pool bo. If an item
 	 * is unallocated, then this value must be -1 to indicate this. */
-	int64_t start_in_dw;
-	int64_t size_in_dw;	/**< Size of the chunk in dwords */
+	int start_in_dw;
+	unsigned size_in_dw;	/**< Size of the chunk in dwords */
 
 	/** Intermediate buffer asociated with an item. It is used mainly for mapping
 	 * items against it. They are listed in the pool's unallocated list */
@@ -58,8 +58,8 @@ struct compute_memory_item
 
 struct compute_memory_pool
 {
-	int64_t next_id;	/**< For generating unique IDs for memory chunks */
-	int64_t size_in_dw;	/**< Size of the pool in dwords */
+	unsigned next_id;	/**< For generating unique IDs for memory chunks */
+	unsigned size_in_dw;	/**< Size of the pool in dwords */
 
 	struct r600_resource *bo;	/**< The pool buffer object resource */
 	struct r600_screen *screen;
@@ -86,14 +86,14 @@ struct compute_memory_pool* compute_memory_pool_new(struct r600_screen *rscreen)
 
 void compute_memory_pool_delete(struct compute_memory_pool* pool);
 
-int64_t compute_memory_prealloc_chunk(struct compute_memory_pool* pool,
-	int64_t size_in_dw);
+int compute_memory_prealloc_chunk(struct compute_memory_pool* pool,
+	unsigned size_in_dw);
 
 struct list_head *compute_memory_postalloc_chunk(struct compute_memory_pool* pool,
-	int64_t start_in_dw);
+	int start_in_dw);
 
 int compute_memory_grow_defrag_pool(struct compute_memory_pool* pool,
-	struct pipe_context *pipe, int new_size_in_dw);
+	struct pipe_context *pipe, unsigned new_size_in_dw);
 
 void compute_memory_shadow(struct compute_memory_pool* pool,
 	struct pipe_context *pipe, int device_to_host);
@@ -107,20 +107,20 @@ void compute_memory_defrag(struct compute_memory_pool *pool,
 
 int compute_memory_promote_item(struct compute_memory_pool *pool,
 	struct compute_memory_item *item, struct pipe_context *pipe,
-	int64_t allocated);
+	int start_in_dw);
 
 void compute_memory_demote_item(struct compute_memory_pool *pool,
 	struct compute_memory_item *item, struct pipe_context *pipe);
 
 void compute_memory_move_item(struct compute_memory_pool *pool,
 	struct pipe_resource *src, struct pipe_resource *dst,
-	struct compute_memory_item *item, uint64_t new_start_in_dw,
+	struct compute_memory_item *item, int new_start_in_dw,
 	struct pipe_context *pipe);
 
-void compute_memory_free(struct compute_memory_pool* pool, int64_t id);
+void compute_memory_free(struct compute_memory_pool* pool, unsigned id);
 
 struct compute_memory_item* compute_memory_alloc(struct compute_memory_pool* pool,
-	int64_t size_in_dw);
+	unsigned size_in_dw);
 
 void compute_memory_transfer(struct compute_memory_pool* pool,
 	struct pipe_context * pipe, int device_to_host,
-- 
2.0.3



More information about the mesa-dev mailing list