r600g/compute: Disable growing the memory pool
authorTom Stellard <thomas.stellard@amd.com>
Wed, 11 Jul 2012 16:18:22 +0000 (16:18 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Wed, 11 Jul 2012 17:53:54 +0000 (17:53 +0000)
The code for growing the memory pool (which is used for storing all of
the global buffers) wasn't working.  There seem to be two separate issues
with the memory pool code.  The first was the way it was growing the pool.
When the memory pool needed more space, it would:

1. Copy the data from the memory pool's backing texture to system memory.
2. Delete the memory pool's texture
3. Create a bigger backing texture for the memory pool.
4. Copy the data from system memory into the bigger texture.

The copy operations didn't seem to be working, and I suspect that since
they were using fragment shaders to do the copy, that there might have
been a problem with the mixing of compute and 3D state.

The other issue is that the size of 1D textures is limited, and I was
having trouble getting 2D textures to work.

I think these problems will be easier to solve once more code is shared
between 3D and compute, which is why I decided to disable it for now
rather than continue searching for a fix.

src/gallium/drivers/r600/compute_memory_pool.c
src/gallium/drivers/r600/compute_memory_pool.h
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h

index 17657f7c51a6c130bfd65f39c2a1a67936b30e6e..cf48bad0985b9e7dee74263f5bb50cdfd0cda308 100644 (file)
@@ -74,23 +74,32 @@ static struct r600_resource_texture * create_pool_texture(struct r600_screen * s
  * Creates a new pool
  */
 struct compute_memory_pool* compute_memory_pool_new(
-       int64_t initial_size_in_dw,
        struct r600_screen * rscreen)
 {
        struct compute_memory_pool* pool = (struct compute_memory_pool*)
                                CALLOC(sizeof(struct compute_memory_pool), 1);
 
-       COMPUTE_DBG("* compute_memory_pool_new() initial_size_in_dw = %ld\n",
+       COMPUTE_DBG("* compute_memory_pool_new()\n");
+
+       pool->screen = rscreen;
+       return pool;
+}
+
+static void compute_memory_pool_init(struct compute_memory_pool * pool,
+       unsigned initial_size_in_dw)
+{
+
+       COMPUTE_DBG("* compute_memory_pool_init() initial_size_in_dw = %ld\n",
                initial_size_in_dw);
 
+       /* XXX: pool->shadow is used when the buffer needs to be resized, but
+        * resizing does not work at the moment.
+        * pool->shadow = (uint32_t*)CALLOC(4, pool->size_in_dw);
+        */
        pool->next_id = 1;
        pool->size_in_dw = initial_size_in_dw;
-       pool->screen = rscreen;
        pool->bo = (struct r600_resource*)create_pool_texture(pool->screen,
                                                        pool->size_in_dw);
-       pool->shadow = (uint32_t*)CALLOC(4, pool->size_in_dw);
-
-       return pool;
 }
 
 /**
@@ -183,16 +192,26 @@ void compute_memory_grow_pool(struct compute_memory_pool* pool,
 
        assert(new_size_in_dw >= pool->size_in_dw);
 
-       new_size_in_dw += 1024 - (new_size_in_dw % 1024);
+       assert(!pool->bo && "Growing the global memory pool is not yet "
+               "supported.  You will see this message if you are trying to"
+               "use more than 64 kb of memory");
 
-       COMPUTE_DBG("  Aligned size = %d\n", new_size_in_dw);
+       if (!pool->bo) {
+               compute_memory_pool_init(pool, 1024 * 16);
+       } else {
+               /* XXX: Growing memory pools does not work at the moment.  I think
+                * it is because we are using fragment shaders to copy data to
+                * the new texture and some of the compute registers are being
+                * included in the 3D command stream. */
+               fprintf(stderr, "Warning: growing the global memory pool to"
+                               "more than 64 kb is not yet supported\n");
+               new_size_in_dw += 1024 - (new_size_in_dw % 1024);
+
+               COMPUTE_DBG("  Aligned size = %d\n", new_size_in_dw);
 
-       if (pool->bo) {
                compute_memory_shadow(pool, pipe, 1);
-       }
-       pool->shadow = (uint32_t*)realloc(pool->shadow, new_size_in_dw*4);
-       pool->size_in_dw = new_size_in_dw;
-       if (pool->bo) {
+               pool->shadow = (uint32_t*)realloc(pool->shadow, new_size_in_dw*4);
+               pool->size_in_dw = new_size_in_dw;
                pool->screen->screen.resource_destroy(
                        (struct pipe_screen *)pool->screen,
                        (struct pipe_resource *)pool->bo);
@@ -200,10 +219,6 @@ void compute_memory_grow_pool(struct compute_memory_pool* pool,
                                                        pool->screen,
                                                        pool->size_in_dw);
                compute_memory_shadow(pool, pipe, 0);
-       } else {
-               pool->bo = (struct r600_resource*)create_pool_texture(
-                                                       pool->screen,
-                                                       pool->size_in_dw);
        }
 }
 
index a14eba1df7ea3f9f3b0754cd8bc90b0b3728d517..3777e3ff5d3112a024218330f22ccbf5126b20d8 100644 (file)
@@ -57,7 +57,7 @@ struct compute_memory_pool
 };
 
 
-struct compute_memory_pool* compute_memory_pool_new(int64_t initial_size_in_dw, struct r600_screen *rscreen); ///Creates a new pool
+struct compute_memory_pool* compute_memory_pool_new(struct r600_screen *rscreen); ///Creates a new pool
 void compute_memory_pool_delete(struct compute_memory_pool* pool); ///Frees all stuff in the pool and the pool struct itself too
 
 int64_t compute_memory_prealloc_chunk(struct compute_memory_pool* pool, int64_t size_in_dw); ///searches for an empty space in the pool, return with the pointer to the allocatable space in the pool, returns -1 on failure
index a0a8a58cd9c2ccf642fe4da61711cc2b36ced0d1..7750c425f84ab4aaa859a91c4ef688215255e78f 100644 (file)
@@ -624,9 +624,10 @@ static int r600_get_compute_param(struct pipe_screen *screen,
        case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE:
                if (ret) {
                        uint64_t * max_global_size = ret;
-                       /* XXX: This is what the proprietary driver reports, we
-                        * may want to use a different value. */
-                       *max_global_size = 201326592;
+                       /* XXX: This is 64kb for now until we get the
+                        * compute memory pool working correctly.
+                        */
+                       *max_global_size = 1024 * 16 * 4;
                }
                return sizeof(uint64_t);
 
@@ -953,7 +954,7 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
        rscreen->use_surface_alloc = debug_get_bool_option("R600_SURF", TRUE);
        rscreen->glsl_feature_level = debug_get_bool_option("R600_GLSL130", TRUE) ? 130 : 120;
 
-       rscreen->global_pool = compute_memory_pool_new(0, rscreen);
+       rscreen->global_pool = compute_memory_pool_new(rscreen);
 
        return &rscreen->screen;
 }
index 0785ade4162132109c994c3ed4b82a0354fe13f3..1b3cef1de068bd7493bc8e1a3eae3ac3eaae24c2 100644 (file)
@@ -109,7 +109,6 @@ enum r600_pipe_state_id {
 struct compute_memory_pool;
 void compute_memory_pool_delete(struct compute_memory_pool* pool);
 struct compute_memory_pool* compute_memory_pool_new(
-       int64_t initial_size_in_dw,
        struct r600_screen *rscreen);
 
 struct r600_pipe_fences {