GCC complains about mixed code and declarations and unhandled enum cases when compiling r600. This patch correct it :<br><br>From 25b5d12eec732ed582a8a3e146c0285819806ba8 Mon Sep 17 00:00:00 2001<br>From: Maxence Le Dore <<a href="mailto:maxence.ledore@gmail.com">maxence.ledore@gmail.com</a>><br>
Date: Thu, 13 Dec 2012 05:17:35 +0100<br>Subject: [PATCH] r600: silent warnings<br><br>---<br> src/gallium/drivers/r600/compute_memory_pool.c     |   12 +++----<br> src/gallium/drivers/r600/evergreen_compute.c       |   27 ++++++++++------<br>
 .../drivers/r600/evergreen_compute_internal.c      |   33 +++++++++++++-------<br> src/gallium/drivers/r600/r600_shader.c             |    5 +--<br> src/gallium/drivers/radeonsi/radeonsi_pipe.c       |    2 ++<br> 5 files changed, 49 insertions(+), 30 deletions(-)<br>
<br>diff --git a/src/gallium/drivers/r600/compute_memory_pool.c b/src/gallium/drivers/r600/compute_memory_pool.c<br>index 46bff32..5b1cb1b 100644<br>--- a/src/gallium/drivers/r600/compute_memory_pool.c<br>+++ b/src/gallium/drivers/r600/compute_memory_pool.c<br>
@@ -93,12 +93,12 @@ int64_t compute_memory_prealloc_chunk(<br>     struct compute_memory_pool* pool,<br>     int64_t size_in_dw)<br> {<br>-    assert(size_in_dw <= pool->size_in_dw);<br>-<br>     struct compute_memory_item *item;<br>
 <br>     int last_end = 0;<br> <br>+    assert(size_in_dw <= pool->size_in_dw);<br>+<br>     COMPUTE_DBG("* compute_memory_prealloc_chunk() size_in_dw = %ld\n",<br>         size_in_dw);<br> <br>@@ -217,6 +217,8 @@ void compute_memory_finalize_pending(struct compute_memory_pool* pool,<br>
     int64_t allocated = 0;<br>     int64_t unallocated = 0;<br> <br>+    int64_t start_in_dw = 0;<br>+<br>     COMPUTE_DBG("* compute_memory_finalize_pending()\n");<br> <br>     for (item = pool->item_list; item; item = item->next) {<br>
@@ -292,8 +294,6 @@ void compute_memory_finalize_pending(struct compute_memory_pool* pool,<br>     for (item = pending_list; item; item = next) {<br>         next = item->next;<br> <br>-        int64_t start_in_dw;<br>
-<br>         /* Search for free space in the pool for this item. */<br>         while ((start_in_dw=compute_memory_prealloc_chunk(pool,<br>                         item->size_in_dw)) == -1) {<br>@@ -397,7 +397,7 @@ struct compute_memory_item* compute_memory_alloc(<br>
     struct compute_memory_pool* pool,<br>     int64_t size_in_dw)<br> {<br>-    struct compute_memory_item *new_item;<br>+    struct compute_memory_item *new_item = NULL, *last_item = NULL;<br> <br>     COMPUTE_DBG("* compute_memory_alloc() size_in_dw = %ld (%ld bytes)\n",<br>
             size_in_dw, 4 * size_in_dw);<br>@@ -409,8 +409,6 @@ struct compute_memory_item* compute_memory_alloc(<br>     new_item->id = pool->next_id++;<br>     new_item->pool = pool;<br> <br>-    struct compute_memory_item *last_item;<br>
-<br>     if (pool->item_list) {<br>         for (last_item = pool->item_list; last_item->next;<br>                         last_item = last_item->next);<br>diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c<br>
index 44831a7..66b0cc6 100644<br>--- a/src/gallium/drivers/r600/evergreen_compute.c<br>+++ b/src/gallium/drivers/r600/evergreen_compute.c<br>@@ -804,15 +804,19 @@ struct pipe_resource *r600_compute_global_buffer_create(<br>
     struct pipe_screen *screen,<br>     const struct pipe_resource *templ)<br> {<br>+    struct r600_resource_global* result = NULL;<br>+    struct r600_screen* rscreen = NULL;<br>+    int size_in_dw = 0;<br>+<br>     assert(templ->target == PIPE_BUFFER);<br>
     assert(templ->bind & PIPE_BIND_GLOBAL);<br>     assert(templ->array_size == 1 || templ->array_size == 0);<br>     assert(templ->depth0 == 1 || templ->depth0 == 0);<br>     assert(templ->height0 == 1 || templ->height0 == 0);<br>
 <br>-    struct r600_resource_global* result = (struct r600_resource_global*)<br>-        CALLOC(sizeof(struct r600_resource_global), 1);<br>-    struct r600_screen* rscreen = (struct r600_screen*)screen;<br>+    result = (struct r600_resource_global*)<br>
+    CALLOC(sizeof(struct r600_resource_global), 1);<br>+    rscreen = (struct r600_screen*)screen;<br> <br>     COMPUTE_DBG("*** r600_compute_global_buffer_create\n");<br>     COMPUTE_DBG("width = %u array_size = %u\n", templ->width0,<br>
@@ -823,7 +827,7 @@ struct pipe_resource *r600_compute_global_buffer_create(<br>     result->base.b.b = *templ;<br>     pipe_reference_init(&result->base.b.b.reference, 1);<br> <br>-    int size_in_dw = (templ->width0+3) / 4;<br>
+    size_in_dw = (templ->width0+3) / 4;<br> <br>     result->chunk = compute_memory_alloc(rscreen->global_pool, size_in_dw);<br> <br>@@ -840,11 +844,14 @@ void r600_compute_global_buffer_destroy(<br>     struct pipe_screen *screen,<br>
     struct pipe_resource *res)<br> {<br>+    struct r600_resource_global* buffer = NULL;<br>+    struct r600_screen* rscreen = NULL;<br>+<br>     assert(res->target == PIPE_BUFFER);<br>     assert(res->bind & PIPE_BIND_GLOBAL);<br>
 <br>-    struct r600_resource_global* buffer = (struct r600_resource_global*)res;<br>-    struct r600_screen* rscreen = (struct r600_screen*)screen;<br>+    buffer = (struct r600_resource_global*)res;<br>+    rscreen = (struct r600_screen*)screen;<br>
 <br>     compute_memory_free(rscreen->global_pool, buffer->chunk->id);<br> <br>@@ -911,12 +918,14 @@ void r600_compute_global_transfer_unmap(<br>     struct pipe_context *ctx_,<br>     struct pipe_transfer* transfer)<br>
 {<br>+    struct r600_context *ctx = NULL;<br>+    struct r600_resource_global* buffer = NULL;<br>+<br>     assert(transfer->resource->target == PIPE_BUFFER);<br>     assert(transfer->resource->bind & PIPE_BIND_GLOBAL);<br>
 <br>-    struct r600_context *ctx = (struct r600_context *)ctx_;<br>-    struct r600_resource_global* buffer =<br>-        (struct r600_resource_global*)transfer->resource;<br>+    ctx = (struct r600_context *)ctx_;<br>
+    buffer = (struct r600_resource_global*)transfer->resource;<br> <br>     COMPUTE_DBG("* r600_compute_global_transfer_unmap()\n");<br> <br>diff --git a/src/gallium/drivers/r600/evergreen_compute_internal.c b/src/gallium/drivers/r600/evergreen_compute_internal.c<br>
index cbf6622..bfe9bf0 100644<br>--- a/src/gallium/drivers/r600/evergreen_compute_internal.c<br>+++ b/src/gallium/drivers/r600/evergreen_compute_internal.c<br>@@ -97,6 +97,8 @@ struct evergreen_compute_resource* get_empty_res(<br>
 {<br>     int code_index = -1;<br>     int code_size = -1;<br>+    int index = 0;<br>+    struct evergreen_compute_resource* res = NULL;<br> <br>     {<br>         int i = 0;<br>@@ -108,9 +110,9 @@ struct evergreen_compute_resource* get_empty_res(<br>
     assert(code_index != -1 && "internal error: resouce index not found");<br>     assert(offset_index < code_size && "internal error: overindexing resource");<br> <br>-    int index = code_index + offset_index;<br>
+    index = code_index + offset_index;<br> <br>-    struct evergreen_compute_resource* res = &pipe->resources[index];<br>+    res = &pipe->resources[index];<br> <br>     res->enabled = true;<br>     res->bo = NULL;<br>
@@ -125,8 +127,10 @@ void evergreen_emit_raw_reg_set(<br>     unsigned index,<br>     int num)<br> {<br>+    int cs_end = 0;<br>+<br>     res->enabled = 1;<br>-    int cs_end = res->cs_end;<br>+    cs_end = res->cs_end;<br>
 <br>     if (index >= EVERGREEN_CONFIG_REG_OFFSET<br>             && index < EVERGREEN_CONFIG_REG_END) {<br>@@ -213,10 +217,12 @@ void evergreen_emit_ctx_reloc(<br>     struct r600_resource *bo,<br>     enum radeon_bo_usage usage)<br>
 {<br>+    u32 rr = 0;<br>+<br>     assert(bo);<br> <br>     ctx->cs->buf[ctx->cs->cdw++] = PKT3(PKT3_NOP, 0, 0);<br>-    u32 rr = r600_context_bo_reloc(ctx, bo, usage);<br>+    rr = r600_context_bo_reloc(ctx, bo, usage);<br>
     ctx->cs->buf[ctx->cs->cdw++] = rr;<br> }<br> <br>@@ -260,13 +266,15 @@ void evergreen_set_rat(<br>     int start,<br>     int size)<br> {<br>+    struct pipe_surface rat_templ;<br>+    struct r600_surface *surf = NULL;<br>
+    struct r600_context *rctx = NULL;  <br>+<br>     assert(id < 12);<br>     assert((size & 3) == 0);<br>     assert((start & 0xFF) == 0);<br> <br>-    struct pipe_surface rat_templ;<br>-    struct r600_surface *surf;<br>
-    struct r600_context *rctx = pipe->ctx;<br>+    rctx = pipe->ctx;<br> <br>     COMPUTE_DBG("bind rat: %i \n", id);<br> <br>@@ -603,13 +611,14 @@ struct r600_resource* r600_compute_buffer_alloc_vram(<br>
     struct r600_screen *screen,<br>     unsigned size)<br> {<br>+    struct pipe_resource * buffer = NULL;<br>     assert(size);<br> <br>-    struct pipe_resource * buffer = pipe_buffer_create(<br>-            (struct pipe_screen*) screen,<br>
-            PIPE_BIND_CUSTOM,<br>-            PIPE_USAGE_IMMUTABLE,<br>-            size);<br>+    buffer = pipe_buffer_create(<br>+        (struct pipe_screen*) screen,<br>+        PIPE_BIND_CUSTOM,<br>+        PIPE_USAGE_IMMUTABLE,<br>
+        size);<br> <br>     return (struct r600_resource *)buffer;<br> }<br>diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c<br>index 72cb585..164a439 100644<br>--- a/src/gallium/drivers/r600/r600_shader.c<br>
+++ b/src/gallium/drivers/r600/r600_shader.c<br>@@ -510,10 +510,11 @@ static int r600_vtx_from_byte_stream(struct r600_shader_ctx *ctx,<br> static int r600_export_from_byte_stream(struct r600_shader_ctx *ctx,<br>     unsigned char * bytes, unsigned bytes_read)<br>
 {<br>+    uint32_t word0 = 0, word1 = 0;<br>     struct r600_bytecode_output output;<br>     memset(&output, 0, sizeof(struct r600_bytecode_output));<br>-    uint32_t word0 = i32_from_byte_stream(bytes, &bytes_read);<br>
-    uint32_t word1 = i32_from_byte_stream(bytes, &bytes_read);<br>+    word0 = i32_from_byte_stream(bytes, &bytes_read);<br>+    word1 = i32_from_byte_stream(bytes, &bytes_read);<br>     if (ctx->bc->chip_class >= EVERGREEN)<br>
         eg_bytecode_export_read(&output, word0,word1);<br>     else<br>diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.c b/src/gallium/drivers/radeonsi/radeonsi_pipe.c<br>index fa16f4c..69df8a9 100644<br>--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.c<br>
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.c<br>@@ -349,6 +349,8 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)<br>     case PIPE_CAP_TEXTURE_MULTISAMPLE:<br>     case PIPE_CAP_COMPUTE:<br>
     case PIPE_CAP_QUERY_TIMESTAMP:<br>+    case PIPE_CAP_CUBE_MAP_ARRAY:<br>+    case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:<br>         return 0;<br> <br>     /* Stream output. */<br>-- <br>1.7.9.5<br><br>